// JavaScript Document
//------------------------------------------- function to check form fields------------------------------------------------
function checkform()
{
	
	//--------------------------------------------- checking email address-----------------------------------------------
	if(document.frmsearch.username.value=='')
	{
		window.alert("Please Enter Your User ID.");
		document.frmsearch.username.focus();
		return false;
	}
	
	//----------------------------------------------checking password -----------------------------------------------------
	if(document.frmsearch.txtpasswd.value.length<6)
	{
		window.alert("Password must be 6 characters or more please check.");
		document.frmsearch.txtpasswd.focus();
		return false;
	}
	
	if(document.frmsearch.txtpasswd.value=='')
	{
		window.alert("Please Enter Password.");
		document.frmsearch.txtpasswd.focus();
		return false;
	}
	//------------------------------------------checking re entered password ------------------------------------------------
	if(document.frmsearch.txtrepasswd.value=='')
	{
		window.alert("Please Re Enter Password.");
		document.frmsearch.txtrepasswd.focus();
		return false;
	}
	//----------------------------------------checking two passwords--------------------------------------------------------
	if(document.frmsearch.txtpasswd.value!=document.frmsearch.txtrepasswd.value)
	{
		window.alert("Password Mismatch Please Check.");
		document.frmsearch.txtrepasswd.focus();
		return false;
	}
	//------------------------------------checking name --------------------------------------------------------------------
	if(document.frmsearch.txtname.value=='')
	{
		window.alert("Please Enter Your Name.");
		document.frmsearch.txtname.focus();
		return false;
	}
	//----------------------------------------checking address------------------------------------------------------------
	if(document.frmsearch.txtaddress.value=='')
	{
		window.alert("Please Enter Address.");
		document.frmsearch.txtaddress.focus();
		return false;
	}
	//--------------------------------------------checking state-----------------------------------------------------------
	if(document.frmsearch.cbostate.value=='Select')
	{
		window.alert("Please Select any State.");
		document.frmsearch.cbostate.focus();
		return false;
	}
	//------------------------------------------------checking gender-----------------------------------------------------
	if(document.frmsearch.cbogender.value=='Select')
	{
		window.alert("Please Enter Your Gender.");
		document.frmsearch.cbogender.focus();
		return false;
	}
	//------------------------------------------checking date--------------------------------------------------------------
	var bod=document.frmsearch.month.value + "/" + document.frmsearch.day.value + "/" + document.frmsearch.year.value;
	if(bod!='')
	{
		var ly=document.frmsearch.year.value%4;

		if(document.frmsearch.month.value==2)
		{
			if(ly==0)
			{
				daylimit=29;
			}
			else
			{
				daylimit=28;
			}
		}
		else if(document.frmsearch.month.value==1 ||  document.frmsearch.month.value==3 || document.frmsearch.month.value==5 || document.frmsearch.month.value==7 || document.frmsearch.month.value==8 || document.frmsearch.month.value==10 || document.frmsearch.month.value==12)
		{
			daylimit=31;
		}
		else if(document.frmsearch.month.value==4 || document.frmsearch.month.value==6 || document.frmsearch.month.value==9 || document.frmsearch.month.value==11)
		{
			daylimit=30;	
		}//--------------------end of else -----------------------------
		
		//----------------------------------------------checking day-------------------------------
		if(document.frmsearch.day.value>daylimit)
		{
			alert("Please Enter a Valid Date .");
			document.frmsearch.day.focus();
			return false;
		}
	}
		
	//------------------------------------checking religion-----------------------------------------------------------------
	if(document.frmsearch.cboreligion.value=='Select')
	{
		window.alert("Please Select Your Religion.");
		document.frmsearch.cboreligion.focus();
		return false;
	}
	//---------------------------------------------checking caste -----------------------------------------------------------
	if(document.frmsearch.cbocaste.value=='Select')
	{
		window.alert("Please Select Your Caste.");
		document.frmsearch.cbocaste.focus();
		return false;
	}
	//------------------------------------checking height----------------------------------------------------------------
	if(document.frmsearch.cboheight.value=='Select')
	{
		window.alert("Please Select Your Height.");
		document.frmsearch.cboheight.focus();
		return false;
	}
	//-----------------------------------------checking marital status---------------------------------------------------
	if(document.frmsearch.cbomarital.value=='Select')
	{
		window.alert("Please Select Your Marital Status.");
		document.frmsearch.cbomarital.focus();
		return false;
	}
	//---------------------------------- checking qualification ---------------------------------------------------------
	if(document.frmsearch.txtqualification.value=='')
	{
		window.alert("Please Enter Your Qualification.");
		document.frmsearch.txtqualification.focus();
		return false;
	}
	//---------------------------------------------checking profession ------------------------------------------------
	if(document.frmsearch.txtprofession.value=='')
	{
		window.alert("Please Enter Your Profession.");
		document.frmsearch.txtprofession.focus();
		return false;
	}
	//---------------------------------------checking father's job ----------------------------------------------------------
	if(document.frmsearch.txtfatherjob.value=='')
	{
		window.alert("Please Enter Job of Father.");
		document.frmsearch.txtfatherjob.focus();
		return false;
	}
	//----------------------------------------checking mother's job---------------------------------------------------------
	if(document.frmsearch.txtmotherjob.value=='')
	{
		window.alert("Please Enter Job of Mother.");
		document.frmsearch.txtmotherjob.focus();
		return false;
	}
	//-----------------------------------------checking salary-------------------------------------------------------------
	if(isNaN(document.frmsearch.txtsalary.value))
	{
		window.alert("Please Enter Numeric Value.");
		document.frmsearch.txtsalary.focus();
		return false;
	}
	
	if(document.frmsearch.txtcontact.value=='')
	{
		window.alert("Please Enter your Contact no.");
		document.frmsearch.txtcontact.focus();
		return false;
	}
	
	//------------------------------------------checking picture---------------------------------------------------------
	if(document.frmsearch.pic.value!='')
	{
		var path=document.frmsearch.pic.value;
		if(path.substring(path.length-3)!='jpg')
		{
			alert('Invalid Picture format.');
			document.frmsearch.pic.focus();
			return false;
		}
	}if(document.frmsearch.confirm_policy.checked==1)
	{return true;
	}
	if(document.frmsearch.confirm_policy.checked!=1)
	{
		alert('Inorder to register you must agree our terms and conditions please check the checkbox');
		return false;
	}	
	
}//------------------------------------- end of function check form ------------------------------------------------------

//------------------------------------- loading contents on form load---------------------------------------------------
function frmload()
{
	
	checkcombo(1);
	checkcombo(2);
	checkcombo(3);
// --------------------------------------------------------adding height to combo box ----------------------------------
	var p=0;
		//--------------------- adding heights to combo box--------------------------------------------------	
	for(i=50;i<300;i++)
	{
			var ne=new Option(i,i);
			document.frmsearch.cboheight.options[p]=ne;
			var ne=new Option(i,i);
			document.frmsearch.cbopheightto.options[p]=ne;
			var ne=new Option(i,i);
			document.frmsearch.cbopheightfrom.options[p]=ne;			
			p++;		
	}
	
	//----------------------------adding days to date of birth-------------------------------------------------------------
		for(i=01;i<=31;i++)
		{
			var d=new Option(i,i);
			document.form5.day.options[i-1]=d;
			//-----------------------------setting month of date of birth------------------------------------------------------
			if(i<=12)
			{
				var m=new Option(i,i);
				document.form5.month.options[i-1]=m;
			}
		}
		
		//-------------------------------------------- setting year of date of birth--------------------------------------------
		var c=0;
		var ny=new Date();
		ny=ny.getYear();
		for(i=(ny-90);i<=ny.getYear()-18;i++)
		{
			var y=new Option(i,i);
			document.form5.year.options[c]=y;
			c++;
		}

		//document.form5.txtemail.focus();	
		
}//---------------------------------------------------------end of frmload function -------------------------------------------




//------------------------------------------- checking religions and loading caste to combo box------------------------------
function checkcombo(obj)
{

var hr=new Array("Select","Adiyan","Adiyodi","Arya vysya","Ambalavasi","Brahmin","Brahmin-Tamil","Brahmin-Saraswath","Bhattathiri","Cheramar","Chettiyar","Dhevara","Ezhava","Ezuthachan","Ganakar","G.S.B","Guptan","Iyer","Kalaripaniker","Kammala","Kaniyan","Kartha","Kshtriya / Varma","Kurava","Kurup","Mannadiar","Mannan","Marar","Menon","Mudaliar","Nadar","Nair","Nair-Chekkala","Nair - Velluthedathu","Nair - Vilakkithala","Naicken","Nambiar","Nambisan","Namboothiri","Panikar","Paravan","Pillai","Pisharody","Poduval","Pulaya","Reddiar","Saiva vellala","Salia","Sambava","Thachar","Thandan","Thiya","Vallala","Vaniya","Vannan","Veerasaiva","Velan","Velar","Viswakarma","Yadava","Others");

var cr=new Array("Select","Basel Mission","Born Again","Berthren","Cannonite","Catholic","Chaldean Syrian","Cheramar","Christian Nadar"," C N I","Convert","C S I","Evangalical","I P C","Jacobite","Kananaya","Kananaya  Catholic","Kananaya Jacobite","Kananaya","Pentecostal","Latin  Catholic","Malankara","Malankara Catholic","Marthoma","Others");

var mr=new Array("Select","Ahmedia","Anafi","Islam","Mappila","Pakhni","Pattanis","Rowthar","Shafi","Shia","Sunni","Others");

var or=new Array("Other");

if(obj==1)
{ 
	//------------------------------------- loading Hindu castes to combo-----------------------------------------------------
	if(document.form5.cboreligion.value=='Hindu')
	{
		//clearing combo box
		for(i=document.form5.cbocaste.length-1;i>=0;i--)
		{
			document.form5.cbocaste.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=hr.length-1;i++)
		{
			var n=new Option(hr[i],hr[i]);
			document.form5.cbocaste.options[i]=n;
		}
		
	}
	
	//------------------------------------------------loadin Christian caste to combo box--------------------------------------
	if(document.form5.cboreligion.value=='Christian')
	{
		
		//clearing combo box
		for(i=document.form5.cbocaste.length-1;i>=0;i--)
		{
			document.form5.cbocaste.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=cr.length-1;i++)
		{
			var n=new Option(cr[i],cr[i]);
			document.form5.cbocaste.options[i]=n;
		}
	}
	
	//----------------------------------------------------loading muslim castes---------------------------------------------
	if(document.form5.cboreligion.value=='Muslim')
	{
		
		//clearing combo box
		for(i=document.form5.cbocaste.length-1;i>=0;i--)
		{
			document.form5.cbocaste.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=mr.length-1;i++)
		{
			var n=new Option(mr[i],mr[i]);
			document.form5.cbocaste.options[i]=n;
		}
	}
	
	//--------------------------------------------------------loading other caste--------------------------------------------
	if(document.form5.cboreligion.value=='Other')
	{
		//clearing combo box
		for(i=document.form5.cbocaste.length-1;i>=0;i--)
		{
			document.form5.cbocaste.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=or.length-1;i++)
		{
			var n=new Option(or[i],or[i]);
			document.form5.cbocaste.options[i]=n;
		}
	
	}
}

else if(obj==2)

{ 
	//------------------------------------- loading Hindu castes to combo-----------------------------------------------------
	if(document.frmsearch.cboreligion.value=='Hindu')
	{
		//clearing combo box
		for(i=document.frmsearch.cbocaste.length-1;i>=0;i--)
		{
			document.frmsearch.cbocaste.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=hr.length-1;i++)
		{
			var n=new Option(hr[i],hr[i]);
			document.frmsearch.cbocaste.options[i]=n;
		}
	}
	
	//------------------------------------------------loadin Christian caste to combo box--------------------------------------
	if(document.frmsearch.cboreligion.value=='Christian')
	{
		
		//clearing combo box
		for(i=document.frmsearch.cbocaste.length-1;i>=0;i--)
		{
			document.frmsearch.cbocaste.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=cr.length-1;i++)
		{
			var n=new Option(cr[i],cr[i]);
			document.frmsearch.cbocaste.options[i]=n;
		}
	}
	
	//----------------------------------------------------loading muslim castes---------------------------------------------
	if(document.frmsearch.cboreligion.value=='Muslim')
	{
		
		//clearing combo box
		for(i=document.frmsearch.cbocaste.length-1;i>=0;i--)
		{
			document.frmsearch.cbocaste.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=mr.length-1;i++)
		{
			var n=new Option(mr[i],mr[i]);
			document.frmsearch.cbocaste.options[i]=n;
		}
	}
	
	//--------------------------------------------------------loading other caste--------------------------------------------
	if(document.frmsearch.cboreligion.value=='Other')
	{
		//clearing combo box
		for(i=document.frmsearch.cbocaste.length-1;i>=0;i--)
		{
			document.frmsearch.cbocaste.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=or.length-1;i++)
		{
			var n=new Option(or[i],or[i]);
			document.frmsearch.cbocaste.options[i]=n;
		}
	
	}
}
else if(obj==3)

{ 
	//------------------------------------- loading Hindu castes to combo-----------------------------------------------------
	if(document.frmsearch.cbopreligion.value=='Hindu')
	{
		//clearing combo box
		for(i=document.frmsearch.cbopcaste.length-1;i>=0;i--)
		{
			document.frmsearch.cbopcaste.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=hr.length-1;i++)
		{
			var n=new Option(hr[i],hr[i]);
			document.frmsearch.cbopcaste.options[i]=n;
		}
	}
	
	//------------------------------------------------loadin Christian caste to combo box--------------------------------------
	if(document.frmsearch.cbopreligion.value=='Christian')
	{
		
		//clearing combo box
		for(i=document.frmsearch.cbopcaste.length-1;i>=0;i--)
		{
			document.frmsearch.cbopcaste.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=cr.length-1;i++)
		{
			var n=new Option(cr[i],cr[i]);
			document.frmsearch.cbopcaste.options[i]=n;
		}
	}
	
	//----------------------------------------------------loading muslim castes---------------------------------------------
	if(document.frmsearch.cbopreligion.value=='Muslim')
	{
		
		//clearing combo box
		for(i=document.frmsearch.cbopcaste.length-1;i>=0;i--)
		{
			document.frmsearch.cbopcaste.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=mr.length-1;i++)
		{
			var n=new Option(mr[i],mr[i]);
			document.frmsearch.cbopcaste.options[i]=n;
		}
	}
	
	//--------------------------------------------------------loading other caste--------------------------------------------
	if(document.frmsearch.cbopreligion.value=='Other')
	{
		//clearing combo box
		for(i=document.frmsearch.cbopcaste.length-1;i>=0;i--)
		{
			document.frmsearch.cbopcaste.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=or.length-1;i++)
		{
			var n=new Option(or[i],or[i]);
			document.frmsearch.cbopcaste.options[i]=n;
		}
	
	}	
}
else if(obj==4)

{ 
	//------------------------------------- loading Hindu castes to combo-----------------------------------------------------
	if(document.frmsearch.Relgn.value=='Hindu')
	{
		//clearing combo box
		for(i=document.frmsearch.cast.length-1;i>=0;i--)
		{
			document.frmsearch.cast.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=hr.length-1;i++)
		{
			var n=new Option(hr[i],hr[i]);
			document.frmsearch.cast.options[i]=n;
		}
	}
	
	//------------------------------------------------loadin Christian caste to combo box--------------------------------------
	if(document.frmsearch.Relgn.value=='Christian')
	{
		
		//clearing combo box
		for(i=document.frmsearch.cast.length-1;i>=0;i--)
		{
			document.frmsearch.cast.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=cr.length-1;i++)
		{
			var n=new Option(cr[i],cr[i]);
			document.frmsearch.cast.options[i]=n;
		}
	}
	
	//----------------------------------------------------loading muslim castes---------------------------------------------
	if(document.frmsearch.Relgn.value=='Muslim')
	{
		
		//clearing combo box
		for(i=document.frmsearch.cast.length-1;i>=0;i--)
		{
			document.frmsearch.cast.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=mr.length-1;i++)
		{
			var n=new Option(mr[i],mr[i]);
			document.frmsearch.cast.options[i]=n;
		}
	}
	
	//--------------------------------------------------------loading other caste--------------------------------------------
	if(document.frmsearch.Relgn.value=='Other')
	{
		//clearing combo box
		for(i=document.frmsearch.cast.length-1;i>=0;i--)
		{
			document.frmsearch.cast.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=or.length-1;i++)
		{
			var n=new Option(or[i],or[i]);
			document.frmsearch.cast.options[i]=n;
		}
	
	}	
}	

else if(obj==5)
{ 
	//------------------------------------- loading Hindu castes to combo-----------------------------------------------------
	if(document.form5.Relgn.value=='Hindu')
	{
		//clearing combo box
		for(i=document.form5.cast.length-1;i>=0;i--)
		{
			document.form5.cast.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=hr.length-1;i++)
		{
			var n=new Option(hr[i],hr[i]);
			document.form5.cast.options[i]=n;
		}
	}
	
	//------------------------------------------------loadin Christian caste to combo box--------------------------------------
	if(document.form5.Relgn.value=='Christian')
	{
		
		//clearing combo box
		for(i=document.form5.cast.length-1;i>=0;i--)
		{
			document.form5.cast.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=cr.length-1;i++)
		{
			var n=new Option(cr[i],cr[i]);
			document.form5.cast.options[i]=n;
		}
	}
	
	//----------------------------------------------------loading muslim castes---------------------------------------------
	if(document.form5.Relgn.value=='Muslim')
	{
		
		//clearing combo box
		for(i=document.form5.cast.length-1;i>=0;i--)
		{
			document.form5.cast.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=mr.length-1;i++)
		{
			var n=new Option(mr[i],mr[i]);
			document.form5.cast.options[i]=n;
		}
	}
	
	//--------------------------------------------------------loading other caste--------------------------------------------
	if(document.form5.Relgn.value=='Other')
	{
		//clearing combo box
		for(i=document.form5.cast.length-1;i>=0;i--)
		{
			document.form5.cast.remove(0);
		}
		//adding new values to combo box caste		
		for(i=0;i<=or.length-1;i++)
		{
			var n=new Option(or[i],or[i]);
			document.form5.cast.options[i]=n;
		}
	
	}	
}	

}//--------------------------------------------end of function check combo box-----------------------------------------------