var SliderLoaderText	 = "<table width='100%' height='100'><tr><td   align='center' class='ListCell'><font size='+2' face='Arial, Helvetica, sans-serif' color='#999999'>Loading...</font><br><img src='images/ajax-loader.gif'><br>Please wait a moment </td></tr></table>"
function ValidateRegistration()	{ 
	if(!IsValidUserName(document.getElementById("txtRUserName").value,"User Name"))	{
		document.getElementById("txtRUserName").focus();
		return false;
	}
	if(document.getElementById("txtRUserName").value.length < 5)	{
		alert("UserName Should Be atleast 5 charecters ");
		document.getElementById("txtRUserName").focus();
		return false;
	}
	if(!IsValid(document.getElementById("txtRPassword").value,"Password"))	{
		document.getElementById("txtRPassword").focus();
		return false;
	}
	if(document.getElementById("txtRPassword").value.length < 5)	{
		alert("Password Should Be atleast 5 charecters ");
		document.getElementById("txtRPassword").focus();
		return false;
	}
	if(!IsValid(document.getElementById("txtConfirmPassword").value,"Confirm Password"))	{
		document.getElementById("txtConfirmPassword").focus();
		return false;
	}
	if(document.getElementById("txtConfirmPassword").value.length < 5)	{
		alert("Confirm Password Should Be atleast 5 charecters ");
		document.getElementById("txtConfirmPassword").focus();
		return false;
	}
	if( document.getElementById("txtRPassword").value != document.getElementById("txtConfirmPassword").value)	{
		alert("Password Mismatch");
		document.getElementById("txtRPassword").focus();
		return false;
	}
		if(!isEmailAddr(document.getElementById("txtEmail").value,"Email Address"))	{
		document.getElementById("txtEmail").focus();
		return false;
	}
	if(!IsAlphaNumeric(document.getElementById("txtFirstName").value,"First Name"))	{
		document.getElementById("txtFirstName").focus();
		return false;
	}
/*	if(!IsAlphaNumeric(document.getElementById("txtLastName").value,"Last Name"))	{
		document.getElementById("txtLastName").focus();
		return false;
	}*/
	if(document.getElementById("txtQuestion").value == "" && document.getElementById("txtQuestion").value != "Other")	{
		alert("Please select the Secret Question");
		document.getElementById("txtQuestion").focus();
		return false;
	}	
	if(document.getElementById("txtQuestion").value == "Other" && document.getElementById("txtQuestion1").value == "")	{
		alert("Please Enter Secret Question");
		document.getElementById("txtQuestion1").focus();
		return false;
	}	
	if(!IsValid(document.getElementById("txtSecretAnswer").value,"Answer"))	{
		document.getElementById("txtSecretAnswer").focus();
		return false;
	}
	if(document.getElementById("hear").value == "Other" && document.getElementById("txtOther").value == "")	{
		alert("Please specify where you have hear about us?");
		document.getElementById("txtOther").focus();
		return false;
	}	
	if(!IsValid(document.getElementById("txtVerification").value,"Verification Code"))	{
		document.getElementById("txtVerification").focus();
		return false;
	}
	if(document.getElementById("terms").checked == false)	{
		alert("Kindly confirm whether you agree with the Terms and Conditions");				
		return false;
	}
	document.getElementById("doSubmit").value = 1;
}
function checkValue(value)	{
	if(value == "Other")	{
		document.getElementById("otherque").style.visibility = "visible";
		document.getElementById("otherque").style.position = "relative";
	}	else	{
		document.getElementById("otherque").style.visibility = "hidden";
		document.getElementById("otherque").style.position = "absolute";
	}
}
function checkStateValue(value)	{
	if(value != "US")	{
		//document.getElementById("statechange").style.visibility = "hidden";
		//document.getElementById("statechange").style.position = "absolute";
		document.getElementById("Zip").style.visibility = "hidden";
		document.getElementById("Zip").style.position = "absolute";
	}	else	{
		//document.getElementById("statechange").style.visibility = "visible";
		//document.getElementById("statechange").style.position = "relative";
		document.getElementById("Zip").style.visibility = "visible";
		document.getElementById("Zip").style.position = "relative";
	}
}

function checkHearValue(value)	{
	if(value == "Other")	{
		document.getElementById("otherHear").style.visibility = "visible";
		document.getElementById("otherHear").style.position = "relative";
	}else	{
		document.getElementById("otherHear").style.visibility = "hidden";
		document.getElementById("otherHear").style.position = "absolute";
	}
}
function onKeyPressOnlyLetters(e)
{
	var key = window.event ? e.keyCode : e.which;
	var keychar = String.fromCharCode(key);
	reg = /[0-9!@#$%^&*()-+=|?<>._,'";:\/\\\[\]{}~`]/;
	return !reg.test(keychar);
}
function ValidateActivation()	{
	if(!IsValid(document.getElementById("UserName").value,"User Name"))	{
		document.getElementById("UserName").focus();
		return false;
	}	
	if(!isEmailAddr(document.getElementById("EmailAddress").value,"Email Address"))	{
		document.getElementById("EmailAddress").focus();
		return false;
	}
	if(!IsValid(document.getElementById("Password").value,"Password"))	{
		document.getElementById("Password").focus();
		return false;
	}	
}

function CheckvalidData(value,chkdata,spanId,fieldName)	{
	var success = function(t){CheckvalidDataComplete(t, spanId,fieldName);}
	var failure = function(t){editFailed(t, spanId);}
	var url = "ajax/registration.php";
	var pars = 'chkdata='+chkdata+'&value='+value;
	var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
}
function CheckvalidDataComplete(t, spanId,fieldName){
	var strValue = t.responseText;
	if(t.responseText != "")	{
		document.getElementById(spanId).innerHTML= ""+t.responseText+"";
		//document.getElementById(spanId).innerHTML= "<span class='RegisterError'>"+t.responseText+"</span>";
		//document.getElementById(fieldName).className = "TextBoxError";
	} else	{
		document.getElementById(spanId).innerHTML= "";
	}
}
function CheckRegistartionData(obj)	{
	var success = function(t){CheckRegistartionDataComplete(t);}
	var failure = function(t){editFailed(t);}
	var url = "ajax/registration.php";
	var pars = 'Login=register&txtRUserName='+document.getElementById("txtRUserName").value+'&txtRPassword='+document.getElementById("txtRPassword").value+'&txtConfirmPassword='+document.getElementById("txtConfirmPassword").value+'&txtEmail='+document.getElementById("txtEmail").value+'&txtFirstName='+document.getElementById("txtFirstName").value+'&txtLastName='+document.getElementById("txtLastName").value+'&txtQuestion='+document.getElementById("txtQuestion").value+'&txtSecretAnswer='+document.getElementById("txtSecretAnswer").value+'&txtVerification='+document.getElementById("txtVerification").value;
   	var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
}
function CheckRegistartionDataComplete(t){
	var strValue = t.responseText.split('||');
	document.getElementById("LoadError").innerHTML =strValue[0];
}
function CheckValidLogin(fname,password,spanId,chkdata)	{
	document.getElementById(spanId).innerHTML = "<img src='images/smallloading.gif'>";
	var success = function(t){CheckValidLoginComplete(t, spanId);}
	var failure = function(t){editFailed(t, spanId);}
	var url = "ajax/registration.php";
	var pars = 'Login='+chkdata+'&fname='+fname+'&pass='+password;
	var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
}
function CheckValidLoginComplete(t,spanId){
	var strValue = t.responseText;
	if(strValue == "")	{
		window.location.href='members/';
	}
	if(strValue != "")	{
		document.getElementById(spanId).innerHTML= "<font class='RegisterError' style='width:200px;'>"+strValue+"</font>";
		return false
	} 
	
}

var DisplayView = function(){
$("Page1").style.display ="none";
$("Page2").style.display ="Block";
$("txtRUserName").focus();
}

function CheckvalidIndexData(value,chkdata,spanId,fieldName)	{ 
	var success = function(t){CheckvalidIndexDataComplete(t, spanId,fieldName,value);}
	var failure = function(t){editFailed(t, spanId);}
	var url = "ajax/registration.php";
	var pars = 'chkdata='+chkdata+'&value='+value;
	var myAjax = new Ajax.Request(url, {method:'post',postBody:pars, onSuccess:success, onFailure:failure});
}
function CheckvalidIndexDataComplete(t, spanId,fieldName,value){
	var strValue = t.responseText;
	document.getElementById(spanId).className = 'error';
	if(t.responseText != "")	{
		document.getElementById(spanId).innerHTML= ""+t.responseText+"";		
	} else	{
		
		if(fieldName =="txtRUserName"){
			document.getElementById(spanId).className = 'indexSuccess';
			document.getElementById(spanId).innerHTML= "your email is "+value+"@arkiva.com";
		}
		else{
			document.getElementById(spanId).innerHTML= "";
		}
	}
}