function chkChar(e)
{	
	var key = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	if((key >=48 && key <=57) || (key >=65 && key <=90) || (key >=97 && key <=122) || key==8 || key ==9)
		return true;
	else
		return false;
}
function chkChar1(e)
{	
	var key = e.keyCode ? e.keyCode : e.which ? e.which : e.charCode;
	if((key >=48 && key <=57) || (key  >=65 && key <=90) || (key  >=97 && key <=122) || key==45 || key==95 || key==8 || key ==9)
		return true;
	else
		return false;
}
function chkForm()
{
	age1 = 0;
	flg = 0;
	if(document.form1.profileName.value == "")
	{
		flg=1;
		alert("Please enter your PROFILE NAME.");
		document.form1.profileName.focus()
		return false;
	}
	else if(document.form1.profileName.value.length < 6)
	{
		flg=1;
		alert("PROFILE NAME must be of atleast 6 characters.");
		document.form1.profileName.focus()
		return false;
	}
	if(document.form1.firstName.value == "")
	{
		flg=1;
		alert("Please enter your FIRST NAME.");
		document.form1.firstName.focus()
		return false;
	}
	if(document.form1.lastName.value == "")
	{
		flg=1;
		alert("Please enter your LAST NAME.");
		document.form1.lastName.focus()
		return false;
	}
	if(document.form1.bdateDay.value=="" || document.form1.bdateMonth.value=="" || document.form1.bdateYear.value=="")
	{
		flg = 1;
		alert("Please enter your BIRTH DATE.");
		document.form1.bdateMonth.focus()
		return false;
	}
	else 
	{
		var bdate1=document.form1.bdateYear.value+"-"+document.form1.bdateMonth.value+"-"+document.form1.bdateDay.value;
		var d1=new Date();
		var tmonth = d1.getMonth()+1;		//Numeric representation of a month, without leading zeros
		var tday = d1.getDate();		// days of the month without leading zeroes
		var tyear = d1.getFullYear();	
		var years = tyear - document.form1.bdateYear.value;
//			alert(bdate1+" => "+d1+" - "+tmonth+" - "+tday+" - "+tyear+" - "+years);
		if (tmonth <= document.form1.bdateMonth.value)
		{  
			if(document.form1.bdateMonth.value == tmonth)
			{
			  if(document.form1.bdateDay.value > tday)
				 years--;
			}
			else
			  years--;
		}
		age1=years;
//			document.form1.bdate.value = bdate1;
	}
	flg1 = 0;
	for(var j=0;j<document.form1.elements.length;j++)
	{ 
		if(document.form1.elements[j].name=="gender")
		{
			if(document.form1.elements[j].checked == true)
				flg1 = 1;
		}
	}
	if(flg1 == 0)
	{
		flg=1;
		alert("Please choose GENDER.");
		return false;
	}
	else
	{
		for(var j=0;j<document.form1.elements.length;j++)
		{ 
			if(document.form1.elements[j].name=="gender")

			{
				if(document.form1.elements[j].checked == true)
				{
					if(document.form1.elements[j].value == "Male")
					{	if(age1<21)
						{	
							alert("Age must not be less than 21 years for Male.");
							flg=1;
							return false;
						}
					}
					if(document.form1.elements[j].value == "Female")
					{	if(age1<18)
						{	
							alert("Age must not be less than 18 years for Female.");
							flg=1;
							return false;
						}
					}
				}
			}
		}
	}
	flg1 = 0;
	for(var j=0;j<document.form1.elements.length;j++)
	{ 
		if(document.form1.elements[j].name=="marital")
		{
			if(document.form1.elements[j].checked == true)
				flg1 = 1;
		}
	}
	if(flg1 == 0)
	{
		flg=1;
		alert("Please choose your MARITAL STATUS.");
		return false;
	}
	if(document.form1.noChildren.value == "")
	{
		flg=1;
		alert("Please select your NUMBER OF CHILDREN.");
		document.form1.noChildren.focus()
		return false;
	}
	if(document.form1.noChildren.value!="None")
	{
		flg1 = 0;
		for(var j=0;j<document.form1.elements.length;j++)
		{ 
			if(document.form1.elements[j].name=="childrenLiving")
			{
				if(document.form1.elements[j].checked == true)
					flg1 = 1;
			}
		}
		if(flg1 == 0)
		{
			flg=1;
			alert("Please indicate CHILD/CHILDREN is/are LIVING WITH YOU.");
			return false;
		}
	}
	if(document.form1.religion.value == "")
	{
		flg=1;
		alert("Please select your RELIGION.");
		document.form1.religion.focus()
		return false;
	}
	if(document.form1.countryLiving.value == "")
	{
		flg=1;
		alert("Please select COUNTRY LIVING IN.");
		document.form1.countryLiving.focus()
		return false;
	}
	flg1 = 0;
	for(var j=0;j<document.form1.elements.length;j++)
	{ 
		if(document.form1.elements[j].name=="resident")
		{
			if(document.form1.elements[j].checked == true)
				flg1 = 1;
		}
	}
	if(flg1 == 0)
	{
		flg=1;
		alert("Please choose your RESIDENT STATUS.");
		return false;
	}
	if(document.form1.citizenship.value == "")
	{
		flg=1;
		alert("Please select CITIZENSHIP");
		document.form1.citizenship.focus()
		return false;
	}
	flg1 = 0;
	for(var j=0;j<document.form1.elements.length;j++)
	{ 
		if(document.form1.elements[j].name=="employedIn")
		{
			if(document.form1.elements[j].checked == true)
				flg1 = 1;
		}
	}
	if(flg1 == 0)
	{
		flg=1;
		alert("Please specify EMPLOYMENT STATUS.");
		return false;
	}
	if(document.form1.email.value == "")
	{
		flg=1;
		alert("Please enter your EMAIL ADDRESS.");
		document.form1.email.focus()
		return false;
	}
	else if(echeck(document.form1.email.value)==false)
	{
		document.form1.email.value="";
		flg = 1;
		document.form1.email.focus()
		return false;
	}
	if(document.form1.choosePassword.value == "")
	{
		flg=1;
		alert("Please Choose 'PASSWORD'.");
		document.form1.choosePassword.focus()
		return false;
	}
	if(document.form1.confirmPassword.value == "")
	{
		flg=1;
		alert("Please Confirm 'PASSWORD'.");
		document.form1.confirmPassword.focus()
		return false;
	}
	if(document.form1.choosePassword.value != "" && document.form1.confirmPassword.value != "")
	{
		if(document.form1.confirmPassword.value.length < 8 || document.form1.choosePassword.value.length < 8)
		{
			flg=1;
			alert("PASSWORD must be of atleast 8 characters.");
			document.form1.confirmPassword.value="";
			document.form1.choosePassword.value="";
			document.form1.choosePassword.focus()
			return false;
		}
		if(document.form1.choosePassword.value != document.form1.confirmPassword.value)
		{
			flg=1;
			alert("PASSWORD does not match, please re-enter password.");
			document.form1.choosePassword.value = "";
			document.form1.confirmPassword.value = "";
			document.form1.choosePassword.focus()
			return false;
		}
		/*	// check password for atleast 6 chars and 2 numbers
		ncnt = 0;
		ccnt = 0;
		if(document.form1.choosePassword.value == document.form1.confirmPassword.value)
		{
			for(i=0; i<document.form1.choosePassword.value.length; i++)
			{	if(document.form1.choosePassword.value.substr(i,1)>='A' && document.form1.choosePassword.value.substr(i,1)<='Z')
				{	ccnt = ccnt + 1;
				}
				if(document.form1.choosePassword.value.substr(i,1)>='a' && document.form1.choosePassword.value.substr(i,1)<='z')
				{	ccnt = ccnt + 1;
				}
				if(document.form1.choosePassword.value.substr(i,1)>='0' && document.form1.choosePassword.value.substr(i,1)<='9')
				{	ncnt = ncnt + 1;
				}
			}
			if(ccnt < 6 || ncnt < 2)
			{
				flg=1;
				alert("Not correct password. Please check how to pick a proper password.");
				document.form1.choosePassword.value = "";
				document.form1.confirmPassword.value = "";
				document.form1.choosePassword.focus()
				return false;
			}
		}
		*/
	}
	if(document.form1.chkTerms.checked == false)
	{
		flg=1;
		alert("Please read and accept TERMS & CONDITIONS.");
		document.form1.chkTerms.focus()
		return false;
	}
	if(flg == 1)
		return false;
	else
		return true;
}
var popUpWin=0;
function openit()
{
  var page="termsConditions.php";
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(page,'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=600,height=600,left=0, top=30,screenX=10,screenY=10');
}
function openit1()
{
  var page="pickPassword.php";
  if(popUpWin)
  {
    if(!popUpWin.closed) popUpWin.close();
  }
  popUpWin = open(page,'popUpWin', 'toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,copyhistory=yes,width=600,height=450,left=0, top=30,screenX=10,screenY=10');
}
