// 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 checkGiftCertificate() {
	senderName = trimSpaces(document.forms[0].senderName.value);
	if(senderName.length <= 0) {
		alert("Plese enter your name");
		document.forms[0].senderName.focus();
		return false;
	}
	
	senderAddress = trimSpaces(document.forms[0].senderAddress.value);
	if(senderAddress.length <= 0) {
		alert("Plese enter your address");
		document.forms[0].senderAddress.focus();
		return false;
	}

	senderCity = trimSpaces(document.forms[0].senderCity.value);
	if(senderCity.length <= 0) {
		alert("Plese enter your city");
		document.forms[0].senderCity.focus();
		return false;
	}
	
	senderState = trimSpaces(document.forms[0].senderState.value);
	if(senderState.length <= 0) {
		alert("Plese enter your state");
		document.forms[0].senderState.focus();
		return false;
	}

	senderZip = trimSpaces(document.forms[0].senderZip.value);
	if(senderZip.length <= 0) {
		alert("Plese enter your ZIP");
		document.forms[0].senderZip.focus();
		return false;
	}
	
	senderPhone = trimSpaces(document.forms[0].senderPhone.value);
	if(senderPhone.length <= 0) {
		alert("Plese enter your telephone number");
		document.forms[0].senderPhone.focus();
		return false;
	}

	senderEmail = trimSpaces(document.forms[0].senderEmail.value);
	if(senderEmail.length <= 0) {
		alert("Plese enter your email address");
		document.forms[0].senderEmail.focus();
		return false;
	}
	if(!checkEmail(senderEmail)) {
		document.forms[0].senderEmail.focus();
		return false;
	}
	
	certificateQuantity = trimSpaces(document.forms[0].certificateQuantity.value);
	certificateAmount = trimSpaces(document.forms[0].certificateAmount.value);
	if(certificateQuantity.length <= 0 && certificateAmount.length <= 0) {
		if(certificateQuantity.length <= 0) {
			alert("Plese enter the certificate quantity");
			document.forms[0].certificateQuantity.focus();
			return false;
		}
		if(certificateAmount.length <= 0) {
			alert("Plese enter the certificate amount");
			document.forms[0].certificateAmount.focus();
			return false;
		}
	}
	
	document.forms[0].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();
}

function checkCouponMail() {
	senderName = trimSpaces(document.forms[0].senderName.value);
	senderEmail = trimSpaces(document.forms[0].senderEmail.value);
	receiverEmail = trimSpaces(document.forms[0].receiverEmail.value);
	if(senderName.length <= 0) {
		alert("You have to enter your name.");
		document.forms[0].senderName.focus();
		return false;
	}
	if(senderEmail.length <= 0) {
		alert("You have to enter your email address.");
		document.forms[0].senderEmail.focus();
		return false;
	}
	if(!checkEmail(senderEmail)) {
		document.forms[0].senderEmail.focus();
		return false;
	}
	if(receiverEmail.length <= 0) {
		alert("You have to enter your friend's email address.");
		document.forms[0].receiverEmail.focus();
		return false;
	}
	if(!checkEmail(receiverEmail)) {
		document.forms[0].receiverEmail.focus();
		return false;
	}
	document.forms[0].frmAction.value = "yes";
}

function checkSubscription(action)
{

 if(action=="sub")
  {
	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].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();
 }
 else
  {	
  	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))
	   {
	    return false;
	   }
	 }  	 
	 
	document.forms[0].frmAction.value="delete";
	alert();
	document.forms[0].submit();
}
}
function checkFeedBack() {
	document.forms[0].visitorName.value = trimSpaces(document.forms[0].visitorName.value);
	if(document.forms[0].visitorName.value.length <= 0) {
		alert("Please enter your name");
		document.forms[0].visitorName.focus();
		return false;
	}

	document.forms[0].emailAddress.value = trimSpaces(document.forms[0].emailAddress.value);
	if(document.forms[0].emailAddress.value.length <= 0) {
		alert("Please enter your email address");
		document.forms[0].emailAddress.focus();
		return false;
	}
	if(!checkEmail(document.forms[0].emailAddress.value)) {
		document.forms[0].emailAddress.focus();
		document.forms[0].emailAddress.select();
		return false;
	}

	document.forms[0].visitorComments.value = trimSpaces(document.forms[0].visitorComments.value);
	if(document.forms[0].visitorComments.value.length <= 0) {
		alert("Please enter your comments");
		document.forms[0].visitorComments.focus();
		return false;
	}
	document.forms[0].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[0].firstName.value);
	if(firstName.length <= 0) {
		alert("Please enter your name.");
		document.forms[0].firstName.focus();
		return false;
	}
/*	
	lastName = trimSpaces(document.forms[0].lastName.value);
	if(lastName.length <= 0) {
		alert("Please enter your last name.");
		document.forms[0].lastName.focus();
		return false;
	}
*/	
	subscriberEmail = trimSpaces(document.forms[0].subscriberemail.value);
	if(subscriberEmail.length <= 0) {
		alert("Please enter your email.");
		document.forms[0].subscriberemail.focus();
		return false;
	}
	if(subscriberEmail.length > 0){
		if(!checkEmail(subscriberEmail)){
			document.forms[0].subscriberemail.focus();
			return false;
		}
	}
	
	document.forms[0].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[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 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[0].email.focus();
  return false;
 }
 else
 {
	 if(email.length>0)
	 {
		 if(!checkEmail(email))
		 {
		  document.forms[0].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[0].district_id.value);
panchayat_id=trimSpaces(document.forms[0].panchayat_id.value);
category_id=trimSpaces(document.forms[0].category_id.value);
org_id=trimSpaces(document.forms[0].org_id.value);
officer=trimSpaces(document.forms[0].officer.value);
hdate=trimSpaces(document.forms[0].hdate.value);
nature=trimSpaces(document.forms[0].nature.value);
complaint=trimSpaces(document.forms[0].complaint.value);
suggestion=trimSpaces(document.forms[0].suggestion.value);
if(district_id.length<=0)
 {
  alert("Sorry, there is no district available under this state");
  document.forms[0].district_id.focus();
  return false;
 }
if(panchayat_id.length<=0)
 {
  alert("Sorry, there is no panchayat available under this district");
  document.forms[0].panchayat_id.focus();
  return false;
 }

if(category_id.length<=0)
 {
  alert("Sorry, there is no organization available under this panchayat");
  document.forms[0].category_id.focus();
  return false;
 }
if(org_id.length<=0)
 {
  alert("Sorry, there is no office available under this organization");
  document.forms[0].org_id.focus();
  return false;
 }
if(officer.length<=0)
 {
  alert("Please enter the officer name");
  document.forms[0].officer.focus();
  return false;
 }
 if(hdate.length<=0)
 {
  alert("Please enter the date of incident");
  document.forms[0].date.focus();
  return false;
 }
	if(nature.length<=0)
	 {
	  alert("Please enter the nature of the complaint");
	  document.forms[0].nature.focus();
	  return false;
	 }
	if(complaint.length<=0)
	 {
	  alert("Please enter your complaint");
	  document.forms[0].complaint.focus();
	  return false;
	 }
	if(suggestion.length<=0)
	 {
		alert("Please enter your suggestion");
		document.forms[0].suggestion.focus();
		return false;
	 }
 document.forms[0].frmAction.value="update";
 document.forms[0].submit();
} 
function checkOrgRegForm()
{
org_name=trimSpaces(document.forms[0].org_name.value);
position =trimSpaces(document.forms[0].position.value);
first_name=trimSpaces(document.forms[0].first_name.value);
last_name=trimSpaces(document.forms[0].last_name.value);
category_id=trimSpaces(document.forms[0].category_id.value);
category_new=trimSpaces(document.forms[0].category_new.value);
district_id=trimSpaces(document.forms[0].district_id.value);
district_new=trimSpaces(document.forms[0].district_new.value);
panchayat_id=trimSpaces(document.forms[0].panchayat_id.value);
panchayat_new=trimSpaces(document.forms[0].panchayat_new.value);
telephone=trimSpaces(document.forms[0].telephone.value);
email=trimSpaces(document.forms[0].email.value);
user_name=trimSpaces(document.forms[0].user_name.value);
password=trimSpaces(document.forms[0].password.value);
if(org_name.length<=0)
 {
  alert("Please enter the organization name");
  document.forms[0].org_name.focus();
  return false;
 }
if(position.length<=0)
 {
  alert("Please enter the position");
  document.forms[0].position.focus();
  return false;
 }
 if(first_name.length<=0)
 {
  alert("Please enter the first name");
  document.forms[0].first_name.focus();
  return false;
 }
if(last_name.length<=0)
 {
  alert("Please enter the last name");
  document.forms[0].last_name.focus();
  return false;
 }
if(category_id.length<=0 && category_new.length<=0)
 {
	alert("Please enter the industry");
	document.forms[0].category_new.focus();
	return false;
 }
if(district_id.length<=0 && district_new.length<=0)
 {
  alert("Please enter the district");
  document.forms[0].district_new.focus();
  return false;
 }
if(panchayat_id.length<=0 && panchayat_new.length<=0)
 {
  alert("Please enter the panchayat");
  document.forms[0].panchayat_new.focus();
  return false;
 }
if(telephone.length<=0)
 {
  alert("Please enter the telephone");
  document.forms[0].telephone.focus();
  return false;
 }
if(email.length<=0)
 {
  alert("Please enter the email");
  document.forms[0].email.focus();
  return false;
 }
 else
 {
	 if(email.length>0)
	 {
		 if(!checkEmail(email))
		 {
		  document.forms[0].email.focus();
		  return false;
		 }
	 }
  }
 if(user_name.length<=0)
{
  alert("Enter the user name");
  document.forms[0].user_name.focus();
   return false;
}
if(password.length<=0)
{
  alert("Enter the password");
  document.forms[0].password.focus();
   return false;
}
document.forms[0].frmAction.value="update";
 return;
} 
function openDynWindow(url) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 550;
	winHeight = 520;
	
	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 openHotelWindow(url,winname) {
	sWidth = screen.availWidth;
	sHeight = screen.availHeight;
	
	winWidth = 100;
	winHeight = 100;
	
	sLeft = (sWidth - winWidth) / 2;
	sTop = (sHeight - winHeight) / 2;
	winname = window.open(url,winname, "width=" + winWidth + ",height=" + winHeight + ",top=" + sTop + ",left=" + sLeft + ",toolbar=0,menubar=0,status=0,scrollbars=0,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 submitLink(sid)
{
		document.forms[0].linkid.value="3";
		document.forms[0].service_id.value=sid;
		document.forms[0].submit();
}

function ShowPriceRequest()
{
dd = document.forms[0].arrival_day.options[document.forms[0].arrival_day.selectedIndex].value;
mm = document.forms[0].arrival_month.options[document.forms[0].arrival_month.selectedIndex].value;
yy = document.forms[0].arrival_year.options[document.forms[0].arrival_year.selectedIndex].value;
if (!checkDate(dd,mm,yy))
return false;

	var tDate = new Date();
	if (mm.length < 2) mm = "0" + mm;
	if (dd.length < 2) dd = "0" + dd;
	sDate = yy + mm + dd;

	sMonth = (tDate.getMonth() + 1).toString();
	sDay = (tDate.getDate()).toString();
	sYear = (tDate.getFullYear()).toString();
	if (sMonth.length < 2) sMonth = "0" + sMonth;
	if (sDay.length < 2) sDay = "0" + sDay;
	sCurDate = sYear + sMonth + sDay;
	
	if (sDate < sCurDate) {
		window.alert("You cannot specify a Travel Date prior to today.");
		document.forms[0].focus();
		return false;
	}

destination = document.forms[0].destination.options[document.forms[0].destination.selectedIndex].value;
if (destination == '')
{
alert("Please select destination");
document.forms[0].destination.focus();
return false;
}
if (!isNumeric('reservation','passengers','Passengers'))
return false;
passengers = parseInt(document.forms[0].passengers.value);
passenger_capacity = parseInt(document.forms[0].passenger_capacity.value);

if (passengers > passenger_capacity )
{
alert("Maximum no. of passengers is "+ passenger_capacity);
document.forms[0].passengers.select();
return false;
}

if (destination != 'others')
{
document.forms[0].action = "reservation1.php?linkid=3";
document.forms[0].submit();
}
else
{
document.forms[0].action = "reservation1_others.php?linkid=3";
document.forms[0].submit();
}
}


function ShowPriceRequestReturn()
{
dd = document.forms[0].arrival_day.options[document.forms[0].arrival_day.selectedIndex].value;
mm = document.forms[0].arrival_month.options[document.forms[0].arrival_month.selectedIndex].value;
yy = document.forms[0].arrival_year.options[document.forms[0].arrival_year.selectedIndex].value;
if (!checkDate(dd,mm,yy))
return false;

	var tDate = new Date();
	if (mm.length < 2) mm = "0" + mm;
	if (dd.length < 2) dd = "0" + dd;
	sDate = yy + mm + dd;

	sMonth = (tDate.getMonth() + 1).toString();
	sDay = (tDate.getDate()).toString();
	sYear = (tDate.getFullYear()).toString();
	if (sMonth.length < 2) sMonth = "0" + sMonth;
	if (sDay.length < 2) sDay = "0" + sDay;
	sCurDate = sYear + sMonth + sDay;
	
	if (sDate < sCurDate) {
		window.alert("You cannot specify a Travel Date prior to today.");
		document.forms[0].focus();
		return false;
	}

destination = document.forms[0].destination.options[document.forms[0].destination.selectedIndex].value;
if (destination == '')
{
alert("Please select destination");
document.forms[0].destination.focus();
return false;
}
if (!isNumeric('reservation','passengers','Passengers'))
return false;
passengers = parseInt(document.forms[0].passengers.value);
passenger_capacity = parseInt(document.forms[0].passenger_capacity.value);

if (passengers > passenger_capacity )
{
alert("Maximum no. of passengers is "+ passenger_capacity);
document.forms[0].passengers.select();
return false;
}
document.forms[0].action = "reservation1_return.php?linkid=3";
document.forms[0].submit();
}

function ShowAddress() {
destination = document.forms[0].destination.options[document.forms[0].destination.selectedIndex].value;
if (destination == '' || destination == 'others' )
{
alert("Please select a hotel to view its address");
document.forms[0].destination.focus();
return false;
}	
openHotelWindow("hotelDetails.php?hotel_id="+destination,'addressWindow');
}

function ShowSearch()
{
var sCriteria = document.forms[0].search.value;
	if (sCriteria == "") {
		window.alert("Please supply a Search value.");
		document.forms[0].search.focus();
		return false;
	}
openHotelWindow("searchDetails.php?search="+sCriteria,'searchWindow');
}

function SetSearch(sValue, sText) {
	document.forms[0].search.value = ""
	if (sValue != "" && sText !="") {
		var oSelect = document.forms[0].destination;
		var iIdx;
		var bFound = false;
		
		for (iIdx=0; iIdx<oSelect.length; iIdx++) {
			if (oSelect.options[iIdx].text == sText) {
				oSelect.selectedIndex = iIdx;
				bFound = true;
				break;
			}
		}
		if (bFound == false) {
			iIdx = oSelect.length;
			var oOption = new Option(sText, sValue);
			oSelect.options[iIdx] = oOption;
			oSelect.selectedIndex = iIdx;
		}
	}
}
	function CloseAddress() {
		if (addressWindow != 0) {
			if (addressWindow.closed!=true) {
				addressWindow.close();
			}
			addressWindow = 0;
		}
	}
	
	function TimeBox_GetTime(sName) {
// Returns time from sName TimeBox in 24 hour 
// format (ex: 9:45 PM is returned as 2145).

//sName = The name that was used to create the TimeBox.

	var sHour = (sName + "_hh").toString();
	var sMins = (sName + "_mm").toString();
	var sAmPm = (sName + "_meridian").toString();
	var sTime = sName.toString();
	var oHour = document.getElementById(sHour);
	var oMins = document.getElementById(sMins);
	var oAmPm = document.getElementById(sAmPm);
	var oTime = document.getElementById(sTime);
		// Standard TimeBox
		var iHour = parseInt(oHour.value);
		var iMins = parseInt(oMins.value);
		//var iAmPm = parseInt(oAmPm.value);
		var iAmPm = oAmPm.value;
		if (iAmPm == 'PM') iHour = iHour + 12;
		if ((iHour % 12) == 0) iHour = iHour - 12;
		return (iHour * 100) + iMins;
}

function ApplyTime(sName) {
// Sets the hidden TimeBox text box.
// This hidden TextBox needs to be set when the
// TimeBox changes, in order to submit the field.

//sName = The name that was used to create the TimeBox.

	var sTime = sName.toString();
	var oTime = document.getElementById(sTime);
	oTime.value = TimeBox_GetTime(sName);
}

function validate()
{
	document.forms[0].first_name.value=trimSpaces(document.forms[0].first_name.value);
	if(document.forms[0].first_name.value.length<=0)
	 {
	 	alert("Enter your First Name");
		document.forms[0].first_name.focus();
		return false;
	 }
	document.forms[0].last_name.value=trimSpaces(document.forms[0].last_name.value);
	if(document.forms[0].last_name.value.length<=0)
	 {
	 	alert("Enter your Last Name");
		document.forms[0].last_name.focus();
		return false;
	 }

document.forms[0].address1.value=trimSpaces(document.forms[0].address1.value);
	if(document.forms[0].address1.value.length<=0)
	 {
	 	alert("Enter your Address");
		document.forms[0].address1.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)
	 {
	 	alert("Enter your State");
		document.forms[0].state.focus();
		return false;
	 }
	 
document.forms[0].zip.value=trimSpaces(document.forms[0].zip.value);
	if(document.forms[0].zip.value.length<=0)
	 {
	 	alert("Enter your Zip");
		document.forms[0].zip.focus();
		return false;
	 }

	email = trimSpaces(document.forms[0].email.value);
	if(email.length > 0) {
	
	if(!checkEmail(email)) {
		document.forms[0].email.focus();
		return false;
	}
	}
	
document.forms[0].airline.value=trimSpaces(document.forms[0].airline.value);
	if(document.forms[0].airline.value.length<=0)
	 {
	 	alert("Enter Flight Name");
		document.forms[0].airline.focus();
		return false;
	 }	

document.forms[0].flight_no.value=trimSpaces(document.forms[0].flight_no.value);
	if(document.forms[0].flight_no.value.length<=0)
	 {
	 	alert("Enter Flight No.");
		document.forms[0].flight_no.focus();
		return false;
	 }

	var iFlTime = TimeBox_GetTime("arr");
	var iPuTime = TimeBox_GetTime("pick");
if (iPuTime < iFlTime) 
{
	alert("Pickup Time cannot be before the flight arrives.");
	return false;
}
}



function validateReturn()
{
document.forms[0].airline.value=trimSpaces(document.forms[0].airline.value);
	if(document.forms[0].airline.value.length<=0)
	 {
	 	alert("Enter Flight Name");
		document.forms[0].airline.focus();
		return false;
	 }	

document.forms[0].flight_no.value=trimSpaces(document.forms[0].flight_no.value);
	if(document.forms[0].flight_no.value.length<=0)
	 {
	 	alert("Enter Flight No.");
		document.forms[0].flight_no.focus();
		return false;
	 }

	var iFlTime = TimeBox_GetTime("arr");
	var iPuTime = TimeBox_GetTime("pick");
	
	if (iPuTime > parseInt(DBTimeOffset(iFlTime, -fPickupTimeDiff))) {
	oCtrl = document.getElementById("pickdrop_Hours");
	alert("Departing pickup time must be at least " + sPickupTimeDiff + " hours prior to departing flight time.");
	return false;
	}
}
//-------------------------------------------------------------------------------------------------
		
		function DepartureTimeChange(sName) {
			//var bUseArriveFields = (sName.toLowerCase().indexOf("rt") != 0) ? true : false;
			//var sTimeBox = (bUseArriveFields!=true) ? "rttime" : "time";
			//var sPickupBox = (bUseArriveFields!=true) ? "rtpickdrop" : "pickdrop";
			var sTimeBox = "arr";
			var sPickupBox = "pick";
			
			
			var oTimeBox = document.getElementById(sTimeBox);
			var iNewTime = parseInt(oTimeBox.value);
			var iTestTime = parseInt(DBTimeOffset(iNewTime, -fPickupTimeDiff));
			iNewTime = (iTestTime>=0) ? iTestTime : 0;
			TimeBox_SetTime(sPickupBox, iNewTime);
		}
//-------------------------------------------------------------------------------------------------
function TimeBox_SetTime(sName, iTime) {
// Sets the time for the sName TimeBox using iTime

// sName = The name that was used to create the TimeBox.
// iTime = 24 hour time format (ex: 9:45 PM is passed in as 2145)
	if (iTime < 0) iTime = 0
	iTime = (iTime % 2400);
	var iHour = Math.floor(iTime / 100);
	var iMins = ((iTime % 100) % 60);
	var iAmPm = 0;
	if (iHour >= 12) {
		iHour = iHour - 12;
		iAmPm = 1;
	}
	if (iHour == 0) iHour = iHour + 12;
	var sHour = (sName + "_hh").toString();
	var sMins = (sName + "_mm").toString();
	var sAmPm = (sName + "_meridian").toString();
	var sTime = sName.toString();
	var oHour = document.getElementById(sHour);
	var oMins = document.getElementById(sMins);
	var oAmPm = document.getElementById(sAmPm);
	var oTime = document.getElementById(sTime);
		// Standard TimeBox
		oHour.selectedIndex = iHour - 1;
		oMins.selectedIndex = iMins;
		oAmPm.selectedIndex = iAmPm;
	oTime.value = TimeBox_GetTime(sName);
}

//-------------------------------------------------------------------------------------------------

	function DBTimeOffset(lTime, fAmount) {

	    var sHours = "";
	    var sMinutes = "";
	    var sTemp = "";
	    var iHours = 0;
	    var iMinutes = 0;
	    
	    sTemp = "0000" + lTime.toString();
			sTemp = sTemp.substr(sTemp.length - 4);
	    sHours = sTemp.substr(0, 2);
	    sMinutes = sTemp.substr(2, 2);
	    
	    iHours = parseInt(sHours) + parseInt(fAmount);
	    iMinutes = parseInt(sMinutes) + (parseFloat(fAmount - parseInt(fAmount)) * 60)
	    if (iMinutes < 0) {
	        iMinutes += 60;
	        iHours -= 1;
	    }
	    if (iHours < 0) iHours += 24;
	    
	    sTemp = "00" + iMinutes.toString();
			sTemp = sTemp.substr(sTemp.length - 2);
	    sTemp = iHours.toString() + sTemp;
	    return sTemp;
    }
//-------------------------------------------------------------------------------------------------

function validatePayment()
{
	document.forms[0].first_name.value=trimSpaces(document.forms[0].first_name.value);
	if(document.forms[0].first_name.value.length<=0)
	 {
	 	alert("Enter your First Name");
		document.forms[0].first_name.focus();
		return false;
	 }
	document.forms[0].last_name.value=trimSpaces(document.forms[0].last_name.value);
	if(document.forms[0].last_name.value.length<=0)
	 {
	 	alert("Enter your Last Name");
		document.forms[0].last_name.focus();
		return false;
	 }

document.forms[0].address1.value=trimSpaces(document.forms[0].address1.value);
	if(document.forms[0].address1.value.length<=0)
	 {
	 	alert("Enter your Address");
		document.forms[0].address1.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)
	 {
	 	alert("Enter your State");
		document.forms[0].state.focus();
		return false;
	 }
	 
document.forms[0].zip.value=trimSpaces(document.forms[0].zip.value);
	if(document.forms[0].zip.value.length<=0)
	 {
	 	alert("Enter your Zip");
		document.forms[0].zip.focus();
		return false;
	 }
	 
document.forms[0].card_number.value=trimSpaces(document.forms[0].card_number.value);
	if(document.forms[0].card_number.value.length<=0)
	 {
	 	alert("Enter your Card Number");
		document.forms[0].card_number.focus();
		return false;
	 }

document.forms[0].security_number.value=trimSpaces(document.forms[0].security_number.value);
	if(document.forms[0].security_number.value.length<=0)
	 {
	 	alert("Enter your Security Number");
		document.forms[0].security_number.focus();
		return false;
	 }
	document.forms[0].frmAction.value = "update";
}



function ShowRequestOthers()
{
from_hotel_id = document.forms[0].from_hotel_id.options[document.forms[0].from_hotel_id.selectedIndex].value;
	if(from_hotel_id.length <=0)
	 {
	 	alert("Select Origin");
		document.forms[0].from_hotel_id.focus();
		return false;
	 }
to_hotel_id = document.forms[0].to_hotel_id.options[document.forms[0].to_hotel_id.selectedIndex].value;
	if(to_hotel_id.length <=0)
	 {
	 	alert("Select Destination");
		document.forms[0].to_hotel_id.focus();
		return false;
	 }
if (from_hotel_id == to_hotel_id)
{
 	 	alert("Origin and Destination can't be the same");
		return false;
}

dd = document.forms[0].pick_day.options[document.forms[0].pick_day.selectedIndex].value;
mm = document.forms[0].pick_month.options[document.forms[0].pick_month.selectedIndex].value;
yy = document.forms[0].pick_year.options[document.forms[0].pick_year.selectedIndex].value;
if (!checkDate(dd,mm,yy))
return false;

	var tDate = new Date();
	if (mm.length < 2) mm = "0" + mm;
	if (dd.length < 2) dd = "0" + dd;
	sDate = yy + mm + dd;

	sMonth = (tDate.getMonth() + 1).toString();
	sDay = (tDate.getDate()).toString();
	sYear = (tDate.getFullYear()).toString();
	if (sMonth.length < 2) sMonth = "0" + sMonth;
	if (sDay.length < 2) sDay = "0" + sDay;
	sCurDate = sYear + sMonth + sDay;
	
	if (sDate < sCurDate) {
		window.alert("You cannot specify a Travel Date prior to today.");
		document.forms[0].focus();
		return false;
	}
}
function validateOthers()
{
	document.forms[0].first_name.value=trimSpaces(document.forms[0].first_name.value);
	if(document.forms[0].first_name.value.length<=0)
	 {
	 	alert("Enter your First Name");
		document.forms[0].first_name.focus();
		return false;
	 }
	document.forms[0].last_name.value=trimSpaces(document.forms[0].last_name.value);
	if(document.forms[0].last_name.value.length<=0)
	 {
	 	alert("Enter your Last Name");
		document.forms[0].last_name.focus();
		return false;
	 }

document.forms[0].address1.value=trimSpaces(document.forms[0].address1.value);
	if(document.forms[0].address1.value.length<=0)
	 {
	 	alert("Enter your Address");
		document.forms[0].address1.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)
	 {
	 	alert("Enter your State");
		document.forms[0].state.focus();
		return false;
	 }
	 
document.forms[0].zip.value=trimSpaces(document.forms[0].zip.value);
	if(document.forms[0].zip.value.length<=0)
	 {
	 	alert("Enter your Zip");
		document.forms[0].zip.focus();
		return false;
	 }

	email = trimSpaces(document.forms[0].email.value);
	if(email.length > 0) {
	
	if(!checkEmail(email)) {
		document.forms[0].email.focus();
		return false;
	}
	}
	document.forms[0].frmAction.value= "update";
}
function delReturn()
{
	if(confirm("Do you really want to cancel the return trip ?")) 
	{
		window.location.href="deleteReturn.php?linkid=3";
		return true;
	}
}

function cancelReservation()
{
	if(confirm("Do you really want to cancel this reservation ?")) 
	{
		window.location.href="cancelReservation.php?linkid=3";
		return true;
	}
}

function checkPreQualify()
{
document.forms[0].first_name.value=trimSpaces(document.forms[0].first_name.value);
if (document.forms[0].first_name.value.length<=0) {
alert('Please Enter Your First Name');
document.forms[0].first_name.focus();
return false;
}

document.forms[0].last_name.value=trimSpaces(document.forms[0].last_name.value);
if (document.forms[0].last_name.value.length<=0) {
alert('Please Enter Your Last Name');
document.forms[0].last_name.focus();
return false;
}

document.forms[0].HomeArea.value=trimSpaces(document.forms[0].HomeArea.value);
if (document.forms[0].HomeArea.value.length < 3) {
alert('Please Verify Your Phone Number');
document.forms[0].HomeArea.focus();
return false;
}

document.forms[0].HomePrefix.value=trimSpaces(document.forms[0].HomePrefix.value);
if (document.forms[0].HomePrefix.value.length < 3) {
alert('Please Verify Your Phone Number');
document.forms[0].HomePrefix.focus();
return false;
}

document.forms[0].HomeSuffix.value=trimSpaces(document.forms[0].HomeSuffix.value);
if (document.forms[0].HomeSuffix.value.length < 4) {
alert('Please Verify Your Phone Number');
document.forms[0].HomeSuffix.focus();
return false;
}
email=trimSpaces(document.forms[0].email.value);

if(email.length <= 0) {
	alert("You have to enter your email address.");
	document.forms[0].email.focus();
	return false;
}
if(!checkEmail(email)) {
	document.forms[0].email.focus();
	return false;
}

document.forms[0].frmAction.value = "update";

}
/*function checkBARegistrationForm()
{
 document.forms[0].firstName.value=trimSpaces(document.forms[0].firstName.value);
 document.forms[0].lastName.value=trimSpaces(document.forms[0].lastName.value);
 document.forms[0].address.value=trimSpaces(document.forms[0].address.value);
 document.forms[0].city.value=trimSpaces(document.forms[0].city.value);
 document.forms[0].zip.value=trimSpaces(document.forms[0].zip.value);
 document.forms[0].state.value=trimSpaces(document.forms[0].state.value);
 document.forms[0].country.value=trimSpaces(document.forms[0].country.value);
 document.forms[0].pNumber.value=trimSpaces(document.forms[0].pNumber.value);
 document.forms[0].Cell.value=trimSpaces(document.forms[0].Cell.value);
 document.forms[0].email.value=trimSpaces(document.forms[0].email.value);
 if(document.forms[0].firstName.value.length<=0)
  { 
    alert("Enter the First Name");
	document.forms[0].firstName.focus();
	return false;
  }

 if(document.forms[0].lastName.value.length<=0)
  { 
    alert("Enter your Last name");
	document.forms[0].lastName.focus();
	return false;
  }
  if(document.forms[0].address.value.length<=0)
  { 
    alert("Enter the address");
	document.forms[0].address.focus();
	return false;
  } 
  if(document.forms[0].city.value.length<=0)
  { 
    alert("Enter the city Name");
	document.forms[0].city.focus();
	return false;
  }

 if(document.forms[0].zip.value.length<=0)
  { 
    alert("Enter your zip code");
	document.forms[0].zip.focus();
	return false;
  }
  if(document.forms[0].state.value.length<=0)
  { 
    alert("Enter the state name");
	document.forms[0].state.focus();
	return false;
  } 
 if(document.forms[0].country.value.length<=0)
  {
    alert("Enter the country name");
	document.forms[0].country.focus();
	return false;
  } 
 if(document.forms[0].pNumber.value.length<=0)
  { 
    alert("Enter the phone Number");
	document.forms[0].pNumber.focus();
	return false;
  }
if(document.forms[0].Cell.value.length<=0)
  { 
    alert("Enter your Cell Number");
	document.forms[0].Cell.focus();
	return false;
  }
  if(document.forms[0].email.value.length <= 0) {
		alert("Please enter your email address");
		document.forms[0].email.focus();
		return false;
	}
 if(!checkEmail(document.forms[0].email.value)) {
		document.forms[0].email.focus();
		document.forms[0].email.select();
		return false;
 }
  document.forms[0].frmAction.value="send";
  return true;	
}
*/
function checkBARegistrationForm(){
	if(document.reg_form.firstName.value == ""){
		alert("Please enter your first name");
		document.reg_form.firstNname.focus()
		return false;
	}
	if(document.reg_form.lastName.value == ""){
		alert("Please enter your last name");
		document.reg_form.lastName.focus()
		return false;
	}
	if(document.reg_form.address.value == ""){
		alert("Please enter your Address");
		document.reg_form.address.focus()
		return false;
	}
	if(document.reg_form.city.value == ""){
		alert("Please enter your city");
		document.reg_form.city.focus()
		return false;
	}
	if(document.reg_form.zip.value == ""){
		alert("Please enter your zip");
		document.reg_form.zip.focus()
		return false;
	}
	if(document.reg_form.state.value == ""){
		alert("Please enter your state");
		document.reg_form.state.focus()
		return false;
	}
	if(document.reg_form.country.value == ""){
		alert("Please enter your country");
		document.reg_form.country.focus()
		return false;
	}
	if(document.reg_form.pNumber.value == ""){
		alert("Please enter your phone number");
		document.reg_form.pNumber.focus()
		return false;
	}
	if(document.reg_form.cell.value == ""){
		alert("Please enter your Mobile number");
		document.reg_form.cell.focus()
		return false;
	}
	if(document.reg_form.email.value == ""){
		alert("Please enter your email");
		document.reg_form.email.focus()
		return false;
	}
}