
function getXMLHTTP()
{
		// will store the reference to the XMLHttpRequest object
		var xmlHttp;
		// this should work for all browsers except IE6 and older
		try
		{
			// try to create XMLHttpRequest object
			xmlHttp = new XMLHttpRequest();
		}
		catch(e)
		{
			// assume IE6 or older
			var XmlHttpVersions = new Array('MSXML2.XMLHTTP.6.0',
			'MSXML2.XMLHTTP.5.0',
			'MSXML2.XMLHTTP.4.0',
			'MSXML2.XMLHTTP.3.0',
			'MSXML2.XMLHTTP',
			'Microsoft.XMLHTTP');
			// try every prog id until one works
			for (var i=0; i<XmlHttpVersions.length && !xmlHttp; i++)
			{
				try
				{
					// try to create XMLHttpRequest object
					xmlHttp = new ActiveXObject(XmlHttpVersions[i]);
				}
				catch (e) {} // ignore potential error
			}
		}
		// return the created object or display an error message
		if (!xmlHttp)
			alert("Error creating the XMLHttpRequest object.");
		else
			return xmlHttp;
}
		
function getState(countryId) 
{		
		var strURL="../inc/findState.php?country="+countryId;
		var req = getXMLHTTP();
		
		if (req)
		{
			req.onreadystatechange = function()
			{
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{						
						document.getElementById('statediv').innerHTML=req.responseText;						
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}	
			};
			req.open("GET", strURL, true);
			req.send(null);
		}		
}
	
	
function getCity(countryId,stateId) 
{		
		var strURL="../inc/findCity.php?country="+countryId+"&state="+stateId;
		var req = getXMLHTTP();
		
		if (req) 
		{
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{						
						document.getElementById('citydiv').innerHTML=req.responseText;						
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}			
}
	
function getCity1(countryId) 
{		
		var strURL="../inc/findCity1.php?country="+countryId;
		var req = getXMLHTTP();
		
		if (req) 
		{
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{						
						document.getElementById('citydiv').innerHTML=req.responseText;						
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
}
	
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 chk()
{
	var MatriForm = this.document.MatriFormStepOne;
		if(MatriForm.name.value == "")
	    {
			alert("Please specify your name");
			MatriForm.name.focus();
			return false;
		}
		if((MatriForm.age.value=="") && (MatriForm.dobday.value=="") && (MatriForm.dobmonth.value=="") && (MatriForm.dobyear.value=="")) 
		{
			alert("Please enter the age or select the date of birth ");
			return false;
		}
		if(isNaN(MatriForm.age.value))
		{
			alert("please enter a valid age");
			return false;
		}
		if(MatriForm.age.value=="")
		{
			if(MatriForm.dobday.value=="")
			{
				alert("Please select date");
				return false;
			}
			if(MatriForm.dobmonth.value=="")
			{
				alert("Please select month");
				return false;
			}
			if(MatriForm.dobyear.value=="")
			{
				alert("Please select year");
				return false;
			}
		}						
		if ( ( MatriForm.gender[0].checked == false ) && ( MatriForm.gender[1].checked == false ) )
		{
			alert ( "Please choose your Gender: Male or Female" );
			return false;
		}
		if(MatriForm.age.value<18 && MatriForm.gender[1].checked && (MatriForm.age.value)!='' )
		{
			alert("User age should be greater than 18 year for registration");
			return false;
		}
		if(MatriForm.age.value<21 && MatriForm.gender[0].checked && (MatriForm.age.value)!='' )
		{
			alert("User age should be greater than 21 year for registration");
			return false;
		}
		var calyear = displayage(MatriForm.dobyear.value,MatriForm.dobmonth.value,MatriForm.dobday.value, 'years', 0, 'rounddown'
		);
		if (MatriForm.age.value=="" && calyear < 21 && MatriForm.gender[0].checked)
		{
			alert("User age should be greater than 21 year for registration");
			return false;
		}
		if((MatriForm.MARITAL_STATUS[0].checked == false) && (MatriForm.MARITAL_STATUS[1].checked == false) && (MatriForm.MARITAL_STATUS[2].checked == false) && (MatriForm.MARITAL_STATUS[3].checked == false))
		{
			alert("Please specify your Maritial status");
			return false;
		}
		if((MatriForm.MARITAL_STATUS[0].checked == false) && (MatriForm.NOOFCHILDREN.value==""))
		{
			alert("please select no. of childeren");
			return false;
		}
		if((MatriForm.MARITAL_STATUS[0].checked == false) && (MatriForm.CHILDLIVINGWITHME[0].checked==false) && (MatriForm.CHILDLIVINGWITHME[1].checked==false) && (MatriForm.NOOFCHILDREN.value!="0") && (MatriForm.NOOFCHILDREN.value!=""))
		{
			alert("please enter living status of childeren");
			return false;
		}
		if(MatriForm.citizenship.value=="Any")
		{
			alert("Please Specify your citizenship");
			return false;
		}
		if(MatriForm.country.value=="Any")
		{
			alert("Please Specify your country");
			return false;
		}
		if(MatriForm.residingstate.value=="Any")
		{
			alert("Please Specify your state");
			return false;
		}
		if(MatriForm.residingcity.value=="Any")
		{
			alert("Please Specify your city");
			return false;
		}
		if(MatriForm.residingstate.value=="")
		{
			alert("Please Specify your state");
			return false;
		}
		if(MatriForm.residingcity.value=="")
		{
			alert("Please Specify your city");
			return false;
		}
		if((MatriForm.occupationcategory[0].checked==false) && (MatriForm.occupationcategory[1].checked==false) && (MatriForm.occupationcategory[2].checked==false) && (MatriForm.occupationcategory[3].checked==false) && (MatriForm.occupationcategory[3].checked==false))
		{
			alert("Please Specify Your occupatiopn");
			return false;
		}
		if((MatriForm.phoneno.value=="") && (MatriForm.mobileno.value==""))
		{
			alert("please specify your contact no");
			return false;
		}
		if((MatriForm.countrycode.value=="") && (MatriForm.phoneno.value!=""))
		{
			alert("please enter your countrycode");
			return false;
		}
		
		if((MatriForm.areacode.value=="") && (MatriForm.phoneno.value!=""))
		{
			alert("please enter your areacode");
			return false;
		}
		if(MatriForm.address.value=="")
		{
			alert("please enter your address");
			return false;
		}
		if(MatriForm.email.value=="")
		{
			alert("enter your emailid \n");
			MatriForm.email.focus();
			return false;
		}
		else
		{
			var str1=MatriForm.email.value 
				
			var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
			if (!filter.test(str1))
			{
				alert("Please input a valid Email address!");
				MatriForm.email.focus();
				return false;
			}
		}
		if(MatriForm.password.value=="")
		{
			alert("please enter your password");
			return false;
		}
		if(MatriForm.password.value.length<="4")
		{
			alert("Your password must be greater than four character");
			return false;
		}
		if(MatriForm.password1.value=="")
		{
			alert("please confirm your password");
			return false;
		}
		if (MatriForm.password.value != MatriForm.password1.value )
		{
			// If null display and alert box
			alert("Password not matched");
			// Place the cursor on the field for revision
			MatriForm.password.focus();
			return false;
		}
		if(MatriForm.TERMS.value=="")
		{
			alert("please accept the terms and condition");
			MatriForm.TERMS.focus();
			return false;
		}
}

function agesel()
{
	var MatriForm = this.document.MatriFormStepOne;
	MatriForm.age.value="";
}

function agefocus()
{
	var MatriForm = this.document.MatriFormStepOne;
	if(MatriForm.age.value!="")
	{
		if(!(MatriForm.dobyear.value=="") && !(MatriForm.dobmonth.value=="") && !(MatriForm.dobday.value==""))
		{
			MatriForm.dobmonth.value=""; MatriForm.dobday.value=""; MatriForm.dobyear.value="";
		}
	}
}	

					
//////////to check user name availabilty/////
/*
This is our function to use xmlhttp requrests, i did not write this part w3 schools did
[url=http://www.w3schools.com/ajax/ajax_browsers.asp]http://www.w3schools.com/ajax/ajax_browsers.asp[/url]
This was quicker than just making my own :)
*/
var xmlHttp; // xmlHttp variable

function GetXmlHttpObject()
{ // This function we will use to call our xmlhttpobject.
	var objXMLHttp=null ;// Sets objXMLHttp to null as default.
	if (window.XMLHttpRequest)
	{ // If we are using Netscape or any other browser than IE lets use xmlhttp.
		objXMLHttp=new XMLHttpRequest(); // Creates a xmlhttp request.
	}
	else if (window.ActiveXObject)
	{ // ElseIf we are using IE lets use Active X.
		objXMLHttp=new ActiveXObject("Microsoft.XMLHTTP"); // Creates a new Active X Object.
	} // End ElseIf.
	return objXMLHttp; // Returns the xhttp object.
}
// Close Function

function CheckUsername(name)
{ // This function we will use to check to see if a username is taken or not.
	xmlHttp=GetXmlHttpObject() // Creates a new Xmlhttp object.
	if (xmlHttp==null)
	{ // If it cannot create a new Xmlhttp object.
		alert ("Browser does not support HTTP Request"); // Alert Them!
		return // Returns.
	} // End If.
	var url="check.php?name="+name ;// Url that we will use to check the username.
	xmlHttp.open("GET",url,true); // Opens the URL using GET
	xmlHttp.onreadystatechange = function()
	{ // This is the most important piece of the puzzle, if onreadystatechange is equal to 4 than that means the request is done.
		if (xmlHttp.readyState == 4)
		{ // If the onreadystatechange is equal to 4 lets show the response text.
			document.getElementById("usernameresult").innerHTML = xmlHttp.responseText; 
			// Updates the div with the response text from check.php
		} // End If.
	}; // Close Function
	xmlHttp.send(null); // Sends NULL instead of sending data.
} // Close Function.

function checkNum(x)
{
   var s_len=x.value.length ;
   var s_charcode = 0;
   for (var s_i=0;s_i<s_len;s_i++)
   {
      s_charcode = x.value.charCodeAt(s_i);
      if(!(s_charcode>=48 && s_charcode<=57))
       {
          alert("Only Numeric Values Allowed");
          x.value='';
          x.focus();
         return false;
       }
   }
   return true;
}
	
function getcaste(religionId) 
{		
		var strURL="../inc/findcaste.php?religion="+religionId;
		var req = getXMLHTTP();
		if (req) 
		{
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{						
						document.getElementById('castediv').innerHTML=req.responseText;						
					} 
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			};			
			req.open("GET", strURL, true);
			req.send(null);
		}		
}

function findcode(countryId) 
{		
		
		var strURL="../inc/findcode.php?country="+countryId;
		//alert(strURL);
		var req = getXMLHTTP();
		
		if (req) 
		{
			
			req.onreadystatechange = function() 
			{
				if (req.readyState == 4) 
				{
					// only if "OK"
					if (req.status == 200) 
					{//alert(req.responseText);						
						document.getElementById('codediv').innerHTML=req.responseText;						
					}
					else 
					{
						alert("There was a problem while using XMLHTTP:\n" + req.statusText);
					}
				}				
			}			
			req.open("GET", strURL, true);
			req.send(null);
		}		
}
<!--
var countDescription = "250";   //Example: var count = "175";
function limiterDescription()
{
	var tex = document.MatriFormStepTwo.comment.value;
	var len = tex.length;
	if(len > countDescription)
	{
			tex = tex.substring(0,countDescription);
			document.MatriFormStepTwo.comment.value =tex;
			return false;
	}
	document.MatriFormStepTwo.limit.value = countDescription-len;
}

var countAddress = "99";   
function limiterAddress()
{
	var tex = document.MatriFormStepOne.address.value;
	var len = tex.length;
	if(len > countAddress)
	{
        tex = tex.substring(0,countAddress);
        document.MatriFormStepOne.address.value =tex;
        return false;
	}
	document.MatriFormStepOne.limit.value = countAddress-len;
}

function CheckUsername(name)
{
 	// This function we will use to check to see if a username is taken or not.
	xmlHttp=GetXmlHttpObject() // Creates a new Xmlhttp object.
	if (xmlHttp==null)
	{ // If it cannot create a new Xmlhttp object.
		alert ("Browser does not support HTTP Request") // Alert Them!
		return // Returns.
	} // End If.
	var url="../inc/check.php?email="+name // Url that we will use to check the username.
	xmlHttp.open("GET",url,true) // Opens the URL using GET
	xmlHttp.onreadystatechange = function () 
	{ // This is the most important piece of the puzzle, if onreadystatechange is equal to 4 than that means the request is done.
		if (xmlHttp.readyState == 4) 
		{ 
			// If the onreadystatechange is equal to 4 lets show the response text.

			//document.frmsales.email.value = xmlHttp.responseText;

			// Updates the div with the response text from check.php
 
			document.getElementById("usernameresult").innerHTML = xmlHttp.responseText;

			//alert(usernameresult);

		} // End If.
	}; // Close Function
	
	xmlHttp.send(null); // Sends NULL instead of sending data.
} // Close Function.

function limiter()
{
	if(document.MatriForm.feet.value=="Feet/Inches" && document.MatriForm.CMS.value=="Cms")
	{
		alert("Please specify your height");
		document.MatriForm.feet.focus();
		return false;
	}
	if ( ( document.MatriForm.physical_status[0].checked == false ) && ( document.MatriForm.physical_status[1].checked == false ) && ( document.MatriForm.physical_status[2].checked == false ) )
	{
		alert ( "Please specify your physical status" );
		return false;
	}
	if(document.MatriForm.education.value=="0")
	{
		alert("please specify your education category");
		document.MatriForm.education.focus();
		return false;
	}
	if(document.MatriForm.occupation.value=="0")
	{
		alert("please specify your occupation");
		document.MatriForm.occupation.focus();
		return false;
	}
	if(document.MatriForm.mothertongue.value=="0")
	{
		alert("please specify your mothertongue");
		document.MatriForm.mothertongue.focus();
		return false;
	}
	if(document.MatriForm.religion.value=="Any")
	{
		alert("Please Specify your religion");
		return false;
	}
	if(document.MatriForm.caste.value=="0")
	{
		alert("Please Specify your caste");
		return false;
	}

	if (!(document.MatriForm.subcaste.value==""))
	{
		if (document.MatriForm.caste.value==0)
		{
			alert("please specify your caste");
			return false;
		}
	}
	if(document.MatriForm.comment.value=="")
	{
		alert("Please Specify your description");
		return false;
	}
	if (document.MatriForm.comment.value=="") 
	{
		alert("Please enter a profile description in not less than 50 characters");
		return false;
	}
	var desc=document.MatriForm.comment.value;
	if (desc.length<50) 
	{
		alert("Please enter a profile description in not less than 50 characters");
		return false;
	}
	if ( ( document.MatriForm.registeredby[0].checked == false ) && ( document.MatriForm.registeredby[1].checked == false ) && ( document.MatriForm.registeredby[2].checked == false ) && ( document.MatriForm.registeredby[3].checked == false ) && ( document.MatriForm.registeredby[4].checked == false ) && ( document.MatriForm.registeredby[5].checked == false ) )
	{
		alert ( "Please specify profile created by" );
		return false;
	}
	return true;
}

function heightsel()
{
	var MatriForm = this.document.MatriFormStepTwo;
	MatriForm.feet.value="Feet/Inches";
}

//function heightfocus()
//{
//	var MatriForm = this.document.MatriFormStepTwo;
//	if(MatriForm.feet.value!="Feet/Inches")
//	{
//		if(!(MatriForm.CMS.value=="Cms"))
//		{
//			MatriForm.CMS.value="Cms"; 
//		}
//	}
//}

function weightfocus()
{
	var MatriForm = this.document.MatriForm;
	if(MatriForm.kgs.value!="Kgs")
	{
		if(!(MatriForm.LBS.value=="Lbs"))
		{
			MatriForm.LBS.value="Lbs"; 
		}
	}
}	

function agefocus()
{
	var MatriForm = this.document.MatriFormStepOne;
	if(MatriForm.age.value!="")
	{
		if(!(MatriForm.dobyear.value=="") && !(MatriForm.dobmonth.value=="") && !(MatriForm.dobday.value==""))
		{
			MatriForm.dobmonth.value=""; MatriForm.dobday.value=""; MatriForm.dobyear.value="";
		}
	}
}	

function weightsel()
{
	var MatriForm = this.document.MatriFormStepTwo;
	MatriForm.kgs.value="Kgs";
}

function weightsel1()
{
	var MatriForm = this.document.MatriFormStepTwo;
	MatriForm.LBS.value="Lbs";
}

function weightselEdit()
{
	var MatriForm = this.document.editPrimeInfo;
	MatriForm.kgs.value="Kgs";
}

function weightsel1Edit()
{
	var MatriForm = this.document.editPrimeInfo;
	MatriForm.LBS.value="Lbs";
}



function validatefam()
{
	if((document.MatriForm.FAMILYVALUE[0].checked==false) && (document.MatriForm.FAMILYVALUE[1].checked==false) && (document.MatriForm.FAMILYVALUE[2].checked==false) && (document.MatriForm.FAMILYVALUE[3].checked==false))
	{
		alert("please specify your family values");
		return false;
	}
	if((document.MatriForm.FAMILYTYPE[0].checked==false) && (document.MatriForm.FAMILYTYPE[1].checked==false) && (document.MatriForm.FAMILYTYPE[2].checked==false))
	{
		alert("please specify your family type");
		return false;
	}
	return true;
}

function showHideItems(myItem)
{
	//this is the ID of the hidden item
	myItemobj = document.getElementById('item1');
	//myItemobj2 = document.getElementById('item2');
	myItemobj3 = document.getElementById('plus_1');
	myItemobj4 = document.getElementById('minus_1');
	
	if(myItem=='0')
	{
		myItemobj.style.display = "none";
		//myItemobj2.style.display = "none";
		//myItemobj4.style.display = "none";
		//myItemobj6.style.display = "none";
		//myItemobj7.style.display = "none";
	}
	else
	{
		//this is the ID of the plus/minus button image
		//var myButton = document.getElementById(myButton);
		if(myItem=='item1')
		{
			if (myItemobj.style.display != "none")
			{
				//items are currently displayed, so hide them
				myItemobj.style.display = "none";
				myItemobj4.style.display = "none";
				myItemobj3.style.display = "block";
		
				// swapImage(myButton,"plus");
			}
			else
			{
				//items are currently hidden, so display them
				myItemobj.style.display = "block";
				myItemobj3.style.display = "none";
				myItemobj4.style.display = "block";
			}
		}
		else
		{
			if (myItemobj2.style.display != "none")
			{
				myItemobj2.style.display = "none";
				myItemobj6.style.display = "none";
				myItemobj5.style.display = "block";
			}
			else
			{
				myItemobj2.style.display = "block";
				myItemobj5.style.display = "none";
				myItemobj6.style.display = "block";
			}
		}
	}
}

function showHideItems1(myItem1)
{
	//this is the ID of the hidden item
	myItemobject = document.getElementById('item11');
	myItemobject2 = document.getElementById('item21');
	myItemobject3 = document.getElementById('plus1_1');
	myItemobject4 = document.getElementById('minus1_1');
	myItemobject5 = document.getElementById('plus1_2');
	myItemobject6 = document.getElementById('minus1_2');
	myItemobject7 = document.getElementById('item3');
	
	if(myItem1=='0')
	{
		myItemobject.style.display = "none";
		myItemobject2.style.display = "none";
		myItemobject4.style.display = "none";
		myItemobject6.style.display = "none";
		myItemobject7.style.display = "none";
	}
	else
	{
		//this is the ID of the plus/minus button image
		//var myButton = document.getElementById(myButton);
		if(myItem1=='item11')
		{
			if (myItemobject.style.display != "none")
		    	{
				//items are currently displayed, so hide them
				myItemobject.style.display = "none";
				myItemobject4.style.display = "none";
				myItemobject3.style.display = "block";
				
				// swapImage(myButton,"plus");
			}
			else
			{
				//items are currently hidden, so display them
				myItemobject.style.display = "block";
				myItemobject3.style.display = "none";
				myItemobject4.style.display = "block";
			}
		}
		else
		{
			if (myItemobject2.style.display != "none")
			{
				myItemobject2.style.display = "none";
				myItemobject6.style.display = "none";
				myItemobject5.style.display = "block";
			}
			else
			{
				myItemobject2.style.display = "block";
				myItemobject5.style.display = "none";
				myItemobject6.style.display = "block";
			}
		}
	}
}

function showHideItems2(myItem)
{
	//this is the ID of the hidden item
	myItemobj = document.getElementById('item22');
	myItemobj2 = document.getElementById('item23');
	myItemobj3 = document.getElementById('plus2_1');
	myItemobj4 = document.getElementById('minus2_1');
	myItemobj5 = document.getElementById('plus2_2');
	myItemobj6 = document.getElementById('minus2_2');
	myItemobj7 = document.getElementById('item3');
	
	if(myItem=='0')
	{
		myItemobj.style.display = "none";
		myItemobj2.style.display = "none";
		myItemobj4.style.display = "none";
		myItemobj6.style.display = "none";
		myItemobj7.style.display = "none";
	}
	else
	{
		//this is the ID of the plus/minus button image
		//var myButton = document.getElementById(myButton);
		if(myItem=='item22')
		{
			if (myItemobj.style.display != "none")
			{
				//items are currently displayed, so hide them
				myItemobj.style.display = "none";
				myItemobj4.style.display = "none";
				myItemobj3.style.display = "block";
				
				// swapImage(myButton,"plus");
			}
			else
			{
				//items are currently hidden, so display them
				myItemobj.style.display = "block";
				myItemobj3.style.display = "none";
				myItemobj4.style.display = "block";
			}
		}
		else
		{
			if (myItemobj2.style.display != "none")
			{
				myItemobj2.style.display = "none";
				myItemobj6.style.display = "none";
				myItemobj5.style.display = "block";
			}
			else
			{
				myItemobj2.style.display = "block";
				myItemobj5.style.display = "none";
				myItemobj6.style.display = "block";
			}
		}
	}
}

function showHideItems3(myItem)
{
	//this is the ID of the hidden item
	myItemobj = document.getElementById('item24');
	myItemobj2 = document.getElementById('item25');
	myItemobj3 = document.getElementById('plus3_1');
	myItemobj4 = document.getElementById('minus3_1');
	myItemobj5 = document.getElementById('plus3_2');
	myItemobj6 = document.getElementById('minus3_2');
	myItemobj7 = document.getElementById('item3');
	
	if(myItem=='0')
	{
		myItemobj.style.display = "none";
		myItemobj2.style.display = "none";
		myItemobj4.style.display = "none";
		myItemobj6.style.display = "none";
		myItemobj7.style.display = "none";
	}
	else
	{
		//this is the ID of the plus/minus button image
		//var myButton = document.getElementById(myButton);
		if(myItem=='item24')
		{
			if (myItemobj.style.display != "none")
			{
				//items are currently displayed, so hide them
				myItemobj.style.display = "none";
				myItemobj4.style.display = "none";
				myItemobj3.style.display = "block";
				
				// swapImage(myButton,"plus");
			}
			else
			{
				//items are currently hidden, so display them
				myItemobj.style.display = "block";
				myItemobj3.style.display = "none";
				myItemobj4.style.display = "block";
			}
		}
		else
		{
			if (myItemobj2.style.display != "none")
			{
				myItemobj2.style.display = "none";
				myItemobj6.style.display = "none";
				myItemobj5.style.display = "block";
			}
			else
			{
				myItemobj2.style.display = "block";
				myItemobj5.style.display = "none";
				myItemobj6.style.display = "block";
			}
		}
	}
}

function showHideItems4(myItem)
{
	//this is the ID of the hidden item
	myItemobj = document.getElementById('item26');
	myItemobj2 = document.getElementById('item27');
	myItemobj3 = document.getElementById('plus4_1');
	myItemobj4 = document.getElementById('minus4_1');
	myItemobj5 = document.getElementById('plus4_2');
	myItemobj6 = document.getElementById('minus4_2');
	myItemobj7 = document.getElementById('item3');
	
	if(myItem=='0')
	{
		myItemobj.style.display = "none";
		myItemobj2.style.display = "none";
		myItemobj4.style.display = "none";
		myItemobj6.style.display = "none";
		myItemobj7.style.display = "none";
	}
	else
	{
		//this is the ID of the plus/minus button image
		//var myButton = document.getElementById(myButton);
		if(myItem=='item26')
		{
			if (myItemobj.style.display != "none")
			{
				//items are currently displayed, so hide them
				myItemobj.style.display = "none";
				myItemobj4.style.display = "none";
				myItemobj3.style.display = "block";
		
				// swapImage(myButton,"plus");
			}
			else
			{
				//items are currently hidden, so display them
				myItemobj.style.display = "block";
				myItemobj3.style.display = "none";
				myItemobj4.style.display = "block";
			}
		}
		else
		{
			if (myItemobj2.style.display != "none")
			{
				myItemobj2.style.display = "none";
				myItemobj6.style.display = "none";
				myItemobj5.style.display = "block";
			}
			else
			{
				myItemobj2.style.display = "block";
				myItemobj5.style.display = "none";
				myItemobj6.style.display = "block";
			}
		}
	}
}

function nameChk() 
{

	var MatriForm = this.document.MatriForm;
	if (MatriForm.name.value=="")
	{ 
		alert("Please enter the name of the prospect");
		MatriForm.name.focus();
		return true;
	} 
	if(MatriForm.age.value=="")
	{
		alert("please enter your age or date of birth");
		MatriForm.age.focus();
		return true;
	}
	elseif(MatriForm.dobday.value=="" || MatriForm.dobmonth.value=="" || MatriForm.dobyear.value=="")
	{
		alert("please enter your date of borth");
		MatriForm.dobday.focus();
		return true;
	}
	if(!MatriForm.gender[0].checked && !MatriForm.gender[1].checked)
	{
		alert("please enter your gender");
	
	}
}

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.MatriFormStepOne;
	//var CHILDLW = MatriForm.NOOFCHILDREN.options[MatriForm.NOOFCHILDREN.selectedIndex].value;
		//alert("hello");
	//this.document.MatriForm.getElementById(id).checked
		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.MatriFormStepOne;
	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=" ";
	}

	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 maritalChk() 
{
	var MatriForm = this.document.MatriForm;
	if ( IsEmpty(MatriForm.MARITAL_STATUS,'radio')) 
	{
		$('maritalspan').innerHTML="Please select the marital status of the user";
		return;
	} 
	else 
	{
		$('maritalspan').innerHTML="&nbsp;";
	}
}

function childChk()
{
	var MatriForm = this.document.MatriFormStepOne;
	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.MatriFormStepOne;
	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 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=" ";
	}
}
