//validate search form
function ValidationSearch(DocumentForm) {
	var LookingFor = DocumentForm.LookingFor.value;
	var Country = DocumentForm.Country.value;
	var AgeFrom = DocumentForm.AgeFrom.value;
	var AgeTo = DocumentForm.AgeTo.value;
	var PhotoMust = DocumentForm.PhotoMust.checked;
	var Occupation = DocumentForm.Occupation.value;
	var Community = DocumentForm.Community.value;
	var Religion = DocumentForm.Religion.value;
	
	if (LookingFor || Country || AgeFrom || AgeTo || PhotoMust || Occupation || Community || Religion) {
		if (AgeFrom == "ALL" || AgeTo == "ALL") {
			alert ("Select age FROM - TO");
			return false;
		}
		if (AgeFrom != AgeTo && AgeFrom > AgeTo) {
			alert ("Select age FROM - TO");
			DocumentForm.AgeFrom.selectedIndex = 0;
			DocumentForm.AgeTo.selectedIndex = 0;
			DocumentForm.AgeFrom.focus();
			return false;
		} 
	} else {
		alert ("Empty criteria not acceptable");
		return false;
	}
}

//validate advance search form
function ValidationAdvSearch(DocumentForm) {
	var MemberId = DocumentForm.MemberId.value;
	var FirstName = DocumentForm.FirstName.value;
	var LastName = DocumentForm.LastName.value;
	var LookingFor = DocumentForm.LookingFor.value;
	var Country = DocumentForm.Country.value;
	var Occupation = DocumentForm.Occupation.value;
	var Community = DocumentForm.Community.value;
	var Religion = DocumentForm.Religion.value;
	var Language = DocumentForm.Language.value;
	var Address = DocumentForm.Address.value;
	var Mobile = DocumentForm.Mobile.value;
	var Education = DocumentForm.Education.value
	
	if (MemberId || FirstName || LastName || LookingFor || Country || Occupation || Community || Religion || Language || Address || Mobile || Education) {
		return true;
	} else {
		alert ("Empty criteria not acceptable");
		return false;
	}
}

function validate_email(value)
{
	apos=value.indexOf("@");
	dotpos=value.lastIndexOf(".");
	no_of_ats = value.split("@").length-1;
	if (apos<1||dotpos-apos<2||no_of_ats>1) 
	{
	return false;
	}
	else
	{
	return true;
	}
}

function validatePvtmsg(frm) {
	/*if (frm.toaddress.value=="")
	{
		alert("Enter To Address");
		frm.toaddress.focus();
		return false;
	}
	else if (!(validate_email(frm.toaddress.value)))
	{
		alert("Enter a valid Email");
		frm.toaddress.value = "";
		frm.toaddress.focus();
		return false;
	}*/
	if (frm.subject.value=="")
	{
		alert("Enter Subject");
		frm.subject.focus();
		return false;
	}
	if (frm.messagebody.value=="")
	{
		val = confirm("Your message is empty.\n Are you sure to send anyway?");
		frm.messagebody.focus();
		return val;
	}
}
