// Survey Personal Info Registration Form JScript source code
var isPopUp = true;

function StateByCountry(countryIndex){
	if (countryIndex ==0){
		document.form1.state.options.selectedIndex=0
	}else{
		document.form1.state.options.selectedIndex=62
	}
}

function CountryByState(stateIndex){
	if (stateIndex==62){
		document.form1.country.options.selectedIndex=1
	}else{
		document.form1.country.options.selectedIndex=0
	}
}

//******************************************************************
// Validates content of fields
//******************************************************************
function checkfield(fieldlabel,fieldname,acceptonly){
var s= new String();
	characters = new RegExp ("[^A-Za-z ]","i");
	numbers = new RegExp ("[^0-9]","i");
	numchar = new RegExp ("[^0-9-^A-Za-z ]","i");
	s = document.form1[fieldname].value;
	result = s.search(eval(acceptonly));
	if (result != -1){
		if (acceptonly == "numchar")
		{
			msg = fieldlabel + " can only contain numbers and characters" + ".";
		}
		else if  (acceptonly == "numbers")
		{
			msg = fieldlabel + " can only contain numbers" + ".";
		}
		else
		{
			msg = fieldlabel + " can only contain characters" + ".";
		}
		document.form1[fieldname].value = "";
		alert(msg);
		document.form1[fieldname].focus();
		return false;
	}
}
//----------------------------------------------------------	

function isFIrstNameOK(){
	var field_val=document.form1.first_name.value.replace(/[ ]/g, "");
	if (field_val.length==0){
		alert('Please type your first name');
		document.form1.first_name.value=""
		document.form1.first_name.focus();
		return false;
		}
	return true;
}

function isLastNameOK(){
	var field_val=document.form1.last_name.value.replace(/[ ]/g, "");
	if (field_val.length==0){
		alert('Please type your last name');
		document.form1.last_name.value="";
		document.form1.last_name.focus();
		return false;
		}
	return true;
}

function isGenderOK(){
	//if(document.form1.gender.value==0){
	var field_val=document.form1.gender.value.replace(/[ ]/g, "");
	if(field_val.length==0){
		alert("Please select your gender.");
		document.form1.gender.focus();
		return false;
	}
	return true;
}

function isAddres1OK(){
	var field_val=document.form1.address1.value.replace(/[ ]/g, "");
	if (field_val.length==0){
		alert('Please type your post address.');
		document.form1.address1.value="";
		document.form1.address1.focus();
		return false;
		}
	return true;
}

function isCityOK(){
	var field_val=document.form1.city.value.replace(/[ ]/g, "");
	if (field_val.length==0){
		alert('Please type your city.');
		document.form1.city.value="";
		document.form1.city.focus();
		return false;
		}
	return true;
}

function month_of_birthOK(){
	if(document.form1.birth_month.value=="00"){
	if (document.form1.birth_month.options[document.form1.birth_month.selectedIndex].value == "00")
		{
		alert('Plese select your month of birth.');
		document.form1.birth_month.focus();
        return false;
		}
	}	
return true;
}
	
function day_of_birthOK(){
	if(document.form1.birth_day.value=="00"){
	if (document.form1.birth_day.options[document.form1.birth_day.selectedIndex].value == "00")
		{
		alert('Plese select your day of birth.');
		document.form1.birth_day.focus();
        return false;
		}
	}	
return true;
}

function year_of_birthOK()
	{
	if(document.form1.birth_year.value=="----")
		{
		alert('Plese select your year of birth.');
		document.form1.birth_year.value="";
		document.form1.birth_year.focus();
		return false;
		}
	if(document.form1.birth_year.value < 1900 || document.form1.birth_year.value >= 2003)
		{
		alert("Year of Birth field is Invalid.\nPlease enter a proper value.");
		document.form1.birth_year.value="";
		document.form1.birth_year.focus();
		return false;
		}
	return true;
}

function isAddressOK(){
	var field_val=document.form1.address1.value.replace(/[ ]/g, "");
	if (field_val.length==0){
		alert('Please type your Address');
		document.form1.address1.value="";
		document.form1.address1.focus();
		return false;
		}
	return true;
}

function isCityOK(){
	var field_val=document.form1.city.value.replace(/[ ]/g, "");
	if (field_val.length==0){
		alert('Please type your City');
		document.form1.city.value="";
		document.form1.city.focus();
		return false;
		}
	return true;
}

function isStateOK(){
	if(document.form1.state.value=='---' || document.form1.state.value.length<1){
		alert("Please select your state.");
		document.form1.state.focus();
		return false;
	}
	return true;
}

function isCountryOK(){
	if(document.form1.country.value=='---' || document.form1.country.value.length<1){
		alert("Please select your country.");
		document.form1.country.focus();
		return false;
	}
	return true;
}

function isZipOK(){
	var field_val=document.form1.zip.value.replace(/[ ]/g, "");
	if (field_val.length<5){
		alert('Please type your postal Zip Code.');
		document.form1.zip.value=""
		document.form1.zip.focus();
		return false;
		}
	return true;
}

function isPnone1OK(){
	var field_val1=document.form1.phone1_1.value.replace(/[ ]/g, "");
	var field_val2=document.form1.phone1_2.value.replace(/[ ]/g, "");
	var field_val3=document.form1.phone1_3.value.replace(/[ ]/g, "");
	
	if (field_val1==0 || field_val1.length<3){
		alert('Please type your phone Area Code.');
		document.form1.phone1_1.value=""
		document.form1.phone1_1.focus();
		return false;
	}
	if (field_val2==0 || field_val2.length<3){
		alert('Please type your phone prefix.');
		document.form1.phone1_2.value=""
		document.form1.phone1_2.focus();
		return false;
	}
	if (field_val3==0 || field_val3.length<4){
		alert('Please type your phone number.');
		document.form1.phone1_3.value=""
		document.form1.phone1_3.focus();
		return false;
	}
return true;
}

function isPnone2OK(){
	var field_val1=document.form1.phone2_1.value.replace(/[ ]/g, "");
	var field_val2=document.form1.phone2_2.value.replace(/[ ]/g, "");
	var field_val3=document.form1.phone2_3.value.replace(/[ ]/g, "");
	
	if (field_val1==0 || field_val1.length<3){
		alert('Please type your phone Area Code.');
		document.form1.phone2_1.value=""
		document.form1.phone2_1.focus();
		return false;
	}
	if (field_val2==0 || field_val2.length<3){
		alert('Please type your phone prefix.');
		document.form1.phone2_2.value=""
		document.form1.phone2_2.focus();
		return false;
	}
	if (field_val3==0 || field_val3.length<4){
		alert('Please type your phone number.');
		document.form1.phone2_3.value=""
		document.form1.phone2_3.focus();
		return false;
	}
return true;
}


function isEMailOK(){
	var emstr;  // e-mail string
	var emstr_confirm;  // e-mail string
	var sht;    // '@' position in e-mail
	var dot;    // '.' position in e-mail
	var Wrongsim='"' + " :*'!%+=;,/#";
	
	emstr=document.form1.email.value.toLowerCase();

	sht=emstr.indexOf('@');
	dot=emstr.indexOf('.');

	if(sht==-1 || dot==-1)
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.email.value="";
		document.form1.email.focus();
		return false;
		}
	if(sht==0||dot==0)
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.email.value="";
		document.form1.email.focus();
		return false;
		}
	if(emstr.charAt(emstr.length-1)=='@'||emstr.charAt(emstr.length-1)=='.')
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.email.value="";
		document.form1.email.focus();
		return false;
		}
	if(emstr.split('@').length!=2)
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.email.value="";
		document.form1.email.focus();
		return false;
		}
	if(emstr.split('@')[1].indexOf('.')==-1||emstr.split('@')[1].indexOf('.')==0)
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.email.value="";
		document.form1.email.focus();
		return false;
		}
	for(i=0;i<emstr.length;i++)
		{
		if(Wrongsim.indexOf(emstr.charAt(i))!=-1)
			{
			alert("Invalid E-mail!\nPlease Type Again.");
			document.form1.email.value="";
			document.form1.email.focus();
			return false;
			}
		}
	return true;
}

function isEMailOK1(){
	var emstr;  // e-mail string
	var emstr_confirm;  // e-mail string
	var sht;    // '@' position in e-mail
	var dot;    // '.' position in e-mail
	var Wrongsim='"' + " :*'!%+=;,/#";
	
	emstr=document.form1.emailchanged.value.toLowerCase();

	sht=emstr.indexOf('@');
	dot=emstr.indexOf('.');

	if(sht==-1 || dot==-1)
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.emailchanged.value="";
		document.form1.emailchanged.focus();
		return false;
		}
	if(sht==0||dot==0)
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.emailchanged.value="";
		document.form1.emailchanged.focus();
		return false;
		}
	if(emstr.charAt(emstr.length-1)=='@'||emstr.charAt(emstr.length-1)=='.')
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.emailchanged.value="";
		document.form1.emailchanged.focus();
		return false;
		}
	if(emstr.split('@').length!=2)
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.emailchanged.value="";
		document.form1.emailchanged.focus();
		return false;
		}
	if(emstr.split('@')[1].indexOf('.')==-1||emstr.split('@')[1].indexOf('.')==0)
		{
		alert("Invalid E-mail!\nPlease Type Again.");
		document.form1.emailchanged.value="";
		document.form1.emailchanged.focus();
		return false;
		}
	for(i=0;i<emstr.length;i++)
		{
		if(Wrongsim.indexOf(emstr.charAt(i))!=-1)
			{
			alert("Invalid E-mail!\nPlease Type Again.");
			document.form1.emailchanged.value="";
			document.form1.emailchanged.focus();
			return false;
			}
		}
	return true;
}

function isPaypalEmailOK(){
	var emstr;  // e-mail string
	var emstr_confirm;  // e-mail string
	var sht;    // '@' position in e-mail
	var dot;    // '.' position in e-mail
	var Wrongsim='"' + " :*'!%+=;,/#";
	
	emstr=document.form1.paypal_email.value.toLowerCase();
if(emstr.length > 0)
	{
	sht=emstr.indexOf('@');
	dot=emstr.indexOf('.');

	if(sht==-1 || dot==-1)
		{
		alert("Invalid Paypal Email!\nPlease Type Again.");
		document.form1.paypal_email.value="";
		document.form1.paypal_email.focus();
		return false;
		}
	if(sht==0||dot==0)
		{
		alert("Invalid Paypal Email!\nPlease Type Again.");
		document.form1.paypal_email.value="";
		document.form1.paypal_email.focus();
		return false;
		}
	if(emstr.charAt(emstr.length-1)=='@'||emstr.charAt(emstr.length-1)=='.')
		{
		alert("Invalid Paypal Email!\nPlease Type Again.");
		document.form1.paypal_email.value="";
		document.form1.paypal_email.focus();
		return false;
		}
	if(emstr.split('@').length!=2)
		{
		alert("Invalid Paypal Email!\nPlease Type Again.");
		document.form1.paypal_email.value="";
		document.form1.paypal_email.focus();
		return false;
		}
	if(emstr.split('@')[1].indexOf('.')==-1||emstr.split('@')[1].indexOf('.')==0)
		{
		alert("Invalid Paypal Email!\nPlease Type Again.");
		document.form1.paypal_email.value="";
		document.form1.paypal_email.focus();
		return false;
		}
	for(i=0;i<emstr.length;i++)
		{
		if(Wrongsim.indexOf(emstr.charAt(i))!=-1)
			{
			alert("Invalid Paypal Email!\nPlease Type Again.");
			document.form1.paypal_email.value="";
			document.form1.paypal_email.focus();
			return false;
			}
		}
	}
	return true;
}


function isGenericEMailOK(email){
	var emstr;  // e-mail string
	var emstr_confirm;  // e-mail string
	var sht;    // '@' position in e-mail
	var dot;    // '.' position in e-mail
	var Wrongsim='"' + " :*'!%+=;,/#";
	
	emstr=email.toLowerCase();

	sht=emstr.indexOf('@');
	dot=emstr.indexOf('.');

	if(sht==-1 || dot==-1)
		{
		return false;
		}
	if(sht==0||dot==0)
		{
		return false;
		}
	if(emstr.charAt(emstr.length-1)=='@'||emstr.charAt(emstr.length-1)=='.')
		{
		return false;
		}
	if(emstr.split('@').length!=2)
		{
		return false;
		}
	if(emstr.split('@')[1].indexOf('.')==-1||emstr.split('@')[1].indexOf('.')==0)
		{
		return false;
		}
	for(i=0;i<emstr.length;i++)
		{
		if(Wrongsim.indexOf(emstr.charAt(i))!=-1)
			{
			return false;
			}
		}
	return true;
}



function isMaritalStatusOk(){
	if(document.form1.marital.selectedIndex==0){
		alert("Please select your Marital Status");
		document.form1.marital.focus();
		return false;
	}
	return true;
}


function isemployedOk(){
	if(document.form1.cur_employed.selectedIndex==0){
		alert("Please select your Employement Status");
		document.form1.cur_employed.focus();
		return false;
	}
	return true;
}

function isHHIncomeOk(){
	if(document.form1.hh_income.selectedIndex==0){
		alert("Please select your Household income");
		document.form1.hh_income.focus();
		return false;
	}
	return true;
}
function isEducationOk(){
	if(document.form1.education.selectedIndex==0){
		alert("Please select your education level");
		document.form1.education.focus();
		return false;
	}
	return true;
}
function isOccupationOk(){
	if(document.form1.occupation.selectedIndex==0){
		alert("Please select your current occupation");
		document.form1.occupation.focus();
		return false;
	}
	return true;
}
function isConsiderOk(){
	if(document.form1.constobe.selectedIndex==0){
		alert("Please select your consider yourself to be");
		document.form1.constobe.focus();
		return false;
	}
	return true;
}

function isoffer3OK(){
	if(!document.form1.offer3[0].checked && !document.form1.offer3[1].checked){
		alert('Please select YES / NO for more offers.');
		document.form1.offer3[0].focus();
		return false;
	}
return true;
}


function isoffer2OK(){
	if(!document.form1.offer2[0].checked && !document.form1.offer2[1].checked){
		alert('Please select YES / NO for more offers.');
		document.form1.offer2[0].focus();
		return false;
	}
return true;
}


function isoffer1OK(){
	if(!document.form1.offer1[0].checked && !document.form1.offer1[1].checked){
		alert('Please select YES / NO for more offers.');
		document.form1.offer1[0].focus();
		return false;
	}
return true;
}



function isPasswordOK(){
	var field_val=document.form1.password.value.replace(/[ ]/g, "");
	if (field_val.length==0){
		alert('Please type your Password');
		document.form1.password.value=""
		document.form1.password.focus();
		return false;
		}
	return true;
}

function isC_PasswordOK(){
	var field_val=document.form1.C_password.value.replace(/[ ]/g, "");
	if (field_val.length==0){
		alert('Please confirm your Password');
		document.form1.C_password.value=""
		document.form1.C_password.focus();
		return false;
		}
	return true;
}

function isPasswordMatchingOK(){
	var field_val=document.form1.password.value.replace(/[ ]/g, "");
	var field_val2=document.form1.C_password.value.replace(/[ ]/g, "");
	if (field_val != field_val2){
		alert('Password doesnot match with confirm password');
		document.form1.password.value=""
		document.form1.password.focus();
		return false;
		}
	return true;
}

function isTermsOk(){
	if (!document.form1.emm_terms.checked){
		alert('Please select Terms and Conditions option');
		document.form1.checked.focus();
		return false;
		}
	return true;
}


function showHide(){

	if (document.getElementById) {
   
		path2 = document.getElementById('coreg2').style;
	}
	else if (document.all) {
   
		path2 = document.all.coreg2.style;
	}

	if (document.forms['form1'].elements['gender'].selectedIndex != 0) {
  
		path2.display = "block";
	}

}
