function ValidateReg()
{
	var frm = document.registration;
	
	//relationship type Validation
	var a=frm.drpRelationShipType.selectedIndex;
	if(frm.drpRelationShipType.options[a].value == "-1")
	{
		alert("Please select Type of Relationship you are interested in?");
		frm.drpRelationShipType.focus();
		return false;
	}
	
	
	//First Name Validation
	var testNames=new RegExp("[^A-Za-z_-]","g");
	var strFname=frm.txtFname.value;
	var strLname=frm.txtLname.value;
	//First Name
	if(strFname=="")
	{
		alert("Please type in a first name.");
		frm.txtFname.focus();
		return false;
	}
	else if(testNames.test(strFname))
	{
		alert("Only characters allowed in name.");
		frm.txtFname.focus();
		frm.txtFname.select();
		return false;
	}
	
	//Last Name Validation
	if(strLname=="")
	{
		alert("Please type in a last name");
		frm.txtLname.focus();
		return false;
	}
	else if(testNames.test(strLname))
	{
		alert("Only characters allowed in name.");
		frm.txtLname.focus();
		frm.txtLname.select();
		return false;
	}
	
	//sex Validation
	var z=frm.drpSex.selectedIndex;
	if(frm.drpSex.options[z].value=="-1")
	{
		alert("Please select Sex.");
		frm.drpSex.focus();
		return false;
	}
	
	//Email validation
	if(frm.txtEmailID.value=="")
	{
		alert("Please enter a Email Id.");
		frm.txtEmailID.focus();
		return false;
	}
	else if(!ValidateEmail(frm.txtEmailID.value))
	{
		frm.txtEmailID.focus();
		return false;
	}	
	
	//Date Of Birth Validation
	z=frm.drpDay.selectedIndex;
	var d=frm.drpDay.options[z].value;
	if(d=="-1")
	{
		alert("Please select Day of birth.");
		frm.drpDay.focus();
		return false;
	}

	z=frm.drpMonth.selectedIndex;
	var m=frm.drpMonth.options[z].value;
	if(m=="-1")
	{
		alert("Please select month of birth.");
		frm.drpMonth.focus();
		return false;
	}

	z=frm.drpYear.selectedIndex;
	var y=frm.drpYear.options[z].value;
	if(y=="-1")
	{
		alert("Please select year of birth");
		frm.drpYear.focus();
		return false;
	}
	
	if(!validDate(eval(d),eval(m),eval(y)))
	{
		frm.drpDay.focus();
		return false;
	}
	
	//Country of citizenship Validation
	z=frm.drpCoc.selectedIndex
	if(frm.drpCoc.options[z].value=="-1")
	{
		alert("Please select country of citizenship.");
		frm.drpCoc.focus();
		return false;
	}
	
	//Immigration status Validation
	z=frm.drpImmigrationStatus.selectedIndex
	if(frm.drpImmigrationStatus.options[z].value=="-1")
	{
		alert("Please select your immigration status.");
		frm.drpImmigrationStatus.focus();
		return false;
	}
	
	//Height Validation
	z=frm.drpHeight.selectedIndex
	if(frm.drpHeight.options[z].value=="-1")
	{
		alert("Please select height.");
		frm.drpHeight.focus();
		return false;
	}
	
	//Weight Validation
	z=frm.drpWeight.selectedIndex;
	if(frm.drpWeight.options[z].value=="-1")
	{
		alert("Please select weight.");
		frm.drpWeight.focus();
		return false;
	}
	
	//Education Validation
	z=frm.drpEducation.selectedIndex
	if(frm.drpEducation.options[z].value==-1)
	{
		alert("Please Select an education level.");
		frm.drpEducation.focus();
		return false;
	}
	
	//Employment Type Validation
	z=frm.drpEmployeeType.selectedIndex
	if(frm.drpEmployeeType.options[z].value==-1)
	{
		alert("Please select an employment type.");
		frm.drpEmployeeType.focus();
		return false;
	}
	
	//Annual salary and salary currency Validation
	z=frm.drpAnnualSal.selectedIndex
	if(frm.drpAnnualSal.options[z].value==-1)
	{
		alert("Please select an annual salary.");
		frm.drpAnnualSal.focus()
		return false;
	}

	z=frm.drpSalCurrency.selectedIndex
	if(frm.drpSalCurrency.options[z].value==-1)
	{
		alert("Please select currency type.");
		frm.drpSalCurrency.focus();
		return false;
	}
	
	//Problem area Validation
	z=frm.drpSp_Case.selectedIndex;
	var y=frm.drpProb_Area.selectedIndex;
	if(frm.drpSp_Case.options[z].value =="N" && frm.drpProb_Area.options[y].value !="N")
	{
		alert("You can not select NONE, when you have selected [Challenged from] option.");
		frm.drpSp_Case.focus();
		return false;
	}

	if(frm.drpSp_Case.options[z].value !="N" && frm.drpProb_Area.options[y].value =="N")
	{
		alert("You can not select NONE, when you have selected [Physically challanged] option.");
		frm.drpProb_Area.focus();
		return false;
	}
	
	//Country of residence Validation
	z=frm.drpCor.selectedIndex
	if(frm.drpCor.options[z].value=="-1")
	{
		alert("Please select country of residence.");
		frm.drpCor.focus();
		return false;
	}
	
	//State of residence Validation
	z=frm.drpSor.selectedIndex
	if(frm.drpSor.options[z].value=="-1")
	{
		alert("Please select a state.");
		frm.drpSor.focus();
		return false;
	}
	else
	{
		frm.hdnSor.value = frm.drpSor.options[z].value;
	}
	
	//City Validation
	z=frm.drpCityM.selectedIndex;	
	if(frm.drpCityM.options[z].value=="-1")
	{
		alert("Please select a city.");
		frm.drpCityM.focus();
		return false;
	}
	else
	{
		frm.hdnCor.value = frm.drpCityM.options[z].value;
	}
	
	//Zip Code validation
	var strZipM = frm.txtZipM.value;
	var testZip=new RegExp("[^0-9A-Za-z]","g");
	if(strZipM=="")
	{
		alert("Please type in your Zip code.");
		frm.txtZipM.focus();
		return false;
	}
	else if (strZipM.charAt(0) == " ") 
	{
		alert("The Zip code should not contain spaces in the beginning.");
		frm.txtZipM.focus();
		frm.txtZipM.select();
		return (false);
	}
	else if(testZip.test(strZipM))
	{
		alert("Only Numbers and Alphabets allowed in Zip code.");
		frm.txtZipM.focus();
		return false;
	}	

	//Telephone Validation
	var testPh=new RegExp("[^0-9-]","g");	
	if(frm.txtPhoneM.value=="")
	{
		alert("Please type in a Phone number.");
		frm.txtPhoneM.focus();
		return false;
	}
	else if(testPh.test(frm.txtPhoneM.value))
	{
		alert("Please type in a valid phone number.");
		frm.txtPhoneM.focus();
		frm.txtPhoneM.select();
		return false;
	}
	
	//Check Userid Validation
	var strUserIdLen=new String(frm.txtUid.value);
	if((strUserIdLen.length<5) || (strUserIdLen.length>30))
	{
		alert("Display name should be minimum 5 characters and maximum 30 characters");
		frm.txtUid.focus();
		return false;
	}
	
	var testUserId=new RegExp("[^A-Za-z0-9-_]","g");
	if((testUserId.test(frm.txtUid.value)) || (frm.txtUid.value==""))
	{
		alert("Only Alphabets,Numbers,Underscore and Dashes allowed in display name");
		frm.txtUid.focus();
		frm.txtUid.select();
		return false;
	}
	var testUserIdforemail=new RegExp("(hotmail|yahoo|rediff|dotnet|dotcom|dotedu|aol|usanet|123india|excite|webtv|satyam|vsnl|quickmail|msn|netaddress|edu|gmail|indiatimes)","i");
	if(testUserIdforemail.test(frm.txtUid.value))
	{
		alert("Display name should not contain any personal information like Email-Id etc.");
		frm.txtUid.focus();
		frm.txtUid.select();
		return false;
	}
	
	if(IsStrictNumeric(frm.txtUid.value))
	{
		alert("Display name should not contain only numbers.");
		frm.txtUid.focus();
		frm.txtUid.select();
		return false;
	}
	
	//Check Password validation
	var strPwdLen=new String(frm.txtPwd.value);
	if((strPwdLen.length<5) || (strPwdLen.length>10))
	{
		alert("Password should be minimum 5 characters and maximum 10 characters");
		frm.txtPwd.focus();
		return false;
	}

	var testPwd=new RegExp("[^A-Za-z0-9-_]","g");
	if((testPwd.test(frm.txtPwd.value)) || (frm.txtPwd.value==""))
	{
		alert("Only Alphabets,Numbers,Underscore and Dashes allowed in Password");
		frm.txtPwd.focus();
		return false;
	}
	
	//validation for userid and password can not be same.
	if (frm.txtUid.value == frm.txtPwd.value)
	{
		alert("Userid and password can not be same.");
		frm.txtUid.focus();
		return false;
	}
	
	//password must be equal to the Re-Enter Password
	if(frm.txtRePwd.value != frm.txtPwd.value)
	{
		alert("Confirm Password does not match Password");
		frm.txtRePwd.focus();
		return false;
	}
	
	//Referal Validation
	if(frm.drpReferal.selectedIndex==0)
	{
		alert("Please Select a Reference.");
		frm.drpReferal.focus();
		return false;
	}
	else if(frm.drpReferal.selectedIndex==1 && frm.txtReferal.value=="")
	{
		alert("Please Enter the name of website.");
		frm.txtReferal.focus();
		return false;
	}
	else if(frm.drpReferal.selectedIndex==2 && frm.txtReferal.value=="")
	{
		alert("Please Enter the name of Existing Member.");
		frm.txtReferal.focus();
		return false;
	}
	else if(frm.drpReferal.selectedIndex==3 && frm.txtReferal.value=="")
	{
		alert("Please Enter the name of Search Engine.");
		frm.txtReferal.focus();
		return false;
	}
	
	//Check if the user has checked Terms & condition checkbox
	if(frm.chkTerms.checked == false)
	{
		alert("Please agree to the Terms and conditions on the site.");
		return false;
	}
	
	return true;
}


//Function  call on the country selection
function drpCob_onClick()
{	
	//fill Countries
	if(document.getElementById('drpCoc').selectedIndex==0)
	{
		document.getElementById('drpCoc').selectedIndex = document.getElementById('drpCob').selectedIndex;
	}
	
	if(document.getElementById('drpCor').selectedIndex==0)
	{
		document.getElementById('drpCor').selectedIndex = document.getElementById('drpCob').selectedIndex;
	}
	
	//fill States
	fillState('drpCor','drpSor');	
	return false;
}

function fillState(drpId,drpSt)
{
	var drpState = document.getElementById(drpSt);
	drpState.options.length = 0;
	var drpCity = document.getElementById('drpCityM');
	drpCity.options.length = 0;
	
	if(document.getElementById(drpId).selectedIndex>0)
	{
		var cntryCd = document.getElementById(drpId).options[document.getElementById(drpId).selectedIndex].value;		
		var strState = document.getElementById("hdn").value;
		var stringArray = strState.split("|");		
		
		drpState.options[drpState.options.length]= new Option('--Select--','-1');
		for(var i=0 ;i<stringArray.length; i++)
		{			
			var temp= stringArray[i];
			if(temp!="")
			{
				var strA = temp.split("+");
				if(strA[0] == cntryCd)
					drpState.options[drpState.options.length]= new Option(strA[2],strA[1]);
			}			
		}
	}
	
	if(drpState.options.length==1)
	{
		drpState.options.length = 0;
		drpCity.options.length = 0;
		drpState.options[drpState.options.length]= new Option("None","0");
		drpCity.options[drpCity.options.length]= new Option("None","0");
	}
	else
	{
		drpCity.options[drpCity.options.length]= new Option("--Select--","0");
	}
	
	//fillCity('drpSor','drpCityM');
	return false;
}

function fillCity(drpSt,drpCity)
{
	var drpCity = document.getElementById(drpCity);
	drpCity.options.length = 0;
	
	if(document.getElementById(drpSt).selectedIndex>0)
	{
		var stateCd = document.getElementById(drpSt).options[document.getElementById(drpSt).selectedIndex].value;		
		var strCity = document.getElementById("hdnSor").value;
		var stringArray = strCity.split("|");
		
		for(var i=0 ;i<stringArray.length; i++)
		{	
			var temp= stringArray[i];
			if(temp!="")
			{
				var strA = temp.split("+");
				if(strA[0] == stateCd)
					drpCity.options[drpCity.options.length]= new Option(strA[2],strA[1]);
			}			
		}
	}
	
	if(drpCity.options.length==0)
	{
		drpCity.options[drpCity.options.length]= new Option("None","0");
	}
	
	return false;
}

function fees_onclick() {
	window.open("../Membership/index.aspx","membership", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes, resizable=no,width=750,height=700,top=10,left=10"); 
}

function Check()
{
	var mail = document.getElementById("txtEmailID").value
	GetEmailID("intermediate.aspx?action=email&code=" + mail);
	var email = document.getElementById("hdnEmail").value;
	if (email=="true") 
	{
		alert("Email Id already exists, Please use another.");
		return false;
	}
	return true;
}

function completeRegistration()
{
	if(document.getElementById("rdOption4").checked)
	{
		var frm = document.registration;
		var strUserIdLen=new String(frm.txtOption4.value);
		if((strUserIdLen.length<5) || (strUserIdLen.length>30))
		{
			alert("Display name should be minimum 5 characters and maximum 30 characters");
			frm.txtOption4.focus();
			return false;
		}

		var testUserId=new RegExp("[^A-Za-z0-9-_]","g");
		if((testUserId.test(frm.txtOption4.value)) || (frm.txtOption4.value==""))
		{
			alert("Only Alphabets,Numbers,Underscore and Dashes allowed in display name");
			frm.txtOption4.focus();
			frm.txtOption4.select();
			return false;
		}
		var testUserIdforemail=new RegExp("(hotmail|yahoo|rediff|dotnet|dotcom|dotedu|aol|usanet|123india|excite|webtv|satyam|vsnl|quickmail|msn|netaddress|edu|gmail|indiatimes)","i");
		if(testUserIdforemail.test(frm.txtOption4.value))
		{
			alert("Display name should not contain any personal information like Email-Id etc.");
			frm.txtOption4.focus();
			frm.txtOption4.select();
			return false;
		}
	}
}

function ViewReferal()
{
	var frm = document.registration;
	if(frm.drpReferal.selectedIndex==1)
	{
		frm.txtReferal.style.display='block';
		frm.txtReferal.value='Website Name';
	}
	else if(frm.drpReferal.selectedIndex==2)
	{
		frm.txtReferal.style.display='block';
		frm.txtReferal.value='Member ID';
	}
	else if(frm.drpReferal.selectedIndex==3)
	{
		frm.txtReferal.style.display='block';
		frm.txtReferal.value='Search Engine';
	}
	else
	{
		frm.txtReferal.style.display='none';		
	}
	return true;
}

function checkAvailability()
{
	var frm = document.registration;
	//Email 
	if(frm.txtEmailID.value=="")
	{
		alert("Please enter a Email Id.");
		frm.txtEmailID.focus();
		return false;
	}
	else if(!ValidateEmail(frm.txtEmailID.value))
	{
		frm.txtEmailID.focus();
		return false;
	}
	return true
}

function SelectSatate()
{
	var strCity;
	var stateCd = document.getElementById('drpSor').options[document.getElementById('drpSor').selectedIndex].value;
	document.getElementById('hdnSor').value = stateCd;
	//getCityList("../intermediate.aspx?SCD="+stateCd);
	var drpCity = document.getElementById("drpCityM");
	drpCity.options.length = 0;

	if(document.getElementById("drpSor").selectedIndex>0)
	{
		strCity = CityList_state(stateCd);
		var stringArray = strCity.split("|");		
		for(var i=0 ;i<stringArray.length; i++)
		{	
			var temp= stringArray[i];
			temp = temp.replace("&", " ");
			if(temp!="")
			{
				var strA = temp.split("+");
				drpCity.options[drpCity.options.length]= new Option(strA[1],strA[0]);
			}			
		}
	}
	
	if(drpCity.options.length==0)
	{
		drpCity.options[drpCity.options.length]= new Option("None","0");
	}
	
	return true;	
}

function getCityList(urlHTML)
{
	document.getElementById("DivResponse").value="";
	var xmlHttp;
	try
	{
		/* Firefox, Opera 8.0+, Safari */
		xmlHttp=new XMLHttpRequest();
	}
	catch (e)
	{
		/* newer IE */
		try
		{
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e)
		{
			/* older IE */
			try
			{
				xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
			}
			catch (e)
			{
				alert("Your browser is old and does not have AJAX support!");
				return false;
			}
		}
	}
	
	xmlHttp.onreadystatechange=function()
	{
		if(xmlHttp.readyState==4)
		{
			document.getElementById("DivResponse").value =xmlHttp.responseText;
		}
	}
	
	xmlHttp.open("GET",urlHTML,true);
	xmlHttp.send(null);
 } 
 
 function drpCityM_OnChange()
 { 
	document.getElementById("hdnCor").value = document.getElementById('drpCityM').options[document.getElementById('drpCityM').selectedIndex].value;
	return false;	
 }

