
var one_day=1000*60*60*24
var one_month=1000*60*60*24*30
var one_year=1000*60*60*24*30*12

function displayage(yr, mon, day, unit, decimal, round){
today=new Date()
var pastdate=new Date(yr, mon-1, day)

var countunit=unit
var decimals=decimal
var rounding=round
finalunit=(countunit=="days")? one_day : (countunit=="months")? one_month : one_year
decimals=(decimals<=0)? 1 : decimals*10

if (unit!="years"){
if (rounding=="rounddown")
alert (Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals+' '+countunit)
else
alert (Math.ceil((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals+' '+countunit)
}
else
{
yearspast=today.getFullYear()-yr-1
tail=(today.getMonth()>mon-1 || today.getMonth()==mon-1 && today.getDate()>=day)? 1 : 0
pastdate.setFullYear(today.getFullYear())
pastdate2=new Date(today.getFullYear()-1, mon-1, day)
tail=(tail==1)? tail+Math.floor((today.getTime()-pastdate.getTime())/(finalunit)*decimals)/decimals : Math.floor((today.getTime()-pastdate2.getTime())/(finalunit)*decimals)/decimals
var calyear=yearspast+tail;
}
return calyear;
}


function updateDay(change,formName,yearName,monthName,dayName)
{	
	
	var form = document.forms[formName];
	var yearSelect = form[yearName];
	var monthSelect = form[monthName];
	var daySelect = form[dayName];
	var year = yearSelect[yearSelect.selectedIndex].value;
	var month = monthSelect[monthSelect.selectedIndex].value;
	var day = daySelect[daySelect.selectedIndex].value;

if (month>0)
{
	if (change == 'month' || (change == 'year' && month == 2))
	{
		var i = 31;
		var flag = true;
		while(flag)
		{
			var date = new Date(year,month-1,i);
			if (date.getMonth() == month - 1)
			{
				flag = false;
			}
			else
			{
				i = i - 1;
			}
		}

		daySelect.length = 0;
		daySelect.length = i;

		var j = 0;
		i=i+1;

		while(j < i)
		{
			if(j==0){daySelect[j] = new Option("-Date-",j);j=j+1;}
			else
			{
				daySelect[j] = new Option(j,j);
				j = j + 1;
			}
		}
		
		/*if (day <= i)
		{daySelect.selectedIndex = day - 1;}
		else
		{daySelect.selectedIndex = daySelect.length - 1;}*/

	}
}
}


function citizen()
{
		var MatriForm = this.document.MatriForm;
	if 	(MatriForm.CITIZENSHIP.value==MatriForm.COUNTRY.value)
	{MatriForm.RESIDENTSTATUS.value=1}
	else
	{MatriForm.RESIDENTSTATUS.value=0}
}
	
function HaveChildnp()
{
		var MatriForm = this.document.MatriForm;
	var CHILDLW = MatriForm.NOOFCHILDREN.options[MatriForm.NOOFCHILDREN.selectedIndex].value;
		
	if(MatriForm.MARITAL_STATUS[0].checked)
	{
		MatriForm.NOOFCHILDREN.disabled=true;	
		MatriForm.CHILDLIVINGWITHME[0].disabled=true;		
		MatriForm.CHILDLIVINGWITHME[1].disabled=true;
		$('nocspan').innerHTML=" ";
		$('clsspan').innerHTML=" ";
    }
	else if ( MatriForm.MARITAL_STATUS[1].checked || MatriForm.MARITAL_STATUS[2].checked  || MatriForm.MARITAL_STATUS[3].checked )
	{
	MatriForm.NOOFCHILDREN.disabled=false;			
	MatriForm.CHILDLIVINGWITHME[0].disabled=true;		
	MatriForm.CHILDLIVINGWITHME[1].disabled=true;
	MatriForm.NOOFCHILDREN.options.selectedIndex=0;
	}
}

function Childliv()
{
	var MatriForm = this.document.MatriForm;
	var CHILDLW = MatriForm.NOOFCHILDREN.options[MatriForm.NOOFCHILDREN.selectedIndex].value;
	var MatriForm = this.document.MatriForm;
	if(MatriForm.MARITAL_STATUS[0].checked)
	{
		MatriForm.NOOFCHILDREN.disabled=true;	
		MatriForm.CHILDLIVINGWITHME[0].disabled=true;		
		MatriForm.CHILDLIVINGWITHME[1].disabled=true;	
		$('nocspan').innerHTML=" ";
		$('clsspan').innerHTML=" ";
	}

	if(MatriForm.MARITAL_STATUS[0].checked==false)
	{
		if(CHILDLW==0 || CHILDLW=="")
		{
			$('childliving').style.display='none';
			MatriForm.CHILDLIVINGWITHME[0].checked=false;
			MatriForm.CHILDLIVINGWITHME[1].checked=false;
			MatriForm.CHILDLIVINGWITHME[0].disabled=true;		
			MatriForm.CHILDLIVINGWITHME[1].disabled=true;	
			$('clsspan').innerHTML=" ";
		}
		else
		{
			$('childliving').style.display='block';
			MatriForm.CHILDLIVINGWITHME[0].disabled=false;		
			MatriForm.CHILDLIVINGWITHME[1].disabled=false;	
		}
	}
	
}	
	
function agefocus()
{
	var MatriForm = this.document.MatriForm;
	if(MatriForm.AGE.value!=""){
		if(!(MatriForm.DOBYEAR.value=="0") && !(MatriForm.DOBMONTH.value=="0") && !(MatriForm.DOBDAY.value=="0"))
		{MatriForm.DOBMONTH.value="0"; MatriForm.DOBDAY.value="0"; MatriForm.DOBYEAR.value="0";}
	}
}	

function agesel()
{var MatriForm = this.document.MatriForm;MatriForm.AGE.value=""}
	
// Function to validate all the inputs
function Validate() {
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=MatriForm.DOMAIN.options[MatriForm.DOMAIN.selectedIndex].text;
	var dact1=dact.split(" - ");
	dact1[1]=dact1[1].toLowerCase();
	MatriForm.action="http://profile."+dact1[1]+"/register/addmatrimonybas.php";
}

if(IsEmpty(MatriForm.NAME,"text"))
{
$('namespan').innerHTML="Please enter the name of the prospect";MatriForm.NAME.value="";$('row1').className="rowcolor";MatriForm.NAME.focus();return false;
}else{$('namespan').innerHTML="&nbsp";$('row1').className="normalrow";
}

if(IsEmpty(MatriForm.AGE,"text"))
{ 
  if (MatriForm.DOBMONTH.options[MatriForm.DOBMONTH.selectedIndex].text=="-Month-")	
  {$('agespan').innerHTML="Please select month";$('row1').className="rowcolor";MatriForm.DOBMONTH.focus();return false;}
  else{$('agespan').innerHTML="&nbsp;";$('row1').className="normalrow";}

  if (MatriForm.DOBDAY.options[MatriForm.DOBDAY.selectedIndex].text=="-Date-")	
  {$('agespan').innerHTML="Please select date";$('row1').className="rowcolor";MatriForm.DOBDAY.focus();return false;}
  else{$('agespan').innerHTML="&nbsp;";$('row1').className="normalrow";}

  if (MatriForm.DOBYEAR.value=="0")		
  {$('agespan').innerHTML="Please select year";$('row1').className="rowcolor";MatriForm.DOBYEAR.focus();return false;}
  else{$('agespan').innerHTML="&nbsp;";$('row1').className="normalrow";}
}	

if(IsEmpty(MatriForm.AGE,"text") && (MatriForm.DOBMONTH.options[MatriForm.DOBMONTH.selectedIndex].text=="-Month-" && MatriForm.DOBDAY.options[MatriForm.DOBDAY.selectedIndex].text=="-Date-" && MatriForm.DOBYEAR.options[MatriForm.DOBYEAR.selectedIndex].text=="-Year-")) 
{
$('agespan').innerHTML="Please enter the age or select the date of birth of the prospect";MatriForm.AGE.value="";$('row1').className="rowcolor";MatriForm.AGE.focus();return false;
}else{$('agespan').innerHTML="&nbsp;";$('row1').className="normalrow";}
		
var age = parseInt( MatriForm.AGE.value );

if( !ValidateNo( MatriForm.AGE.value, "0123456789" ) )
{$('agespan').innerHTML="Please enter a valid age";$('row1').className="rowcolor";MatriForm.AGE.focus();return false;}
else{$('agespan').innerHTML="&nbsp;";$('row1').className="normalrow";}

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";$('row1').className="rowcolor";MatriForm.AGE.focus();return false;}
else{$('agespan').innerHTML="&nbsp;";$('row1').className="normalrow";}
			
if (MatriForm.AGE.value=="" && calyear < 21 && MatriForm.GENDER[0].checked)
{$('agespan').innerHTML="Prospect should be 21 years to register";$('row1').className="rowcolor";MatriForm.AGE.focus();return false;}
else{$('agespan').innerHTML="&nbsp;";$('row1').className="normalrow";}

if (MatriForm.AGE.value < 18 && MatriForm.GENDER[1].checked && !(MatriForm.AGE.value==""))
{$('agespan').innerHTML="Prospect should be 18 years to register";$('row1').className="rowcolor";MatriForm.AGE.focus();return false;}
else{$('agespan').innerHTML="&nbsp;";$('row1').className="normalrow";}
			
if (MatriForm.AGE.value=="" && calyear < 18 && MatriForm.GENDER[1].checked)
{$('agespan').innerHTML="Prospect Should be 18 years to Register";$('row1').className="rowcolor";MatriForm.AGE.focus();return false;}
else{$('agespan').innerHTML="&nbsp;";$('row1').className="normalrow";}


if ( age > 70 && calyear > 70)
{$('agespan').innerHTML="Maximum age allowed is 70";$('row1').className="rowcolor";MatriForm.AGE.focus( );return false;}
else{$('agespan').innerHTML="&nbsp;";$('row1').className="normalrow";}


if (!MatriForm.GENDER[0].checked && !MatriForm.GENDER[1].checked)
{$('genderspan').innerHTML="Please select the gender of the prospect";$('row2').className="rowcolor";MatriForm.GENDER[0].focus( );return false;}
else if (MatriForm.GENDER[0].checked || MatriForm.GENDER[1].checked){$('genderspan').innerHTML="&nbsp";$('row2').className="normalrow";}


if ( IsEmpty(MatriForm.MARITAL_STATUS,'radio'))
{$('maritalspan').innerHTML="Please select the marital status of the prospect";$('row2').className="rowcolor";MatriForm.MARITAL_STATUS[0].focus( );return false;}
else{$('maritalspan').innerHTML="&nbsp;";$('row2').className="normalrow";}

if ( !(MatriForm.MARITAL_STATUS[0].checked) && MatriForm.NOOFCHILDREN.selectedIndex == 0 )
{$('nocspan').innerHTML="Please select the number of children";$('row2').className="rowcolor";MatriForm.NOOFCHILDREN.focus( );return false;}
else{$('nocspan').innerHTML=" ";$('row3').className="normalrow";}
		
if ( !(MatriForm.MARITAL_STATUS[0].checked) && MatriForm.NOOFCHILDREN.options[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";$('row2').className="rowcolor";MatriForm.CHILDLIVINGWITHME[0].focus( );return false;}
else{$('clsspan').innerHTML=" ";$('row2').className="normalrow";}

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";$('row3').className="rowcolor";MatriForm.RELIGION.focus( );return false;}
else{$('religionspan').innerHTML=" ";$('row3').className="normalrow";}

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 (MatriForm.CASTE.selectedIndex==0)
		{$('castespan').innerHTML="Please select the caste";$('row12').className="errorrow";MatriForm.CASTE.focus();return false;}	
		else{$('castespan').innerHTML=" ";$('row12').className="normalrow";}
	}
	
if(document.MatriForm.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";
}




	selbox=$('SUBCASTE1');
	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(MatriForm.RESIDENTSTATUS,'radio'))
{$('resspan').innerHTML="Please select the resident status of the prospect";$('row5').className="rowcolor";MatriForm.RESIDENTSTATUS[1].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 employment status";$('row6').className="rowcolor";MatriForm.OCCUPATIONCATEGORY[0].focus( );return false;}
else{$('empspan').innerHTML=" ";$('row6').className="normalrow";}
		
//Phone validation
if(MatriForm.COUNTRYCODE.value=="Country code" && MatriForm.AREACODE.value=="Area code" && MatriForm.PHONENO.value=="Telephone number" && MatriForm.MOBILENO.value=="Mobile number")
{$('phonespan').innerHTML="Please enter the contact number";$('row7').className="rowcolor";MatriForm.PHONENO.focus();return false; }
else{$('phonespan').innerHTML="";$('row7').className="normalrow";}

if ((IsEmpty(MatriForm.PHONENO,'text') || MatriForm.PHONENO.value=="Telephone number")  && (IsEmpty(MatriForm.MOBILENO,'text') || MatriForm.MOBILENO.value=="Mobile number"))
{$('phonespan').innerHTML="Please enter the contact number";$('row7').className="rowcolor";MatriForm.PHONENO.focus();return false;}
else{$('phonespan').innerHTML="";$('row7').className="normalrow";}

if (!(IsEmpty(MatriForm.COUNTRYCODE,'text')))
{
	if (!ValidateNo(MatriForm.COUNTRYCODE.value,'1234567890'))
	{$('phonespan').innerHTML="Please enter a valid country code";$('row7').className="rowcolor";MatriForm.COUNTRYCODE.focus();return false;}
	else{$('phonespan').innerHTML="";$('row7').className="normalrow";}
}


if (!IsEmpty(MatriForm.PHONENO,'text') && MatriForm.PHONENO.value!="Telephone number")
{
	if (IsEmpty(MatriForm.COUNTRYCODE,'text') || MatriForm.COUNTRYCODE.value=="Country code")
	{$('phonespan').innerHTML="Please enter the country code";$('row7').className="rowcolor";MatriForm.COUNTRYCODE.focus();return false;}
	else{$('phonespan').innerHTML="";$('row7').className="normalrow";}
			
	if (IsEmpty(MatriForm.AREACODE,'text') || MatriForm.AREACODE.value=="Area code")
	{$('phonespan').innerHTML="Please enter area / STD code";$('row7').className="rowcolor";MatriForm.AREACODE.focus();return false;}
	else{$('phonespan').innerHTML="";$('row7').className="normalrow";}
}

if (!IsEmpty(MatriForm.MOBILENO,'text') && MatriForm.MOBILENO.value!="Mobile number")
{
	if (IsEmpty(MatriForm.COUNTRYCODE,'text') || MatriForm.COUNTRYCODE.value=="Country code")
	{$('phonespan').innerHTML="Please enter the country code";$('row7').className="rowcolor";MatriForm.COUNTRYCODE.focus();return false;}
	else{$('phonespan').innerHTML="";$('row7').className="normalrow";}
}

// Check E-mail
if (IsEmpty(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(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 ( !ValidateEmail( MatriForm.EMAIL.value ) )
{$('emailspan').innerHTML="Invalid valid e-mail ID.";$('row8').className="rowcolor";MatriForm.EMAIL.value="";MatriForm.EMAIL.focus( );return false;}
else{$('emailspan').innerHTML=" ";$('row8').className="normalrow";}

for ( var Idx = 0; Idx < MatriForm.EMAIL.value.length; Idx++ )
{
	if ( MatriForm.EMAIL.value.charAt(Idx) == '	' || MatriForm.EMAIL.value.charAt(Idx) == ' ' || MatriForm.EMAIL.value.charAt(Idx) == ',' || MatriForm.EMAIL.value.charAt(Idx) == '/' || MatriForm.EMAIL.value.charAt(Idx) == '\\' || MatriForm.EMAIL.value.charAt(Idx) == ';' )
	{$('emailspan').innerHTML="Blanks or other invalid characters are not allowed in the e-mail id. Please enter only one e-mail id.";$('row8').className="rowcolor";MatriForm.EMAIL.value="";MatriForm.EMAIL.focus( );return false;}
	else{$('emailspan').innerHTML=" ";$('row8').className="normalrow";}
}*/

if(IsEmpty(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.TERMS.checked)
{$('termsspan').innerHTML="Please accept the terms and conditions to proceed further ";$('row10').className="rowcolor";MatriForm.PASSWD2.focus( );return false;}
else{$('termsspan').innerHTML=" ";$('row10').className="normalrow";}
//MatriForm.action = 'http://'+DOMAINARRAY['domainmodule']+'/register/addmatrimonybas.php';
if($('SUBCASTE').value=='Enter sub caste here')
	$('SUBCASTE').value='';
MatriForm.method = 'post';
return true;						
}

function nameChk() {
	var MatriForm = this.document.MatriForm;
	if (IsEmpty(MatriForm.NAME,"text")) {
		$('namespan').innerHTML="Please enter the name of the prospect";
		MatriForm.NAME.value="";
		return;
	} else {
		$('namespan').innerHTML="&nbsp";
	}
}

function ageChk() {
	var MatriForm = this.document.MatriForm;
	if (IsEmpty(MatriForm.AGE,"text") && (MatriForm.DOBMONTH.options[MatriForm.DOBMONTH.selectedIndex].text=="-Month-" && MatriForm.DOBDAY.options[MatriForm.DOBDAY.selectedIndex].text=="-Date-" && MatriForm.DOBYEAR.options[MatriForm.DOBYEAR.selectedIndex].text=="-Year-")) {
		$('agespan').innerHTML="Please enter the age or select the date of birth of the prospect";
		MatriForm.AGE.value="";
		return;
	} else { 
		$('agespan').innerHTML="&nbsp;";
	}

	if (IsEmpty(MatriForm.AGE,"text")) { 
		if (MatriForm.DOBMONTH.options[MatriForm.DOBMONTH.selectedIndex].text=="-Month-") {
			$('agespan').innerHTML="Please select month";
			return;
		} else {
			$('agespan').innerHTML="&nbsp;";
		}

		if (MatriForm.DOBDAY.options[MatriForm.DOBDAY.selectedIndex].text=="-Date-") {
			$('agespan').innerHTML="Please select date";
			return;
		} else {
			$('agespan').innerHTML="&nbsp;";
		}

		if (MatriForm.DOBYEAR.value=="0") {
			$('agespan').innerHTML="Please select year";
			return;
		} else {
			$('agespan').innerHTML="&nbsp;";
		}
	}

	var age = parseInt( MatriForm.AGE.value );

	if ( !ValidateNo( MatriForm.AGE.value, "0123456789" ) ) {
		$('agespan').innerHTML="Please enter a valid age";
		return;
	} 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";
		return;
	} else {
		$('agespan').innerHTML="&nbsp;";
	}

	if (MatriForm.AGE.value=="" && calyear < 21 && MatriForm.GENDER[0].checked) {
		$('agespan').innerHTML="Prospect should be 21 years to register";
		return;
	} 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";
		return;
	} else {
		$('agespan').innerHTML="&nbsp;";
	}

	if (MatriForm.AGE.value=="" && calyear < 18 && MatriForm.GENDER[1].checked) {
		$('agespan').innerHTML="Prospect Should be 18 years to Register";
		return;
	} else {
		$('agespan').innerHTML="&nbsp;";
	}

	if ( age > 70 && calyear > 70) {
		$('agespan').innerHTML="Maximum age allowed is 70";
		return;
	} else {
		$('agespan').innerHTML="&nbsp;";
	}
}

function genderChk() {
	var MatriForm = this.document.MatriForm;
	if (!MatriForm.GENDER[0].checked && !MatriForm.GENDER[1].checked) {
		$('genderspan').innerHTML="Please select the gender of the prospect";
		return;
	} else if (MatriForm.GENDER[0].checked || MatriForm.GENDER[1].checked) {
		$('genderspan').innerHTML="&nbsp";
	}
}
function maritalChk() {
	var MatriForm = this.document.MatriForm;
	if ( IsEmpty(MatriForm.MARITAL_STATUS,'radio')) {
		$('maritalspan').innerHTML="Please select the marital status of the prospect";
		return;
	} else {
		$('maritalspan').innerHTML="&nbsp;";
	}
}

function childChk() {
	var MatriForm = this.document.MatriForm;
	if ( !(MatriForm.MARITAL_STATUS[0].checked) && MatriForm.NOOFCHILDREN.selectedIndex == 0 ) {
		$('nocspan').innerHTML="Please select the number of children";
		return;
	} else {
		$('nocspan').innerHTML=" ";
	}
}
function childstatusChk() {
	var MatriForm = this.document.MatriForm;
	if ( !(MatriForm.MARITAL_STATUS[0].checked) && MatriForm.NOOFCHILDREN.options[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";
		return;
	} else {
		$('clsspan').innerHTML=" ";
	}
}
function religionChk() {
	var MatriForm = this.document.MatriForm;
	if ( MatriForm.RELIGION.selectedIndex == 0 ) {
		$('religionspan').innerHTML="Please select the religion of the prospect";
		return;
	} else {
		$('religionspan').innerHTML=" ";
	}
}
function citizenChk() {
	var MatriForm = this.document.MatriForm;
	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";
		return;
	} else {
		$('citispan').innerHTML=" ";
	}
}

function countryChk() {
	var MatriForm = this.document.MatriForm;
	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";
		return;
	} else {
		$('clspan').innerHTML=" ";
	}
}
function residingChk() {
	var MatriForm = this.document.MatriForm;
	if ( IsEmpty(MatriForm.RESIDENTSTATUS,'radio')) {
		$('resspan').innerHTML="Please select the resident status of the prospect";
		return;
	} else {
		$('resspan').innerHTML=" ";
	}
}

function occupationChk() {
	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 employment status";
		return;
	} else {
		$('empspan').innerHTML=" ";
	}
}

function phoneChk() {
	var MatriForm = this.document.MatriForm;
	//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";
		return;
	} else {
		$('phonespan').innerHTML="";
	}

	if ((IsEmpty($('PHONENO'),'text') || $('PHONENO').value=="Telephone number")  && (IsEmpty($('MOBILENO'),'text') || $('MOBILENO').value=="Mobile number")) {
		$('phonespan').innerHTML="Please enter the contact number";
		return;
	} else {
		$('phonespan').innerHTML="";
	}

	if (!(IsEmpty($('COUNTRYCODE'),'text'))) {
		if (!ValidateNo($('COUNTRYCODE').value,'1234567890')) {
			$('phonespan').innerHTML="Please enter a valid country code";
			return;
		} else {
			$('phonespan').innerHTML="";
		}
	}

	if (!IsEmpty($('PHONENO'),'text') && $('PHONENO').value!="Telephone number") {
		if (IsEmpty($('COUNTRYCODE'),'text') || $('COUNTRYCODE').value=="Country code") {
			$('phonespan').innerHTML="Please enter the country code";
			return;
		} else {
			$('phonespan').innerHTML="";
		}
				
		if (IsEmpty($('AREACODE'),'text') || $('AREACODE').value=="Area code") {
			$('phonespan').innerHTML="Please enter area / STD code";
			return;
		} else {
			$('phonespan').innerHTML="";
		}
	}

	if (!IsEmpty($('MOBILENO'),'text') && $('MOBILENO').value!="Mobile number") {
		if (IsEmpty($('COUNTRYCODE'),'text') || $('COUNTRYCODE').value=="Country code") {
			$('phonespan').innerHTML="Please enter the country code";
			return;
		} else {
			$('phonespan').innerHTML="";
		}
	}
}

function emailChk() {
	var MatriForm = this.document.MatriForm;
	// Check E-mail
	if (IsEmpty(MatriForm.EMAIL,"text")) {
		$('emailspan').innerHTML="Please enter a valid E-mail address";
		return;
	} else {
		$('emailspan').innerHTML=" ";
	}
	if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,4})+$/.test(MatriForm.EMAIL.value))) {
		$('emailspan').innerHTML="Please enter a valid E-mail address";
		return;
	} else {
		$('emailspan').innerHTML=" ";
	}
}

function passwordChk() {
	var MatriForm = this.document.MatriForm;
	if (IsEmpty(MatriForm.PASSWD1,"password")) {
		$('passwdspan').innerHTML="Please enter your password";
		return;
	} else {
		$('passwdspan').innerHTML=" ";
	}


	if ( MatriForm.PASSWD1.value.length < 4 ) {
		$('passwdspan').innerHTML="Your password must have a minimum of 4 characters";
		return;
	} else {
		$('passwdspan').innerHTML=" ";
	}

	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.";
		return;
	} else {
		$('passwdspan').innerHTML=" ";
	}

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";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)) ) || (ch==' '))
			{goodPasswd = 0;break;}
	}

	if ( goodPasswd ==0 ) {
		$('passwdspan').innerHTML="Spaces or special characters are not allowed in the password";
		return;
	} else {
		$('passwdspan').innerHTML=" ";
	}
}
function passwordCChk() {
	var MatriForm = this.document.MatriForm;
	if (MatriForm.PASSWD2.value=="") {
		$('cpasswdspan').innerHTML="Please confirm your password";
		return;
	} else {
		$('cpasswdspan').innerHTML=" ";
	}

	if ( MatriForm.PASSWD1.value != MatriForm.PASSWD2.value ) {
		$('cpasswdspan').innerHTML="Sorry, both the passwords do not match";
		return;
	} else {
		$('cpasswdspan').innerHTML=" ";
	}

}
function termsChk() {
	var MatriForm = this.document.MatriForm;
	if (!MatriForm.TERMS.checked) {
		$('termsspan').innerHTML="Please accept the terms and conditions to proceed further ";
		return;
	} else {
		$('termsspan').innerHTML=" ";
	}
}

function citizen_chk()
{
	var MatriForm = this.document.MatriForm;
	if (MatriForm.COUNTRY.options[MatriForm.COUNTRY.selectedIndex].value>0 && MatriForm.CITIZENSHIP.options[MatriForm.CITIZENSHIP.selectedIndex].value>0)
	{
		if (MatriForm.COUNTRY.options[MatriForm.COUNTRY.selectedIndex].value== MatriForm.CITIZENSHIP.options[MatriForm.CITIZENSHIP.selectedIndex].value)
		{
			var res=MatriForm.RESIDENTSTATUS.length;
			for(i=0;i<res;i++){MatriForm.RESIDENTSTATUS[i].disabled=true;MatriForm.RESIDENTSTATUS[i].checked=false;}
			MatriForm.RESIDENTSTATUS[0].disabled=false;
			MatriForm.RESIDENTSTATUS[0].checked=true;
			$('residingstatusCitizenRdb').style.display='';
			$('residingstatusCitizenLbl').style.display='';
			$('residingStatusOptions').style.display='none';
			$('residingStatusLable').innerHTML = '';
		}
		else
		{
			var res=MatriForm.RESIDENTSTATUS.length;
			for(i=0;i<res;i++){MatriForm.RESIDENTSTATUS[i].disabled=false;}
			MatriForm.RESIDENTSTATUS[0].checked=false;
			$('residingStatusOptions').style.display='block';
			$('residingstatusCitizenRdb').style.display='none';
			$('residingstatusCitizenLbl').style.display='none';
			$('residingStatusLable').innerHTML = 'of '+MatriForm.CITIZENSHIP.options[MatriForm.COUNTRY.selectedIndex].text;
		}
	}

	makerequest(MatriForm.COUNTRY.options[MatriForm.COUNTRY.selectedIndex].value);
}

function whats(Width,Height,Scrollbars,tcont,content)
{
	var did="http://www.tamilmatrimony.com";
	var Name=did.substring(did.indexOf('.')+1,did.indexOf('.com')+4)	
	var features = 'status=no left=0 top=0,scrollbars=' + Scrollbars + ',width=' + Width + ',height=' + Height;
	var what=window.open('','', features );
	what.document.write('<html><head><title>'+Name+'</title></head><body style="margin:0px"><table border="0" cellpadding="0" cellspacing="0" style="border:5px solid #F48442"><tr><td valign="top">');
	what.document.write('<div style="padding:5px;line-height:17px"><font style="font-family:verdana;font-size:11px;"><b>'+tcont+':</b><br><br>'+content+'</font></div>');
	what.document.write('<div style="padding:5px;text-align:right"><a href="javascript:window.close();" style="font-family:verdana;font-size:11px;color:#000000">Close</a></div>');
	what.document.write('</td></tr></table></body></html>');
	what.document.close();
}
//  -->



function conchk()
{
	var MatriForm = this.document.MatriForm;
	if((IsEmpty($('COUNTRYCODE'),'text') && IsEmpty($('AREACODE'),'text') && IsEmpty($('PHONENO'),'text') && IsEmpty($('MOBILENO'),'text')) || (
	$('COUNTRYCODE').value=="Country code" && $('AREACODE').value=="Area code" && $('PHONENO').value=="Telephone number" &&  $('MOBILENO').value=="Mobile number"))
	{$('phonespan').innerHTML="Please enter the phone or mobile number";$('row7').className="normalrow";return false; }
	else{$('phonespan').innerHTML="";$('row7').className="normalrow";}
}

var ccode_request=false;
function makerequest(cvalue)
{
	if(cvalue>0 && cvalue!=null)
	{
	ccode_request = createajax();
	var url="../register/addmatrimony_countrycode.php?country="+cvalue; //Mano
	ccode_request.onreadystatechange = processResponse;
	ccode_request.open('GET', url, true);
	ccode_request.send(null);
	}
}

function processResponse()
{
	var MatriForm = document.MatriForm;
	if (ccode_request.readyState == 4) 
	{
		if (ccode_request.status == 200) 
		{
			$('COUNTRYCODE').value=ccode_request.responseText;
		}
	}
}

function termschk()
{
	var MatriForm = this.document.MatriForm;
	if(!MatriForm.TERMS.checked)
	{$('termsspan').innerHTML="Please accept the terms and conditions to proceed further ";MatriForm.TERMS.focus();$('row10').className="rowcolor";return false; }
	else{$('termsspan').innerHTML="&nbsp;";$('row10').className="normalrow";}
}
function clearErrorMsg(rowid,spanid)
{
	$(spanid).innerHTML='';
}
var phoneInterchanged = 0;
function phoneInpAlign(countryValue) {
	if(countryValue == '98'){
		if(phoneInterchanged != 1) {
			var cont1 = $('firstContDiv').innerHTML;
			var cont2 = $('secContDiv').innerHTML;
			$('firstContDiv').innerHTML=cont2;
			$('secContDiv').innerHTML=cont1;
			phoneInterchanged =1;
		}
		$('areacodelabel').innerHTML='STD';

	} else {
		if(phoneInterchanged == 1) {
			var cont1 = $('firstContDiv').innerHTML;
			var cont2 = $('secContDiv').innerHTML;
			$('firstContDiv').innerHTML=cont2;
			$('secContDiv').innerHTML=cont1;
			phoneInterchanged =0;
		}
		$('areacodelabel').innerHTML='Area';
	}
}

	function regslidemtab(dname, hpscount) {
		for(var i=1; i<=hpscount; i++)
		{
			var divid = "rsdiv"+i;
			var tdivid = "rstab"+i;
			var tdividc = "rstabc"+i;			
			$(divid).style.display="none";
			$(tdivid).style.display="none";
			$(tdividc).style.display="block";		
		}

		for(var i=1; i<=hpscount; i++)
		{
			var divid1 = "rsdiv"+i;
			var tdivid = "rstab"+i;
			var tdividc = "rstabc"+i;
			if(divid1==dname)
			{				
				$(dname).style.display = "block";
				$(tdivid).style.display = "block";
				$(tdividc).style.display = "none";			
			}
		}
	}

	function domaincheck()
	{
		if($('DOMAIN').selectedIndex==0)
		{$('domainspan').innerHTML="Please select the domain";
		}else{$('domainspan').innerHTML="&nbsp";}
	}

function subcasteChk(){
	var MatriForm = this.document.MatriForm;
	if (!(MatriForm.SUBCASTE.value=="Enter sub caste here" || MatriForm.SUBCASTE.value=="")) {
		if (MatriForm.CASTE.value==0 || MatriForm.CASTE.selectedIndex==0) {
			$('castespan').innerHTML="Please enter the caste";
			return;
		} else {
			$('castespan').innerHTML=" ";
		}
	}
}
function subcastechk1() {
	selbox=$('SUBCASTE1');
	selectedText = selbox.options[selbox.selectedIndex].text;
	if(selectedText == 'Others' && ($('SUBCASTE').value=='' || $('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";
		return;
	}
	else {
	$('subcastestar').style.display='none';
	$('subcastespan').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 makerequestsubcaste(lang, rel, caste) {
	if(caste>0 && caste!=null)
	{
	ccode_request = createajax();
	if(lang=="BHARAT") {
		lang=$('DOMAIN').value;
	}
	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 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];
			  //alert(listValueArray[i]+" "+listValueArray[i+1]);
			  try
				{
				citysel.add(y,null); // standards compliant
				}
			  catch(ex)
				{
				citysel.add(y); // IE only
				}
			}
		}
	}
	else
	{
		emptySubcasteSel();
	}
}


function casteSelectAct(selectobj){
	$('nocasteselhint').style.display='none';
	var MatriForm = this.document.MatriForm;
	if(selectobj.value=='o') {
		emptySelBox('SUBCASTE1');
		$('SUBCASTE').value='Enter sub caste here';
		$('SUBCASTE').style.display='none';
		$('SUBCASTE1').style.display='block';
	}
	else 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 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 = document.MatriForm.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') {
	
	if(selectedText == 'Others' && (document.MatriForm.SUBCASTE.value=='Enter sub caste here' || document.MatriForm.SUBCASTE.value=='')) {
		$('subcastestar').style.display='block';
		$('subcastespan').innerHTML="If your sub caste is not listed here, please enter it in the text box";
	}
	else {$('subcastestar').style.display='none';$('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 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 checkcastenobar() {
	var MatriForm = this.document.MatriForm;
	if (MatriForm.CASTE.value==0){MatriForm.CASTENOBAR.checked=true;}else{MatriForm.CASTENOBAR.checked=false;}
}

function makerequestcaste(lang, rel) {
	if(rel>0 && rel!=null) {
		ccode_request = createajax();
		if(lang=='BHARAT')
			lang = $('DOMAIN').value;
		qString = "language="+lang+"&religion="+rel;
		var url="../register/ajax_get_caste.php?"+qString;
		ccode_request.onreadystatechange = processResponsecaste;
		ccode_request.open('GET', url, true);
		ccode_request.send(null);
	} else { emptySelBox('CASTE'); }
}

function processResponsecaste() {
	if (ccode_request.readyState == 4) {
		if (ccode_request.status == 200) {
			var casteselbox = $('CASTE');
			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 { casteselbox.add(y,null); }	// standards compliant
				catch(ex) { casteselbox.add(y); }	// IE only
			}
		}
	} else { emptyCasteBox('CASTE'); }
}

// this function removes all the options of the selectbox 
function emptySelBox(elementId) {
	var box = $(elementId);
	if (box.length>0) {
		for(i=box.length;i>=0;i--) { box.remove(i);	}
	}
	var y=document.createElement('option');
	y.value='0';
	y.text='- Select -';
	try	{ box.add(y,null); }
	catch(ex) { box.add(y); }// IE only
}


function emptyCasteBox(elementId) {
	var box = $(elementId);
	if (box.length>0) {
		for(i=box.length;i>=0;i--) { box.remove(i);	}
	}
	var y=document.createElement('option');
	y.value='o';
	y.text='- Select -';
	try	{ box.add(y,null); }
	catch(ex) { box.add(y); }// IE only
}


function makerequestreligion(domain) {
	if(domain>0 && domain!=null) {
		ccode_request = createajax();
		qString = "domain="+domain;
		var url="../register/ajax_get_religion.php?"+qString;
		ccode_request.onreadystatechange = processResponsereligion;
		ccode_request.open('GET', url, true);
		ccode_request.send(null);
	} else { emptySelBox('RELIGION'); }
}

function processResponsereligion() {
	if (ccode_request.readyState == 4) {
		if (ccode_request.status == 200) {
			var relselbox = $('RELIGION');
			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 { relselbox.add(y,null); }	// standards compliant
				catch(ex) { relselbox.add(y); }	// IE only
			}
		}
	} else { emptySelBox('RELIGION'); }
}

function emptyrel(val) {
	if(val==0) {
	emptySelBox('RELIGION');
	}
}

function hidsubcasteupdate() {
	selbox= $('SUBCASTE1');
	var othersubcaste = $('SUBCASTE').value;
	selectedText = selbox.options[selbox.selectedIndex].text;
	if(selectedText=='Others' && (othersubcaste!='Enter sub caste here' || othersubcaste!='')) {
		$('hidsubcaste').value = selbox.value+"~~"+othersubcaste;
	}
		
}




function gothraDet(religion) {
	if(religion==1) {
		$('gothradiv').style.display='block';
	}
	else {
		$('gothradiv').style.display='none';
		MatriForm.GOTHRAM.value='0';
		MatriForm.GOTHRAMOTHERS.value='';
		MatriForm.GOTHRAMOTHERS.style.display='none';
		$('gothrastart').style.display='none';
	}
}

function 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 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 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 = processResponseGothra;
	gothrareq.open('GET', url, true);
	gothrareq.send(null);
}

function processResponseGothra() {
	if (gothrareq.readyState == 4) {
		if (gothrareq.status == 200) {
			var gothraAvail = gothrareq.responseText;
			$('gothraAvail').value=gothraAvail;
			chkgothra2();
		}
	}
}


function 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';
	}
}

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 chkCaste() {
	if($('CASTE').value=='o')
		$('castespan').innerHTML = 'Please select the caste of the prospect';
	else
		$('castespan').innerHTML = '';
}