// JavaScript Document
function setMenuItem() {
	category = document.forms[1].category.options[document.forms[1].category.selectedIndex].value;
	hashIndex = category.indexOf("#");
	if(hashIndex < 0){
		anchorName = "";
		document.forms[1].submit();
	}
	else{
		anchorName = category.substr(hashIndex, category.length);
		window.location.href = anchorName;
	}
}

function checkGiftCertificate() {
	senderName = trimSpaces(document.forms[1].senderName.value);
	if(senderName.length <= 0) {
		alert("Plese enter your name");
		document.forms[1].senderName.focus();
		return false;
	}
	
	senderAddress = trimSpaces(document.forms[1].senderAddress.value);
	if(senderAddress.length <= 0) {
		alert("Plese enter your address");
		document.forms[1].senderAddress.focus();
		return false;
	}

	senderCity = trimSpaces(document.forms[1].senderCity.value);
	if(senderCity.length <= 0) {
		alert("Plese enter your city");
		document.forms[1].senderCity.focus();
		return false;
	}
	
	senderState = trimSpaces(document.forms[1].senderState.value);
	if(senderState.length <= 0) {
		alert("Plese enter your state");
		document.forms[1].senderState.focus();
		return false;
	}

	senderZip = trimSpaces(document.forms[1].senderZip.value);
	if(senderZip.length <= 0) {
		alert("Plese enter your ZIP");
		document.forms[1].senderZip.focus();
		return false;
	}
	
	senderPhone = trimSpaces(document.forms[1].senderPhone.value);
	if(senderPhone.length <= 0) {
		alert("Plese enter your telephone number");
		document.forms[1].senderPhone.focus();
		return false;
	}

	senderEmail = trimSpaces(document.forms[1].senderEmail.value);
	if(senderEmail.length <= 0) {
		alert("Plese enter your email address");
		document.forms[1].senderEmail.focus();
		return false;
	}
	if(!checkEmail(senderEmail)) {
		document.forms[1].senderEmail.focus();
		return false;
	}
	
	certificateQuantity = trimSpaces(document.forms[1].certificateQuantity.value);
	certificateAmount = trimSpaces(document.forms[1].certificateAmount.value);
	if(certificateQuantity.length <= 0 && certificateAmount.length <= 0) {
		if(certificateQuantity.length <= 0) {
			alert("Plese enter the certificate quantity");
			document.forms[1].certificateQuantity.focus();
			return false;
		}
		if(certificateAmount.length <= 0) {
			alert("Plese enter the certificate amount");
			document.forms[1].certificateAmount.focus();
			return false;
		}
	}
	
	document.forms[1].frmAction.value = "send";
}

function printCoupon(couponid){
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 700;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showCouponFrame.php?couponid=" + couponid, "printCoupon", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}

function closeWindow() {
	parent.window.opener.window.focus();
	parent.window.close();
}

function printWindow() {
	parent.mainFrame.focus();
	window.print(parent.mainFrame);
}

function checkCouponMail() {
	senderName = trimSpaces(document.forms[1].senderName.value);
	senderEmail = trimSpaces(document.forms[1].senderEmail.value);
	receiverEmail = trimSpaces(document.forms[1].receiverEmail.value);
	if(senderName.length <= 0) {
		alert("You have to enter your name.");
		document.forms[1].senderName.focus();
		return false;
	}
	if(senderEmail.length <= 0) {
		alert("You have to enter your email address.");
		document.forms[1].senderEmail.focus();
		return false;
	}
	if(!checkEmail(senderEmail)) {
		document.forms[1].senderEmail.focus();
		return false;
	}
	if(receiverEmail.length <= 0) {
		alert("You have to enter your friend's email address.");
		document.forms[1].receiverEmail.focus();
		return false;
	}
	if(!checkEmail(receiverEmail)) {
		document.forms[1].receiverEmail.focus();
		return false;
	}
	document.forms[1].frmAction.value = "yes";
}

function checkSubscription(action)
{

 if(action=="sub")
  {
	document.forms[1].lastName.value=trimSpaces(document.forms[1].lastName.value);
	if(document.forms[1].lastName.value.length<=0)
	 {
	 	alert("Enter your Last Name");
		document.forms[1].lastName.focus();
		return false;
	 }

	document.forms[1].firstName.value=trimSpaces(document.forms[1].firstName.value);
	if(document.forms[1].firstName.value.length<=0)
	 {
	 	alert("Enter your First Name");
		document.forms[1].firstName.focus();
		return false;
	 }

	   	
	document.forms[1].email.value=trimSpaces(document.forms[1].email.value);
	if(document.forms[1].email.value.length<=0)
	 {
	 	alert("Enter Email Id");
		document.forms[1].email.focus();
		return false;
	 }
	else
	 {
	   if(!checkEmail(document.forms[1].email.value))
	   {
		document.forms[1].email.focus();
	    return false;
	   }
	 }  	 
	 
	document.forms[1].frmAction.value="update";
	document.forms[1].submit();
 }
 else
  {	
  	document.forms[1].email.value=trimSpaces(document.forms[1].email.value);
	if(document.forms[1].email.value.length<=0)
	 {
	 	alert("Enter Email Id");
		document.forms[1].email.focus();
		return false;
	 }
	else
	 {
	   if(!checkEmail(document.forms[1].email.value))
	   {
	    return false;
	   }
	 }  	 
	 
	document.forms[1].frmAction.value="delete";
	alert();
	document.forms[1].submit();
}
}
function checkFeedBack() {
	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 checkEmailList() {
	
	firstName = trimSpaces(document.forms[1].firstName.value);
	if(firstName.length <= 0) {
		alert("Please enter your name.");
		document.forms[1].firstName.focus();
		return false;
	}
/*	
	lastName = trimSpaces(document.forms[1].lastName.value);
	if(lastName.length <= 0) {
		alert("Please enter your last name.");
		document.forms[1].lastName.focus();
		return false;
	}
*/	
	subscriberEmail = trimSpaces(document.forms[1].subscriberemail.value);
	if(subscriberEmail.length <= 0) {
		alert("Please enter your email.");
		document.forms[1].subscriberemail.focus();
		return false;
	}
	if(subscriberEmail.length > 0){
		if(!checkEmail(subscriberEmail)){
			document.forms[1].subscriberemail.focus();
			return false;
		}
	}
	
	document.forms[1].frmAction.value = "update";

}
function checkField2(page)
  {
	if(document.investor.userName.value.length<=0) 
	{ 
	alert("Enter the user name"); 
	document.investor.userName.focus();
	if(page=="home")
		return; 
	else
	     return false;
	}
	if(document.investor.password.value.length<=0) 
	{ 
	alert("Enter the password"); 
	document.investor.password.focus();
	if(page=="home")
		return; 
	else
	     return false;
	}
	document.investor.frmAction.value="login";
	document.investor.submit();
 }
function checkListing()
{

	document.forms[1].lastName.value=trimSpaces(document.forms[1].lastName.value);
	if(document.forms[1].lastName.value.length<=0)
	 {
	 	alert("Enter your Last Name");
		document.forms[1].lastName.focus();
		return false;
	 }

	document.forms[1].firstName.value=trimSpaces(document.forms[1].firstName.value);
	if(document.forms[1].firstName.value.length<=0)
	 {
	 	alert("Enter your First Name");
		document.forms[1].firstName.focus();
		return false;
	 }
	 
	document.forms[1].street.value=trimSpaces(document.forms[1].street.value);
	if(document.forms[1].street.value.length<=0)
	 {
	 	alert("Enter your street");
		document.forms[1].street.focus();
		return false;
	 }

	   	
	document.forms[1].apartment.value=trimSpaces(document.forms[1].apartment.value);
	if(document.forms[1].apartment.value.length<=0)
	 {
	 	alert("Enter your Apartment");
		document.forms[1].apartment.focus();
		return false;
	 }

	   	
	   	
	document.forms[1].city.value=trimSpaces(document.forms[1].city.value);
	if(document.forms[1].city.value.length<=0)
	 {
	 	alert("Enter your City");
		document.forms[1].city.focus();
		return false;
	 }

	   	
	   	
	document.forms[1].state.value=trimSpaces(document.forms[1].state.value);
	if(document.forms[1].state.value.length<=0)
	 {
		if(document.forms[1].state1.value.length<=0)
		 {
			alert("Enter your State");
			document.forms[1].state1.focus();
			return false;
		 }
		 else if(document.forms[1].country.value=="US")
		 {
			alert("Select your country");
			document.forms[1].country.focus();
			return false;
		 }
	 }

	document.forms[1].phone.value=trimSpaces(document.forms[1].phone.value);
	if(document.forms[1].phone.value.length<=0)
	 {
	 	alert("Enter your Phone");
		document.forms[1].phone.focus();
		return false;
	 }

   	
	document.forms[1].email.value=trimSpaces(document.forms[1].email.value);
	if(document.forms[1].email.value.length<=0)
	 {
	 	alert("Enter Email Id");
		document.forms[1].email.focus();
		return false;
	 }
	else
	 {
	   if(!checkEmail(document.forms[1].email.value))
	   {
		document.forms[1].email.focus();
	    return false;
	   }
	 }  	 
	 
	document.forms[1].frmAction.value="update";
	document.forms[1].submit();
}
 function activate(pic)
 {
	 document.img1.src=pic;
	/* img2.style.visibility='hidden';
	 img3.style.visibility='hidden';
	 img4.style.visibility='hidden';
	 img5.style.visibility='hidden';
 	 img6.style.visibility='hidden';
	 eval(pic+".style.visibility='visible'");*/
 }
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 checkUserForm()
{
firstName=trimSpaces(document.regform.first_name.value);
lastName=trimSpaces(document.regform.last_name.value);
user_name=trimSpaces(document.regform.user_name.value);
password=trimSpaces(document.regform.password.value);
email=trimSpaces(document.regform.email.value);
if(firstName.length<=0)
{
  alert("Enter your first name");
  document.regform.first_name.focus();
   return false;
}
if(lastName.length<=0)
{
  alert("Enter your last name");
  document.regform.last_name.focus();
   return false;
}
if(email.length<=0)
 {
  alert("Please enter the email");
  document.forms[1].email.focus();
  return false;
 }
 else
 {
	 if(email.length>0)
	 {
		 if(!checkEmail(email))
		 {
		  document.forms[1].email.focus();
		  return false;
		 }
	 }
  }
if(user_name.length<=0)
{
  alert("Enter the user name");
  document.regform.user_name.focus();
   return false;
}
if(password.length<=0)
{
  alert("Enter the password");
  document.regform.password.focus();
   return false;
}

document.regform.frmAction.value="update";
document.regform.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 checkComplaintForm()
{
district_id=trimSpaces(document.forms[1].district_id.value);
panchayat_id=trimSpaces(document.forms[1].panchayat_id.value);
category_id=trimSpaces(document.forms[1].category_id.value);
org_id=trimSpaces(document.forms[1].org_id.value);
officer=trimSpaces(document.forms[1].officer.value);
hdate=trimSpaces(document.forms[1].hdate.value);
nature=trimSpaces(document.forms[1].nature.value);
complaint=trimSpaces(document.forms[1].complaint.value);
suggestion=trimSpaces(document.forms[1].suggestion.value);
if(district_id.length<=0)
 {
  alert("Sorry, there is no district available under this state");
  document.forms[1].district_id.focus();
  return false;
 }
if(panchayat_id.length<=0)
 {
  alert("Sorry, there is no panchayat available under this district");
  document.forms[1].panchayat_id.focus();
  return false;
 }

if(category_id.length<=0)
 {
  alert("Sorry, there is no organization available under this panchayat");
  document.forms[1].category_id.focus();
  return false;
 }
if(org_id.length<=0)
 {
  alert("Sorry, there is no office available under this organization");
  document.forms[1].org_id.focus();
  return false;
 }
if(officer.length<=0)
 {
  alert("Please enter the officer name");
  document.forms[1].officer.focus();
  return false;
 }
 if(hdate.length<=0)
 {
  alert("Please enter the date of incident");
  document.forms[1].date.focus();
  return false;
 }
	if(nature.length<=0)
	 {
	  alert("Please enter the nature of the complaint");
	  document.forms[1].nature.focus();
	  return false;
	 }
	if(complaint.length<=0)
	 {
	  alert("Please enter your complaint");
	  document.forms[1].complaint.focus();
	  return false;
	 }
	if(suggestion.length<=0)
	 {
		alert("Please enter your suggestion");
		document.forms[1].suggestion.focus();
		return false;
	 }
 document.forms[1].frmAction.value="update";
 document.forms[1].submit();
} 
function checkOrgRegForm()
{
org_name=trimSpaces(document.forms[1].org_name.value);
position =trimSpaces(document.forms[1].position.value);
first_name=trimSpaces(document.forms[1].first_name.value);
last_name=trimSpaces(document.forms[1].last_name.value);
category_id=trimSpaces(document.forms[1].category_id.value);
category_new=trimSpaces(document.forms[1].category_new.value);
district_id=trimSpaces(document.forms[1].district_id.value);
district_new=trimSpaces(document.forms[1].district_new.value);
panchayat_id=trimSpaces(document.forms[1].panchayat_id.value);
panchayat_new=trimSpaces(document.forms[1].panchayat_new.value);
telephone=trimSpaces(document.forms[1].telephone.value);
email=trimSpaces(document.forms[1].email.value);
user_name=trimSpaces(document.forms[1].user_name.value);
password=trimSpaces(document.forms[1].password.value);
if(org_name.length<=0)
 {
  alert("Please enter the organization name");
  document.forms[1].org_name.focus();
  return false;
 }
if(position.length<=0)
 {
  alert("Please enter the position");
  document.forms[1].position.focus();
  return false;
 }
 if(first_name.length<=0)
 {
  alert("Please enter the first name");
  document.forms[1].first_name.focus();
  return false;
 }
if(last_name.length<=0)
 {
  alert("Please enter the last name");
  document.forms[1].last_name.focus();
  return false;
 }
if(category_id.length<=0 && category_new.length<=0)
 {
	alert("Please enter the industry");
	document.forms[1].category_new.focus();
	return false;
 }
if(district_id.length<=0 && district_new.length<=0)
 {
  alert("Please enter the district");
  document.forms[1].district_new.focus();
  return false;
 }
if(panchayat_id.length<=0 && panchayat_new.length<=0)
 {
  alert("Please enter the panchayat");
  document.forms[1].panchayat_new.focus();
  return false;
 }
if(telephone.length<=0)
 {
  alert("Please enter the telephone");
  document.forms[1].telephone.focus();
  return false;
 }
if(email.length<=0)
 {
  alert("Please enter the email");
  document.forms[1].email.focus();
  return false;
 }
 else
 {
	 if(email.length>0)
	 {
		 if(!checkEmail(email))
		 {
		  document.forms[1].email.focus();
		  return false;
		 }
	 }
  }
 if(user_name.length<=0)
{
  alert("Enter the user name");
  document.forms[1].user_name.focus();
   return false;
}
if(password.length<=0)
{
  alert("Enter the password");
  document.forms[1].password.focus();
   return false;
}
document.forms[1].frmAction.value="update";
 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 showCoupon(galleryid) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 600;
	winHeight = 500;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;

	window.open("showCouponFrame.php?couponid=" + galleryid , "picture", "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
	return;
}
function txtClear(dispText)
{
	if(dispText.value==dispText.defaultValue)
	{
		dispText.value="";
	}
}
function showDesc(elementName,page)
{				

	if(elementName=='search' && page=='home'){
		document.search.searchKey.value =trimSpaces(document.search.searchKey.value);
		if(document.search.searchKey.value=="")
		{
		alert("Enter search string");
		document.search.searchKey.focus();
		return false;
		}
		else
		{
		document.search.action="php/displaySearch.php"; 
		document.search.submit();
        }
	}
	if(elementName=='search' && page=='sub'){
		document.search.searchKey.value =trimSpaces(document.search.searchKey.value);
		if(document.search.searchKey.value=="")
		{
		alert("Enter search string");
		document.search.searchKey.focus();
		return false;
		}
		else
		{
		document.search.action="displaySearch.php";
		document.search.submit();
        }
	}
}
function verifyLogin(){
		uname =trimSpaces(document.verifylogin.uname.value);
		if(uname.length<=0){
			  alert("Please enter emailID");
			  document.verifylogin.uname.focus();
			  return false;
		}else{
			   if(!checkEmail(document.verifylogin.uname.value))
			   {
				document.verifylogin.uname.focus();
				return false;
			   }
		    }
	   password = trimSpaces(document.verifylogin.password.value);
	   if(password.length<=0){
	    alert("Please enter password");
		document.verifylogin.password.focus();
		return false;
	   }
      document.verifylogin.frmAction.value='chklogin';
  document.verifylogin.submit(); 
  return true;
}
function chkRegistration(){
		email =trimSpaces(document.forms[1].email.value);
		if(email.length<=0){
			  alert("Please enter emailID");
			  document.forms[1].email.focus();
			  return false;
		}else{
			   if(!checkEmail(document.forms[1].email.value))
			   {
				document.forms[1].email.focus();
				return false;
			   }
		    }
	   pwd = trimSpaces(document.forms[1].pwd.value);
	   if(pwd.length<=0){
	    alert("Please enter password");
		document.forms[1].pwd.focus();
		return false;
	   }
	   pwd1 = trimSpaces(document.forms[1].pwd1.value);
	   if(pwd1.length<=0){
	    alert("Please re-enter password");
		document.forms[1].pwd1.focus();
		return false;
	   }else if(pwd1 != pwd){
	    alert("Your confirmed Password is not matching with previously entered Password");
		document.forms[1].pwd1.focus();
		return false;
	   }
	   lastName = trimSpaces(document.forms[1].lastName.value);
	   firstName = trimSpaces(document.forms[1].firstName.value);
	   address = trimSpaces(document.forms[1].address.value);
	   city = trimSpaces(document.forms[1].city.value);
	   state = trimSpaces(document.forms[1].state.value);
	   zip = trimSpaces(document.forms[1].zip.value);
	   phoneC = trimSpaces(document.forms[1].phoneC.value);
	   phoneN = trimSpaces(document.forms[1].phoneN.value);
	   if(lastName.length<=0){
	    alert("Please enter Last Name");
		document.forms[1].lastName.focus();
		return false;
	   }
	   if(firstName.length<=0){
	    alert("Please enter First Name"); 
		document.forms[1].firstName.focus();
		return false;
	   }
	   document.forms[1].frmAction.value='update';
}
function chkActivation(){
	email=document.forms[1].email.value;
	if(email.length<=0){
	alert("Please enter your email");
	document.forms[1].email.focus();
	return false;
	}
	else{
			   if(!checkEmail(document.forms[1].email.value))
			   {
				document.forms[1].email.focus();
				return false;
			   }
	document.forms[1].frmAction.value="update";
	}
}
function checkMemApplication() {
	first_name = trimSpaces(document.forms[1].first_name.value);
	if(first_name.length <= 0) {
		alert("Please enter your first name.");
		document.forms[1].first_name.focus();
		return false;
	}
	last_name = trimSpaces(document.forms[1].last_name.value);
	if(last_name.length <= 0) {
		alert("Please enter your last name.");
		document.forms[1].last_name.focus();
		return false;
	}
	address = trimSpaces(document.forms[1].address.value);
	if(address.length <= 0) {
		alert("Please enter your address.");
		document.forms[1].address.focus();
		return false;
	}
	city = trimSpaces(document.forms[1].city.value);
	if(city.length <= 0) {
		alert("Please enter your city.");
		document.forms[1].profile.focus();
		return false;
	}
	state = trimSpaces(document.forms[1].state.value);
	if(state.length <= 0) 
	{
		alert("Please enter your State.");
		document.forms[1].state.focus();
		return false;
	}
	zip_code = trimSpaces(document.forms[1].zip_code.value);
	if(zip_code.length <= 0) {
		alert("Please enter your zip code.");
		document.forms[1].zip_code.focus();
		return false;
	}
	phone_day = trimSpaces(document.forms[1].phone_day.value);
	if(phone_day.length <= 0) {
		alert("Please enter your phone number (day).");
		document.forms[1].phone_day.focus();
		return false;
	}
	phone_eve = trimSpaces(document.forms[1].phone_eve.value);
	if(phone_eve.length <= 0) {
		alert("Please enter your phone number (eve).");
		document.forms[1].phone_eve.focus();
		return false;
	}
	email = trimSpaces(document.forms[1].email.value);
	if(email.length <= 0) {
		alert("Please enter your email.");
		document.forms[1].email.focus();
		return false;
	}
	if(email.length > 0){
		if(!checkEmail(email)){
			document.forms[1].email.focus();
			return false;
		}
	}
	nativeplace = trimSpaces(document.forms[1].nativeplace.value);
	if(nativeplace.length <= 0) {
	    if(document.forms[1].borninindia.value=='Y')
		alert("Please enter your nativeplace ");
		else
		alert("Please enter your parent's nativeplace ");
		document.forms[1].nativeplace.focus();
		return false;
	}
	languages = trimSpaces(document.forms[1].languages.value);
	if(languages.length <= 0) {
		alert("Please fill this cell");
		document.forms[1].languages.focus();
		return false;
	}		
		
document.forms[1].frmAction.value = "update";
	document.forms[1].submit();
}
function showPhotoPop(id,no) {  
	sWidth = screen.availWidth;  
	sHeight = screen.availHeight;
	winWidth = 450;
	winHeight = 400;
	sLeft = (sWidth - winWidth) / 2; 
	sTop = (sHeight - winHeight) / 2;
	window.open("showProfilePhoto.php?id="+id+"&no="+no,"Cities","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function showPhotoGalleryPop1(photoid) {  
	sWidth = screen.availWidth;  
	sHeight = screen.availHeight;
	winWidth = 450;
	winHeight = 400;
	sLeft = (sWidth - winWidth) / 2; 
	sTop = (sHeight - winHeight) / 2;
	window.open("showProfileGalleryPhoto.php?photoid="+photoid,"Cities","width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=1,resizable=0");
}
function checkContact(){
	contactname = trimSpaces(document.contact.visitorName.value);
	contactemail = trimSpaces(document.contact.visitorEmail.value);
	contactphone = trimSpaces(document.contact.visitorPhone.value);
	suggestions = trimSpaces(document.contact.visitorComments.value);
	if(contactname.length <= 0){
		alert("Please enter your name.");
		document.contact.visitorName.focus();
		return false;
	}
	if(!checkEmail(contactemail)) {
		document.contact.visitorEmail.focus();
		return false;
	}
	if(contactphone.length <= 0){
		alert("Please enter your telephone #.");
		document.contact.visitorPhone.focus();
		return false;
	}
	if(suggestions.length <= 0){
		alert("Please enter your queries/suggestions.");
		document.contact.visitorComments.focus();
		return false;
	}
	document.contact.frmAction.value = "send";
}
function checkGuestBook(toDo) {
	rowSelected = false;
	if(document.guestbook.elements["guestbookId[]"].length > 0) {
		for(itemCount = 0; itemCount < document.guestbook.elements["guestbookId[]"].length; itemCount++) {
			if(document.guestbook.elements["guestbookId[]"][itemCount].checked) {
				rowSelected = true;
			}
		}
	}
	else {
		if(document.guestbook.elements["guestbookId[]"].checked) {
			rowSelected = true;
		}
	}
	
	if(toDo == "reject") {
		actType = "deletion";
	}
	else {
		actType = "approval";
	}
	
	if(!rowSelected) {
		alert("No comments selected for " + actType);
		return false;
	}
	else {
		if(toDo == "reject") {
			if(!confirm("Do you really want to reject and delete these comments?")) {
				return false;
			}
		}
	}
	document.guestbook.frmAction.value = toDo;
	document.guestbook.submit();
}
function doSubmit(v){
  document.frm.frmAction.value=v;
  document.frm.submit();
}