// JavaScript Document
function setMenuItem() {
	category = document.forms[0].category.options[document.forms[0].category.selectedIndex].value;
	hashIndex = category.indexOf("#");
	if(hashIndex < 0){
		anchorName = "";
		document.forms[0].submit();
	}
	else{
		anchorName = category.substr(hashIndex, category.length);
		window.location.href = anchorName;
	}
}

function closeWindow() {
	parent.window.opener.window.focus();
	parent.window.close();
}

function printWindow() {
	window.print();
}

function checkFeedBack() {
	document.feedback.firstName.value = trimSpaces(document.feedback.firstName.value);
	if(document.feedback.firstName.value.length <= 0) {
		alert("Please enter your first name");
		document.feedback.firstName.focus();
		return false;
	}
	document.feedback.lastName.value = trimSpaces(document.feedback.lastName.value);
	if(document.feedback.lastName.value.length <= 0) {
		alert("Please enter your last name");
		document.feedback.lastName.focus();
		return false;
	}

	document.feedback.email.value = trimSpaces(document.feedback.email.value);
	if(document.feedback.email.value.length <= 0) {
		alert("Please enter your email address");
		document.feedback.email.focus();
		return false;
	}
	if(!checkEmail(document.feedback.email.value)) {
		document.feedback.email.focus();
		document.feedback.email.select();
		return false;
	}
	document.feedback.frmAction.value = "update";
}

function checkFeedBack1() {
	document.forms[1].visitorName.value = trimSpaces(document.forms[1].visitorName.value);
	if(document.forms[1].visitorName.value.length <= 0) {
		alert("Please enter your name");
		document.forms[1].visitorName.focus();
		return false;
	}

	document.forms[1].emailAddress.value = trimSpaces(document.forms[1].emailAddress.value);
	if(document.forms[1].emailAddress.value.length <= 0) {
		alert("Please enter your email address");
		document.forms[1].emailAddress.focus();
		return false;
	}
	if(!checkEmail(document.forms[1].emailAddress.value)) {
		document.forms[1].emailAddress.focus();
		document.forms[1].emailAddress.select();
		return false;
	}

	document.forms[1].visitorComments.value = trimSpaces(document.forms[1].visitorComments.value);
	if(document.forms[1].visitorComments.value.length <= 0) {
		alert("Please enter your comments");
		document.forms[1].visitorComments.focus();
		return false;
	}
	document.forms[1].frmAction.value = "update";
}

function showPicture(gid,cid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showPicture.php?galleryid=" + gid + "&category=" +cid, "picture", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}


function checkField2(page)
  {
	if(document.loginForm.userName.value.length <= 0) 
	{ 
	alert("Enter Email"); 
	document.loginForm.userName.focus();
	if(page=="home")
		return false; 
	else
	     return false;
	}
	if(document.loginForm.password.value.length <= 0) 
	{ 
	alert("Enter the password"); 
	document.loginForm.password.focus();
	if(page=="home")
		return false; 
	else
	     return false;
	}
	if(page=="home")
	document.loginForm.action = "php/userLogin.php";
	else
	document.loginForm.action = "userLogin.php";
	document.loginForm.frmAction.value="login";
	document.loginForm.submit();
	
 }
 
 
 function doSearch()
 {
 
 ageFrom = parseInt(document.loginForm.ageFrom.value);
 ageTo = parseInt(document.loginForm.ageTo.value);
 	if(ageFrom > ageTo) 
	{ 
	alert("Invalid From & To Age"); 
	document.loginForm.ageTo.focus();
	return false;
   }
 
 	document.loginForm.action = "php/search_results.php";
	document.loginForm.submit();
 }
 
function checkListing()
{

	document.forms[0].lastName.value=trimSpaces(document.forms[0].lastName.value);
	if(document.forms[0].lastName.value.length<=0)
	 {
	 	alert("Enter your Last Name");
		document.forms[0].lastName.focus();
		return false;
	 }

	document.forms[0].firstName.value=trimSpaces(document.forms[0].firstName.value);
	if(document.forms[0].firstName.value.length<=0)
	 {
	 	alert("Enter your First Name");
		document.forms[0].firstName.focus();
		return false;
	 }
	 
	document.forms[0].street.value=trimSpaces(document.forms[0].street.value);
	if(document.forms[0].street.value.length<=0)
	 {
	 	alert("Enter your street");
		document.forms[0].street.focus();
		return false;
	 }

	   	
	document.forms[0].apartment.value=trimSpaces(document.forms[0].apartment.value);
	if(document.forms[0].apartment.value.length<=0)
	 {
	 	alert("Enter your Apartment");
		document.forms[0].apartment.focus();
		return false;
	 }

	   	
	   	
	document.forms[0].city.value=trimSpaces(document.forms[0].city.value);
	if(document.forms[0].city.value.length<=0)
	 {
	 	alert("Enter your City");
		document.forms[0].city.focus();
		return false;
	 }

	   	
	   	
	document.forms[0].state.value=trimSpaces(document.forms[0].state.value);
	if(document.forms[0].state.value.length<=0)
	 {
		if(document.forms[0].state1.value.length<=0)
		 {
			alert("Enter your State");
			document.forms[0].state1.focus();
			return false;
		 }
		 else if(document.forms[0].country.value=="US")
		 {
			alert("Select your country");
			document.forms[0].country.focus();
			return false;
		 }
	 }

	document.forms[0].phone.value=trimSpaces(document.forms[0].phone.value);
	if(document.forms[0].phone.value.length<=0)
	 {
	 	alert("Enter your Phone");
		document.forms[0].phone.focus();
		return false;
	 }

   	
	document.forms[0].email.value=trimSpaces(document.forms[0].email.value);
	if(document.forms[0].email.value.length<=0)
	 {
	 	alert("Enter Email Id");
		document.forms[0].email.focus();
		return false;
	 }
	else
	 {
	   if(!checkEmail(document.forms[0].email.value))
	   {
		document.forms[0].email.focus();
	    return false;
	   }
	 }  	 
	 
	document.forms[0].frmAction.value="update";
	document.forms[0].submit();
}

function submitSearch(page)
{
	if(page == 'home') {
		val = 'php/';
	}else {val = '';}
	searchKey = trimSpaces(document.search.searchKey.value);
	if(searchKey == '') {
		alert("Enter search string");
		document.search.searchKey.focus();
		return;
	}
	//document.search.action = "displaySearch.php?searchKey=" + searchKey;
	document.search.action = val+"displaySearch.php";
	document.search.submit();
}
function checkKey(page){
	if(window.event.keyCode == 13) {
		if(page == 'home') {
			val = 'php/';
		}else {val = '';}

		searchKey = trimSpaces(document.search.searchKey.value);
		if(searchKey == '') {
			alert("Enter search string");
			document.search.searchKey.focus();
			return false;
		}else {
			document.search.action = val+"displaySearch.php";
			document.search.submit();
		}		
	}
}
function validateFields(from)
{
user_name=trimSpaces(document.loginform.user_name.value);
password=trimSpaces(document.loginform.password.value);
if(user_name.length<=0)
	{
	  alert("Enter the user name");
	  document.loginform.user_name.focus();
	 if(from=="home")
	   return;
	 else
	   return false;
	}
if(password.length<=0)
	{
	  alert("Enter the password");
	  document.loginform.password.focus();
	 if(from=="home")
	   return;
	 else
	   return false;
	}
	document.loginform.frmAction.value="login";
	document.loginform.submit();
}

function showEventPicture(imgURL, imgType) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	if(imgType == "photo") {
		winWidth = 400;
		winHeight = 400;
	}
	else {
		winWidth = 125;
		winHeight = 100;
	}
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showeventPicture.php?imgURL=" + imgURL, "photograph", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}
function showCalendar1(frmElement, dispElement) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 375;
	winHeight = 300;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showCalendar1.php?frmElement=" + frmElement + "&dispElement=" + dispElement, "Calendar", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");
	return;
}

function openDynWindow(url) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 700;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open(url, "News", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}

function openDynWindow1(url,width,height) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = width;
	winHeight = height;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	window.open(url, "News", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function valRegistration1()
{
profile_id = trimSpaces(document.forms[1].profile_id.value);
email = trimSpaces(document.forms[1].email.value);
email_confirm = trimSpaces(document.forms[1].email_confirm.value);
password = trimSpaces(document.forms[1].password.value);
password_confirm = trimSpaces(document.forms[1].password_confirm.value);

relationship = document.forms[1].relationship.options[document.forms[1].relationship.selectedIndex].value;
if (relationship == "")
{
	  alert("Please choose who is creating the profile");
	  document.forms[1].relationship.focus();
	  return false;
}

if (profile_id.length <4 )
{
	  alert("Please enter Profile ID with minimum 4 characters.\n No special characters are alowed.");
	  document.forms[1].profile_id.focus();
	  return false;
}
if(!checkAllowedChars(profile_id,'AN_'))
{
	  alert("Special characters are not alowed");
	  document.forms[1].profile_id.focus();
	  return false;
}

if (email.length <= 0 )
{
	  alert("Please enter your email.");
	  document.forms[1].email.focus();
	  return false;
}

	if(!checkEmail(document.forms[1].email.value))
	{
	document.forms[1].email.focus();
	return false;
	}

if (email_confirm.length <= 0 )
{
	  alert("Please confirm your email.");
	  document.forms[1].email_confirm.focus();
	  return false;
}

if (email != email_confirm )
{
	  alert("Please re-enter correct email.");
	  document.forms[1].email_confirm.focus();
	  return false;
}

if (password.length <4 )
{
	  alert("Please enter your password with minimum 4 characters.");
	  document.forms[1].password.focus();
	  return false;
}

if (password_confirm.length <= 0 )
{
	  alert("Please confirm your password.");
	  document.forms[1].password_confirm.focus();
	  return false;
}
if (password != password_confirm )
{
	  alert("Please re-enter correct password.");
	  document.forms[1].password_confirm.focus();
	  return false;
}


chFlag = false;
for(i=0; i < document.forms[1].gender.length ;i++)
{
if(document.forms[1].gender[i].checked)
chFlag = true;
}

if (!chFlag)
{
	  alert("Please select gender.");
	  return false;
}

dd = document.forms[1].pick_day.options[document.forms[1].pick_day.selectedIndex].value;
mm = document.forms[1].pick_month.options[document.forms[1].pick_month.selectedIndex].value;
yy = document.forms[1].pick_year.options[document.forms[1].pick_year.selectedIndex].value;

if (!checkDate(dd,mm,yy))
return false;
document.forms[1].frmAction.value="update";
}


function setCategory(chooser,dbElement,frmElement)  
{
	var categoryChooser = chooser.form.elements[frmElement];
    // empty previous settings 
	
    categoryChooser.options.length = 0;
    // get chosen value to act as index to regiondb hash table
	var choice = chooser.options[chooser.selectedIndex].value;
	
	var db = dbElement[choice];
	// insert default first item
	categoryChooser.options[0] = new Option("Select", ""); //new Option("Select one", "");
	categoryChooser.options[1] = new Option("Doesn't matter", "");

	if (choice != "") 
	{
		// loop through array of the hash table entry, and populate options
	   if(dbElement[choice])
	   {
			for (var i = 0; i < db.length; i++) 
			{            
				categoryChooser.options[i + 2] = new Option(db[i].text, db[i].value);
			}
		}		
	}
	categoryChooser.selectedIndex = 0;

	obj = eval(chooser);
	
	if(obj.options[obj.selectedIndex].text == "Select" || obj.options[obj.selectedIndex].text == 'Other' || obj.options[obj.selectedIndex].text == 'No Religion' || obj.options[obj.selectedIndex].text == 'Spiritual - not religious')

	{
		document.forms[1].usr_caste.disabled = true;
	}
	else
	 {
		document.forms[1].usr_caste.disabled = false;
	} 
	
}

function resetReligion()
{
	if(typeof religionDb == 'object') 
	{
		setCategory(document.forms[1].usr_religion,religionDb,'usr_caste');
	}
	/*
	if(typeof stateDb == 'object') 
	{
		setCategory(document.forms[1].stateId,stateDb,'cityId');
	}*/
}
// function to reset the caste drop down 
function resetCaste()
{
	if(typeof religionDb == 'object') 
	{
		setCategory(document.forms[1].stateId,stateDb,'cityId');
	}
}

function taLimit() {
	var taObj=event.srcElement;
	if (taObj.value.length==taObj.maxLength*1) return false;
}

function taCount(textname,no) { 
	var taObj=event.srcElement;
	if (taObj.value.length>taObj.maxLength*1) taObj.value=taObj.value.substring(0,taObj.maxLength*1);
	document.profile.elements[textname].value=taObj.value.length;
	if(taObj.value.length==taObj.maxLength*1) alert("You can enter only "+no+" characters");

}
function init()
{
ifcountry_india_usa(document.profile.country)
}


function ifcountry_india_usa(obj){

		if(obj.options[obj.selectedIndex].text == 'India'){
		document.profile.state_india.disabled = false;
		
		document.profile.state_usa[0].selected = true;
		document.profile.state_usa.disabled = true;

		document.profile.state_others.value = ""; 
		document.profile.state_others.disabled = true; 

		return true;
	}
	else
		if(obj.options[obj.selectedIndex].text == 'United States' ){
			document.profile.state_india[0].selected = true;
			document.profile.state_india.disabled = true;
			
			document.profile.state_usa.disabled = false;

			document.profile.state_others.value = ""; 
			document.profile.state_others.disabled = true; 

			return true;
		}
		else{
			document.profile.state_others.disabled = false; 

			document.profile.state_usa[0].selected = true;
			document.profile.state_usa.disabled = true;

			document.profile.state_india[0].selected = true;
			document.profile.state_india.disabled = true;

			return true;
		}
}


function valRegistration2()
{
relationship = document.forms[1].relationship.options[document.forms[1].relationship.selectedIndex].value;
usr_height = document.forms[1].usr_height.options[document.forms[1].usr_height.selectedIndex].value;
usr_handicap = document.forms[1].usr_handicap.options[document.forms[1].usr_handicap.selectedIndex].value;
usr_religion = document.forms[1].usr_religion.options[document.forms[1].usr_religion.selectedIndex].value;
usr_mother_tongue = document.forms[1].usr_mother_tongue.options[document.forms[1].usr_mother_tongue.selectedIndex].value;
usr_education = document.forms[1].usr_education.options[document.forms[1].usr_education.selectedIndex].value;
usr_occupation = document.forms[1].usr_occupation.options[document.forms[1].usr_occupation.selectedIndex].value;



if (relationship == "")
{
	  alert("Please choose who is creating the profile");
	  document.forms[1].relationship.focus();
	  return false;
}

dd = document.forms[1].pick_day.options[document.forms[1].pick_day.selectedIndex].value;
mm = document.forms[1].pick_month.options[document.forms[1].pick_month.selectedIndex].value;
yy = document.forms[1].pick_year.options[document.forms[1].pick_year.selectedIndex].value;

if (!checkDate(dd,mm,yy))
return false;


usr_marital_statusF = false;
for(i=0; i < document.forms[1].usr_marital_status.length ;i++)
{
if(document.forms[1].usr_marital_status[i].checked)
usr_marital_statusF = true;
}
if (!usr_marital_statusF)
{
	  alert("Please select Marital status.");
	  document.forms[1].usr_marital_status[0].focus();
	  return false;
}


usr_childrenF = false;
for(i=0; i < document.forms[1].usr_children.length ;i++)
{
if(document.forms[1].usr_children[i].checked)
usr_childrenF = true;
}
if (!usr_childrenF)
{
	  alert("Please select Have children.");
	  document.forms[1].usr_children[0].focus();
	  return false;
}


if (usr_height == "")
{
	  alert("Please select height");
	  document.forms[1].usr_height.focus();
	  return false;
}

usr_body_typeF = false;
for(i=0; i < document.forms[1].usr_body_type.length ;i++)
{
if(document.forms[1].usr_body_type[i].checked)
usr_body_typeF = true;
}
if (!usr_body_typeF)
{
	  alert("Please select Body type.");
	  document.forms[1].usr_body_type[0].focus();
	  return false;
}


usr_complexionF = false;
for(i=0; i < document.forms[1].usr_complexion.length ;i++)
{
if(document.forms[1].usr_complexion[i].checked)
usr_complexionF = true;
}
if (!usr_complexionF)
{
	  alert("Please select Complexion.");
	  document.forms[1].usr_complexion[0].focus();
	  return false;
}

if (usr_handicap == "")
{
	  alert("Please select Special cases");
	  document.forms[1].usr_handicap.focus();
	  return false;
}

if (usr_religion == "")
{
	  alert("Please select Religion");
	  document.forms[1].usr_religion.focus();
	  return false;
}

if (usr_mother_tongue == "")
{
	  alert("Please select Mother Tongue");
	  document.forms[1].usr_mother_tongue.focus();
	  return false;
}

usr_family_valuesF = false;
for(i=0; i < document.forms[1].usr_family_values.length ;i++)
{
if(document.forms[1].usr_family_values[i].checked)
usr_family_valuesF = true;
}
if (!usr_family_valuesF)
{
	  alert("Please select Family values.");
	  document.forms[1].usr_family_values[0].focus();
	  return false;
}

if (usr_education == "")
{
	  alert("Please select Education");
	  document.forms[1].usr_education.focus();
	  return false;
}

if (usr_occupation == "")
{
	  alert("Please select Occupation");
	  document.forms[1].usr_occupation.focus();
	  return false;
}

usr_dietF = false;
for(i=0; i < document.forms[1].usr_diet.length ;i++)
{
if(document.forms[1].usr_diet[i].checked)
usr_dietF = true;
}
if (!usr_dietF)
{
	  alert("Please select Diet.");
	  document.forms[1].usr_diet[0].focus();
	  return false;
}


usr_smokeF = false;
for(i=0; i < document.forms[1].usr_smoke.length ;i++)
{
if(document.forms[1].usr_smoke[i].checked)
usr_smokeF = true;
}
if (!usr_smokeF)
{
	  alert("Please select Smoking habit.");
	  document.forms[1].usr_smoke[0].focus();
	  return false;
}

usr_drinkF = false;
for(i=0; i < document.forms[1].usr_drink.length ;i++)
{
if(document.forms[1].usr_drink[i].checked)
usr_drinkF = true;
}
if (!usr_drinkF)
{
	  alert("Please select Drinking habit.");
	  document.forms[1].usr_drink[0].focus();
	  return false;
}

country = document.forms[1].country.options[document.forms[1].country.selectedIndex].value;
state_india = document.forms[1].state_india.options[document.forms[1].state_india.selectedIndex].value;
state_usa = document.forms[1].state_usa.options[document.forms[1].state_usa.selectedIndex].value;
state_others = trimSpaces(document.forms[1].state_others.value);

if (country == "IN" && state_india == "")
{
	  alert("Please select State.");
	  document.forms[1].state_india.focus();
	  return false;

}

if (country == "US" && state_usa == "")
{
	  alert("Please select State.");
	  document.forms[1].state_usa.focus();
	  return false;

}

if (country != "IN" && country != "US"  && state_others == "")
{
	  alert("Please enter state.");
	  document.forms[1].state_others.focus();
	  return false;
}

residency_statusF = false;
for(i=0; i < document.forms[1].residency_status.length ;i++)
{
if(document.forms[1].residency_status[i].checked)
residency_statusF = true;
}
if (!residency_statusF)
{
	  alert("Please select Residency Status.");
	  document.forms[1].residency_status[0].focus();
	  return false;
}

usr_desc = trimSpaces(document.forms[1].usr_desc.value);
usr_family_bg = trimSpaces(document.forms[1].usr_family_bg.value);

if (usr_desc.length <100)
{
	  alert("Personal description should contain a minimum 1of 00 characters");
	  document.forms[1].usr_desc.focus();
	  return false;
}

if (usr_desc.length >4000)
{
	  alert("Personal description can't contain more than 4000 characters");
	  document.forms[1].usr_desc.focus();
	  return false;
}

if (usr_family_bg.length <100)
{
	  alert("Family background should contain a minimum of 100 characters");
	  document.forms[1].usr_family_bg.focus();
	  return false;
}

if (usr_desc.length >1000)
{
	  alert("Family background can't contain more than 1000 characters");
	  document.forms[1].usr_family_bg.focus();
	  return false;
}
document.forms[1].frmAction.value="update";
}


function valAccount()
{
email = trimSpaces(document.forms[1].email.value);
password = trimSpaces(document.forms[1].password.value);
password_new = trimSpaces(document.forms[1].password_new.value);
password_new_confirm =  trimSpaces(document.forms[1].password_new_confirm.value);

if (email.length <= 0 )
{
	  alert("Please enter your email.");
	  document.forms[1].email.focus();
	  return false;
}

if(!checkEmail(document.forms[1].email.value))
{
document.forms[1].email.focus();
return false;
}

if (password.length > 0 )
{

	if (password_new.length < 4 )
	{
		  alert("Please enter your new password with minimun 4 characters.");
		  document.forms[1].password_new.focus();
		  return false;
	}
	
	if (password_new_confirm <= 0 )
	{
		  alert("Please re-enter your new password.");
		  document.forms[1].password_new_confirm.focus();
		  return false;
	}
	
	if (password_new != password_new_confirm )
	{
		  alert("Please re-enter correct password.");
		  document.forms[1].password_new_confirm.focus();
		  return false;
	}
}
	
document.forms[1].frmAction.value = "update";

}
function showPhoto(iconUrl) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 300;
	winHeight = 300;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	
	window.open("showPhoto.php?iconUrl=" + iconUrl,"iconURL","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");
}

function removePhoto() {
		if(confirm("Do you really want to delete your photo?")) {
			document.forms[1].frmAction.value = "removePhoto";
			document.forms[1].submit();
		}
		else {
			return;
		}
}


function valEditProfile()
{
relationship = document.forms[1].relationship.options[document.forms[1].relationship.selectedIndex].value;
usr_height = document.forms[1].usr_height.options[document.forms[1].usr_height.selectedIndex].value;
usr_handicap = document.forms[1].usr_handicap.options[document.forms[1].usr_handicap.selectedIndex].value;
usr_religion = document.forms[1].usr_religion.options[document.forms[1].usr_religion.selectedIndex].value;
usr_mother_tongue = document.forms[1].usr_mother_tongue.options[document.forms[1].usr_mother_tongue.selectedIndex].value;
usr_education = document.forms[1].usr_education.options[document.forms[1].usr_education.selectedIndex].value;
usr_occupation = document.forms[1].usr_occupation.options[document.forms[1].usr_occupation.selectedIndex].value;



if (relationship == "")
{
	  alert("Please choose who is creating the profile");
	  document.forms[1].relationship.focus();
	  return false;
}

dd = document.forms[1].pick_day.options[document.forms[1].pick_day.selectedIndex].value;
mm = document.forms[1].pick_month.options[document.forms[1].pick_month.selectedIndex].value;
yy = document.forms[1].pick_year.options[document.forms[1].pick_year.selectedIndex].value;

if (!checkDate(dd,mm,yy))
return false;


if (usr_height == "")
{
	  alert("Please select height");
	  document.forms[1].usr_height.focus();
	  return false;
}

if (usr_handicap == "")
{
	  alert("Please select Special cases");
	  document.forms[1].usr_handicap.focus();
	  return false;
}

if (usr_religion == "")
{
	  alert("Please select Religion");
	  document.forms[1].usr_religion.focus();
	  return false;
}

if (usr_mother_tongue == "")
{
	  alert("Please select Mother Tongue");
	  document.forms[1].usr_mother_tongue.focus();
	  return false;
}


if (usr_education == "")
{
	  alert("Please select Education");
	  document.forms[1].usr_education.focus();
	  return false;
}

if (usr_occupation == "")
{
	  alert("Please select Occupation");
	  document.forms[1].usr_occupation.focus();
	  return false;
}


country = document.forms[1].country.options[document.forms[1].country.selectedIndex].value;
state_india = document.forms[1].state_india.options[document.forms[1].state_india.selectedIndex].value;
state_usa = document.forms[1].state_usa.options[document.forms[1].state_usa.selectedIndex].value;
state_others = trimSpaces(document.forms[1].state_others.value);

if (country == "IN" && state_india == "")
{
	  alert("Please select State.");
	  document.forms[1].state_india.focus();
	  return false;

}

if (country == "US" && state_usa == "")
{
	  alert("Please select State.");
	  document.forms[1].state_usa.focus();
	  return false;

}

if (country != "IN" && country != "US"  && state_others == "")
{
	  alert("Please enter state.");
	  document.forms[1].state_others.focus();
	  return false;
}

usr_desc = trimSpaces(document.forms[1].usr_desc.value);
usr_family_bg = trimSpaces(document.forms[1].usr_family_bg.value);

if (usr_desc.length <100)
{
	  alert("Personal description should contain a minimum 1of 00 characters");
	  document.forms[1].usr_desc.focus();
	  return false;
}

if (usr_desc.length >4000)
{
	  alert("Personal description can't contain more than 4000 characters");
	  document.forms[1].usr_desc.focus();
	  return false;
}

if (usr_family_bg.length <100)
{
	  alert("Family background should contain a minimum of 100 characters");
	  document.forms[1].usr_family_bg.focus();
	  return false;
}

if (usr_desc.length >1000)
{
	  alert("Family background can't contain more than 1000 characters");
	  document.forms[1].usr_family_bg.focus();
	  return false;
}
document.forms[1].frmAction.value="update";
}


function valAccount()
{
email = trimSpaces(document.forms[1].email.value);
password = trimSpaces(document.forms[1].password.value);
password_new = trimSpaces(document.forms[1].password_new.value);
password_new_confirm =  trimSpaces(document.forms[1].password_new_confirm.value);

if (email.length <= 0 )
{
	  alert("Please enter your email.");
	  document.forms[1].email.focus();
	  return false;
}

if(!checkEmail(document.forms[1].email.value))
{
document.forms[1].email.focus();
return false;
}

if (password.length > 0 )
{

	if (password_new.length < 4 )
	{
		  alert("Please enter your new password with minimun 4 characters.");
		  document.forms[1].password_new.focus();
		  return false;
	}
	
	if (password_new_confirm <= 0 )
	{
		  alert("Please re-enter your new password.");
		  document.forms[1].password_new_confirm.focus();
		  return false;
	}
	
	if (password_new != password_new_confirm )
	{
		  alert("Please re-enter correct password.");
		  document.forms[1].password_new_confirm.focus();
		  return false;
	}
}
	
document.forms[1].frmAction.value = "update";

}
function openCustWindow(href,winWidth,winHeight) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open(href, "Photos", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=yes,resizable=0");
	return;
}

function addPartnerProfile()
{

part_age_from = parseInt(document.forms[1].part_age_from.options[document.forms[1].part_age_from.selectedIndex].value);
part_age_to = parseInt(document.forms[1].part_age_to.options[document.forms[1].part_age_to.selectedIndex].value);
 	if(part_age_from > part_age_to) 
	{ 
	alert("Invalid From & To Age"); 
	document.forms[1].part_age_from.focus();
	return false;
   }


part_height_from = parseInt(document.forms[1].part_height_from.options[document.forms[1].part_height_from.selectedIndex].value);
part_height_to = parseInt(document.forms[1].part_height_to.options[document.forms[1].part_height_to.selectedIndex].value);
 	if(part_height_from > part_height_to) 
	{ 
	alert("Invalid From & To Height"); 
	document.forms[1].part_height_from.focus();
	return false;
   }

document.forms[1].frmAction.value = "update";
}

function doAdvSearch()
{

part_age_from = parseInt(document.forms[1].part_age_from.options[document.forms[1].part_age_from.selectedIndex].value);
part_age_to = parseInt(document.forms[1].part_age_to.options[document.forms[1].part_age_to.selectedIndex].value);
 	if(part_age_from > part_age_to) 
	{ 
	alert("Invalid From & To Age"); 
	document.forms[1].part_age_from.focus();
	return false;
   }


part_height_from = parseInt(document.forms[1].part_height_from.options[document.forms[1].part_height_from.selectedIndex].value);
part_height_to = parseInt(document.forms[1].part_height_to.options[document.forms[1].part_height_to.selectedIndex].value);
 	if(part_height_from > part_height_to) 
	{ 
	alert("Invalid From & To Height"); 
	document.forms[1].part_height_from.focus();
	return false;
   }

}
function getRequest(regn_id) { 
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	winWidth = 300;
	winHeight = 300;
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;  
	window.open("getRequest.php?regn_id=" + regn_id,"","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,resizable=0");
}
function checkrequestUser()
{
name=trimSpaces(document.forms[0].name.value);
email = trimSpaces(document.forms[0].email.value);
if(name.length<=0) 
{
alert("Please enter your name.");
	  document.forms[0].name.focus();
	  return false;
}

if (email.length <= 0 )
{
	  alert("Please enter your email.");
	  document.forms[0].email.focus();
	  return false;
}

if(!checkEmail(document.forms[0].email.value))
{

document.forms[0].email.focus();
return false;
}
document.forms[0].frmAction.value="Send"; 
return true;  
} 