
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()
{
		if(document.MatriForm.name.value == "")
	    	{
			alert("Please specify your name");
			document.MatriForm.name.focus();
			return false;
		}
		if((document.MatriForm.age.value=="") && (document.MatriForm.dobday.value=="") && (document.MatriForm.dobmonth.value=="") && (document.MatriForm.dobyear.value=="")) 
		{
			alert("Please enter the age or select the date of birth ");
			return false;
		}
		if(isNaN(document.MatriForm.age.value))
		{
			alert("please enter a valid age");
			return false;
		}
		if(document.MatriForm.age.value=="")
		{
			if(document.MatriForm.dobday.value=="")
			{
				alert("Please select date");
				return false;
			}
			if(document.MatriForm.dobmonth.value=="")
			{
				alert("Please select month");
				return false;
			}
			if(document.MatriForm.dobyear.value=="")
			{
				alert("Please select year");
				return false;
			}
		}						
		if ( ( document.MatriForm.gender[0].checked == false ) && ( document.MatriForm.gender[1].checked == false ) )
		{
			alert ( "Please choose your Gender: Male or Female" );
			return false;
		}
		if(document.MatriForm.age.value<18 && document.MatriForm.gender[1].checked && (document.MatriForm.age.value)!='' )
		{
			alert("User age should be greater than 18 year for registration");
			return false;
		}
		if(document.MatriForm.age.value<21 && document.MatriForm.gender[0].checked && (document.MatriForm.age.value)!='' )
		{
			alert("User age should be greater than 21 year for registration");
			return false;
		}
		var calyear = displayage(document.MatriForm.dobyear.value,document.MatriForm.dobmonth.value,document.MatriForm.dobday.value, 'years', 0, 'rounddown'
		);
		if (document.MatriForm.age.value=="" && calyear < 21 && document.MatriForm.gender[0].checked)
		{
			alert("User age should be greater than 21 year for registration");
			return false;
		}
		if((document.MatriForm.MARITAL_STATUS[0].checked == false) && (document.MatriForm.MARITAL_STATUS[1].checked == false) && (document.MatriForm.MARITAL_STATUS[2].checked == false) && (document.MatriForm.MARITAL_STATUS[3].checked == false))
		{
			alert("Please specify your Maritial status");
			return false;
		}
		if((document.MatriForm.MARITAL_STATUS[0].checked == false) && (document.MatriForm.NOOFCHILDREN.value==""))
		{
			alert("please select no. of childeren");
			return false;
		}
		if((document.MatriForm.MARITAL_STATUS[0].checked == false) && (document.MatriForm.CHILDLIVINGWITHME[0].checked==false) && (document.MatriForm.CHILDLIVINGWITHME[1].checked==false))
		{
			alert("please enter living status of childeren");
			return false;
		}
		if(document.MatriForm.citizenship.value=="Any")
		{
			alert("Please Specify your citizenship");
			return false;
		}
		if(document.MatriForm.country.value=="Any")
		{
			alert("Please Specify your country");
			return false;
		}
		if(document.MatriForm.residingstate.value=="Any")
		{
			alert("Please Specify your state");
			return false;
		}
		if(document.MatriForm.residingcity.value=="Any")
		{
			alert("Please Specify your city");
			return false;
		}
		if(document.MatriForm.residingstate.value=="")
		{
			alert("Please Specify your state");
			return false;
		}
		if(document.MatriForm.residingcity.value=="")
		{
			alert("Please Specify your city");
			return false;
		}
		if((document.MatriForm.occupationcategory[0].checked==false) && (document.MatriForm.occupationcategory[1].checked==false) && (document.MatriForm.occupationcategory[2].checked==false) && (document.MatriForm.occupationcategory[3].checked==false) && (document.MatriForm.occupationcategory[3].checked==false))
		{
			alert("Please Specify Your occupatiopn");
			return false;
		}
		if((document.MatriForm.phoneno.value=="") && (document.MatriForm.mobileno.value==""))
		{
			alert("please specify your contact no");
			return false;
		}
		if((document.MatriForm.countrycode.value=="") && (document.MatriForm.phoneno.value!=""))
		{
			alert("please enter your countrycode");
			return false;
		}
		if((document.MatriForm.areacode.value=="") && (document.MatriForm.phoneno.value!=""))
		{
			alert("please enter your areacode");
			return false;
		}
		if(document.MatriForm.email.value=="")
		{
			alert("enter your emailid \n");
			document.MatriForm.email.focus();
			return false;
		}
		else
		{
			var str1=document.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!");
				document.MatriForm.email.focus();
				return false;
			}
		}
		if(document.MatriForm.password.value=="")
		{
			alert("please enter your password");
			return false;
		}
		if(document.MatriForm.password.value.length<="4")
		{
			alert("Your password must be greater than four character");
			return false;
		}
		if(document.MatriForm.password1.value=="")
		{
			alert("please confirm your password");
			return false;
		}
		if (document.MatriForm.password.value != document.MatriForm.password1.value )
		{
			// If null display and alert box
			alert("Password not matched");
			// Place the cursor on the field for revision
			document.MatriForm.password.focus();
			return false;
		}
		if(document.MatriForm.TERMS.value=="")
		{
			alert("please accept the terms and condition");
			document.MatriForm.TERMS.focus();
			return false;
		}
}

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

function agefocus()
{
	var MatriForm = this.document.MatriForm;
	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 getCasteSearch(religionId)
{	
		var strURL="inc/findCasteSearch.php?RELIGION1="+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 addSearch(var1,var2,hiddenvar)
{
	var hiddenvalue;
	var str=document.form1;
	var flag=0;
	while(flag<str.elements.length)
	{
		if(str.elements[flag].name==var1)
		{
		obj1=str.elements[flag];
		break;
		}
	flag++;
	}

	var flag=0;

	while(flag<str.elements.length)
	{
		if(str.elements[flag].name==var2)
		{
		obj2=str.elements[flag];
		break;
		}
	flag++;

	}
	
	var flag=0;
	
	while(flag<str.elements.length)
	{
		if(str.elements[flag].name==hiddenvar)
		{
			hidden_name=str.elements[flag];
			break;
		}
		flag++;
	}
	
	if(obj2.options.length>0 && obj2.options[0].value=="All")
	{
		var l = obj1.options.selectedIndex;
		if(l==-1);
		else
		{
			obj2.options[0]=null;
			var len=obj1.options.length-1;
			for(a=len;a>=0;a--)
			{
				if(obj1.options[a].selected)
				{
					var optn=document.createElement("OPTION");
					optn.innerHTML=obj1.options[a].text;
					optn.value=obj1.options[a].value;
					obj2.options.add(optn);
				}
			}
			removeSearch(var1,var2,hiddenvar);
		}

	}
	else
	{
		if(obj1.options.length == 0)
		;
		else
		{
			var k=obj1.options.length-1;
			var len_obj2 = obj2.length;
			while(k>=0)
			{
				if(obj1.options[k].selected)
				{
					var arr = new Option();
					arr.value=obj1.options[k].value;
					arr.text=obj1.options[k].text;
					obj1.remove(k);

					for(i=0;i<obj2.options.length;i++)
					if(obj2[i].value == arr.value)
					{
						var repeat_name=true;
						break;
					}

					if(repeat_name == true)
					{
						repeat_name=false;
					}
					else
					{
						if (arr.value=="All" || arr.value=="0")
						obj2.options.length=0;
						else
						{
							for(var l=0;l<obj2.options.length;l++)
							if(obj2.options[l].value=="All" || obj2.options[l].value=="0")
								obj2.options[l]=null;
						}
						obj2.options[obj2.options.length]=arr;
	
						if (arr.value=="All" || arr.value=="0")
							removeSearch(var1,var2,hiddenvar);
					}
				}
				k--;
			}
		}
	
	}
	var k=0,str1,str2;
	while(k<obj2.options.length)
	{
		str2=obj2.options[k].value;
		str1=str1+","+str2;
		k++;
	}
	
	hidden_name.value=str1;
}

function removeSearch(var1,var2,hiddenvar)
{
	var str=document.form1;
	var flag=0;
	
	while(flag<str.elements.length)
	{
		if(str.elements[flag].name==var1)
		{
			obj1=str.elements[flag];
			break;
		}
		flag++;
	}
	
	var flag=0;
	
	while(flag<str.elements.length)
	{
		if(str.elements[flag].name==var2)
		{
			obj2=str.elements[flag];
			break;
		}
		flag++;
	}
	
	var flag=0;

	while(flag<str.elements.length)
	{
		if(str.elements[flag].name==hiddenvar)
		{
			hidden_name=str.elements[flag];
			break;
		}
		flag++;
	}
	if(obj2.options.length == 0)
	;
	else
	{
		var len=obj2.options.length;
		for(a=len-1;a>=0;a--)
		{
			if(obj2.options[a].selected == true)
				obj2.remove(a);
		}
		obj1.innerHTML="";
		if((var1=="Occupation[]")||(var1=="Education_Level_New[]") ||(var1=="Education_Level") ||(var1=="Education_Level[]")||(var1=="Caste[]")||(var1==	
			"Income[]") || (var1=="STAR[]"))
		{
			if(var1=="Occupation[]")
			{
		  	 var origval="All#1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#27#28#29#30#31#32#33#34#35#36#37#38#39#40#41#42#".split("#");
		   	 var origlab="ALL#Accounts/ Tax/ CS/ Audit#Advtg/ Media/ Mktg/ MR#Agent#Airlines/ Reservations/ Travel#Anchoring/ TV/ Films#Architecture/ Interior Design#Banking/ Insurance#Call Centre/ ITES/ Telecalling#Content/ Editing/ Journalism#Corporate Commn./ PR#Corporate Planning/ Consulting#Cust. Service/ Operations#Entrepreneur/ Businessmen#Export/ Import#Fashion#Front Office/ Secretarial Staff#Graphic/ Web Design#Hotels/ Restaurants#HR/ Admin/ PM/ IR/ Training#IT Software#IT Hardware/ Telecom#Legal/ Law#Logistics/ Purchase/ SCM#Medical/ Healthcare#Packaging Development#Prod./ Maintenance/ Service Engg#R&D/ Engineering Design#Sales#Security#Site Engnr/ Project Mgmt#Teaching/ Education/ Languages#Agriculture/ Farming#Civil Services(IAS/ IFS/ IPS/ IRS/ etc.)#Defence Services#Govt. Services#Home Maker#Retired#Social Services#Sportsman#Beauty, Health & Fitness Professional#Student#Others#".split("#");
			}
		else if(var1=="Education_Level_New[]")
		{
			var origval="Any#Bachelors - Engineering/ Computers#Masters - Engineering/ Computers#Bachelors - Arts/ Science/ Commerce/ Others#Masters - Arts/ Science/ Commerce/ Others#Management - BBA/ MBA/ Others#Medicine - General/ Dental/ Surgeon/ Others#Legal - BL/ ML/ LLB/ LLM/ Others#Service - IAS/ IPS/ Others#PhD#Diploma#Higher Secondary/ Secondary#".split("#");
			var origlab="Any#Bachelors - Engineering/ Computers#Masters - Engineering/ Computers#Bachelors - Arts/ Science/ Commerce/ Others#Masters - Arts/ Science/ Commerce/ Others#Management - BBA/ MBA/ Others#Medicine - General/ Dental/ Surgeon/ Others#Legal - BL/ ML/ LLB/ LLM/ Others#Service - IAS/ IPS/ Others#PhD#Diploma#Higher Secondary/ Secondary#".split("#");
		}
		else if(var1=="Education_Level[]")
		{
			var origval="Any#Bachelors - Engineering/ Computers#Masters - Engineering/ Computers#Bachelors - Arts/ Science/ Commerce/ Others#Masters - Arts/ Science/ Commerce/ Others#Management - BBA/ MBA/ Others#Medicine - General/ Dental/ Surgeon/ Others#Legal - BL/ ML/ LLB/ LLM/ Others#Service - IAS/ IPS/ Others#PhD#Diploma#Higher Secondary/ Secondary#".split("#");
			var origlab="Any#Bachelors - Engineering/ Computers#Masters - Engineering/ Computers#Bachelors - Arts/ Science/ Commerce/ Others#Masters - Arts/ Science/ Commerce/ Others#Management - BBA/ MBA/ Others#Medicine - General/ Dental/ Surgeon/ Others#Legal - BL/ ML/ LLB/ LLM/ Others#Service - IAS/ IPS/ Others#PhD#Diploma#Higher Secondary/ Secondary#".split("#");
		}
		else if(var1=="Caste[]")
		{
			var origval="Any#Agarwal#Baniya#Brahmin#Brahmin-Bhatt#Brahmin-Bhumihar#Brahmin- Dhiman#Brahmin- Kanyakubj#Brahmin- Gaur#Brahmin- Maithil#Brahmin- Saryuparian#Brahmin- Garhwali#Brahmin-Goswami#Brahmin- Pandit#Brahmin- Sanadya#Brahmin-Sakaldwipi#Brahmin- Saraswat#Brahmin- Kumoani#Brahmin-Tyagi#Jatav#Chandravanshi Kahar#Chaudary#Chaurasia#Chhetri#Dhobi#Garhwali#Goan#Gupta#Intercaste#Jaiswal#Jat#Kadava Patel#Kalar#Kalwar#Kamboj#Kashyap#Kayastha#Khandelwal#Khatri#Kori#Kshatriya#Kumhar#Kurmi Kshatriya#Leva patel#Lingayath#Mahajan#Mahar#Maheshwari#Mali#Malla#Maratha#Meena#Mehra#Nai#Oswal#Pal#Pasi#Patel#Rajput#Rawat#Sahu#Saini#SC#Sonar#Teli#Thakur#ST#Vaishnav#Vaishya#Viswakarma#Yadav#Brahmin - Jangid#Dusadh(Paswan)#Gujjar#Gujar#Jangra - Brahmin#Jogi(Nath)#Katiya#Kharwar#Kushwaha(Koiri)#Lodhi Rajput#Mathur#Brahmin - Narmadiya#Varshney#Raigar#Guarv#Muslim-Ansari#Muslim-Arain#Muslim-Awan#Muslim-Bohra#Muslim-Dekkani#Muslim-Dudekula#Muslim-Hanafi#Muslim-Jat#Muslim-Jat#Muslim-Khoja#Muslim-Lebbai#Muslim-Malik#Muslim-Mapila#Muslim-Maraicar#Muslim-Memon#Muslim-Mughal#Muslim-Pathan#Muslim-Qureshi#Muslim-Rajpot#Muslim-Rowther#Muslim-Shafi#Muslim-Sheikh#Muslim-Siddiqui#Muslim-Syed#Muslim-UnSpecified#Muslim-Others#Christian-Born Again#Christian-Bretheren#Christian-Church of South India#Christian-Evangelist#Christian-Jacobite#Christian-Knanaya#Christian-Knanaya Catholic#Christian-Knanaya Jacobite#Christian-Latin Catholic#Christian-Malankara#Christian-Marthoma#Christian-Others#Christian-Pentacost#Christian-Roman Catholic#Christian-Syrian Catholic#Christian-Syrian Jacobite#Christian-Syrian Orthodox#Christian-Syro Malabar#Christian-Unspecified#Sikh-Ahluwalia#Sikh-Arora#Sikh-Bhatia#Sikh-Ghumar#Sikh-Intercaste#Sikh-Jat#Sikh-Kamboj#Sikh-Khatri#Sikh-Kshatriya#Sikh-Lubana#Sikh-Majabi#Sikh-No Bar#Sikh-Others#Sikh-Rajput#Sikh-Ramdasia#Sikh-Ramgharia#Sikh-Saini#Sikh-Ravidasia#Sikh-Bhatra#Sikh-Tonk Kshatriya#Sikh-Unspecified#Jain-Agarwal#Jain-Bania#Jain-Intercaste#Jain-Jaiswal#Jain-Khandewal#Jain-Kutchi#Jain-No Bar#Jain-Oswal#Jain-Others#Jain-Porwal#Jain-Unspecified#Jain-Vaishya#Irani#Parsi#Intercaste#".split("#");
	var origlab="Any#Agarwal#Baniya#Brahmin#Brahmin-Bhatt#Brahmin-Bhumihar#Brahmin- Dhiman#Brahmin- Kanyakubj#Brahmin- Gaur#Brahmin- Maithil#Brahmin- Saryuparian#Brahmin- Garhwali#Brahmin-Goswami#Brahmin- Pandit#Brahmin- Sanadya#Brahmin-Sakaldwipi#Brahmin- Saraswat#Brahmin- Kumoani#Brahmin-Tyagi#Jatav#Chandravanshi Kahar#Chaudary#Chaurasia#Chhetri#Dhobi#Garhwali#Goan#Gupta#Intercaste#Jaiswal#Jat#Kadava Patel#Kalar#Kalwar#Kamboj#Kashyap#Kayastha#Khandelwal#Khatri#Kori#Kshatriya#Kumhar#Kurmi Kshatriya#Leva patel#Lingayath#Mahajan#Mahar#Maheshwari#Mali#Malla#Maratha#Meena#Mehra#Nai#Oswal#Pal#Pasi#Patel#Rajput#Rawat#Sahu#Saini#SC#Sonar#Teli#Thakur#ST#Vaishnav#Vaishya#Viswakarma#Yadav#Brahmin - Jangid#Dusadh(Paswan)#Gujjar#Gujar#Jangra - Brahmin#Jogi(Nath)#Katiya#Kharwar#Kushwaha(Koiri)#Lodhi Rajput#Mathur#Brahmin - Narmadiya#Varshney#Raigar#Guarv#Muslim-Ansari#Muslim-Arain#Muslim-Awan#Muslim-Bohra#Muslim-Dekkani#Muslim-Dudekula#Muslim-Hanafi#Muslim-Jat#Muslim-Jat#Muslim-Khoja#Muslim-Lebbai#Muslim-Malik#Muslim-Mapila#Muslim-Maraicar#Muslim-Memon#Muslim-Mughal#Muslim-Pathan#Muslim-Qureshi#Muslim-Rajpot#Muslim-Rowther#Muslim-Shafi#Muslim-Sheikh#Muslim-Siddiqui#Muslim-Syed#Muslim-UnSpecified#Muslim-Others#Christian-Born Again#Christian-Bretheren#Christian-Church of South India#Christian-Evangelist#Christian-Jacobite#Christian-Knanaya#Christian-Knanaya Catholic#Christian-Knanaya Jacobite#Christian-Latin Catholic#Christian-Malankara#Christian-Marthoma#Christian-Others#Christian-Pentacost#Christian-Roman Catholic#Christian-Syrian Catholic#Christian-Syrian Jacobite#Christian-Syrian Orthodox#Christian-Syro Malabar#Christian-Unspecified#Sikh-Ahluwalia#Sikh-Arora#Sikh-Bhatia#Sikh-Ghumar#Sikh-Intercaste#Sikh-Jat#Sikh-Kamboj#Sikh-Khatri#Sikh-Kshatriya#Sikh-Lubana#Sikh-Majabi#Sikh-No Bar#Sikh-Others#Sikh-Rajput#Sikh-Ramdasia#Sikh-Ramgharia#Sikh-Saini#Sikh-Ravidasia#Sikh-Bhatra#Sikh-Tonk Kshatriya#Sikh-Unspecified#Jain-Agarwal#Jain-Bania#Jain-Intercaste#Jain-Jaiswal#Jain-Khandewal#Jain-Kutchi#Jain-No Bar#Jain-Oswal#Jain-Others#Jain-Porwal#Jain-Unspecified#Jain-Vaishya#Irani#Parsi#Intercaste#".split("#");
		}
		else if(var1=="Income[]")
		{
			var origval="All#1#2#3#4#5#6#16#17#18#8#9#10#11#12#13#14#15#".split("#");
			var origlab="All#Under Rs.50,000#Rs.50,001 - 1,00,000#Rs.1,00,001 - 2,00,000#Rs.2,00,001 - 3,00,000#Rs.3,00,001 - 4,00,000#Rs.4,00,001 - 5,00,000#Rs.5,00,001 - 7,50,000#Rs.7,50,001 - 10,00,000#Rs.10,00,001 and above#Under $25,000#$25,001 - 50,000#$50,001 - 75,000#$75,001 - 100,000#$100,001 - 150,000#$150,001 - 200,000#$200,001 and above#No Income#".split("#");
		}
		var addflag=1;
		for(a=0;a<origval.length;a++)
		{
			addflag=1;
			for(var b=0;b<obj2.options.length;b++)
			{
					if(origlab[a]==obj2.options[b].text)
					{
						addflag=0;
						break;
					}
				}
			if(addflag==1)
			{
				var optn = document.createElement("OPTION");
				optn.value=origval[a];
				optn.text=origlab[a];
				obj1.options.add(optn);
			}
		}

		}
		else if(var1=="Country_Residence[]")
		{
			var origval="Any#India#United States of America#United Arab Emirates#Malaysia#United Kingdom#Australia#Saudi Arabia#Canada#Singapore#Kuwait#Afghanistan#Albania#Algeria#American Samoa#Andorra#Angola#Anguilla#Antarctica#Antigua and Barbuda#Argentina#Armenia#Aruba#Australia#Austria#Azerbaijan#Bahamas#Bahrain#Bangladesh#Barbados#Belarus#Belgium#Belize#Benin#Bermuda#Bhutan#Bolivia#Bosnia and Herzegovina#Botswana#Bouvet Island#Brazil#British Indian Ocean Territory#British Virgin Islands#Brunei#Bulgaria#Burkina Faso#Burundi#Cambodia#Cameroon#Canada#Cape Verde#Cayman Islands#Central African Republic#Chad#Chile#China#Christmas Island#Cocos Islands#Colombia#Comoros#Congo#Cook Islands#Costa Rica#Croatia#Cuba#Cyprus#Czech Republic#Denmark#Djibouti#Dominica#Dominican Republic#East Timor#Ecuador#Egypt#El Salvador#Equatorial Guinea#Eritrea#Estonia#Ethiopia#Falkland Islands#Faroe Islands#Fiji#Finland#France#French Guiana#French Polynesia#French Southern Territories#Gabon#Gambia#Georgia#Germany#Ghana#Gibraltar#Greece#Greenland#Grenada#Guadeloupe#Guam#Guatemala#Guinea#Guinea-Bissau#Guyana#Haiti#Heard and McDonald Islands#Honduras#Hong Kong#Hungary#Iceland#India#Indonesia#Iran#Iraq#Ireland#Israel#Italy#Ivory Coast#Jamaica#Japan#Jordan#Kazakhstan#Kenya#Kiribati#Korea, North#Korea, South#Kuwait#Kyrgyzstan#Laos#Latvia#Lebanon#Lesotho#Liberia#Libya#Liechtenstein#Lithuania#Luxembourg#Macau#Macedonia, Former Yugoslav Rep#Madagascar#Malawi#Malaysia#Maldives#Mali#Malta#Marshall Islands#Martinique#Mauritania#Mauritius#Mayotte#Mexico#Micronesia, Federated States o#Moldova# 	Monaco#Mongolia#Montserrat#Morocco#Mozambique#Myanmar#Namibia#Nauru#Nepal#Netherlands#Netherlands Antilles#New Caledonia#New Zealand#Nicaragua#Niger#Nigeria#Niue#Norfolk Island#Northern Mariana Islands#Norway#Oman#Pakistan#Palau#Panama#Papua New Guinea#Paraguay#Peru#Philippines#Pitcairn Island#Poland#Portugal#Puerto Rico#Qatar#Reunion#Romania#Russia#Rwanda#S. Georgia and S. Sandwich Isl#Saint Kitts & Nevis#Saint Lucia#Saint Vincent and The Grenadin#Samoa#San Marino#Sao Tome and Principe#Saudi Arabia#Senegal#Seychelles#Sierra Leone#Singapore#Slovakia#Slovenia#Somalia#South Africa#Spain#Sri Lanka#St. Helena#St. Pierre and Miquelon#Sudan#Suriname#Svalbard and Jan Mayen Islands#Swaziland#Sweden#Switzerland#Syria#Taiwan#Tajikistan#Tanzania#Thailand#Togo#Tokelau#Tonga#Trinidad and Tobago#Tunisia#Turkey#Turkmenistan#Turks and Caicos Islands#Tuvalu#Uganda#Ukraine#United Arab Emirates# 	United Kingdom#United States of America#Uruguay#Uzbekistan#Vanuatu#Vatican City#Venezuela#Vietnam#Virgin Islands#Wallis and Futuna Islands#Western Sahara#Yemen#Yugoslavia (Former)#Zaire#Zambia#Zimbabwe#".split("#");
		var origlab="Any#India#United States of America#United Arab Emirates#Malaysia#United Kingdom#Australia#Saudi Arabia#Canada#Singapore#Kuwait#Afghanistan#Albania#Algeria#American Samoa#Andorra#Angola#Anguilla#Antarctica#Antigua and Barbuda#Argentina#Armenia#Aruba#Australia#Austria#Azerbaijan#Bahamas#Bahrain#Bangladesh#Barbados#Belarus#Belgium#Belize#Benin#Bermuda#Bhutan#Bolivia#Bosnia and Herzegovina#Botswana#Bouvet Island#Brazil#British Indian Ocean Territory#British Virgin Islands#Brunei#Bulgaria#Burkina Faso#Burundi#Cambodia#Cameroon#Canada#Cape Verde#Cayman Islands#Central African Republic#Chad#Chile#China#Christmas Island#Cocos Islands#Colombia#Comoros#Congo#Cook Islands#Costa Rica#Croatia#Cuba#Cyprus#Czech Republic#Denmark#Djibouti#Dominica#Dominican Republic#East Timor#Ecuador#Egypt#El Salvador#Equatorial Guinea#Eritrea#Estonia#Ethiopia#Falkland Islands#Faroe Islands#Fiji#Finland#France#French Guiana#French Polynesia#French Southern Territories#Gabon#Gambia#Georgia#Germany#Ghana#Gibraltar#Greece#Greenland#Grenada#Guadeloupe#Guam#Guatemala#Guinea#Guinea-Bissau#Guyana#Haiti#Heard and McDonald Islands#Honduras#Hong Kong#Hungary#Iceland#India#Indonesia#Iran#Iraq#Ireland#Israel#Italy#Ivory Coast#Jamaica#Japan#Jordan#Kazakhstan#Kenya#Kiribati#Korea, North#Korea, South#Kuwait#Kyrgyzstan#Laos#Latvia#Lebanon#Lesotho#Liberia#Libya#Liechtenstein#Lithuania#Luxembourg#Macau#Macedonia, Former Yugoslav Rep#Madagascar#Malawi#Malaysia#Maldives#Mali#Malta#Marshall Islands#Martinique#Mauritania#Mauritius#Mayotte#Mexico#Micronesia, Federated States o#Moldova# 	Monaco#Mongolia#Montserrat#Morocco#Mozambique#Myanmar#Namibia#Nauru#Nepal#Netherlands#Netherlands Antilles#New Caledonia#New Zealand#Nicaragua#Niger#Nigeria#Niue#Norfolk Island#Northern Mariana Islands#Norway#Oman#Pakistan#Palau#Panama#Papua New Guinea#Paraguay#Peru#Philippines#Pitcairn Island#Poland#Portugal#Puerto Rico#Qatar#Reunion#Romania#Russia#Rwanda#S. Georgia and S. Sandwich Isl#Saint Kitts & Nevis#Saint Lucia#Saint Vincent and The Grenadin#Samoa#San Marino#Sao Tome and Principe#Saudi Arabia#Senegal#Seychelles#Sierra Leone#Singapore#Slovakia#Slovenia#Somalia#South Africa#Spain#Sri Lanka#St. Helena#St. Pierre and Miquelon#Sudan#Suriname#Svalbard and Jan Mayen Islands#Swaziland#Sweden#Switzerland#Syria#Taiwan#Tajikistan#Tanzania#Thailand#Togo#Tokelau#Tonga#Trinidad and Tobago#Tunisia#Turkey#Turkmenistan#Turks and Caicos Islands#Tuvalu#Uganda#Ukraine#United Arab Emirates# 	United Kingdom#United States of America#Uruguay#Uzbekistan#Vanuatu#Vatican City#Venezuela#Vietnam#Virgin Islands#Wallis and Futuna Islands#Western Sahara#Yemen#Yugoslavia (Former)#Zaire#Zambia#Zimbabwe#".split("#");
		var addflag=1;
		var a=0;
		for(a=0;a<15;a++)
		{
			addflag=1;
			for(var b=0;b<obj2.options.length;b++)
			{
				if(origlab[a]==obj2.options[b].text)
				{
					addflag=0;
					break;
				}

			}
			if(addflag==1)
			{
				var optn=document.createElement("OPTION");
				optn.value=origval[a];
				optn.text=origlab[a];
				obj1.options.add(optn);
			}
		}
		var optgrp=document.createElement("OPTGROUP");
		optgrp.innerHTML="&nbsp;";
		obj1.appendChild(optgrp);
		for(a=15;a<origval.length;a++)
		{
			addflag=1;
			for(var b=0;b<obj2.options.length;b++)
			{
				if(origlab[a]==obj2.options[b].text)
			{
			addflag=0;
			break;
		}

		}
		if(addflag==1)
		{
			var optn=document.createElement("OPTION");
			optn.value=origval[a];
			optn.text=origlab[a];
			obj1.options.add(optn);
		}
		}
	}
	else if(var1=="City_India[]")
	{
		var origvallist="All#UP01#TR01#GU01#UP31#MI01#RA01#MH01#UP02#UP03#RA02#HA01#UP04#PU01#GU02#GU03#KA01#TN01#WB01#MH02#UP05#KA02#WB02#UP06#GU04#PU02#KA03#RA03#MP01#RA04#MP02#OR01#KA04#RA05#MP03#BI01#KE01#PH00#TN02#MP04#TN03#TN04#TN05#AP01#OR02#HP01#UP07#DE00#MP05#BI02#KA05#AS01#NA01#AS02#MP06#WB03#KE02#TN06#UP08#UP09#HA02#PU03#UP10#PU04#UP11#GU05#RA06#SI01#BI03#UP12#GO00#UP13#KA06#JK01#AP02#PU05#HA03#AS03#MP07#UP14#UP15#PU06#KA07#AP03#MA01#MP08#AR01#MP09#RA07#RA11#PU10#JK04#BI04#UP16#RA08#AS04#GU06#AP04#GU07#UP17#TN07#UP18#HP02#MP10#WB04#KE03#TN08#NA02#MH03#WB05#RA09#KE04#KE05#KE06#AP05#JK02#UP19#PU07#AP06#TN09#KA08#UP20#UP21#UP22#MH04#UP23#UP24#BI05#KA09#MH05#MH06#MH07#TN10#AP07#UP25#KE07#AP08#GU08#KE09#HA06#OR03#PU08#PU09#BI06#TN11#PO00#MH08#UP26#MP12#TN12#GU09#TN13#BI07#UP27#HA04#UP28#OR04#UP29#TN14#MH09#ME01#HP03#MH10#AS05#HA05#MH11#JK03#GU10#MH12#TN15#KE08#TN16#TN17#TN16#TN20#TN18#GU12#RA10#MP11#MH13#GU11#UP30#TN19#AP10#AP11#%AP#AP09#AR#AS#BI#CH#DN#DD#GU#HA#HP#JK#JH#KA#KE#LA#MP#MH#MA#ME#MI#NA#OR#PU#RA#SI#TN#TR#UP#UT#WB#%1#2#50#3#4#5#6#7#8#49#9#10#11#51#12#13#14#15#16#17#18#19#20#21#22#23#24#25#52#53#54#26#27#28#29#30#31#32#55#33#34#35#36#56#37#38#39#40#41#57#42#43#44#45#46#47#48#".split("%");
		var origlablist="ALL#Agra#Agartala#Ahmedabad#Ahmednagar#Aizwal#Ajmer#Akola#Aligarh#Allahabad#Alwar#Ambala#Amethi#Amritsar#Anand#Ankleshwar#Ankola#Arcot#Asansol#Aurangabad#Ayodhya#Bangalore#Barddhaman#Bareilly#Baroda#Bathinda#Belgaum#Bharatpur#Bhilai#Bhilwara#Bhopal#Bhubaneshwar#Bidar#Bikaner#Bilaspur#Bokaro#Calicut#Chandigarh#Chennai#Chhindwara#Chidambaram#Coimbatore#Cuddalore#Cuddapah#Cuttack#Dalhousie#DehraDun#Delhi#Deora#Dhanbad#Dharwad#Dibrugarh#Dimapur#Dispur#Durg#Durgapur#Ernakulam#Erode#Etawah#Faizabad#Faridabad#Faridkot#Fatehpur#Ferozpur#Firozabad#Gandhinagar#Ganganagar#Gangtok#Gaya#Ghaziabad#Goa#Gorakhpur#Gulbarga#Gulmarg#Guntur#Gurdaspur#Gurgaon#Guwahati#Gwalior#Hapur#Haridwar#Hoshiarpur#Hubli#Hyderabad#Imphal#Indore#Itanagar#Jabalpur#Jaipur#Jaisalmer#Jalandhar#Jammu#Jamshedpur#Jhansi#Jodhpur#Jorhat#Junagadh#Kakinada#Kandla#Kannauj#Kanniyakumari#Kanpur#Kasauli#Khajuraho#Kharagpur#Kochi#Kodaikanal#Kohima#Kolhapur#Kolkata#Kota#Kottayam#Kovalam#Kozhikode#Kurnool#Leh#Lucknow#Ludhiana#Machilipatnam#Madurai#Mangalore#Mathura#Meerut#Moradabad#Mumbai#Mussoorie#Muzaffarnagar#Muzaffarpur#Mysore#Nagpur#Nanded#Nashik#Nilgiri#Nellore#Noida#Palakkad#Palampet#Palanpur#Pandalam#Panipat#Paradeep#Pathankot#Patiala#Patna#Periyar#Pondicherry#Pune#Rae Bareli#Raipur#Rajahmundry#Rajkot#Rameswaram#Ranchi#Rishikesh#Rohtak#Roorkee#Rourkela#Saharanpur#Salem#Sangli#Shillong#Shimla#Shirdi#Silchar#Sirsa#Solapur#Srinagar#Surat#Thane#Thanjavur#Thiruvananthapuram#Tiruchirapalli#Tirunelvelli#Trichi#Trivandrum#Tuticorin#Vapi#Udaipur#Ujjain#Ulhasnagar#Vadodara#Varanasi#Vellore#Vijaywada#Vishakhapatnam#%Andhra Pradesh#Warangal#Arunachal Pradesh#Assam#Bihar#Chhattisgarh#Dadra & Nagar Haveli#Daman & Diu#Gujarat#Haryana#Himachal Pradesh#Jammu & Kashmir#Jharkhand#Karnataka#Kerala#Lakshadweep#Madhya Pradesh#Maharashtra#Manipur#Meghalaya#Mizoram#Nagaland#Orissa#Punjab#Rajasthan#Sikkim#Tamil Nadu#Tripura#Uttar Pradesh#Uttaranchal#West Bengal#%USA - Alabama#USA - Alaska#USA - American Samoa#USA - Arizona#USA - Arkansas#USA - California#USA - Colorado#USA - Connecticut#USA - Delaware#USA - Detroit#USA - District of Columbia#USA - Florida#USA - Georgia#USA - Guam#USA - Hawaii#USA - Idaho#USA - Illinois#USA - Indiana#USA - Iowa#USA - Kansas#USA - Kentucky#USA - Louisiana#USA - Maine#USA - Maryland#USA - Massachusetts#USA - Michigan#USA - Minnesota#USA - Mississippi#USA - Missouri#USA - Montana#USA - Nebraska#USA - Nevada#USA - New Hampshire#USA - New Jersey#USA - New Mexico#USA - New York#USA - North Carolina#USA - North Dakota#USA - Northern Mariana Islands#USA - Ohio#USA - Oklahoma#USA - Oregon#USA - Pennsylvania#USA - Puerto Rico#USA - Rhode Island#USA - South Carolina#USA - South Dakota#USA - Tennessee#USA - Texas#USA - United States Virgin Islands#USA - Utah#USA - Vermont#USA - Virginia#USA - Washington#USA - West Virginia#USA - Wisconsin#USA - Wyoming#".split("%");
		var origval1=origvallist[0].split("#");
		var origlab1=origlablist[0].split("#");
		var origval2=origvallist[1].split("#");
		var origlab2=origlablist[1].split("#");
		var origval3=origvallist[2].split("#");
		var origlab3=origlablist[2].split("#");
		var a=0;
		var addflag=1;
		len=origval1.length-1;
		for(a=0;a<len;a++)
		{
			addflag=1;
			for(var b=0;b<obj2.options.length;b++)
			{
			if(origlab1[a]==obj2.options[b].text)
			{
				addflag=0;
				break;
			}
		
		}
		if(addflag==1)
		{
			var optn=document.createElement("OPTION");
			optn.value=origval1[a];
			optn.text=origlab1[a];
			obj1.options.add(optn);
		}
	}
	var optgrp=document.createElement("OPTGROUP");
	optgrp.innerHTML="&nbsp;";
	obj1.appendChild(optgrp);
	len=origval2.length-1;
		for(a=0;a<len;a++)
		{
			addflag=1;
			for(var b=0;b<obj2.options.length;b++)
			{
				if(origlab2[a]==obj2.options[b].text)
				{
					addflag=0;
					break;
				}

			}
			if(addflag==1)
			{
				var optn=document.createElement("OPTION");
				optn.value=origval2[a];
				optn.text=origlab2[a];
				obj1.options.add(optn);
			}
		}
	var optgrp=document.createElement("OPTGROUP");
	optgrp.innerHTML="&nbsp;";
	obj1.appendChild(optgrp);
	for(a=0;a<origval3.length;a++)
	{
		addflag=1;
		for(var b=0;b<obj2.options.length;b++)
		{
			if(origlab3[a]==obj2.options[b].text)
			{
				addflag=0;
				break;
			}

		}
		if(addflag==1)
		{
			var optn=document.createElement("OPTION");
			optn.value=origval3[a];
			optn.text=origlab3[a];
			obj1.options.add(optn);
		}
	}

}
else if(var1=="Mtongue[]")
{
	var origvallist="All#Hindi#Punjabi#".split("%");
	var origlablist="All#Hindi#Punjabi#".split("%");;
	for(var b=0;b<origvallist.length;b++)
	{
		var origval=origvallist[b].split("#");
		var origlab=origlablist[b].split("#");
		len=origval.length-1;
		var a=0;
		var addflag=1;
		if(b==1)
		{
			var optn=document.createElement("OPTION");
			optn.text="All Hindi";
			optn.value="10,19,33,7,28,13";
			obj1.options.add(optn);
			var optgrp=document.createElement("OPTGROUP");
			optgrp.innerHTML="&nbsp;";
			obj1.appendChild(optgrp);
			var optgrp=document.createElement("OPTGROUP");
			optgrp.label="Communities in North India";
			optgrp.style.color="#5494C6";
			obj1.appendChild(optgrp);
		}
else if(b==2)
{
	var optgrp=document.createElement("OPTGROUP");
	optgrp.label="Communities in West India";
	optgrp.style.color="#5494C6";
	obj1.appendChild(optgrp);
}
else if(b==3)
{
	var optgrp=document.createElement("OPTGROUP");
	optgrp.label="Communities in South India";
	optgrp.style.color="#5494C6";
	obj1.appendChild(optgrp);
}
else if(b==4)
{
	var optgrp=document.createElement("OPTGROUP");
	optgrp.label="Communites in East India";
	optgrp.style.color="#5494C6";
	obj1.appendChild(optgrp);
}
else if(b==5)
{
	var optgrp=document.createElement("OPTGROUP");
	optgrp.label="-----------------";
	obj1.appendChild(optgrp);
}
	for(a=0;a<len;a++)
	{
		addflag=1;
		for(var c=0;c<obj2.options.length;c++)
		{
			if(origlab[a]==obj2.options[c].text)
			{
				addflag=0;
				break;
			}
		}
		if(addflag==1)
		{
			var optn=document.createElement("OPTION");
			optn.value=origval[a];
			optn.text=origlab[a];
			obj1.options.add(optn);
		}
	}
	var optgrp=document.createElement("OPTGROUP");
	optgrp.innerHTML="&nbsp;";
	obj1.appendChild(optgrp);
	}
	}

	}

	var k=0,str1,str2;

	while(k<obj2.options.length)
	{
		str2=obj2.options[k].value;
		str1=str1+","+str2;
		k++;
	}
	hidden_name.value=str1;
}

function addAdvanceSearch(var1,var2,hiddenvar)
{
	var hiddenvalue;
	var str=document.form1;
	var flag=0;
	while(flag<str.elements.length)
	{
		if(str.elements[flag].name==var1)
		{
			obj1=str.elements[flag];
			break;
		}
	flag++;
	}

	var flag=0;
	
	while(flag<str.elements.length)
	{
		if(str.elements[flag].name==var2)
		{
			obj2=str.elements[flag];
			break;
		}
		flag++;
	
	}

	var flag=0;
	
	while(flag<str.elements.length)
	{
		if(str.elements[flag].name==hiddenvar)
		{
			hidden_name=str.elements[flag];
			break;
		}
		flag++;
	}
	if(obj2.options.length>0 && obj2.options[0].value=="All")
	{
		var l = obj1.options.selectedIndex;
		if(l==-1)
		;
		else
		{
			obj2.options[0]=null;
			var len=obj1.options.length-1;
			for(a=len;a>=0;a--)
			{
				if(obj1.options[a].selected)
				{
					var optn=document.createElement("OPTION");
					optn.innerHTML=obj1.options[a].text;
					optn.value=obj1.options[a].value;
					obj2.options.add(optn);
				}
			}
	
			removeAdvanceSearch(var1,var2,hiddenvar);
		}
		
	}	
	else
	{
		if(obj1.options.length == 0)
		;
		else
		{
		var k=obj1.options.length-1;
		var len_obj2 = obj2.length;
		while(k>=0)
	{
	if(obj1.options[k].selected)
	{
	var arr = new Option();
	arr.value=obj1.options[k].value;
	arr.text=obj1.options[k].text;
	obj1.remove(k);
	
	for(i=0;i<obj2.options.length;i++)
	if(obj2[i].value == arr.value)
	{
	var repeat_name=true;
	break;
	}

	if(repeat_name == true)
	{
	repeat_name=false;
	}
	else
	{
	if (arr.value=="All" || arr.value=="0")
	obj2.options.length=0;
	else
	{
	for(var l=0;l<obj2.options.length;l++)
	if(obj2.options[l].value=="All" || obj2.options[l].value=="0")
	obj2.options[l]=null;
	}
	obj2.options[obj2.options.length]=arr;
	
	if (arr.value=="All" || arr.value=="0")
	removeAdvanceSearch(var1,var2,hiddenvar);
	}
	}
	k--;
	}
	}
	}
	var k=0,str1,str2;
	while(k<obj2.options.length)
	{
	str2=obj2.options[k].value;
	str1=str1+","+str2;
	k++;
	}
	
	hidden_name.value=str1;
}

function removeAdvanceSearch(var1,var2,hiddenvar)
{
var str=document.form1;
var flag=0;

while(flag<str.elements.length)
{
if(str.elements[flag].name==var1)
{
obj1=str.elements[flag];
break;
}
flag++;
}

var flag=0;

while(flag<str.elements.length)
{
if(str.elements[flag].name==var2)
{
obj2=str.elements[flag];
break;
}
flag++;
}

var flag=0;

while(flag<str.elements.length)
{
if(str.elements[flag].name==hiddenvar)
{
hidden_name=str.elements[flag];
break;
}
flag++;
}
if(obj2.options.length == 0)
;
else
{
var len=obj2.options.length;
for(a=len-1;a>=0;a--)
{
if(obj2.options[a].selected == true)
obj2.remove(a);
}
obj1.innerHTML="";
if((var1=="Occupation[]")||(var1=="Education_Level_New[]") ||(var1=="Education_Level") ||(var1=="Education_Level[]")||(var1=="Caste[]")||(var1=="Income[]") ||(var1=="MOTHERTONGUE[]") || (var1=="STAR[]"))
{
if(var1=="Occupation[]")
{
var origval="All#1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#27#28#29#30#31#32#33#34#35#36#37#38#39#40#41#42#".split("#");
var origlab="ALL#Accounts/ Tax/ CS/ Audit#Advtg/ Media/ Mktg/ MR#Agent#Airlines/ Reservations/ Travel#Anchoring/ TV/ Films#Architecture/ Interior Design#Banking/ Insurance#Call Centre/ ITES/ Telecalling#Content/ Editing/ Journalism#Corporate Commn./ PR#Corporate Planning/ Consulting#Cust. Service/ Operations#Entrepreneur/ Businessmen#Export/ Import#Fashion#Front Office/ Secretarial Staff#Graphic/ Web Design#Hotels/ Restaurants#HR/ Admin/ PM/ IR/ Training#IT Software#IT Hardware/ Telecom#Legal/ Law#Logistics/ Purchase/ SCM#Medical/ Healthcare#Packaging Development#Prod./ Maintenance/ Service Engg#R&D/ Engineering Design#Sales#Security#Site Engnr/ Project Mgmt#Teaching/ Education/ Languages#Agriculture/ Farming#Civil Services(IAS/ IFS/ IPS/ IRS/ etc.)#Defence Services#Govt. Services#Home Maker#Retired#Social Services#Sportsman#Beauty, Health & Fitness Professional#Student#Others#".split("#");
}
else if(var1=="Education_Level_New[]")
{
var origval="Any#Bachelors - Engineering/ Computers#Masters - Engineering/ Computers#Bachelors - Arts/ Science/ Commerce/ Others#Masters - Arts/ Science/ Commerce/ Others#Management - BBA/ MBA/ Others#Medicine - General/ Dental/ Surgeon/ Others#Legal - BL/ ML/ LLB/ LLM/ Others#Service - IAS/ IPS/ Others#PhD#Diploma#Higher Secondary/ Secondary#".split("#");
var origlab="Any#Bachelors - Engineering/ Computers#Masters - Engineering/ Computers#Bachelors - Arts/ Science/ Commerce/ Others#Masters - Arts/ Science/ Commerce/ Others#Management - BBA/ MBA/ Others#Medicine - General/ Dental/ Surgeon/ Others#Legal - BL/ ML/ LLB/ LLM/ Others#Service - IAS/ IPS/ Others#PhD#Diploma#Higher Secondary/ Secondary#".split("#");
}
else if(var1=="Education_Level[]")
{
var origval="Any#Bachelors - Engineering/ Computers#Masters - Engineering/ Computers#Bachelors - Arts/ Science/ Commerce/ Others#Masters - Arts/ Science/ Commerce/ Others#Management - BBA/ MBA/ Others#Medicine - General/ Dental/ Surgeon/ Others#Legal - BL/ ML/ LLB/ LLM/ Others#Service - IAS/ IPS/ Others#PhD#Diploma#Higher Secondary/ Secondary#".split("#");
var origlab="Any#Bachelors - Engineering/ Computers#Masters - Engineering/ Computers#Bachelors - Arts/ Science/ Commerce/ Others#Masters - Arts/ Science/ Commerce/ Others#Management - BBA/ MBA/ Others#Medicine - General/ Dental/ Surgeon/ Others#Legal - BL/ ML/ LLB/ LLM/ Others#Service - IAS/ IPS/ Others#PhD#Diploma#Higher Secondary/ Secondary#".split("#");
}
else if(var1=="Caste[]")
{
var origval="Any#Agarwal#Baniya#Brahmin#Brahmin-Bhatt#Brahmin-Bhumihar#Brahmin- Dhiman#Brahmin- Kanyakubj#Brahmin- Gaur#Brahmin- Maithil#Brahmin- Saryuparian#Brahmin- Garhwali#Brahmin-Goswami#Brahmin- Pandit#Brahmin- Sanadya#Brahmin-Sakaldwipi#Brahmin- Saraswat#Brahmin- Kumoani#Brahmin-Tyagi#Jatav#Chandravanshi Kahar#Chaudary#Chaurasia#Chhetri#Dhobi#Garhwali#Goan#Gupta#Intercaste#Jaiswal#Jat#Kadava Patel#Kalar#Kalwar#Kamboj#Kashyap#Kayastha#Khandelwal#Khatri#Kori#Kshatriya#Kumhar#Kurmi Kshatriya#Leva patel#Lingayath#Mahajan#Mahar#Maheshwari#Mali#Malla#Maratha#Meena#Mehra#Nai#Oswal#Pal#Pasi#Patel#Rajput#Rawat#Sahu#Saini#SC#Sonar#Teli#Thakur#ST#Vaishnav#Vaishya#Viswakarma#Yadav#Brahmin - Jangid#Dusadh(Paswan)#Gujjar#Gujar#Jangra - Brahmin#Jogi(Nath)#Katiya#Kharwar#Kushwaha(Koiri)#Lodhi Rajput#Mathur#Brahmin - Narmadiya#Varshney#Raigar#Guarv#Muslim-Ansari#Muslim-Arain#Muslim-Awan#Muslim-Bohra#Muslim-Dekkani#Muslim-Dudekula#Muslim-Hanafi#Muslim-Jat#Muslim-Jat#Muslim-Khoja#Muslim-Lebbai#Muslim-Malik#Muslim-Mapila#Muslim-Maraicar#Muslim-Memon#Muslim-Mughal#Muslim-Pathan#Muslim-Qureshi#Muslim-Rajpot#Muslim-Rowther#Muslim-Shafi#Muslim-Sheikh#Muslim-Siddiqui#Muslim-Syed#Muslim-UnSpecified#Muslim-Others#Christian-Born Again#Christian-Bretheren#Christian-Church of South India#Christian-Evangelist#Christian-Jacobite#Christian-Knanaya#Christian-Knanaya Catholic#Christian-Knanaya Jacobite#Christian-Latin Catholic#Christian-Malankara#Christian-Marthoma#Christian-Others#Christian-Pentacost#Christian-Roman Catholic#Christian-Syrian Catholic#Christian-Syrian Jacobite#Christian-Syrian Orthodox#Christian-Syro Malabar#Christian-Unspecified#Sikh-Ahluwalia#Sikh-Arora#Sikh-Bhatia#Sikh-Ghumar#Sikh-Intercaste#Sikh-Jat#Sikh-Kamboj#Sikh-Khatri#Sikh-Kshatriya#Sikh-Lubana#Sikh-Majabi#Sikh-No Bar#Sikh-Others#Sikh-Rajput#Sikh-Ramdasia#Sikh-Ramgharia#Sikh-Saini#Sikh-Ravidasia#Sikh-Bhatra#Sikh-Tonk Kshatriya#Sikh-Unspecified#Jain-Agarwal#Jain-Bania#Jain-Intercaste#Jain-Jaiswal#Jain-Khandewal#Jain-Kutchi#Jain-No Bar#Jain-Oswal#Jain-Others#Jain-Porwal#Jain-Unspecified#Jain-Vaishya#Irani#Parsi#Intercaste#".split("#");
var origlab="Any#Agarwal#Baniya#Brahmin#Brahmin-Bhatt#Brahmin-Bhumihar#Brahmin- Dhiman#Brahmin- Kanyakubj#Brahmin- Gaur#Brahmin- Maithil#Brahmin- Saryuparian#Brahmin- Garhwali#Brahmin-Goswami#Brahmin- Pandit#Brahmin- Sanadya#Brahmin-Sakaldwipi#Brahmin- Saraswat#Brahmin- Kumoani#Brahmin-Tyagi#Jatav#Chandravanshi Kahar#Chaudary#Chaurasia#Chhetri#Dhobi#Garhwali#Goan#Gupta#Intercaste#Jaiswal#Jat#Kadava Patel#Kalar#Kalwar#Kamboj#Kashyap#Kayastha#Khandelwal#Khatri#Kori#Kshatriya#Kumhar#Kurmi Kshatriya#Leva patel#Lingayath#Mahajan#Mahar#Maheshwari#Mali#Malla#Maratha#Meena#Mehra#Nai#Oswal#Pal#Pasi#Patel#Rajput#Rawat#Sahu#Saini#SC#Sonar#Teli#Thakur#ST#Vaishnav#Vaishya#Viswakarma#Yadav#Brahmin - Jangid#Dusadh(Paswan)#Gujjar#Gujar#Jangra - Brahmin#Jogi(Nath)#Katiya#Kharwar#Kushwaha(Koiri)#Lodhi Rajput#Mathur#Brahmin - Narmadiya#Varshney#Raigar#Guarv#Muslim-Ansari#Muslim-Arain#Muslim-Awan#Muslim-Bohra#Muslim-Dekkani#Muslim-Dudekula#Muslim-Hanafi#Muslim-Jat#Muslim-Jat#Muslim-Khoja#Muslim-Lebbai#Muslim-Malik#Muslim-Mapila#Muslim-Maraicar#Muslim-Memon#Muslim-Mughal#Muslim-Pathan#Muslim-Qureshi#Muslim-Rajpot#Muslim-Rowther#Muslim-Shafi#Muslim-Sheikh#Muslim-Siddiqui#Muslim-Syed#Muslim-UnSpecified#Muslim-Others#Christian-Born Again#Christian-Bretheren#Christian-Church of South India#Christian-Evangelist#Christian-Jacobite#Christian-Knanaya#Christian-Knanaya Catholic#Christian-Knanaya Jacobite#Christian-Latin Catholic#Christian-Malankara#Christian-Marthoma#Christian-Others#Christian-Pentacost#Christian-Roman Catholic#Christian-Syrian Catholic#Christian-Syrian Jacobite#Christian-Syrian Orthodox#Christian-Syro Malabar#Christian-Unspecified#Sikh-Ahluwalia#Sikh-Arora#Sikh-Bhatia#Sikh-Ghumar#Sikh-Intercaste#Sikh-Jat#Sikh-Kamboj#Sikh-Khatri#Sikh-Kshatriya#Sikh-Lubana#Sikh-Majabi#Sikh-No Bar#Sikh-Others#Sikh-Rajput#Sikh-Ramdasia#Sikh-Ramgharia#Sikh-Saini#Sikh-Ravidasia#Sikh-Bhatra#Sikh-Tonk Kshatriya#Sikh-Unspecified#Jain-Agarwal#Jain-Bania#Jain-Intercaste#Jain-Jaiswal#Jain-Khandewal#Jain-Kutchi#Jain-No Bar#Jain-Oswal#Jain-Others#Jain-Porwal#Jain-Unspecified#Jain-Vaishya#Irani#Parsi#Intercaste#".split("#");
}
else if(var1=="MOTHERTONGUE[]")
{
var origval="0#1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#27#28#29#30#31#32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47#48#49#50#51#99#".split("#");
var origlab="Any#Arunachali#Assamese#Awadhi#Bengali#Bhojpuri#Brij#Bihari#Chatisgarhi#Dogri#English#French#Garhwali#Garo#Gujarati#Haryanvi#Himachali/Pahari#Hindi#Kanauji#Kannada#Kashmiri#Khandesi#Khasi#Konkani#Koshali#Kumoani#Kutchi#Lepcha#Ladacki#Magahi#Maithili#Malayalam#Manipuri#Marathi#Marwari#Miji#Mizo#Monpa#Nicobarese#Nepali#Oriya#Punjabi#Rajasthani#Sanskrit#Santhali#Sindhi#Sourashtra#Tamil#Telugu#Tripuri#Tulu#Urdu#Others#".split("#");

}
else if(var1=="STAR[]")
{
var origval="0#1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#".split("#");
var origlab="Any#Ardra / Thiruvathira#Ashlesha / Ayilyam#Ashwini / Ashwathi#Bharani#Chitra / Chitha#Dhanista / Avittam#Hastha / Atham#Jyesta / Kettai#Krithika / Karthika#Makha / Magam#Moolam / Moola#Mrigasira / Makayiram#Poorvabadrapada / Puratathi#Poorvapalguni / Puram / Pubbhe#Poorvashada / Pooradam#Punarvasu / Punarpusam#Pushya / Poosam / Pooyam#Revathi#Rohini#Shatataraka / Sadayam / Satabishek#Shravan / Thiruvonam#Swati / Chothi#Uttarabadrapada / Uthratadhi#Uttarapalguni / Uthram#Uttarashada / Uthradam#Vishaka / Vishakam#".split("#");
}




else if(var1=="Income[]")
{
var origval="All#1#2#3#4#5#6#16#17#18#8#9#10#11#12#13#14#15#".split("#");
var origlab="All#Under Rs.50,000#Rs.50,001 - 1,00,000#Rs.1,00,001 - 2,00,000#Rs.2,00,001 - 3,00,000#Rs.3,00,001 - 4,00,000#Rs.4,00,001 - 5,00,000#Rs.5,00,001 - 7,50,000#Rs.7,50,001 - 10,00,000#Rs.10,00,001 and above#Under $25,000#$25,001 - 50,000#$50,001 - 75,000#$75,001 - 100,000#$100,001 - 150,000#$150,001 - 200,000#$200,001 and above#No Income#".split("#");
}
var addflag=1;
for(a=0;a<origval.length;a++)
{
addflag=1;
for(var b=0;b<obj2.options.length;b++)
{
if(origlab[a]==obj2.options[b].text)
{
addflag=0;
break;
}
}
if(addflag==1)
{
var optn = document.createElement("OPTION");
optn.value=origval[a];
optn.text=origlab[a];
obj1.options.add(optn);
}
}

}
else if(var1=="Country_Residence[]")
{
var origval="Any#India#United States of America#United Arab Emirates#Malaysia#United Kingdom#Australia#Saudi Arabia#Canada#Singapore#Kuwait#Afghanistan#Albania#Algeria#American Samoa#Andorra#Angola#Anguilla#Antarctica#Antigua and Barbuda#Argentina#Armenia#Aruba#Australia#Austria#Azerbaijan#Bahamas#Bahrain#Bangladesh#Barbados#Belarus#Belgium#Belize#Benin#Bermuda#Bhutan#Bolivia#Bosnia and Herzegovina#Botswana#Bouvet Island#Brazil#British Indian Ocean Territory#British Virgin Islands#Brunei#Bulgaria#Burkina Faso#Burundi#Cambodia#Cameroon#Canada#Cape Verde#Cayman Islands#Central African Republic#Chad#Chile#China#Christmas Island#Cocos Islands#Colombia#Comoros#Congo#Cook Islands#Costa Rica#Croatia#Cuba#Cyprus#Czech Republic#Denmark#Djibouti#Dominica#Dominican Republic#East Timor#Ecuador#Egypt#El Salvador#Equatorial Guinea#Eritrea#Estonia#Ethiopia#Falkland Islands#Faroe Islands#Fiji#Finland#France#French Guiana#French Polynesia#French Southern Territories#Gabon#Gambia#Georgia#Germany#Ghana#Gibraltar#Greece#Greenland#Grenada#Guadeloupe#Guam#Guatemala#Guinea#Guinea-Bissau#Guyana#Haiti#Heard and McDonald Islands#Honduras#Hong Kong#Hungary#Iceland#India#Indonesia#Iran#Iraq#Ireland#Israel#Italy#Ivory Coast#Jamaica#Japan#Jordan#Kazakhstan#Kenya#Kiribati#Korea, North#Korea, South#Kuwait#Kyrgyzstan#Laos#Latvia#Lebanon#Lesotho#Liberia#Libya#Liechtenstein#Lithuania#Luxembourg#Macau#Macedonia, Former Yugoslav Rep#Madagascar#Malawi#Malaysia#Maldives#Mali#Malta#Marshall Islands#Martinique#Mauritania#Mauritius#Mayotte#Mexico#Micronesia, Federated States o#Moldova# 	Monaco#Mongolia#Montserrat#Morocco#Mozambique#Myanmar#Namibia#Nauru#Nepal#Netherlands#Netherlands Antilles#New Caledonia#New Zealand#Nicaragua#Niger#Nigeria#Niue#Norfolk Island#Northern Mariana Islands#Norway#Oman#Pakistan#Palau#Panama#Papua New Guinea#Paraguay#Peru#Philippines#Pitcairn Island#Poland#Portugal#Puerto Rico#Qatar#Reunion#Romania#Russia#Rwanda#S. Georgia and S. Sandwich Isl#Saint Kitts & Nevis#Saint Lucia#Saint Vincent and The Grenadin#Samoa#San Marino#Sao Tome and Principe#Saudi Arabia#Senegal#Seychelles#Sierra Leone#Singapore#Slovakia#Slovenia#Somalia#South Africa#Spain#Sri Lanka#St. Helena#St. Pierre and Miquelon#Sudan#Suriname#Svalbard and Jan Mayen Islands#Swaziland#Sweden#Switzerland#Syria#Taiwan#Tajikistan#Tanzania#Thailand#Togo#Tokelau#Tonga#Trinidad and Tobago#Tunisia#Turkey#Turkmenistan#Turks and Caicos Islands#Tuvalu#Uganda#Ukraine#United Arab Emirates# 	United Kingdom#United States of America#Uruguay#Uzbekistan#Vanuatu#Vatican City#Venezuela#Vietnam#Virgin Islands#Wallis and Futuna Islands#Western Sahara#Yemen#Yugoslavia (Former)#Zaire#Zambia#Zimbabwe#".split("#");
var origlab="Any#India#United States of America#United Arab Emirates#Malaysia#United Kingdom#Australia#Saudi Arabia#Canada#Singapore#Kuwait#Afghanistan#Albania#Algeria#American Samoa#Andorra#Angola#Anguilla#Antarctica#Antigua and Barbuda#Argentina#Armenia#Aruba#Australia#Austria#Azerbaijan#Bahamas#Bahrain#Bangladesh#Barbados#Belarus#Belgium#Belize#Benin#Bermuda#Bhutan#Bolivia#Bosnia and Herzegovina#Botswana#Bouvet Island#Brazil#British Indian Ocean Territory#British Virgin Islands#Brunei#Bulgaria#Burkina Faso#Burundi#Cambodia#Cameroon#Canada#Cape Verde#Cayman Islands#Central African Republic#Chad#Chile#China#Christmas Island#Cocos Islands#Colombia#Comoros#Congo#Cook Islands#Costa Rica#Croatia#Cuba#Cyprus#Czech Republic#Denmark#Djibouti#Dominica#Dominican Republic#East Timor#Ecuador#Egypt#El Salvador#Equatorial Guinea#Eritrea#Estonia#Ethiopia#Falkland Islands#Faroe Islands#Fiji#Finland#France#French Guiana#French Polynesia#French Southern Territories#Gabon#Gambia#Georgia#Germany#Ghana#Gibraltar#Greece#Greenland#Grenada#Guadeloupe#Guam#Guatemala#Guinea#Guinea-Bissau#Guyana#Haiti#Heard and McDonald Islands#Honduras#Hong Kong#Hungary#Iceland#India#Indonesia#Iran#Iraq#Ireland#Israel#Italy#Ivory Coast#Jamaica#Japan#Jordan#Kazakhstan#Kenya#Kiribati#Korea, North#Korea, South#Kuwait#Kyrgyzstan#Laos#Latvia#Lebanon#Lesotho#Liberia#Libya#Liechtenstein#Lithuania#Luxembourg#Macau#Macedonia, Former Yugoslav Rep#Madagascar#Malawi#Malaysia#Maldives#Mali#Malta#Marshall Islands#Martinique#Mauritania#Mauritius#Mayotte#Mexico#Micronesia, Federated States o#Moldova# 	Monaco#Mongolia#Montserrat#Morocco#Mozambique#Myanmar#Namibia#Nauru#Nepal#Netherlands#Netherlands Antilles#New Caledonia#New Zealand#Nicaragua#Niger#Nigeria#Niue#Norfolk Island#Northern Mariana Islands#Norway#Oman#Pakistan#Palau#Panama#Papua New Guinea#Paraguay#Peru#Philippines#Pitcairn Island#Poland#Portugal#Puerto Rico#Qatar#Reunion#Romania#Russia#Rwanda#S. Georgia and S. Sandwich Isl#Saint Kitts & Nevis#Saint Lucia#Saint Vincent and The Grenadin#Samoa#San Marino#Sao Tome and Principe#Saudi Arabia#Senegal#Seychelles#Sierra Leone#Singapore#Slovakia#Slovenia#Somalia#South Africa#Spain#Sri Lanka#St. Helena#St. Pierre and Miquelon#Sudan#Suriname#Svalbard and Jan Mayen Islands#Swaziland#Sweden#Switzerland#Syria#Taiwan#Tajikistan#Tanzania#Thailand#Togo#Tokelau#Tonga#Trinidad and Tobago#Tunisia#Turkey#Turkmenistan#Turks and Caicos Islands#Tuvalu#Uganda#Ukraine#United Arab Emirates# 	United Kingdom#United States of America#Uruguay#Uzbekistan#Vanuatu#Vatican City#Venezuela#Vietnam#Virgin Islands#Wallis and Futuna Islands#Western Sahara#Yemen#Yugoslavia (Former)#Zaire#Zambia#Zimbabwe#".split("#");

var addflag=1;
var a=0;
for(a=0;a<15;a++)
{
addflag=1;
for(var b=0;b<obj2.options.length;b++)
{
if(origlab[a]==obj2.options[b].text)
{
addflag=0;
break;
}

}
if(addflag==1)
{
var optn=document.createElement("OPTION");
optn.value=origval[a];
optn.text=origlab[a];
obj1.options.add(optn);
}
}
var optgrp=document.createElement("OPTGROUP");
optgrp.innerHTML="&nbsp;";
obj1.appendChild(optgrp);
for(a=15;a<origval.length;a++)
{
addflag=1;
for(var b=0;b<obj2.options.length;b++)
{
if(origlab[a]==obj2.options[b].text)
{
addflag=0;
break;
}

}
if(addflag==1)
{
var optn=document.createElement("OPTION");
optn.value=origval[a];
optn.text=origlab[a];
obj1.options.add(optn);
}
}
}
else if(var1=="CITIZENSHIP[]")
{
var origval="Any#India#United States of America#United Arab Emirates#Malaysia#United Kingdom#Australia#Saudi Arabia#Canada#Singapore#Kuwait#Afghanistan#Albania#Algeria#American Samoa#Andorra#Angola#Anguilla#Antarctica#Antigua and Barbuda#Argentina#Armenia#Aruba#Australia#Austria#Azerbaijan#Bahamas#Bahrain#Bangladesh#Barbados#Belarus#Belgium#Belize#Benin#Bermuda#Bhutan#Bolivia#Bosnia and Herzegovina#Botswana#Bouvet Island#Brazil#British Indian Ocean Territory#British Virgin Islands#Brunei#Bulgaria#Burkina Faso#Burundi#Cambodia#Cameroon#Canada#Cape Verde#Cayman Islands#Central African Republic#Chad#Chile#China#Christmas Island#Cocos Islands#Colombia#Comoros#Congo#Cook Islands#Costa Rica#Croatia#Cuba#Cyprus#Czech Republic#Denmark#Djibouti#Dominica#Dominican Republic#East Timor#Ecuador#Egypt#El Salvador#Equatorial Guinea#Eritrea#Estonia#Ethiopia#Falkland Islands#Faroe Islands#Fiji#Finland#France#French Guiana#French Polynesia#French Southern Territories#Gabon#Gambia#Georgia#Germany#Ghana#Gibraltar#Greece#Greenland#Grenada#Guadeloupe#Guam#Guatemala#Guinea#Guinea-Bissau#Guyana#Haiti#Heard and McDonald Islands#Honduras#Hong Kong#Hungary#Iceland#India#Indonesia#Iran#Iraq#Ireland#Israel#Italy#Ivory Coast#Jamaica#Japan#Jordan#Kazakhstan#Kenya#Kiribati#Korea, North#Korea, South#Kuwait#Kyrgyzstan#Laos#Latvia#Lebanon#Lesotho#Liberia#Libya#Liechtenstein#Lithuania#Luxembourg#Macau#Macedonia, Former Yugoslav Rep#Madagascar#Malawi#Malaysia#Maldives#Mali#Malta#Marshall Islands#Martinique#Mauritania#Mauritius#Mayotte#Mexico#Micronesia, Federated States o#Moldova# 	Monaco#Mongolia#Montserrat#Morocco#Mozambique#Myanmar#Namibia#Nauru#Nepal#Netherlands#Netherlands Antilles#New Caledonia#New Zealand#Nicaragua#Niger#Nigeria#Niue#Norfolk Island#Northern Mariana Islands#Norway#Oman#Pakistan#Palau#Panama#Papua New Guinea#Paraguay#Peru#Philippines#Pitcairn Island#Poland#Portugal#Puerto Rico#Qatar#Reunion#Romania#Russia#Rwanda#S. Georgia and S. Sandwich Isl#Saint Kitts & Nevis#Saint Lucia#Saint Vincent and The Grenadin#Samoa#San Marino#Sao Tome and Principe#Saudi Arabia#Senegal#Seychelles#Sierra Leone#Singapore#Slovakia#Slovenia#Somalia#South Africa#Spain#Sri Lanka#St. Helena#St. Pierre and Miquelon#Sudan#Suriname#Svalbard and Jan Mayen Islands#Swaziland#Sweden#Switzerland#Syria#Taiwan#Tajikistan#Tanzania#Thailand#Togo#Tokelau#Tonga#Trinidad and Tobago#Tunisia#Turkey#Turkmenistan#Turks and Caicos Islands#Tuvalu#Uganda#Ukraine#United Arab Emirates# 	United Kingdom#United States of America#Uruguay#Uzbekistan#Vanuatu#Vatican City#Venezuela#Vietnam#Virgin Islands#Wallis and Futuna Islands#Western Sahara#Yemen#Yugoslavia (Former)#Zaire#Zambia#Zimbabwe#".split("#");
var origlab="Any#India#United States of America#United Arab Emirates#Malaysia#United Kingdom#Australia#Saudi Arabia#Canada#Singapore#Kuwait#Afghanistan#Albania#Algeria#American Samoa#Andorra#Angola#Anguilla#Antarctica#Antigua and Barbuda#Argentina#Armenia#Aruba#Australia#Austria#Azerbaijan#Bahamas#Bahrain#Bangladesh#Barbados#Belarus#Belgium#Belize#Benin#Bermuda#Bhutan#Bolivia#Bosnia and Herzegovina#Botswana#Bouvet Island#Brazil#British Indian Ocean Territory#British Virgin Islands#Brunei#Bulgaria#Burkina Faso#Burundi#Cambodia#Cameroon#Canada#Cape Verde#Cayman Islands#Central African Republic#Chad#Chile#China#Christmas Island#Cocos Islands#Colombia#Comoros#Congo#Cook Islands#Costa Rica#Croatia#Cuba#Cyprus#Czech Republic#Denmark#Djibouti#Dominica#Dominican Republic#East Timor#Ecuador#Egypt#El Salvador#Equatorial Guinea#Eritrea#Estonia#Ethiopia#Falkland Islands#Faroe Islands#Fiji#Finland#France#French Guiana#French Polynesia#French Southern Territories#Gabon#Gambia#Georgia#Germany#Ghana#Gibraltar#Greece#Greenland#Grenada#Guadeloupe#Guam#Guatemala#Guinea#Guinea-Bissau#Guyana#Haiti#Heard and McDonald Islands#Honduras#Hong Kong#Hungary#Iceland#India#Indonesia#Iran#Iraq#Ireland#Israel#Italy#Ivory Coast#Jamaica#Japan#Jordan#Kazakhstan#Kenya#Kiribati#Korea, North#Korea, South#Kuwait#Kyrgyzstan#Laos#Latvia#Lebanon#Lesotho#Liberia#Libya#Liechtenstein#Lithuania#Luxembourg#Macau#Macedonia, Former Yugoslav Rep#Madagascar#Malawi#Malaysia#Maldives#Mali#Malta#Marshall Islands#Martinique#Mauritania#Mauritius#Mayotte#Mexico#Micronesia, Federated States o#Moldova# 	Monaco#Mongolia#Montserrat#Morocco#Mozambique#Myanmar#Namibia#Nauru#Nepal#Netherlands#Netherlands Antilles#New Caledonia#New Zealand#Nicaragua#Niger#Nigeria#Niue#Norfolk Island#Northern Mariana Islands#Norway#Oman#Pakistan#Palau#Panama#Papua New Guinea#Paraguay#Peru#Philippines#Pitcairn Island#Poland#Portugal#Puerto Rico#Qatar#Reunion#Romania#Russia#Rwanda#S. Georgia and S. Sandwich Isl#Saint Kitts & Nevis#Saint Lucia#Saint Vincent and The Grenadin#Samoa#San Marino#Sao Tome and Principe#Saudi Arabia#Senegal#Seychelles#Sierra Leone#Singapore#Slovakia#Slovenia#Somalia#South Africa#Spain#Sri Lanka#St. Helena#St. Pierre and Miquelon#Sudan#Suriname#Svalbard and Jan Mayen Islands#Swaziland#Sweden#Switzerland#Syria#Taiwan#Tajikistan#Tanzania#Thailand#Togo#Tokelau#Tonga#Trinidad and Tobago#Tunisia#Turkey#Turkmenistan#Turks and Caicos Islands#Tuvalu#Uganda#Ukraine#United Arab Emirates# 	United Kingdom#United States of America#Uruguay#Uzbekistan#Vanuatu#Vatican City#Venezuela#Vietnam#Virgin Islands#Wallis and Futuna Islands#Western Sahara#Yemen#Yugoslavia (Former)#Zaire#Zambia#Zimbabwe#".split("#");

var addflag=1;
var a=0;
for(a=0;a<15;a++)
{
addflag=1;
for(var b=0;b<obj2.options.length;b++)
{
if(origlab[a]==obj2.options[b].text)
{
addflag=0;
break;
}

}
if(addflag==1)
{
var optn=document.createElement("OPTION");
optn.value=origval[a];
optn.text=origlab[a];
obj1.options.add(optn);
}
}
var optgrp=document.createElement("OPTGROUP");
optgrp.innerHTML="&nbsp;";
obj1.appendChild(optgrp);
for(a=15;a<origval.length;a++)
{
addflag=1;
for(var b=0;b<obj2.options.length;b++)
{
if(origlab[a]==obj2.options[b].text)
{
addflag=0;
break;
}

}
if(addflag==1)
{
var optn=document.createElement("OPTION");
optn.value=origval[a];
optn.text=origlab[a];
obj1.options.add(optn);
}
}
}

else if(var1=="City_India[]")
{
var origvallist="All#UP01#TR01#GU01#UP31#MI01#RA01#MH01#UP02#UP03#RA02#HA01#UP04#PU01#GU02#GU03#KA01#TN01#WB01#MH02#UP05#KA02#WB02#UP06#GU04#PU02#KA03#RA03#MP01#RA04#MP02#OR01#KA04#RA05#MP03#BI01#KE01#PH00#TN02#MP04#TN03#TN04#TN05#AP01#OR02#HP01#UP07#DE00#MP05#BI02#KA05#AS01#NA01#AS02#MP06#WB03#KE02#TN06#UP08#UP09#HA02#PU03#UP10#PU04#UP11#GU05#RA06#SI01#BI03#UP12#GO00#UP13#KA06#JK01#AP02#PU05#HA03#AS03#MP07#UP14#UP15#PU06#KA07#AP03#MA01#MP08#AR01#MP09#RA07#RA11#PU10#JK04#BI04#UP16#RA08#AS04#GU06#AP04#GU07#UP17#TN07#UP18#HP02#MP10#WB04#KE03#TN08#NA02#MH03#WB05#RA09#KE04#KE05#KE06#AP05#JK02#UP19#PU07#AP06#TN09#KA08#UP20#UP21#UP22#MH04#UP23#UP24#BI05#KA09#MH05#MH06#MH07#TN10#AP07#UP25#KE07#AP08#GU08#KE09#HA06#OR03#PU08#PU09#BI06#TN11#PO00#MH08#UP26#MP12#TN12#GU09#TN13#BI07#UP27#HA04#UP28#OR04#UP29#TN14#MH09#ME01#HP03#MH10#AS05#HA05#MH11#JK03#GU10#MH12#TN15#KE08#TN16#TN17#TN16#TN20#TN18#GU12#RA10#MP11#MH13#GU11#UP30#TN19#AP10#AP11#%AP#AP09#AR#AS#BI#CH#DN#DD#GU#HA#HP#JK#JH#KA#KE#LA#MP#MH#MA#ME#MI#NA#OR#PU#RA#SI#TN#TR#UP#UT#WB#%1#2#50#3#4#5#6#7#8#49#9#10#11#51#12#13#14#15#16#17#18#19#20#21#22#23#24#25#52#53#54#26#27#28#29#30#31#32#55#33#34#35#36#56#37#38#39#40#41#57#42#43#44#45#46#47#48#".split("%");
var origlablist="ALL#Agra#Agartala#Ahmedabad#Ahmednagar#Aizwal#Ajmer#Akola#Aligarh#Allahabad#Alwar#Ambala#Amethi#Amritsar#Anand#Ankleshwar#Ankola#Arcot#Asansol#Aurangabad#Ayodhya#Bangalore#Barddhaman#Bareilly#Baroda#Bathinda#Belgaum#Bharatpur#Bhilai#Bhilwara#Bhopal#Bhubaneshwar#Bidar#Bikaner#Bilaspur#Bokaro#Calicut#Chandigarh#Chennai#Chhindwara#Chidambaram#Coimbatore#Cuddalore#Cuddapah#Cuttack#Dalhousie#DehraDun#Delhi#Deora#Dhanbad#Dharwad#Dibrugarh#Dimapur#Dispur#Durg#Durgapur#Ernakulam#Erode#Etawah#Faizabad#Faridabad#Faridkot#Fatehpur#Ferozpur#Firozabad#Gandhinagar#Ganganagar#Gangtok#Gaya#Ghaziabad#Goa#Gorakhpur#Gulbarga#Gulmarg#Guntur#Gurdaspur#Gurgaon#Guwahati#Gwalior#Hapur#Haridwar#Hoshiarpur#Hubli#Hyderabad#Imphal#Indore#Itanagar#Jabalpur#Jaipur#Jaisalmer#Jalandhar#Jammu#Jamshedpur#Jhansi#Jodhpur#Jorhat#Junagadh#Kakinada#Kandla#Kannauj#Kanniyakumari#Kanpur#Kasauli#Khajuraho#Kharagpur#Kochi#Kodaikanal#Kohima#Kolhapur#Kolkata#Kota#Kottayam#Kovalam#Kozhikode#Kurnool#Leh#Lucknow#Ludhiana#Machilipatnam#Madurai#Mangalore#Mathura#Meerut#Moradabad#Mumbai#Mussoorie#Muzaffarnagar#Muzaffarpur#Mysore#Nagpur#Nanded#Nashik#Nilgiri#Nellore#Noida#Palakkad#Palampet#Palanpur#Pandalam#Panipat#Paradeep#Pathankot#Patiala#Patna#Periyar#Pondicherry#Pune#Rae Bareli#Raipur#Rajahmundry#Rajkot#Rameswaram#Ranchi#Rishikesh#Rohtak#Roorkee#Rourkela#Saharanpur#Salem#Sangli#Shillong#Shimla#Shirdi#Silchar#Sirsa#Solapur#Srinagar#Surat#Thane#Thanjavur#Thiruvananthapuram#Tiruchirapalli#Tirunelvelli#Trichi#Trivandrum#Tuticorin#Vapi#Udaipur#Ujjain#Ulhasnagar#Vadodara#Varanasi#Vellore#Vijaywada#Vishakhapatnam#%Andhra Pradesh#Warangal#Arunachal Pradesh#Assam#Bihar#Chhattisgarh#Dadra & Nagar Haveli#Daman & Diu#Gujarat#Haryana#Himachal Pradesh#Jammu & Kashmir#Jharkhand#Karnataka#Kerala#Lakshadweep#Madhya Pradesh#Maharashtra#Manipur#Meghalaya#Mizoram#Nagaland#Orissa#Punjab#Rajasthan#Sikkim#Tamil Nadu#Tripura#Uttar Pradesh#Uttaranchal#West Bengal#%USA - Alabama#USA - Alaska#USA - American Samoa#USA - Arizona#USA - Arkansas#USA - California#USA - Colorado#USA - Connecticut#USA - Delaware#USA - Detroit#USA - District of Columbia#USA - Florida#USA - Georgia#USA - Guam#USA - Hawaii#USA - Idaho#USA - Illinois#USA - Indiana#USA - Iowa#USA - Kansas#USA - Kentucky#USA - Louisiana#USA - Maine#USA - Maryland#USA - Massachusetts#USA - Michigan#USA - Minnesota#USA - Mississippi#USA - Missouri#USA - Montana#USA - Nebraska#USA - Nevada#USA - New Hampshire#USA - New Jersey#USA - New Mexico#USA - New York#USA - North Carolina#USA - North Dakota#USA - Northern Mariana Islands#USA - Ohio#USA - Oklahoma#USA - Oregon#USA - Pennsylvania#USA - Puerto Rico#USA - Rhode Island#USA - South Carolina#USA - South Dakota#USA - Tennessee#USA - Texas#USA - United States Virgin Islands#USA - Utah#USA - Vermont#USA - Virginia#USA - Washington#USA - West Virginia#USA - Wisconsin#USA - Wyoming#".split("%");
var origval1=origvallist[0].split("#");
var origlab1=origlablist[0].split("#");
var origval2=origvallist[1].split("#");
var origlab2=origlablist[1].split("#");
var origval3=origvallist[2].split("#");
var origlab3=origlablist[2].split("#");
var a=0;
var addflag=1;
len=origval1.length-1;
for(a=0;a<len;a++)
{
addflag=1;
for(var b=0;b<obj2.options.length;b++)
{
if(origlab1[a]==obj2.options[b].text)
{
addflag=0;
break;
}

}
if(addflag==1)
{
var optn=document.createElement("OPTION");
optn.value=origval1[a];
optn.text=origlab1[a];
obj1.options.add(optn);
}
}
var optgrp=document.createElement("OPTGROUP");
optgrp.innerHTML="&nbsp;";
obj1.appendChild(optgrp);
len=origval2.length-1;
for(a=0;a<len;a++)
{
addflag=1;
for(var b=0;b<obj2.options.length;b++)
{
if(origlab2[a]==obj2.options[b].text)
{
addflag=0;
break;
}

}
if(addflag==1)
{
var optn=document.createElement("OPTION");
optn.value=origval2[a];
optn.text=origlab2[a];
obj1.options.add(optn);
}
}
var optgrp=document.createElement("OPTGROUP");
optgrp.innerHTML="&nbsp;";
obj1.appendChild(optgrp);
for(a=0;a<origval3.length;a++)
{
addflag=1;
for(var b=0;b<obj2.options.length;b++)
{
if(origlab3[a]==obj2.options[b].text)
{
addflag=0;
break;
}

}
if(addflag==1)
{
var optn=document.createElement("OPTION");
optn.value=origval3[a];
optn.text=origlab3[a];
obj1.options.add(optn);
}
}

}
else if(var1=="Mtongue[]")
{
var origvallist="0#1#2#3#4#5#6#7#8#9#10#11#12#13#14#15#16#17#18#19#20#21#22#23#24#25#26#27#28#29#30#31#32#33#34#35#36#37#38#39#40#41#42#43#44#45#46#47#48#49#50#51#99#".split("#");
var origlablist="Any#Arunachali#Assamese#Awadhi#Bengali#Bhojpuri#Brij#Bihari#Chatisgarhi#Dogri#English#French#Garhwali#Garo#Gujarati#Haryanvi#Himachali/Pahari#Hindi#Kanauji#Kannada#Kashmiri#Khandesi#Khasi#Konkani#Koshali#Kumoani#Kutchi#Lepcha#Ladacki#Magahi#Maithili#Malayalam#Manipuri#Marathi#Marwari#Miji#Mizo#Monpa#Nicobarese#Nepali#Oriya#Punjabi#Rajasthani#Sanskrit#Santhali#Sindhi#Sourashtra#Tamil#Telugu#Tripuri#Tulu#Urdu#Others#".split("#");

for(var b=0;b<origvallist.length;b++)
{
var origval=origvallist[b].split("#");
var origlab=origlablist[b].split("#");
len=origval.length-1;
var a=0;
var addflag=1;
if(b==1)
{
var optn=document.createElement("OPTION");
optn.text="All Hindi";
optn.value="10,19,33,7,28,13";
obj1.options.add(optn);
var optgrp=document.createElement("OPTGROUP");
optgrp.innerHTML="&nbsp;";
obj1.appendChild(optgrp);
var optgrp=document.createElement("OPTGROUP");
optgrp.label="Communities in North India";
optgrp.style.color="#5494C6";
obj1.appendChild(optgrp);
}
else if(b==2)
{
var optgrp=document.createElement("OPTGROUP");
optgrp.label="Communities in West India";
optgrp.style.color="#5494C6";
obj1.appendChild(optgrp);
}
else if(b==3)
{
var optgrp=document.createElement("OPTGROUP");
optgrp.label="Communities in South India";
optgrp.style.color="#5494C6";
obj1.appendChild(optgrp);
}
else if(b==4)
{
var optgrp=document.createElement("OPTGROUP");
optgrp.label="Communites in East India";
optgrp.style.color="#5494C6";
obj1.appendChild(optgrp);
}
else if(b==5)
{
var optgrp=document.createElement("OPTGROUP");
optgrp.label="-----------------";
obj1.appendChild(optgrp);
}
for(a=0;a<len;a++)
{
addflag=1;
for(var c=0;c<obj2.options.length;c++)
{
if(origlab[a]==obj2.options[c].text)
{
addflag=0;
break;
}
}
if(addflag==1)
{
var optn=document.createElement("OPTION");
optn.value=origval[a];
optn.text=origlab[a];
obj1.options.add(optn);
}
}
var optgrp=document.createElement("OPTGROUP");
optgrp.innerHTML="&nbsp;";
obj1.appendChild(optgrp);
}
}

}

/*if(obj2.options.length == 0)
{
var arr = new Option();
arr.value=obj1.options[0].value;
arr.text=obj1.options[0].text;
obj2.options[obj2.options.length]=arr;
}*/

var k=0,str1,str2;

while(k<obj2.options.length)
{
str2=obj2.options[k].value;
str1=str1+","+str2;
k++;
}
hidden_name.value=str1;
}

function chkgender(g)
{ //alert(g);
	if (g=="F")   
	{ 
		document.form1.minAge.value="18"; document.form1.maxAge.value="30"; 
	}
	if (g=="M") 
	{  
		document.form1.minAge.value="21"; document.form1.maxAge.value="33"; 
	}
}

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.MatriForm.comment.value;
	var len = tex.length;
	if(len > countDescription)
	{
			tex = tex.substring(0,countDescription);
			document.MatriForm.comment.value =tex;
			return false;
	}
	document.MatriForm.limit.value = countDescription-len;
}

var countAddress = "99";   
function limiterAddress()
{
	var tex = document.MatriForm.address.value;
	var len = tex.length;
	if(len > countAddress)
	{
        tex = tex.substring(0,countAddress);
        document.MatriForm.address.value =tex;
        return false;
	}
	document.MatriForm.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.MatriForm;
	MatriForm.feet.value="Feet/Inches";
}

function heightfocus()
{
	var MatriForm = this.document.MatriForm;
	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.MatriForm;
	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.MatriForm;
	MatriForm.kgs.value="Kgs";
}

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