var loadingImg = '<table width="65%" align="center" border="0"><tr><td align="center"><img src="'+SiteGlobalPath+'images/green_loading.gif" border="0" align="absmiddle"></td></tr></table>';
function EditProfileURL(value,Ident,CommunitySiteId,MemberId,spanId)	{
	
	alert(value+' - '+Ident+' - '+CommunitySiteId+' - '+MemberId+' - '+spanId)
	return false;
//alert(document.getElementById("hdNumber").value);
	/*if(document.getElementById("hdNumber").value>2)	{
		for(var i=1; i<document.getElementById("hdNumber").value;i++) {
			document.getElementById("trDataRow"+i).display="none";
		}
	}*/
	
	if(document.getElementById("ProfileURLTitle"))
		document.getElementById("ProfileURLTitle").innerHTML = "Edit Profile URL";
	if(document.getElementById("ProfileURLSubTitle"))
		document.getElementById("ProfileURLSubTitle").innerHTML = "Edit Profile URL";
	if(document.getElementById("LoadHelp")) {
		RemoveLayer();
		RemoveLayer2();
	}
	
			
	document.getElementById("DisplayAnotherURL").style.visibility='hidden';
	document.getElementById("DisplayAnotherURL").style.position = "absolute";
	document.getElementById("txtRURL0").focus()
	document.getElementById("txtRURL0").value = value;
	document.getElementById("hdLogo0").value = CommunitySiteId;
	if(document.getElementById("txtRURLId"))
		document.getElementById("txtRURLId").value = Ident;
	document.getElementById("ErrorDisplay").innerHTML = "";
	//document.getElementById("FormAction").innerHTML ='<img src="images/update.gif" border="0" style="cursor:pointer;" onclick=UpdateProfileURL("'+value+'","'+Ident+'","'+MemberId+'") tabindex="3" />';
	document.getElementById("FormAction").innerHTML ='<input type="image" src="'+SiteGlobalPath+'images/update.gif" border="0" style="cursor:pointer;" />';
	showLogo(value,'DomainLogo0','hdLogo0',SiteAjaxFolder+'showlogo.php');
	opacity("DomainLogo0_ID", 0, 200, 500);	
}

function DeleteProfileURL(Ident,MemberId) {
	if(confirm("Are you surely want to Delete this Profile URL?"))	{
		document.getElementById("ProfileURL_list").innerHTML = loadingImg;
		var success = function(t){DeleteProfileURLComplete(t,Ident);}
		var failure = function(t){DeleteProfileURLFailed(t);}
		var url = SiteAjaxFolder+"update_profilrurl.php";
		var pars = 'hdProfileURLId='+Ident+'&hdMemberId='+MemberId+'&hdAction=delete';
		var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
	}
}

function DeleteProfileURLComplete(t,Ident)	{
	var strValue = trim(t.responseText);
	
	var strDisplay	= strValue.split("||");
	
	document.getElementById("ProfileURL_list").innerHTML = strDisplay[0];
	document.getElementById("ErrorDisplay").innerHTML = strDisplay[1];
}

function UpdateProfileURL(value,Ident,MemberId,spanId) {

	value = document.getElementById("txtRURL0").value;
	if(!IsValidHTTP(value))	{
		alert("Enter valid URL eg. 'http://www.msn.com'");
		return false;
	} else {
		document.getElementById("ProfileURL_list").innerHTML = "<img src='"+SiteGlobalPath+"images/smallloading.gif'>";
		
		var success = function(t){UpdateProfileURLComplete(t,MemberId,spanId);}
		var failure = function(t){UpdateProfileURLFailed(t, spanId);}
		var url = SiteAjaxFolder+"update_profilrurl.php";
		var pars = 'hdProfileURLId='+Ident+'&hdProfileURL='+value+'&hdMemberId='+MemberId;
		var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
	}
}

function UpdateProfileURLComplete(t,MemberId,spanId){
	var strValue = trim(t.responseText);
	document.getElementById("ProfileURL_list").innerHTML = strValue;
	document.getElementById("txtRURL0").value = "";
	document.getElementById("txtRURLId").value = "";
	document.getElementById("FormAction").innerHTML = '<input type="image" src="'+SiteGlobalPath+'images/submit.gif"  tabindex="3" />';
	document.getElementById("DisplayAnotherURL").style.visibility='visible';
	if(document.getElementById("ProfileURLTitle"))
		document.getElementById("ProfileURLTitle").innerHTML = "Add Profile URL";
	if(document.getElementById("ProfileURLSubTitle"))
		document.getElementById("ProfileURLSubTitle").innerHTML = "Profile URL";

}

function VerifyProfileURL(url)	{
	window.open(url)
}

function IsValidHTTP(strURL,n)
{
	strURL 		= strURL.toUpperCase();
			
	if(strURL==""||strURL=="HTTP://") return false	
	thePrefix 	= strURL.substr(0,7).toUpperCase();
	if(thePrefix!="HTTP://") return false;
	if(n!=-1) if(strURL.split("/").length>n) return false;
	
	return true
}

function IsValidURL(Val,Label)
{
	var inValidChars = "abcdefghijklmnopqrstuvwxyz ABCDEFGHIJKLMNOPQRSTUVWXYZ 1234567890-_:/.";
    for (i = 0; i < Val.length; i++){   
        var c = Val.charAt(i);
        if (inValidChars.indexOf(c) == -1 ){
			alert("Invalid characters found in "+Label);
			return false;
		}
    }
	var c,cnd,msg,len;
	c=0;
	cnd="http://";
	msg="Enter valid URL eg. 'http://www.msn.com'";
	len=7;
	if (Label=="web")
	{
		cnd="www";
		msg="Enter valid Website name eg. 'www.msn.com'";
		len=3;
	}
	if (Val.substring(0,len)!=cnd)
	{
		alert(msg);
		return false;
	}
	else
	{
		for (i=0;i<Val.length;i++)
		{
			if ((Val.charAt(i))==".")
				c=c+1;
		}
		
		if (c<2)
		{
				alert(msg);
				return false;
		}
	}
	return true;
}


function LoadNetworkTemplate(strNetWorkAction)	{
	spanid = 'ProfileArea';

//document.getElementById(spanid).innerHTML = "<table width='95%' border='0' id='tblMain' cellspacing='2' cellpadding='1' class='ProfileTable'><tbody  id='tbodyMain' align='center'><tr><td width='31%' colspan='3' height='8'></td></tr><tr><td align='right' valign='top' class='RequiredField' id='ProfileURLSubTitle'>&nbsp;</td><td align='right' valign='top' class='ListCell' id='ProfileURLSubTitle' ><img src='"+SiteAutocompleteGlobalPath+"images/spacer.gif' height='28' style='padding-bottom:2px;padding-right:2px;padding-left:2px;'></td></tr></tbody></table>";
	document.getElementById("ErrorDisplay").innerHTML = "";
	var success = function(t){LoadNetworkTemplateComplete(t, spanid,strNetWorkAction);}
	var failure = function(t){editFailed(t, strNetWorkAction);}
	var url = SiteAjaxFolder+"update_profilrurl.php";
	var pars = 'FormAction=Profile&NetWorkAction='+strNetWorkAction;
    var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
}
function LoadNetworkTemplateComplete(t,spanId,strNetWorkAction){
	var strValue = trim(t.responseText);
	strDisplay = strValue.split("||");
//	document.getElementById("ErrorDisplay").innerHTML = "";
	opacity("tblMain", 0, 200, 500);	
	document.getElementById(spanId).innerHTML=strDisplay[0];
	document.getElementById("NetWorkLogo").src=SiteGlobalPath+'logos/'+strDisplay[1];
}

function AssignProfileUrlToMember(profileIdent)	{
	var success = function(t){AssignProfileUrlToMemberComplete(t, profileIdent);}
	var failure = function(t){editFailed(t, profileIdent);}
	var url = SiteAjaxFolder+"update_profilrurl.php";
	var pars = 'FormAction=Profile&hdAction=AssignProfileUrl&profileIdent='+profileIdent;
    var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
	
}

function AssignProfileUrlToMemberComplete(t,profileIdent){
	var strValue = trim(t.responseText);
}
/*function InsertURL()	{
	spanid = 'ProfileArea';

}
*/