var timer=0;function createCookie(name,value,days)
{alert('days');if(days)
{var date=new Date();date.setTime(date.getTime()+(days*24*60*60*1000));var expires="; expires="+date.toGMTString();}
else
{var expires="";}
document.cookie=name+"="+value+expires+"; path=/";}
function readCookie(name)
{var nameEQ=name+"=";var ca=document.cookie.split(';');for(var i=0;i<ca.length;i++)
{var c=ca[i];alert(c);while(c.charAt(0)==' ')c=c.substring(1,c.length);if(c.indexOf(nameEQ)==0)
{return c.substring(nameEQ.length,c.length);}}
return null;}
function eraseCookie(name)
{createCookie(name,"",-1);}
function validate(formName)
{var invalidChars='\/\'\\ ";:?!()[]\{\}~!#$%^&*+=^|,<>^';var addr=formName.primary_id.value;if(formName.gender_title.value=="")
{alert("Please select a Title.");formName.gender_title.focus();return false;}
else if(formName.fname.value=="")
{alert("Please enter a First Name.");formName.fname.focus();return false;}
else if(formName.lname.value=="")
{alert("Please enter a Last Name.");formName.lname.focus();return false;}
else if(formName.fname.value!="" && formName.mname.value!="" && formName.lname.value!="" && formName.fname.value==formName.lname.value && formName.fname.value==formName.mname.value)
{alert("First Name, Middle Name and Last Name should not be same.");formName.fname.focus();return false;}
else if(formName.fname.value!="" && formName.lname.value!="" && formName.fname.value==formName.lname.value)
{alert("First Name and Last Name should not be same.");formName.fname.focus();return false;}
else if(!validateEmail(formName.primary_id.value,true,true))
{formName.primary_id.focus();return false;}
else if(!validatePassword(formName.password.value))
{formName.password.focus();return false;}
else if(formName.select_country.value=="")
{alert("Please select a Country.");formName.select_country.focus();return false;}
else if(formName.check_value.value=="")
{alert("Please enter a Security String.");formName.check_value.focus();return false;}
for(i=0;i<invalidChars.length;i++)
{if(addr.indexOf(invalidChars.charAt(i),0)>-1)
{if(true)
{if(confirm("Email '"+addr+"' contains special characters. \\n Do you want to continue\?"))
{return(true);}
else{formName.primary_id.select();return(false);}}}}
formName.submit();}
function validatePart2(formname)
{if(!validateEmail(formname.pref_id.value,false,true))
{formname.pref_id.focus();return false;}
else if(!validateEmail(formname.ref_by.value,false,true))
{formname.ref_by.focus();return false;}
else if(!validateFileExtension(formname.user_icon.value))
{formname.user_icon.focus();return false;}
else if(formname.questions1.value=="")
{alert("Please select the first security question.");formname.questions1.focus();return false;}
else if(formname.a1.value=="")
{alert("Please enter the first answer.");formname.a1.focus();return false;}
else if(formname.questions2.value=="")
{alert("Please select the second security question.");formname.questions2.focus();return false;}
else if(formname.questions2.value==formname.questions1.value)
{alert("Please select the distinct security question.");formname.questions2.focus();return false;}
else if(formname.a2.value=="")
{alert("Please enter the second answer.");formname.a2.focus();return false;}
else if(formname.check_value.value=="")
{alert("Please enter a Security String.");formname.check_value.focus();return false;}
else if(!formname.adult.checked)
{alert("Please confirm your age.");formname.adult.focus();return false;}
else if(!formname.terms_conditions.checked)
{alert("Please accept the terms and conditions.");formname.terms_conditions.focus();return false;}
formname.submit();formname.detail_signup.disabled=true;}
function checkSecurityString(secString)
{if(formname.check_value.value=="")
{alert("Please enter the security string.");return false;}
else
{if(formname.check_value.value!=secString)
{alert("The security string does not match. Please re-enter.");return false;}}
return true;}
function decorate(div)
{if(div.style.backgroundColor=="")
div.style.backgroundColor="red";else
div.style.backgroundColor="";}
function loadData(tab,restoreData,hideTab)
{var title="";var fname="";var mname="";var lname="";var country="";var email="";var membership="";if(restoreData!="")
{var split=restoreData.split("|");var title=split[0];var fname=split[1];var mname=split[2];var lname=split[3];var country=split[4];var email=split[5];var membership=split[6];}
var content=document.getElementById('content');var tab1=document.getElementById('title1');var tab2=document.getElementById('title2');if(hideTab=="Y")
{tab2.style.visibility="hidden"}
else
{tab2.style.visibility=""}
content.style.borderTop="1px solid #EFEFEF";if(tab=="title1")
{tab1.style.backgroundColor="#EFEFEF"
tab2.style.backgroundColor="white"}
else if(tab=="title2")
{tab2.style.backgroundColor="#EFEFEF"
tab1.style.backgroundColor="white"}
xmlHttp=GetXmlHttpObject();if(xmlHttp==null)
{alert("Browser does not support HTTP Request")
return}
xmlHttp.onreadystatechange=function()
{if(xmlHttp.readyState==4||xmlHttp.readyState=="complete")
{content.innerHTML=xmlHttp.responseText;}}
xmlHttp.open("GET","register_data.php?tab_id="+tab+"&title="+title+"&fname="+fname+"&mname="+mname+"&lname="+lname+"&country="+country+"&email="+email+"&membership="+membership+"&sid="+Math.random(),true);xmlHttp.send(null);}
function GetXmlHttpObject()
{var xmlHttp=null;try
{xmlHttp=new XMLHttpRequest();}
catch(e)
{try
{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e)
{xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
return xmlHttp;}
function showPopUp(temp)
{location.href="/login_info.php?action="+temp;}
function runLoop(time)
{time=time*1000;t=setTimeout("showPopUp()",time);}
function incrementTimer(temp)
{
	var newTemp=temp;
	var time=readCookie("popup_time");
	time=parseInt(time);
	if(!time)
	{time = 900;}
	var globalTimer=readCookie("global_timer");
	globalTimer=parseInt(globalTimer);
	if(!globalTimer)
	{
		globalTimer=timer+1;
	}
	else
	{
		globalTimer=globalTimer+1;
	}
	if(globalTimer<=time)
	{
		c=setTimeout("incrementTimer('"+newTemp+"')",1000);
	}
	else
	{
		globalTimer=0;showPopUp(newTemp);
	}
	if(globalTimer>=3000)
	{
		createCookie("global_timer","",-1);
	}
	createCookie("global_timer",globalTimer,1);
}
function hidePopUp()
{var popup=document.getElementById("popup");var fullpage=document.getElementById("fullpage");fullpage.style.visibility="hidden"
popup.style.visibility="hidden"}
function validateEmail(addr,man,db)
{if(addr==''&&man)
{if(db)alert('Please Enter a Valid Email.');return false;}
if(addr=='')return true;for(i=0;i<addr.length;i++)
{if(addr.charCodeAt(i)>127)
{if(db)alert("Email contains non ascii characters.");return false;}}
var atPos=addr.indexOf('@',0);var commaPos=addr.indexOf(',',0);if(commaPos!=-1)
{alert("Email Id cannot contain any comma");return false;}
if(atPos==-1)
{if(db)alert('Email must contain an @');return false;}
if(atPos==0)
{if(db)alert('Email must not start with @');return false;}
if(addr.indexOf('@',atPos+1)>-1)
{if(db)alert('Email must contain only one @');return false;}
if(addr.indexOf('.',atPos)==-1)
{if(db)alert('Email address must contain a period in the domain name.');return false;}
if(addr.indexOf('@.',0)!=-1)
{if(db)alert('Period must not immediately follow @ in Email.');return false;}
if(addr.indexOf('.@',0)!=-1)
{if(db)alert('Period must not immediately precede @ in Email.');return false;}
if(addr.indexOf('..',0)!=-1)
{if(db)alert('Two periods must not be adjacent in Email address.');return false;}
var suffix=addr.substring(addr.lastIndexOf('.')+1);if(suffix.length!=2&&suffix!='com'&&suffix!='net'&&suffix!='org'&&suffix!='edu'&&suffix!='int'&&suffix!='mil'&&suffix!='gov'&suffix!='arpa'&&suffix!='biz'&&suffix!='aero'&&suffix!='name'&&suffix!='coop'&&suffix!='info'&&suffix!='pro'&&suffix!='museum')
{if(db)alert('Invalid primary domain in the Email.');return false;}
return true;}
function validatePassword(password)
{var length=password.length;var alpha="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";var numeric="0123456789";var passCheck=new Array();var passCheckAlpha=new Array();var count=0; var alphaCount=0; if(length==0)
{alert("Please enter a Password.");return false;}
else if(length<8)
{alert("Password should be minimum 8 characters.");return false;}
else
{for(var i=0;i<length;i++)
{var str=password.charAt(i);passCheck[i]=numeric.indexOf(str);if(passCheck[i]!=-1)
{count=count+1;}}
for(var j=0;j<length;j++)
{var strAlpha=password.charAt(j);passCheckAlpha[j]=alpha.indexOf(strAlpha);if(passCheckAlpha[j]!=-1)
{alphaCount=alphaCount+1;}}
var regexAlphaNum=/^[0-9A-Za-z]+$/;var nonAlpanNumFound;if(regexAlphaNum.test(password)){nonAlpanNumFound=0;}else{nonAlpanNumFound=1;}}
if(count==0 || alphaCount==0 || nonAlpanNumFound==1)
{alert("Please enter an alphanumeric password.");return false;}
return true;}
function validateFileExtension(filename)
{var formatCheck=new Array(".jpg",".jpeg",".JPG",".JPEG",".gif",".GIF");var length=formatCheck.length;var count=0;var fileLength=filename.length;if(fileLength!=0)
{for(var i=0;i<length;i++)
{var extension=filename.lastIndexOf(formatCheck[i]);if(extension==-1)
{count=count+1;}
else if(extension!=-1)
{break;}}
if(count==length)
{alert("Invalid image format.");return false;}}
return true;}
function refreshCaptcha() { $("#captchaImg").attr("src", ""); d = new Date(); $("#captchaImg").attr("src", "/User/visual-captcha.php?"+d.getTime()); }
function showPNote(frmName) { if(frmName.membership[1].checked) { document.getElementById('paidNote').style.display='block'; } else { document.getElementById('paidNote').style.display='none'; } }
