/*****************************************************************
* Author : Poomalairaj.R <poomalairaj@bharatmatrimony.com>
* file name : singlepagevalidate.js
* desc : JS validation functions  for single page registration
* Date : 11:20 AM 9/6/2008
******************************************************************/	
// Function to validate all the inputs in the single page registration
function Validate_singlePage() {
var MatriForm = this.document.MatriForm;

if($('DOMAIN'))
{
	if($('DOMAIN').selectedIndex==0)
	{$('domainspan').innerHTML="Please select the domain";$('row0').className="rowcolor";MatriForm.DOMAIN.focus();return false;
	}else{$('domainspan').innerHTML="&nbsp";$('row0').className="normalrow";}
	
	var dact=document.MatriForm.DOMAIN.options[document.MatriForm.DOMAIN.selectedIndex].text;
	var dact1=dact.split(" - ");
	document.MatriForm.action="http://profile."+dact1[1]+"/register/singlepageregister.php";
}
if(IsEmpty(document.MatriForm.NAME,"text"))
{
$('namespan').innerHTML="Please enter the name of the prospect";MatriForm.NAME.value="";MatriForm.NAME.focus();return false;
}else{$('namespan').innerHTML="&nbsp";}

	
if(IsEmpty(document.MatriForm.AGE,"text"))
{ 
  if (document.MatriForm.DOBMONTH.options[document.MatriForm.DOBMONTH.selectedIndex].text=="-Month-")	
  {$('agespan').innerHTML="Please select month";MatriForm.DOBMONTH.focus();return false;}
  else{$('agespan').innerHTML="&nbsp;";}

  if (document.MatriForm.DOBDAY.options[document.MatriForm.DOBDAY.selectedIndex].text=="-Date-")	
  {$('agespan').innerHTML="Please select date";MatriForm.DOBDAY.focus();return false;}
  else{$('agespan').innerHTML="&nbsp;";}

  if (document.MatriForm.DOBYEAR.value=="0")		
  {$('agespan').innerHTML="Please select year";MatriForm.DOBYEAR.focus();return false;}
  else{$('agespan').innerHTML="&nbsp;";}
}	


if(IsEmpty(document.MatriForm.AGE,"text") && (document.MatriForm.DOBMONTH.options[document.MatriForm.DOBMONTH.selectedIndex].text=="-Month-" && document.MatriForm.DOBDAY.options[document.MatriForm.DOBDAY.selectedIndex].text=="-Date-" && document.MatriForm.DOBYEAR.options[document.MatriForm.DOBYEAR.selectedIndex].text=="-Year-")) 
{
$('agespan').innerHTML="Please enter the age or select the date of birth of the prospect";MatriForm.AGE.value="";MatriForm.AGE.focus();return false;
}else{$('agespan').innerHTML="&nbsp;";}

var age = parseInt( MatriForm.AGE.value );

if( !ValidateNo( MatriForm.AGE.value, "0123456789" ) )
{$('agespan').innerHTML="Please enter a valid age";MatriForm.AGE.focus();return false;}
else{$('agespan').innerHTML="&nbsp;";}

var calyear = displayage(MatriForm.DOBYEAR.value,MatriForm.DOBMONTH.value,MatriForm.DOBDAY.value, 'years', 0, 'rounddown')

if (MatriForm.AGE.value<21 && MatriForm.GENDER[0].checked && !(MatriForm.AGE.value==""))
{$('agespan').innerHTML="Prospect should be 21 years to register";MatriForm.AGE.focus();return false;}
else{$('agespan').innerHTML="&nbsp;";}
			
if (MatriForm.AGE.value=="" && calyear < 21 && MatriForm.GENDER[0].checked)
{$('agespan').innerHTML="Prospect should be 21 years to register";MatriForm.AGE.focus();return false;}
else{$('agespan').innerHTML="&nbsp;";}

if (MatriForm.AGE.value < 18 && MatriForm.GENDER[1].checked && !(MatriForm.AGE.value==""))
{$('agespan').innerHTML="Prospect should be 18 years to register";MatriForm.AGE.focus();return false;}
else{$('agespan').innerHTML="&nbsp;";}
			
if (MatriForm.AGE.value=="" && calyear < 18 && MatriForm.GENDER[1].checked)
{$('agespan').innerHTML="Prospect Should be 18 years to Register";MatriForm.AGE.focus();return false;}
else{$('agespan').innerHTML="&nbsp;";}


if ( age > 70 && calyear > 70)
{$('agespan').innerHTML="Maximum age allowed is 70";MatriForm.AGE.focus( );return false;}
else{$('agespan').innerHTML="&nbsp;";}


if (!MatriForm.GENDER[0].checked && !MatriForm.GENDER[1].checked)
{$('genderspan').innerHTML="Please select the gender of the prospect";MatriForm.GENDER[0].focus( );return false;}
else if (MatriForm.GENDER[0].checked || MatriForm.GENDER[1].checked){$('genderspan').innerHTML="&nbsp";}


if ( IsEmpty(document.MatriForm.MARITAL_STATUS,'radio'))
{$('maritalspan').innerHTML="Please select the marital status of the prospect";MatriForm.MARITAL_STATUS[0].focus( );return false;}
else{$('maritalspan').innerHTML="&nbsp;";}

if ( !(document.MatriForm.MARITAL_STATUS[0].checked) && MatriForm.NOOFCHILDREN.selectedIndex == 0 )
{$('nocspan').innerHTML="Please select the number of children";MatriForm.NOOFCHILDREN.focus( );return false;}
else{$('nocspan').innerHTML=" ";}
		
if ( !(document.MatriForm.MARITAL_STATUS[0].checked) && document.MatriForm.NOOFCHILDREN.options[document.MatriForm.NOOFCHILDREN.selectedIndex].value >= 1 && !MatriForm.CHILDLIVINGWITHME[0].checked && !MatriForm.CHILDLIVINGWITHME[1].checked)
{$('clsspan').innerHTML="Please indicate whether the child/children is/are living with you";MatriForm.CHILDLIVINGWITHME[0].focus( );return false;}
else{$('clsspan').innerHTML=" ";}
		
if (MatriForm.MOTHERTONGUE.selectedIndex==0)
{$('mothertonguespan').innerHTML="Please select the mother tongue of the prospect";$('row11').className="errorrow";MatriForm.MOTHERTONGUE.focus();return false;}	
else{$('mothertonguespan').innerHTML=" ";$('row11').className="normalrow";}

if ( MatriForm.RELIGION.selectedIndex == 0 )
{$('religionspan').innerHTML="Please select the religion of the prospect";MatriForm.RELIGION.focus( );return false;}
else{$('religionspan').innerHTML=" ";}

if($('CASTE').value=='o') {$('castespan').innerHTML = 'Please select the caste of the prospect';$('CASTE').focus();return false;}
else{$('castespan').innerHTML='';}

if (!(MatriForm.SUBCASTE.value=="Enter sub caste here")) {
	if ($('CASTE').selectedIndex==0)
	{$('castespan').innerHTML="Please select the caste";$('CASTE').focus();return false;}	
	else{$('castespan').innerHTML=" ";}
}
	
if($('CASTE').value=='999' && document.MatriForm.SUBCASTE.value=='Enter sub caste here') {
	$('subcastespan').innerHTML="Please enter your sub caste";$('SUBCASTE').focus();return false;
} else {$('subcastespan').innerHTML="";}
	
if($('SUBCASTE1').options[$('SUBCASTE1').selectedIndex].text =='Others' && $('SUBCASTE').value=='Enter sub caste here' )
{
	$('subcastestar').style.display='block';
	$('subcastespan').innerHTML="If your sub caste is not listed here, please enter it in the text box";
	$('row12').className="errorrow";MatriForm.SUBCASTE.focus();return false;
} 
else {$('subcastestar').style.display='none';$('subcastespan').innerHTML=" ";$('row12').className="normalrow";}
	
var selbox=$('SUBCASTE1');
var selectedText = selbox.options[selbox.selectedIndex].text;

if(selbox.style.display=='block') 
{
	if(selectedText == '- Select -' && $('CASTE').value!='o' && $('CASTE').value!='0')
	{$('subcastestar').style.display='block';$('subcastespan').innerHTML="Please select your sub caste";selbox.focus();return false;}
	else 
	{
	if(selectedText!='Others') {$('subcastespan').innerHTML=" "; $('subcastestar').style.display='none';$('row12').className="normalrow";}
	}
}
	

if($('gothraAvail').value=='yes') {
	if($('GOTHRAM').value == 0) {
		$('gothrastart').style.display = 'block';
		$('gothraspan').innerHTML = "&nbsp;&nbsp;Please select Gothra of the prospect";
		$('GOTHRAM').focus();return false;
	}
	else {
		$('gothraspan').innerHTML = "";
		$('gothrastart').style.display = 'none';
	}
}

	if($('GOTHRAM').value=="999" && $('GOTHRAMOTHERS').value=='') { $('gothraspan').innerHTML = "&nbsp;&nbsp;Please enter Gothra of the prospect"; $('GOTHRAMOTHERS').focus();return false; }
	else { $('gothraspan').innerHTML = ""; }
if ( parseInt( MatriForm.CITIZENSHIP.options[MatriForm.CITIZENSHIP.selectedIndex].value ) == 0 || MatriForm.CITIZENSHIP.options[MatriForm.CITIZENSHIP.selectedIndex].value=="")
{$('citispan').innerHTML="Please select the citizenship of the prospect";$('row4').className="rowcolor";MatriForm.CITIZENSHIP.focus( );return false;}
else{$('citispan').innerHTML=" ";$('row4').className="normalrow";}

if ( parseInt( MatriForm.COUNTRY.options[MatriForm.COUNTRY.selectedIndex].value ) == 0 || MatriForm.COUNTRY.options[MatriForm.COUNTRY.selectedIndex].value=="" )
{$('clspan').innerHTML="Please select the country of living of the prospect";$('row4').className="rowcolor";MatriForm.COUNTRY.focus( );return false;}
else{$('clspan').innerHTML=" ";$('row4').className="normalrow";}

if ( IsEmpty(document.MatriForm.RESIDENTSTATUS,'radio'))
{$('resspan').innerHTML="Please select the resident status of the prospect";$('row5').className="rowcolor";MatriForm.RESIDENTSTATUS[0].focus( );return false;}
else{$('resspan').innerHTML=" ";$('row5').className="normalrow";}

if ( !MatriForm.OCCUPATIONCATEGORY[0].checked && !MatriForm.OCCUPATIONCATEGORY[1].checked && !MatriForm.OCCUPATIONCATEGORY[2].checked && !MatriForm.OCCUPATIONCATEGORY[3].checked && !MatriForm.OCCUPATIONCATEGORY[4].checked)
{$('empspan').innerHTML="Please select the organization type the prospect is employed with";$('row6').className="rowcolor";MatriForm.OCCUPATIONCATEGORY[0].focus( );return false;}
else{$('empspan').innerHTML=" ";$('row6').className="normalrow";}
//Phone validation

if($('COUNTRYCODE').value=="Country code" && $('AREACODE').value=="Area code" && $('PHONENO').value=="Telephone number" && $('MOBILENO').value=="Mobile number")
{$('phonespan').innerHTML="Please enter the contact number";$('row7').className="rowcolor";$('PHONENO').focus();return false; }
else{$('phonespan').innerHTML="";$('row7').className="normalrow";}
if (IsEmpty($('PHONENO'),'text')  && IsEmpty($('MOBILENO'),'text'))
{$('phonespan').innerHTML="Please enter the contact number";$('row7').className="rowcolor";$('PHONENO').focus();return false;}
else{$('phonespan').innerHTML="";$('row7').className="normalrow";}

if (!(IsEmpty($('COUNTRYCODE'),'text')))
{
	if (!ValidateNo($('COUNTRYCODE').value,'1234567890'))
	{$('phonespan').innerHTML="Please enter a valid country code";$('row7').className="rowcolor";$('COUNTRYCODE').focus();return false;}
	else{$('phonespan').innerHTML="";$('row7').className="normalrow";}
}

if (!IsEmpty($('PHONENO'),'text') && $('PHONENO').value!="Telephone number")
{
	if (IsEmpty($('COUNTRYCODE'),'text') )
	{$('phonespan').innerHTML="Please enter the country code";$('row7').className="rowcolor";$('COUNTRYCODE').focus();return false;}
	else{$('phonespan').innerHTML="";$('row7').className="normalrow";}
			
	if (IsEmpty($('AREACODE'),'text'))
	{$('phonespan').innerHTML="Please enter area / STD code";$('row7').className="rowcolor";$('AREACODE').focus();return false;}
	else{$('phonespan').innerHTML="";$('row7').className="normalrow";}
}

if (!IsEmpty($('MOBILENO'),'text') && $('MOBILENO').value!="Mobile number")
{
	if (IsEmpty($('COUNTRYCODE'),'text'))
	{$('phonespan').innerHTML="Please enter the country code";$('row7').className="rowcolor";$('COUNTRYCODE').focus();return false;}
	else{$('phonespan').innerHTML="";$('row7').className="normalrow";}
}

// Check E-mail
if (IsEmpty(document.MatriForm.EMAIL,"text"))
{$('emailspan').innerHTML="Please enter a valid E-mail address";$('row8').className="rowcolor";MatriForm.EMAIL.focus( );return false;}
else{$('emailspan').innerHTML=" ";$('row8').className="normalrow";}
if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(document.MatriForm.EMAIL.value)))
	{
	$('emailspan').innerHTML="Please enter a valid E-mail address";$('row8').className="rowcolor";MatriForm.EMAIL.focus( );return false;}
	else{$('emailspan').innerHTML=" ";$('row8').className="normalrow";
	}

if(IsEmpty(document.MatriForm.PASSWD1,"password"))
{$('passwdspan').innerHTML="Please enter your password";$('row9').className="rowcolor";MatriForm.PASSWD1.focus( );return false;}
else{$('passwdspan').innerHTML=" ";$('row9').className="normalrow";}


if ( MatriForm.PASSWD1.value.length < 4 )
{$('passwdspan').innerHTML="Password must have a minimum of 4 characters";$('row9').className="rowcolor";MatriForm.PASSWD1.focus( );return false;}
else{$('passwdspan').innerHTML=" ";$('row9').className="normalrow";}

var pwd1=MatriForm.PASSWD1.value;
pwd1=pwd1.toUpperCase()
var una=MatriForm.NAME.value
una=una.toUpperCase()

if (pwd1 == una)
{$('passwdspan').innerHTML="The name and password cannot be the same. Please change the password";$('row9').className="rowcolor";MatriForm.PASSWD1.focus( );return false;}
else{$('passwdspan').innerHTML=" ";$('row9').className="normalrow";}

if(pwd1=='123456')
{$('passwdspan').innerHTML="Sorry, your password has been rejected.It is recommended that you submit a password with alphanumeric characters.";$('row9').className="rowcolor";MatriForm.PASSWD1.focus( );return false;}
else{$('passwdspan').innerHTML=" ";$('row9').className="normalrow";}

tmpPass = MatriForm.PASSWD1.value;
goodPasswd = 1;

for( var idx=0; idx< tmpPass.length; idx++ )
{
	ch = tmpPass.charAt(idx);
	if( !((ch>='a') && (ch<='z')) && !((ch>='A') && (ch<='Z')) && !((ch>=0) && (ch <=9)) )
	{goodPasswd = 0;break;}
}

if ( goodPasswd ==0 )
{$('passwdspan').innerHTML="Spaces or special characters are not allowed in the password";$('row9').className="rowcolor";MatriForm.PASSWD1.focus( );return false;}
else{$('passwdspan').innerHTML=" ";$('row9').className="normalrow";}


if(MatriForm.PASSWD2.value=="")
{$('cpasswdspan').innerHTML="Please confirm your password";$('row9').className="rowcolor";MatriForm.PASSWD2.focus( );return false;}
else{$('cpasswdspan').innerHTML=" ";$('row9').className="normalrow";}

if ( MatriForm.PASSWD1.value != MatriForm.PASSWD2.value )
{$('cpasswdspan').innerHTML="Sorry, both the passwords do not match";$('row9').className="rowcolor";MatriForm.PASSWD2.focus( );return false;}
else{$('cpasswdspan').innerHTML=" ";$('row9').className="normalrow";}

if (MatriForm.FEET.selectedIndex==0 && MatriForm.CMS.selectedIndex==0)
{$('heightspan').innerHTML="Please select the height of the prospect";$('row1').className="errorrow";MatriForm.FEET.focus();return false;}
else{$('heightspan').innerHTML=" ";}

if (MatriForm.EDUCATION.selectedIndex==0)
{$('educationcategoryspan').innerHTML="Please select the education category of the prospect";$('row5').className="errorrow";MatriForm.EDUCATION.focus();return false;}	
else{$('educationcategoryspan').innerHTML=" ";$('row5').className="normalrow";}

if($('OCCUPATIONCATEGORY4').checked==true) {	// if business is chosen.....
	if (!(IsEmpty($('INCOME1'),'text'))) {
	if ($('INCOME_CURRENCY1').selectedIndex==0)
	{$('annualincomespan').innerHTML="Please select the currency type";$('INCOME_CURRENCY1').focus();return false;}	
	else{$('annualincomespan').innerHTML=" ";}

	if(!ValidateNo($('INCOME1').value,'1234567890 ,.'))
	{$('annualincomespan').innerHTML="Please enter a valid income.";$('INCOME1').focus();return false;}	
	else{$('annualincomespan').innerHTML=" ";}
		}
}
	
else if(!($('OCCUPATIONCATEGORY5').checked==true)) {
if ($('OCCUPATION1').value=="" || $('OCCUPATION1').selectedIndex==0)
{$('occupationspan').innerHTML="Please select the occupation of the prospect";$('OCCUPATION1').focus();return false;}	
else{$('occupationspan').innerHTML=" ";}

if (!($('OCCUPATION1').selectedIndex==0)) {
if (IsEmpty($('OCCUPATION1'),'select'))
{$('occupationspan').innerHTML="Please select the occupation of the prospect";$('OCCUPATION1').focus();return false;}	
else{$('occupationspan').innerHTML=" ";}
}
		
		if (!(IsEmpty($('INCOME1'),'text'))) {
			if ($('INCOME_CURRENCY1').selectedIndex==0)
			{$('annualincomespan').innerHTML="Please select the currency type";$('INCOME_CURRENCY1').focus();return false;}	
			else{$('annualincomespan').innerHTML=" ";}
			if(!ValidateNo($('INCOME1').value,'1234567890 ,.'))
			{$('annualincomespan').innerHTML="Please enter a valid income";$('INCOME1').focus();return false;}	
			else{$('annualincomespan').innerHTML=" ";}
		}
	}
/*	
	if (MatriForm.MOTHERTONGUE.selectedIndex==0)
	{$('mothertonguespan').innerHTML="Please select the mother tongue of the prospect";$('row11').className="errorrow";MatriForm.MOTHERTONGUE.focus();return false;}	
	else{$('mothertonguespan').innerHTML=" ";$('row11').className="normalrow";}
*/
	if ($('RESIDINGSTATE').selectedIndex==0)
	{$('residingstatespan').innerHTML="Please select the residing state of the prospect";$('row22').className="errorrow";$('RESIDINGSTATE').focus();return false;}	
	else{$('residingstatespan').innerHTML=" ";$('row22').className="normalrow";}

	if (IsEmpty($('RESIDINGSTATE'),'text'))
	{$('residingstatespan').innerHTML="Please enter the residing state of the prospect";$('row22').className="errorrow";$('RESIDINGSTATE').focus();return false;}	
	else{$('residingstatespan').innerHTML=" ";$('row22').className="normalrow";}

	if ($('RESIDINGCITY').selectedIndex==0)
	{$('residingcityspan').innerHTML="Please select the residing city of the prospect";$('row22').className="errorrow";$("RESIDINGCITY").focus();return false;}	
	else{$('residingcityspan').innerHTML=" ";$('row22').className="normalrow";}

	if (IsEmpty($('RESIDINGCITY'),'text'))
	{$('residingcityspan').innerHTML="Please enter the residing city of the prospect";$('row22').className="errorrow";$("RESIDINGCITY").focus();return false;}	
	else{$('residingcityspan').innerHTML=" ";$('row22').className="normalrow";}

	document.MatriForm.DESCRIPTION.value=$('DESCRIPTION1').value;

	if(document.MatriForm.DESCRIPTION.value=="")
    {$('aboutmyselfspan').innerHTML="Please enter a profile description in not less than 50 characters";$('row17').className="errorrow";$('DESCRIPTION1').focus();return false;}	
	else{$('aboutmyselfspan').innerHTML=" ";$('row17').className="normalrow";}

	var desc=$('DESCRIPTION1').value;

	if(desc.length<50)
    {$('aboutmyselfspan').innerHTML="Please enter a profile description in not less than 50 characters";$('row17').className="errorrow";$('DESCRIPTION1').focus();return false;}	
	else{$('aboutmyselfspan').innerHTML=" ";$('row17').className="normalrow";}

	var radio_choice = false;
	for (counter = 0; counter < MatriForm.REGISTERED_BY.length; counter++)
		{
		if (MatriForm.REGISTERED_BY[counter].checked)
			radio_choice = true; 
		}
	if ( radio_choice === false ) {
		$('profilecreatedbyspan').innerHTML="Please select your relationship with the prospect";
		$('row18').className="errorrow";
		MatriForm.REGISTERED_BY[0].focus();
		return false;
	} else {
		$('profilecreatedbyspan').innerHTML=" ";
		$('row18').className="normalrow";
	}
	if(!document.MatriForm.TERMS.checked)
{$('termsspan').innerHTML="Please accept the terms and conditions to proceed further ";$('row10').className="rowcolor";MatriForm.TERMS.focus( );return false;}
else{$('termsspan').innerHTML=" ";$('row10').className="normalrow";}
	MatriForm.method = 'post';
	if($('SUBCASTE').value=='Enter sub caste here')
		$('SUBCASTE').value='';
	$('hidcountrycode').value=$('COUNTRYCODE').value;
	$('hidareacode').value=$('AREACODE').value;
	$('hidphoneno').value=$('PHONENO').value;
	$('hidmobileno').value=$('MOBILENO').value;
	return true;
}

function occupationChk1() {
	var MatriForm = this.document.MatriForm;
	if ( !MatriForm.OCCUPATIONCATEGORY[0].checked && !MatriForm.OCCUPATIONCATEGORY[1].checked && !MatriForm.OCCUPATIONCATEGORY[2].checked && !MatriForm.OCCUPATIONCATEGORY[3].checked && !MatriForm.OCCUPATIONCATEGORY[4].checked) {
		$('empspan').innerHTML="Please select the organization type the prospect is employed with";
		return;
	} else {
		$('empspan').innerHTML=" ";
	}
}


function occupationChk() {
	if($('OCCUPATIONCATEGORY4').checked==true)
	{
		if (!(IsEmpty($('INCOME1'),'text'))) {
			if ($('INCOME_CURRENCY1').selectedIndex==0)
			{$('annualincomespan').innerHTML="Please select the currency type";return;}	
			else{$('annualincomespan').innerHTML=" ";}

			if(!ValidateNo($('INCOME1').value,'1234567890 ,.'))
			{$('annualincomespan').innerHTML="Please enter a valid income.";return;}	
			else{$('annualincomespan').innerHTML=" ";}
		}
	}
	
	else if(!($('OCCUPATIONCATEGORY5').checked==true))
	{
		if ($('OCCUPATION1').value=="" || $('OCCUPATION1').selectedIndex==0)
		{$('occupationspan').innerHTML="Please select the occupation of the prospect";return;}	
		else{$('occupationspan').innerHTML=" ";}

		if (!($('OCCUPATION1').selectedIndex==0))
		{
			if (IsEmpty($('OCCUPATION1'),'select'))
			{$('occupationspan').innerHTML="Please select the occupation of the prospect";return;}	
			else{$('occupationspan').innerHTML=" ";}
		}
	}
}

function onFEET()
{
	if (!(document.MatriForm.CMS.value=="0"))
	{document.MatriForm.CMS.value="0";}

	if (!(document.MatriForm.FEET.value=="0"))
	{$('heightspan').innerHTML=" ";}		
}
	
function heightChk(){
	var MatriForm = this.document.MatriForm;
	if (MatriForm.FEET.selectedIndex==0 && MatriForm.CMS.selectedIndex==0) {
		$('heightspan').innerHTML="Please select the height of the prospect";
		return;
	} else {
		$('heightspan').innerHTML=" ";
	}
}

function educationChk() {
	var MatriForm = this.document.MatriForm;
	if (MatriForm.EDUCATION.selectedIndex==0) {
		$('educationcategoryspan').innerHTML="Please select the education category of the prospect";
		return;
	} else {
		$('educationcategoryspan').innerHTML=" ";
	}
}
/*
function motherChk() {
	var MatriForm = this.document.MatriForm;
	if (MatriForm.MOTHERTONGUE.selectedIndex==0) {
		$('mothertonguespan').innerHTML="Please select the mother tongue of the prospect";
		return;
	} else {
		$('mothertonguespan').innerHTML=" ";
	}
}*/
function residingstateChk() {
	if ($('RESIDINGSTATE').selectedIndex==0)
	{$('residingstatespan').innerHTML="Please select the residing state of the prospect";return;}
	else{$('residingstatespan').innerHTML=" ";}
}

function residingstateChk1() {
	if (IsEmpty($('RESIDINGSTATE'),'text'))
	{$('residingstatespan').innerHTML="Please enter the residing state of the prospect";return;}	
	else{$('residingstatespan').innerHTML=" ";}
}

function residingcityChk() {
	if ($('RESIDINGCITY').selectedIndex==0)
	{$('residingcityspan').innerHTML="Please select the residing city of the prospect";return;}	
	else{$('residingcityspan').innerHTML=" ";}
}

function residingcityChk1() {
	if (IsEmpty($('RESIDINGCITY'),'text'))
	{$('residingcityspan').innerHTML="Please enter the residing city of the prospect";return;}	
	else{$('residingcityspan').innerHTML=" ";}
}

function descChk() {
	var MatriForm = this.document.MatriForm;
	document.MatriForm.DESCRIPTION.value=$('DESCRIPTION1').value;

	if (document.MatriForm.DESCRIPTION.value=="") {
		$('aboutmyselfspan').innerHTML="Please enter a profile description in not less than 50 characters";
		return;
	} else {
		$('aboutmyselfspan').innerHTML=" ";
	}
	var desc=$('DESCRIPTION1').value;
	if (desc.length<50) {
		$('aboutmyselfspan').innerHTML="Please enter a profile description in not less than 50 characters";
		return;
	} else {
		$('aboutmyselfspan').innerHTML=" ";
	}
}


// Author : Poomalairaj.R <poomalairaj@bharatmatrimony.com>
// File name : singlepageregisterform.php
// Desc : JS validation functions  for single page registration
// Date : 11:20 AM 9/6/2008

function createdChk() {
	var MatriForm = this.document.MatriForm;
	var radio_choice = false;
	for (counter = 0; counter < MatriForm.REGISTERED_BY.length; counter++)
		{
		if (MatriForm.REGISTERED_BY[counter].checked)
			radio_choice = true; 
		}
	if ( radio_choice === false ) {
		$('profilecreatedbyspan').innerHTML="Please select your relationship with the prospect";
		return;
	} else {
		$('profilecreatedbyspan').innerHTML=" ";
	}
}

var state_request=false;
function makerequeststate(cvalue, thisrowid)
{
	var reqloc=location.href;
	var reqloc1=reqloc.substring(reqloc.indexOf('.')+1,reqloc.indexOf('.com'))
	if (cvalue==98) {
		var stateid = $('rescity');		
		stateid.innerHTML = '<div id="addpagecities"><select class="smalltxt" style="width:165px" NAME="RESIDINGCITY" ID="RESIDINGCITY" size="1" onfocus="enterfiled(\'row22\');residingstateChk();" onblur="onexit(\'row22\');residingcityChk();hidsetcity(this);" onchange="clearErrorMsg(\'row22\',\'residingcityspan\');residingcityChk();"><option value="" Selected>- Select -</option></select></div>';
		$('rescitylabel').innerHTML='Residing City / District<font class="clr1 mediumtxt boldtxt">*</font>';
	}
	else {
		var stateid = $('rescity');		
		stateid.innerHTML= '<input type=text class=inputtext name="RESIDINGCITY" id="RESIDINGCITY" size=24 maxlength=40 class="addtextfiled" value="" onfocus="enterfiled(\'row22\')"  onblur="onexit(\'row22\');residingcityChk1();hidsetcity(this);"	onchange="clearErrorMsg(\'row22\',\'residingcityspan\')">';
		$('rescitylabel').innerHTML='Residing City<font class="clr1 mediumtxt boldtxt">*</font>';
	}
		
	if(cvalue>0 && cvalue!=null)
	{
	state_request = createajax();
	var url="/register/singlepageajaxstatecity.php?thisrowid="+thisrowid+"&country="+cvalue;
	state_request.onreadystatechange = processResponsestate;
	state_request.open('GET', url, true);
	state_request.send(null);
	}
	else
	{
		var stateid = $('resstate');
		stateid.innerHTML = '<input type=text class=inputtext name="RESIDINGSTATE" size=24 maxlength=40 class="addtextfiled" value="" onfocus="enterfiled(\'row'+thisrowid+'\')"  onblur="onexit(\'row'+thisrowid+'\');residingstateChk();hidsetstate(this);" onchange="clearErrorMsg(\'row'+thisrowid+'\',\'residingstatespan\')" onkeypress="residingstateChk();">&nbsp;&nbsp;<font class="normaltxt1"><font color="#FF6600"></font></font>';
	}
}

function processResponsestate()
{
	if (state_request.readyState == 4) 
	{
		if (state_request.status == 200) 
		{
			var statesel = $('resstate');
			var listValues = state_request.responseText;			
			statesel.innerHTML = listValues;
		}
	}	
}

//ajax to load city list box 
// modified by poomalai
var ccode_request=false;
function makerequestnew(cvalue)
{
	var reqloc=location.href;
	var reqloc1=reqloc.substring(reqloc.indexOf('.')+1,reqloc.indexOf('.com'))
	if(cvalue>0 && cvalue!=null)
	{
	ccode_request = createajax();
	var url="/register/addmatrimony_getcities.php?stateid="+cvalue; //Mano
	ccode_request.onreadystatechange = processResponsenew;
	ccode_request.open('GET', url, true);
	ccode_request.send(null);
	}
	else
	{
		emptyCitySel();
	}
}

function makerequestsubcaste(lang, rel, caste) {
	rel = document.MatriForm.RELIGION.value;
	if(caste>0 && caste!=null) {
	ccode_request = createajax();
	qString = "domain="+lang+"&religion="+rel+"&caste="+caste;
	var url="../register/ajax_get_subcaste.php?"+qString;
	ccode_request.onreadystatechange = processResponsesubcaste;
	ccode_request.open('GET', url, true);
	ccode_request.send(null);}
	else{emptyCitySel(); }
}

function processResponsenew() {
	if (ccode_request.readyState == 4) {
		if (ccode_request.status == 200) {
			var citysel = $('RESIDINGCITY');
			var listValues = ccode_request.responseText;
			listValueArray = listValues.split('~');
			for(i=0;i<listValueArray.length;i=i+2) {
			  var y=document.createElement('option');
			  y.value=listValueArray[i];
			  y.text=listValueArray[i+1];
			  try { citysel.add(y,null); }
			  catch(ex) { citysel.add(y);}
			}
		}
	}
	else{ emptyCitySel(); }
}


function processResponsesubcaste() {
	if (ccode_request.readyState == 4) {
		if (ccode_request.status == 200) {
			var citysel = $('SUBCASTE1');
			var listValues = ccode_request.responseText;
			listValueArray = listValues.split('~');
			if(listValues=='0~- Select -') {
				$('SUBCASTE').style.display='block';
				$('SUBCASTE1').style.display='none';
			}
			else {
				$('SUBCASTE').style.display='none';
				$('SUBCASTE').value='Enter sub caste here';
				$('SUBCASTE1').style.display='block';
			}
			
			for(i=0;i<listValueArray.length;i=i+2) {
			  var y=document.createElement('option');
			  y.value=listValueArray[i];
			  y.text=listValueArray[i+1];
			  try {citysel.add(y,null);}
			  catch(ex){
				citysel.add(y);}
			}
		}
	}
	else{emptySubcasteSel();}
}

function emptyCitySel() {
	var citysel = $('RESIDINGCITY');
	if (citysel.length>0){
		for(i=citysel.length;i>=0;i--){
			citysel.remove(i);
		}
	}
	var y=document.createElement('option');
	y.value='0';
	y.text='- Select -';
	try
	{
		citysel.add(y,null); // standards compliant
	}
	catch(ex)
	{
		citysel.add(y); // IE only
	}
}
//Used to store state value to a hidden variable and this hidden element is used while posting the form hidstate
function hidsetstate(obj) {
	var hidstate = $('hidstate');
	if(obj.type=='text') {
		hidstate.value = obj.value;
	}
	if(obj.type=='select-one') {
		hidstate.value = obj.value;
	}
}
//Used to store city value to a hidden variable and this hidden element is used while posting the form
function hidsetcity(obj) {
	var hidcity = $('hidcity');
	if(obj.type=='text') {
		hidcity.value = obj.value;
	}
	if(obj.type=='select-one') {
		hidcity.value = obj.value;
	}
}
//Used to store caste value to a hidden variable and this hidden element is used while posting the form
function hidsetcaste(obj) {
	var hidcaste = $('hidcaste');
	if(obj.type=='text') {
		hidcaste.value = obj.value;
	}
	if(obj.type=='select-one') {
		hidcaste.value = obj.value;
	}
}


//ajax for cate selection
var caste_req=false;
function makerequestcaste(cvalue, thisrowid)
{
	var reqloc=location.href;
	var reqloc1=reqloc.substring(reqloc.indexOf('.')+1,reqloc.indexOf('.com'))
	if(cvalue>0 && cvalue!=null) {
		caste_req = createajax();
		dblang=0;
		if($('hiddblang')){dblang=$('hiddblang').value;}
		var url="/register/singlepageajaxcaste.php?thisrowid="+thisrowid+"&Religion="+cvalue+"&dblang="+dblang;
		caste_req.onreadystatechange = processResponsecaste;
		caste_req.open('GET', url, true);
		caste_req.send(null);
	}
	else {
		var casteid = $('selcaste');
		casteid.innerHTML = '<select class="smalltxt" style="width:170px" NAME="CASTE"  id="CASTE" size="1" onchange="checkcastenobar();casteSelectAct(this);subcasteChk();hidsetcaste(this);" onfocus="enterfiled(\'row'+thisrowid+'\')"  onblur="onexit(\'row'+thisrowid+'\');"><option value="o" Selected>- Select -</option></select>';
	}
}

function processResponsecaste()
{
	if (caste_req.readyState == 4) 
	{
		if (caste_req.status == 200) 
		{
			var statesel = $('selcaste');
			var listValues = caste_req.responseText;			
			statesel.innerHTML = listValues;
		}
	}	
}


function checkcastenobar()
{
	if ($('CASTE').value==0){MatriForm.CASTENOBAR.checked=true;}else{MatriForm.CASTENOBAR.checked=false;}
}
function subcasteChk(){
	if (!($('SUBCASTE').value=="Enter sub caste here" || $('SUBCASTE').value=="")) {
		if ($('CASTE').value==0 || $('CASTE').selectedIndex==0) {
			$('castespan').innerHTML="Please enter the caste";
			return;
		} else {
			$('castespan').innerHTML=" ";
		}
	}
}

function subcastechk2(selbox) {
	selbox=$('SUBCASTE1');
	selectedText = selbox.options[selbox.selectedIndex].text;
	if(selectedText == '- Select -' && $('CASTE').value!='o' && $('CASTE').value!='0'){
		$('subcastestar').style.display='block';
		$('subcastespan').innerHTML="Please select your sub caste";
		
		return;
	}
	else {
		if(selectedText!='Others') {
			$('subcastespan').innerHTML=" "; 
			$('subcastestar').style.display='none';
		}
	}
}

function casteSelectAct(selectobj){
	$('nocasteselhint').style.display='none';
	var MatriForm = this.document.MatriForm;
	if (selectobj.value==0) {
		$('nocastehint').style.display='block';
		$('CNBhint').style.display='none';
		MatriForm.SUBCASTE.value='';
		MatriForm.SUBCASTE.disabled=true;
		MatriForm.SUBCASTE1.selectedIndex=0;
		MatriForm.SUBCASTE1.disabled=true;

	} else {
		$('nocastehint').style.display='none';
		$('CNBhint').style.display='block';
		MatriForm.SUBCASTE.disabled=false;
		MatriForm.SUBCASTE1.disabled=false;
	}
}
function onKGS()
{
	if (!(document.MatriForm.LBS.value=="0")){document.MatriForm.LBS.value="0";}
}
	
function onLBS()
{
	if (!(document.MatriForm.KGS.value=="0")){document.MatriForm.KGS.value="0";}		
}
function onCMS()
{
	if (!(document.MatriForm.FEET.value=="0"))
	{document.MatriForm.FEET.value="0";}
	
	if (!(document.MatriForm.CMS.value=="0"))
	{document.getElementById('heightspan').innerHTML=" ";document.getElementById('row1').className="normalrow";}
}


function cmsleft()
{
	if (document.MatriForm.FEET.value=="0" && document.MatriForm.CMS.value=="0")
	{document.getElementById('heightspan').innerHTML="Please select the height of the prospect";return false}
}

function seldblang(domain) {
	if (domain!=0){$('hiddblang').value=domain;}
}


//ajax to load raasi list box 
var raasi_request=false;
function loadraasi() {
	domainval = $('DOMAIN').selectedIndex;
	if(domainval==0){domainval =10;}
	var reqloc=location.href;
	var reqloc1=reqloc.substring(reqloc.indexOf('.')+1,reqloc.indexOf('.com'))
	raasi_request = createajax();
	var url="/register/singlepageajaxraasi.php?domainlang="+domainval;
	raasi_request.onreadystatechange = processResponseraasi;
	raasi_request.open('GET', url, true);
	raasi_request.send(null);
}

function processResponseraasi() {
	if (raasi_request.readyState == 4) {
		if (raasi_request.status == 200) {
			var raasisel = $('RAASI');
			var listValues = raasi_request.responseText;
			listValueArray = listValues.split('~');
			for(i=0;i<listValueArray.length;i=i+2) {
			  var y=document.createElement('option');
			  y.value=listValueArray[i];
			  y.text=listValueArray[i+1];
				try {
					raasisel.add(y,null); // standards compliant
				}
				catch(ex) {
					raasisel.add(y); // IE only
				}
			}
		}
	}
	else
	{
		emptyRaasi();
	}
}


function emptyRaasi()
{
	var raasisel = $('RAASI');
	if (raasisel.length>0)
	{
		for(i=raasisel.length;i>=0;i--)
		{
			raasisel.remove(i);
		}
	}
	var y=document.createElement('option');
	y.value='';
	y.text='Optional-';
	try
	{
		raasisel.add(y,null); // standards compliant
	}
	catch(ex)
	{
		raasisel.add(y); // IE only
	}
}


function emptySubcasteSel()
{
	var citysel = $('SUBCASTE1');
	if (citysel.length>0)
	{
		for(i=citysel.length;i>=0;i--)
		{
			citysel.remove(i);
		}
	}
	var y=document.createElement('option');
	y.value='0';
	y.text='- Select -';
	try
	{
		citysel.add(y,null); // standards compliant
	}
	catch(ex)
	{
		citysel.add(y); // IE only
	}
}

function subcastechk1() {
	selbox=$('SUBCASTE1');
	selectedText = selbox.options[selbox.selectedIndex].text;
	if(selectedText == 'Others' && ($('SUBCASTE').value=='' || $('SUBCASTE').value=='Enter sub caste here' )){
		$('subcastespan').innerHTML="If your sub caste is not listed here, please enter it in the text box";
		return;
	}
	else {$('subcastespan').innerHTML=" "; }
}


function othercasteChk(selbox) {
	selectedText = selbox.options[selbox.selectedIndex].text;
	if(selectedText == 'Others') {
		$('SUBCASTE').style.display='block';
	}
	else {
		$('SUBCASTE').value='Enter sub caste here';
		$('SUBCASTE').style.display='none';
		val = selbox.value;
		text = selectedText;
		if(val !='' && val != '0' && val != 0){
			$('hidsubcaste').value = val+"~~"+text;
		}
		else
			$('hidsubcaste').value = '';
	}
}



function emptyOtherCasteCheck() {
var caste = $('CASTE').value;
if(caste=='999' && (document.MatriForm.SUBCASTE.value=='Enter sub caste here' || document.MatriForm.SUBCASTE.value==''))
	$('subcastespan').innerHTML="Please enter your sub caste";
else {
	selbox = $('SUBCASTE1');
	selectedText = selbox.options[selbox.selectedIndex].text;
	if(selectedText == 'Others' && (document.MatriForm.SUBCASTE.value=='Enter sub caste here' || document.MatriForm.SUBCASTE.value==''))
		$('subcastespan').innerHTML="If your sub caste is not listed here, please enter it in the text box";
	else
		$('subcastespan').innerHTML="";
	}
}

function subcasteCaption(action) {
	if(action=='clear') {
		if($('SUBCASTE').value =='' || $('SUBCASTE').value =='Enter sub caste here' )
			$('SUBCASTE').value='';
	}
	else {
		if($('SUBCASTE').value =='' || $('SUBCASTE').value =='Enter sub caste here' )
			$('SUBCASTE').value='Enter sub caste here';
	}

}

function makereqoccupation(occCat) {
	var reqloc=location.href;
	var reqloc1=reqloc.substring(reqloc.indexOf('.')+1,reqloc.indexOf('.com'))
	
	var matriform = document.MatriForm;
	var countryLiving = matriform.COUNTRY.value;
	ccode_request = createajax();
	var url="/register/ajax_get_occupation.php?OccupationCategory="+occCat+"&Country="+countryLiving+"&rowid=16";

	ccode_request.onreadystatechange = processResponseocc;
	ccode_request.open('GET', url, true);
	ccode_request.send(null);
}

function processResponseocc() {
	if (ccode_request.readyState == 4) {
		if (ccode_request.status == 200) {
			var occOut = ccode_request.responseText;
			$('occContent').innerHTML = occOut;
		}
	}
}

function amountChk() {
	if (!(IsEmpty($('INCOME1'),'text')))
	{
		if ($('INCOME_CURRENCY1').selectedIndex==0)
		{$('annualincomespan').innerHTML="Please select the currency type";return;}	
		else{$('annualincomespan').innerHTML=" ";}

		if(!ValidateNo($('INCOME1').value,'1234567890 ,.'))
		{$('annualincomespan').innerHTML="Please enter a valid income";return;}	
		else{$('annualincomespan').innerHTML=" ";}
	}
}

function hidUpdateVal(name, val, reset) {
	if(reset=='reset') {
		$('OCCUPATION').value = '';
		$('OCCUPATIONDETAIL').value = '';
		$('INCOME_CURRENCY').value = '';
		$('INCOME').value = '';
	}
	else {
		$(name).value=val;
		if(name=='INCOME') {
			$('INCOME_CURRENCY').value = $('INCOME_CURRENCY1').value ;
		}
	}
}

function single_gothraDet(religion) {
	if(religion==1) {
		$('gothradetails').style.display='block';
		$('gothradiv').style.display='block';
	}
	else {
		$('gothradetails').style.display='none';
		$('gothradiv').style.display='none';
		MatriForm.GOTHRAM.value='0';
		MatriForm.GOTHRAMOTHERS.value='';
		MatriForm.GOTHRAMOTHERS.style.display='none';
		$('gothrastart').style.display='none';
		MatriForm.STAR.value='';
		$('RAASI').value='';
		$('HOROMATCH1').checked=false;
		$('HOROMATCH2').checked=false;
		$('HOROMATCH3').checked=false;
		$('MANGLIK1').checked=false;
		$('MANGLIK2').checked=false;
		$('MANGLIK3').checked=false;
	}
}

function single_chkgothra() {
	var gothra = $('GOTHRAM').value;
	if(gothra=="999") {
		$('GOTHRAMOTHERS').style.display = 'block';
		$('gothrastart').style.display = 'block';
		if($('GOTHRAMOTHERS').value=='')
			$('gothraspan').innerHTML = "&nbsp;&nbsp;Please enter Gothra of the prospect";
		else
			$('gothraspan').innerHTML = "";
	}
	else {
		if($('gothraAvail').value=='yes') {
			$('GOTHRAMOTHERS').style.display = 'none';
			$('gothraspan').innerHTML = "";
			$('GOTHRAMOTHERS').value='';
		}
		else {
			$('GOTHRAMOTHERS').style.display = 'block';
		}
	}
}


function single_chkgothra1() {
	var gothraAvail = $('gothraAvail').value;
	if(gothraAvail=='yes') {
		if($('GOTHRAM').value == 0) {
			$('gothraspan').innerHTML = "&nbsp;&nbsp;Please select Gothra of the prospect";
			$('gothrastart').style.display = 'block';
		}
		else {
			if($('GOTHRAM').value == '999') {
				$('gothraspan').innerHTML = "&nbsp;&nbsp;Please enter Gothra of the prospect";
				$('gothrastart').style.display = 'block';
			}
			else {
				$('gothraspan').innerHTML = "";
				$('gothrastart').style.display = 'none';
			}
		}
	}
	else {
		$('GOTHRAM').style.display = 'none';
		$('GOTHRAM').value = 0;
		$('GOTHRAMOTHERS').style.display = 'block';
	}
}


function single_makereqGothraChk(domain) {
	if(domain=='bharat')
		domain = $('DOMAIN').value;
	var caste = $('CASTE').value;
	gothrareq = createajax();
	var url="/register/ajax_chk_gothra.php?domain="+domain+"&caste="+caste;
	
	gothrareq.onreadystatechange = single_processResponseGothra;
	gothrareq.open('GET', url, true);
	gothrareq.send(null);
}

function single_processResponseGothra() {
	if (gothrareq.readyState == 4) {
		if (gothrareq.status == 200) {
			var gothraAvail = gothrareq.responseText;
			$('gothraAvail').value=gothraAvail;
			single_chkgothra2();
		}
	}
}


function single_chkgothra2() {
	var gothraAvail = $('gothraAvail').value;
	if(gothraAvail == 'yes') {
		$('GOTHRAM').value=0;
		$('GOTHRAMOTHERS').value='';
		$('GOTHRAM').style.display = 'block';
		$('GOTHRAMOTHERS').style.display = 'none';
		$('gothraspan').innerHTML = "";
		$('gothrastart').style.display = 'none';
	}
	else {
		$('GOTHRAM').value=0;
		$('GOTHRAMOTHERS').value='';
		$('GOTHRAM').style.display = 'none';
		$('GOTHRAMOTHERS').style.display = 'block';
		$('gothraspan').innerHTML = "";
		$('gothrastart').style.display = 'none';
	}
}