
function validate(form)
{
	if(Trim(form.Name.value).length < 1)
	{
		alert("Enter Name")
		form.Name.select()
		form.Name.focus() 
		 
		return false	
	}
	if(Trim(form.Name.value).length > 30)
	{		
		alert("Maximum allowed length of Name is 30 !!!")
		form.Name.select()
		form.Name.focus() 
		 
		return false	
	}		
	if(form.religion.value == "SelectReligion")
	{
		alert("Select Religion")		
		form.religion.focus() 
		 
		return false
	}
	
	if(form.caste.value == "Select")
	{
		alert("Select Caste")		
		form.caste.focus() 
		 
		return false
	}	
	if(form.caste.value == "")
	{
		alert("Select Caste")		
		form.caste.focus() 
		return false
	}	
	if(form.caste.value == null)
	{
		alert("Select Caste")		
		form.caste.focus() 
		return false
	}	
//	if(Trim(form.subcaste.value).length > 50)
//	{		
//		alert("Maximum allowed length of sub caste is 50 !!!")
//		form.subcaste.select()
//		form.subcaste.focus() 
//		 
//		return false	
//	}		
	if(form.Gender.value == "")
	{
		alert("Select Gender")		
		form.Gender.focus() 
		 
		return false	
	}
	
	if(form.Day.value == "")
	{
		alert("Select Day")		
		form.Day.focus() 
		 
		return false	
	}
	if(form.Month.value == "")
	{
		alert("Select Month")		
		form.Month.focus() 
		 
		return false	
	}
	if(form.Year.value == "")
	{
		alert("Select Year")		
		form.Year.focus() 
		 
		return false	
	}
	
	if(form.Education_Level.value == "")
	{
		alert("Select Education ")		
		form.Education_Level.focus() 
		 
		return false
	}	
	if(Trim(form.Qualification.value).length > 400)
	{		
		alert("Maximum allowed length of Qualification is 400 !!!")
		form.Qualification.select()
		form.Qualification.focus() 
		 
		return false	
	}					
	
	if(form.Job_Category.value == "")
	{
		alert("Select Job Category")		
		form.Job_Category.focus() 
		 
		return false
	}		
	if(Trim(form.JobDescription.value).length > 400)
	{		
		alert("Maximum allowed length of Job Description is 400 !!!")
		form.JobDescription.select()
		form.JobDescription.focus() 
		 
		return false	
	}	
		
//	if(Trim(form.PlaceOfWork.value).length > 50)
//	{		
//		alert("Maximum allowed length of Place Of Work is 50 !!!")
//		form.PlaceOfWork.select()
//		form.PlaceOfWork.focus() 
//		 
//		return false	
//	}
/*	if(form.Monthly_Income.value == "")
	{
		alert("Select Monthly Income")		
		form.Monthly_Income.focus() 
		 
		return false
	}	*/	
	if(form.Height.value == "")
	{
		alert("Select Height")		
		form.Height.focus() 
		 
		return false
	}
/*	if(form.Complexion.value == "")
	{
		alert("Select Complexion")		
		form.Complexion.focus() 
		 
		return false
	}*/
	if(Trim(form.Fathers_Job.value).length > 100)
	{		
		alert("Maximum allowed length of Father's Job is 100 !!!")
		form.Fathers_Job.select()
		form.Fathers_Job.focus() 
		 
		return false	
	}	
	if(Trim(form.Mothers_Job.value).length > 100)
	{		
		alert("Maximum allowed length of Mother's Job is 100 !!!")
		form.Mothers_Job.select()
		form.Mothers_Job.focus() 
		 
		return false	
	}	
	if(Trim(form.LanguagesSpeak.value).length < 1)
	{
		alert("Select Languages Speak")		
		form.LanguagesSpeak.focus() 
		 
		return false
	}	
	if(form.State_Country.value == "false")
	{
		alert("Select State/Country")		
		form.State_Country.focus() 
		 
		return false
	}
		if(Trim(form.City.value).length < 1)
		{
			alert("Enter District")
			form.City.select()
			form.City.focus() 
			
			return false	
		}		
		if(Trim(form.City.value).length > 20)
		{		
			alert("Maximum allowed length of District is 20 !!!")
			form.City.select()
			form.City.focus() 
			 
			return false	
		}			
	
	if(Trim(form.NowResiding.value).length > 50)
	{		
		alert("Maximum allowed length of Now Residing is 50 !!!")
		form.NowResiding.select()
		form.NowResiding.focus() 
		 
		return false	
	}	
/*	if(form.Share_of_Property.value == "")
	{
		alert("Select Share of Property")		
		form.Share_of_Property.focus() 
		 
		return false
	}	*/
//	if(Trim(form.ShareDetails.value).length > 250)
//	{		
//		alert("Maximum allowed length of ShareDetails is 250 !!!")
//		form.ShareDetails.select()
//		form.ShareDetails.focus() 
//		 
//		return false	
//	}		
	if(form.Marital_Status.value == "")
	{
		alert("Select Marital Status")		
		form.Marital_Status.focus() 
		 
		return false
	}
	if(!form.NoOfChildrenBoys.disabled)
	{	
		if(form.NoOfChildrenBoys.value == "")
		{			
			alert("Select No Of Childrens")		
			form.NoOfChildrenBoys.focus() 
		 
			return false				
		}	
	}
//	if(!form.NoOfChildrenGirls.disabled)
//	{	
//		if(form.NoOfChildrenGirls.value == "")
//		{			
//			alert("Select No Of Girls")		
//			form.NoOfChildrenGirls.focus() 
//		 
//			return false				
//		}	
//	}	
   if(Trim(form.Fathers_Name.value).length < 1)
	{
		alert("Enter Contact Person ")
		form.Fathers_Name.select()
		form.Fathers_Name.focus() 
		 
		return false	
	}
	if(Trim(form.Fathers_Name.value).length > 50)
	{		
		alert("Maximum allowed length of Father's Name is 50 !!!")
		form.Fathers_Name.select()
		form.Fathers_Name.focus() 
		 
		return false	
	}	
//	if(Trim(form.Mothers_Name.value).length > 50)
//	{		
//		alert("Maximum allowed length of Mother's Name is 50 !!!")
//		form.Mothers_Name.select()
//		form.Mothers_Name.focus() 
//		 
//		return false	
//	}	
	if(Trim(form.Address.value).length < 1)
	{
		alert("Enter Address")
		form.Address.select()
		form.Address.focus() 
		 
		return false	
	}	
	if(Trim(form.Address.value).length > 250)
	{		
		alert("Maximum allowed length of Address is 250 !!!")
		form.Address.select()
		form.Address.focus() 
		 
		return false	
	}			
//	if(Trim(form.OfficialAddress.value).length > 200)
//	{		
//		alert("Maximum allowed length of Official Address is 200 !!!")
//		form.OfficialAddress.select()
//		form.OfficialAddress.focus() 
//		 
//		return false	
//	}
	//email validation	
		
//	if(Trim(form.email.value).length < 1)
//	{
//		alert("Enter Email")
//		form.email.select()
//		form.email.focus() 
//		 
//		return false	
//	}
//	else if(Trim(form.email.value).length > 50)
//	{		
//		alert("Maximum allowed length of Email is 50 !!!")
//		form.email.select()
//		form.email.focus() 
//		 
//		return false	
//	}		
//	else
//	{
//		if (checkemail(form.email.value) == false )
//		{
//			form.email.select()
//			form.email.focus() 			
//			return false
//		}	
//		
//	}

	if(Trim(form.Phone.value).length < 1)
	{		
		alert("Enter Phone")
		form.Phone.select()
		form.Phone.focus() 
		 
		return false	
	}
	
	if(Trim(form.Phone.value).length > 50)
	{		
		alert("Maximum allowed length of Phone is 50 !!!")
		form.Phone.select()
		form.Phone.focus() 
		 
		return false	
	}
				
	if(Trim(form.BriefDetails.value).length > 400)
	{		
		alert("Maximum allowed length of Brief Details is 400 !!!")
		form.BriefDetails.select()
		form.BriefDetails.focus() 
		 
		return false	
	}	
	
	if(Trim(form.Other_Details.value).length > 400)
	{		
		alert("Maximum allowed length of About Yourself is 400 !!!")
		form.Other_Details.select()
		form.Other_Details.focus() 
		 
		return false	
	}	
	
//	if(Trim(form.Birth_Place.value).length > 100)
//	{		
//		alert("Maximum allowed length of Birth Place is 100 !!!")
//		form.Birth_Place.select()
//		form.Birth_Place.focus() 
//		 
//		return false	
//	}	

/*	if(Trim(form.Age1.value).length < 1)
	{		
		alert("Select Demand Age !!!")
		form.Age1.focus() 		 
		return false	
	}
	if(Trim(form.Age2.value).length < 1)
	{		
		alert("Select Demand Age !!!")
		form.Age2.focus() 		 
		return false	
	}
	if(Trim(form.DHeight1.value).length < 1)
	{		
		alert("Select Demand Height !!!")
		form.DHeight1.focus() 		 
		return false	
	}
	if(Trim(form.DHeight2.value).length < 1)
	{		
		alert("Select Demand Height !!!")
		form.DHeight2.focus() 		 
		return false	
	}
	
	
	if(Trim(form.Demand_Marital_Status.value).length < 1)
	{		
		alert("Select Demand Marital Status !!!")
		form.Demand_Marital_Status.focus() 		 
		return false	
	}	*/
/*	if(Trim(form.Demand_Job_Category.value).length < 1)
	{		
		alert("Select Demand Job Category !!!")
		form.Demand_Job_Category.focus() 		 
		return false	
	}	
	if(Trim(form.Demand_Education_Level.value).length < 1)
	{		
		alert("Select Demand Education Level !!!")
		form.Demand_Education_Level.focus() 		 
		return false	
	}*/	
	try{
	if(Trim(form.DemandJobDescription.value).length > 400)
	{		
		alert("Maximum allowed length of Demand Job Description is 400 !!!")
		form.DemandJobDescription.select()
		form.DemandJobDescription.focus() 
		 
		return false	
	}	
	}catch(ee){}
	try{
	    if(Trim(form.DemandFamilyStatus.value).length > 400)
	    {		
		    alert("Maximum allowed length of Demand Family Status is 400 !!!")
		    form.DemandFamilyStatus.select()
		    form.DemandFamilyStatus.focus() 
    		 
		    return false	
	    }	
    }catch(ee){}
    try{
	    if(Trim(form.DemandOther.value).length > 400)
	    {		
		    alert("Maximum allowed length of DemandOther is 400 !!!")
		    form.DemandOther.select()
		    form.DemandOther.focus() 
    		 
		    return false	
	    }		
	 }catch(ee){}
	 
	 try{
	    if(Trim(form.username.value).length < 4)
	    {		
		    alert("Username must have minimum 4 letters")
		    form.username.select()
		    form.username.focus() 
    		 
		    return false	
	    }	
	}catch(ee){}
	try{
	if(Trim(form.username.value).length > 20)
	{		
		alert("Username do not allowed to exceed 20 letters")
		form.username.select()
		form.username.focus() 
		 
		return false	
	}	
	}catch(ee){}
	 try{
	if(Trim(form.Password.value).length < 4)
	{		
		alert("Password must have minimum 4 letters")
		form.Password.select()
		form.Password.focus() 
		 
		return false	
	}	
	}catch(ee){}
	 try{	
	if(Trim(form.Password.value).length > 20)
	{		
		alert("Password do not allowed to exceed 20 letters")
		form.Password.select()
		form.Password.focus() 
		 
		return false	
	}
	}catch(ee){}
	 
	 
    try{	
	if(form.Password.value!=form.Passconfirm.value)
	{		
		alert("Password Must Match")
		form.Passconfirm.select()
		form.Passconfirm.focus() 
		return false	
	}
	}catch(ee){}
	
	//5 email validation
	//first email
	
	if(form.agree.checked==false)
	{
		alert("\n Please agree the terms and conditions   !!! ")
		form.agree.focus() 
		return false
	}
/*		
	if(form.agree.checked == false)
	{
		alert("\n Please agree the terms and conditions of mynriservices.com  !!! ")
		return false
	}*/			
	form.submit();
	return true			
}

function ManageChildrens(name1,name2)
{

	if(name1.value=="Never married" || name1.value=="")
	{
		name2.disabled = true
		//name3.disabled = true
	}
	else
	{
		name2.disabled = false
		//name3.disabled = false
	}

}

function ManageDistricts(name1,name2,name3)
{

	if(name1.value=="Kerala")
	{
		name2.disabled = false
		name2.style.display = 'block';
		name3.value = ""
		name3.disabled = true
		name3.style.display = 'none';
	}
	else
	{
		name2.disabled = true
		name2.style.display = 'none';
		name3.value = ""
		name3.disabled = false
		name3.style.display = 'block';
	}

}

function ManagePlaceOfWork(name1,name2)
{

	if( (name1.value != "Kerala") && (name1.value != "INDIA") && (name1.value != ""))
	{
		name2.disabled = false
		name2.style.display = 'block';		
	}
	else
	{
		name2.disabled = true
		name2.style.display = 'none';		
	}

}

function ManageHoroscope(name1,name2)
{

	if(name1.value=="Hindu")
	{
		name2.disabled = false
		name2.style.display = 'block';		
	}
	else
	{
		name2.disabled = true
		name2.style.display = 'none';	
	}

}

function ManageDemandJadhakam(rel,DJadhakam)
{
	if(rel.value=="Hindu")
	{
		DJadhakam.disabled = false
	}
	else
	{
		DJadhakam.disabled = true
	}	
}

function ChangeDemandJadhakam(TJadhakam,DJadhakam)
{
	DJadhakam.disabled = false
	DJadhakam.value = TJadhakam.value
}

function ManagePartnerReligion(rel,prel) 
{
	prel.value = rel.value
}

function checkemail(strEmail)
{
	var str= strEmail
	var filter=/^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i
	if (filter.test(str))
	return true
	else
	{
		alert("Please input a valid email address!")
		return false
	}
}

function searchSpace(name)
{
	var str = name.value
	
	if( str.indexOf(" ",0) >= 0 )
	{
		alert ("Please do not use any space.");
		name.focus();
		name.select();
		return false;
	}
	else
	{return true;}
}
function LTrim(str)
{
        var whitespace = new String(" \t\n\r ");
        // last space character is not a space, but alt+0160,
        // another invisible char.
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(0)) != -1) {
            // We have a string with leading blank(s)...
            var j=0, i = s.length;
            // Iterate from the far left of string until we
            // don't have any more whitespace...
            while (j < i && whitespace.indexOf(s.charAt(j)) != -1)
                j++;
            // Get the substring from the first non-whitespace
            // character to the end of the string...
            s = s.substring(j, i);
        }
        return s;
}
// Trims all spaces to the right of a specific string
function RTrim(str)
{
        // We don't want to trip JUST spaces, but also tabs,
        // line feeds, etc.  Add anything else you want to
        // "trim" here in whitespace
        var whitespace = new String(" \t\n\r ");
        // last space character is not a space, but alt+0160,
        // another invisible char.
        var s = new String(str);
        if (whitespace.indexOf(s.charAt(s.length-1)) != -1) {
            // We have a string with trailing blank(s)...
            var i = s.length - 1;       // Get length of string
            // Iterate from the far right of string until we
            // don't have any more whitespace...
            while (i >= 0 && whitespace.indexOf(s.charAt(i)) != -1)
                i--;
            // Get the substring from the front of the string to
            // where the last non-whitespace character is...
            s = s.substring(0, i+1);
        }
        return s;
}
                                                                                                                        
// Trims all spaces to the left and right of a specific string by calling RTim
// and LTrim
function Trim(str)
{
        return RTrim(LTrim(str));
}
