	function submitChange()
	{
		document.frmHotelSearch.method="POST";
		document.frmHotelSearch.hdnact.value="change";
		document.frmHotelSearch.action="default.asp"
		document.frmHotelSearch.submit();
	}
	function clearList(combo)
	{
		var x=combo.length;
		var i=0;
		for(i=x; i>0; i--)
		{
			combo.options[i-1]=null;
		}
	}

	function addDays(myval, startDay, endDay, gap)
	{
		var objForm=document.frmHotelSearch;

		var dcombo,mcombo,ycombo;
		if(myval==1)
		{
			dcombo=eval("objForm.CmbBxCheckInDate_DD")
			mcombo=eval("objForm.CmbBxCheckInDate_MM")
			ycombo=eval("objForm.CmbBxCheckInDate_YYYY")
		}
		else
		{
			dcombo=eval("objForm.CmbBxCheckOutDate_DD")
			mcombo=eval("objForm.CmbBxCheckOutDate_MM")
			ycombo=eval("objForm.CmbBxCheckOutDate_YYYY")
		}

		var i=0;

		for(i=startDay; i<=endDay; i+=gap)
		{
			dcombo.options[dcombo.length]=new Option(i,i);
		}
	}

	function dayList(myval)
	{
		var objForm=document.frmHotelSearch;

		var dcombo,mcombo,ycombo;
		if(myval==1)
		{
			dcombo=eval("objForm.CmbBxCheckInDate_DD")
			mcombo=eval("objForm.CmbBxCheckInDate_MM")
			ycombo=eval("objForm.CmbBxCheckInDate_YYYY")
		}
		else
		{
			dcombo=eval("objForm.CmbBxCheckOutDate_DD")
			mcombo=eval("objForm.CmbBxCheckOutDate_MM")
			ycombo=eval("objForm.CmbBxCheckOutDate_YYYY")
		}

		clearList(dcombo);

		if(ycombo.value==2005)
		{
			if(mcombo.value==4 || mcombo.value==6 || mcombo.value==9 || mcombo.value==11)
				addDays(myval, 1, 30, 1)
			else if(mcombo.value==1 || mcombo.value==3 || mcombo.value==5 || mcombo.value==7 || mcombo.value==8 || mcombo.value==10 || mcombo.value==12)
				addDays(myval, 1, 31, 1)
			else if(mcombo.value==2)
				addDays(myval, 1, 28, 1)
		}
		else if(ycombo.value==2006)
		{
			if(mcombo.value==4 || mcombo.value==6 || mcombo.value==9 || mcombo.value==11)
				addDays(myval, 1, 30, 1)
			else if(mcombo.value==1 || mcombo.value==3 || mcombo.value==5 || mcombo.value==7 || mcombo.value==8 || mcombo.value==10 || mcombo.value==12)
				addDays(myval, 1, 31, 1)
			else if(mcombo.value==2)
				addDays(myval, 1, 28, 1)
		}
	}

	function durationChange()
	{
		var objForm=document.frmHotelSearch;

		var ddCID,mmCID,yyyyCID;
		var ddCOD,mmCOD,yyyyCOD;
		var tempCID,tempCOD;
		ddCID=document.frmHotelSearch.CmbBxCheckInDate_DD[document.frmHotelSearch.CmbBxCheckInDate_DD.selectedIndex].value;
		mmCID=document.frmHotelSearch.CmbBxCheckInDate_MM[document.frmHotelSearch.CmbBxCheckInDate_MM.selectedIndex].value;
		yyyyCID=document.frmHotelSearch.CmbBxCheckInDate_YYYY[document.frmHotelSearch.CmbBxCheckInDate_YYYY.selectedIndex].value;
		tempCID="";
		tempCID=mmCID + "/" + ddCID + "/" + yyyyCID;

		ddCOD=document.frmHotelSearch.CmbBxCheckOutDate_DD[document.frmHotelSearch.CmbBxCheckOutDate_DD.selectedIndex].value;
		mmCOD=document.frmHotelSearch.CmbBxCheckOutDate_MM[document.frmHotelSearch.CmbBxCheckOutDate_MM.selectedIndex].value;
		yyyyCOD=document.frmHotelSearch.CmbBxCheckOutDate_YYYY[document.frmHotelSearch.CmbBxCheckOutDate_YYYY.selectedIndex].value;
		tempCOD="";
		tempCOD=mmCOD + "/" + ddCOD + "/" + yyyyCOD;

		tempCID=new Date(yyyyCID,mmCID-1,ddCID);
		tempCOD=new Date(yyyyCOD,mmCOD-1,ddCOD);

		var duration=(tempCOD.getTime()-tempCID.getTime())/86400000;
		objForm.Duration.value=duration;
	}

	function changeDuration()
	{
		var objForm=document.frmHotelSearch;

		if(isNaN(objForm.Duration.value))
		{
			alert("Duration should be a number");
			objForm.Duration.value="1";
			objForm.Duration.focus();
			return;
		}

		var duration=new Number(objForm.Duration.value);

		if(duration<=0)
		{
			alert("Duration should be greater than zero");
			objForm.Duration.value="1";
			objForm.Duration.focus();
			return;
		}

		dateChange();
	}

	//Function added on 04/09/02 by Sameer for Check-out date change on change of Check-in date
	function dateChange()
	{
		var ddCID,mmCID,yyyyCID;
		var ddCOD,mmCOD,yyyyCOD;
		var tempCID,tempCOD;
		var duration;
		duration=new Number(document.frmHotelSearch.Duration.value);
		ddCID=document.frmHotelSearch.CmbBxCheckInDate_DD.value;
		mmCID=document.frmHotelSearch.CmbBxCheckInDate_MM.value;
		yyyyCID=document.frmHotelSearch.CmbBxCheckInDate_YYYY.value;
		tempCID="";
		tempCID=mmCID + "/" + ddCID + "/" + yyyyCID;
		if(!isValidDate(document.frmHotelSearch.CmbBxCheckInDate_DD,tempCID))
		return;
		tempCID=ddCID + "/" + mmCID + "/" + yyyyCID;
		tempCOD = dateAdd(tempCID,duration);
		ddCOD = tempCOD.substring(0,tempCOD.indexOf("/"));
		mmCOD = tempCOD.substring(tempCOD.indexOf("/") + 1,tempCOD.lastIndexOf("/"));
		yyyyCOD = tempCOD.substring(tempCOD.lastIndexOf("/") + 1);
		document.frmHotelSearch.CmbBxCheckOutDate_DD.value = ddCOD;
		document.frmHotelSearch.CmbBxCheckOutDate_MM.value = mmCOD;
		document.frmHotelSearch.CmbBxCheckOutDate_YYYY.value = yyyyCOD;
document.frmHotelSearch.CmbBxNumberOfRooms.focus();
	}

	function validateHS()
	{
	
var ddCID,mmCID,yyyyCID;
		var ddCOD,mmCOD,yyyyCOD;
		var tempCID,tempCOD;
		
		var chkinDate = document.frmHotelSearch.txtArriDate.value;
		var chkoutDate = document.frmHotelSearch.txtDepDate.value;
		inid = chkinDate.split('/');
		outid = chkoutDate.split('/');
		ddCID=inid[1];//document.frmHotelSearch.CmbBxCheckInDate_DD[document.frmHotelSearch.CmbBxCheckInDate_DD.selectedIndex].value;
		mmCID=inid[0];//document.frmHotelSearch.CmbBxCheckInDate_MM[document.frmHotelSearch.CmbBxCheckInDate_MM.selectedIndex].value;
		yyyyCID=inid[2];//document.frmHotelSearch.CmbBxCheckInDate_YYYY[document.frmHotelSearch.CmbBxCheckInDate_YYYY.selectedIndex].value;
		tempCID="";
		tempCID=document.frmHotelSearch.txtArriDate.value;//mmCID + "/" + ddCID + "/" + yyyyCID;

		ddCOD=outid[1];//document.frmHotelSearch.CmbBxCheckOutDate_DD[document.frmHotelSearch.CmbBxCheckOutDate_DD.selectedIndex].value;
		mmCOD=outid[0];//document.frmHotelSearch.CmbBxCheckOutDate_MM[document.frmHotelSearch.CmbBxCheckOutDate_MM.selectedIndex].value;
		yyyyCOD=outid[2];//document.frmHotelSearch.CmbBxCheckOutDate_YYYY[document.frmHotelSearch.CmbBxCheckOutDate_YYYY.selectedIndex].value;
		tempCOD="";
		tempCOD=document.frmHotelSearch.txtDepDate.value;//mmCOD + "/" + ddCOD + "/" + yyyyCOD;

		if (document.frmHotelSearch.cmbBxQuickSearch.selectedIndex==0)
		{
			alert("Please Select a Hotel");
			document.frmHotelSearch.cmbBxQuickSearch.focus();
			return;
		}

		if(!isValidDate(document.frmHotelSearch.CmbBxCheckInDate_DD,tempCID))
		return;
		if(!isValidDate(document.frmHotelSearch.CmbBxCheckOutDate_DD,tempCOD))
		return;

		/*************************/
		/* For arrival check days*/
		/*************************/

		var arrival_check_days;
		arrival_check_days=document.frmHotelSearch.hdnarrival_check_days.value;

		tempCID=new Date(yyyyCID,mmCID-1,ddCID);
		tempCOD=new Date(yyyyCOD,mmCOD-1,ddCOD);
		today=new Date();
		temp_day=parseInt(today.getDate())+ parseInt(arrival_check_days);

		//Create a variable temp date to check for the validation of arrival check days
		/*
		This section has been modified. The logic is to calculate the milliseconds of todays
		date and the number of milliseconds for arrival check days are added to it.
		Then the milliseconds are compared against milliseconds of the check-in-date and check-out-date.
		Also note that the check does not need to be applied for check-out date as check-out date has to be greater
		than the check-in date.
		-- Anil Diwan 31 August 2000
		*/
		d=(parseInt(arrival_check_days));

		if(tempCID.getTime()<(today.getTime()))
		{
			alert("Check-in date should be greater than current date")
			//alert("Check-in date should be " + arrival_check_days + " days greater than current date")
			//document.frmHotelSearch.CmbBxCheckInDate_DD.focus()
			return;
		}

		/************************/
		if(tempCOD<=tempCID)
		{
			alert("Check-out date should be greater than check-in date");
			return;
		}

		/*******************************************************************************************/
		/* Check to see if the stay period is Greater than or equal to the minimum allowed stay period*/
		/*******************************************************************************************/

		if((tempCOD.getTime() - tempCID.getTime()) < 1*86400000)
		{
			alert("The minimum stay period should not be less than 1 days");
			//document.frmHotelSearch.CmbBxCheckOutDate_DD.focus();
			return;
		}

		/*****************************/

		/*******************************************************************************************/
		/* Check to see if the stay period is less than or equal to the maximum allowed stay period*/
		/*******************************************************************************************/
		if((tempCOD.getTime()-tempCID.getTime())>30*86400000)
		{
			alert("The maximum stay period should not be greater than 30 days");
			//document.frmHotelSearch.CmbBxCheckOutDate_DD.focus();
			return;
		}
		/*****************************/



		/*******************************************************************************************/
		/* Check to see if the check in date is less than the maxmimum booking date                */
		/*******************************************************************************************/

		/*tempMaxBookingDate=new Date("6/17/2006");
		if(tempCID.getTime()>tempMaxBookingDate.getTime())
		{
			alert("Check in date cannot exceed Saturday, June 17, 2006");
			//document.frmHotelSearch.CmbBxCheckInDate_DD.focus();
			return;
		}

		if(tempCOD.getTime()>tempMaxBookingDate.getTime())
		{
			alert("Check out date cannot exceed Saturday, June 17, 2006");
			//document.frmHotelSearch.CmbBxCheckOutDate_DD.focus();
			return;
		}*/
		/*******************************************************************************************/



		var cmbVal,id
		cmbVal=document.frmHotelSearch.cmbBxQuickSearch[document.frmHotelSearch.cmbBxQuickSearch.selectedIndex].value;
		id=cmbVal.split("-");
		document.frmHotelSearch.CmbBxNumberOfRooms.value = document.frmHotelSearch.strRooms.value;
		varNoRooms = document.frmHotelSearch.CmbBxNumberOfRooms.value;
		varCID = mmCID+'/'+ddCID+'/' +yyyyCID
		varCOD = mmCOD+'/'+ddCOD+'/' +yyyyCOD
		varCurrType = check();

// Check for whether user is coming from package or not

		nextURL = "http://hotelbooking.travelpartnerweb.com/index.jsp?strGroupId=JOJ&itemCode="+id[0]+"&checkIn="+varCID+"&checkOut="+varCOD+"&currency="+varCurrType+"&strRooms="+varNoRooms+"&strAdultsRoom1="+document.frmHotelSearch.strAdultsRoom1.value+"&strChildrenRoom1="+document.frmHotelSearch.strChildrenRoom1.value+"&strAdultsRoom2="+document.frmHotelSearch.strAdultsRoom2.value+"&strChildrenRoom2="+document.frmHotelSearch.strChildrenRoom2.value+"&strAdultsRoom3="+document.frmHotelSearch.strAdultsRoom3.value+"&strChildrenRoom3="+document.frmHotelSearch.strChildrenRoom3.value+"&strAdultsRoom4="+document.frmHotelSearch.strAdultsRoom4.value+"&strChildrenRoom4="+document.frmHotelSearch.strChildrenRoom4.value;
		document.frmHotelSearch.action=nextURL;
		document.frmHotelSearch.submit();



	}

function popUpRoomListing(mypage){
	var myname = "Online_booking";
	var w = 900;
	var h = 550;
	var scroll = 1;
	var LeftPosition = (screen.width) ? (screen.width-w)/2 : 0;
	var TopPosition = (screen.height) ? (screen.height-h)/2 : 0;
	settings =	'height='+h+',width='+w+',top='+TopPosition+',left='+LeftPosition+',scrollbars='+scroll+',resizable,toolbar=0,location=0,directories=0,status=0,menubar=0';

	win = window.open(mypage,myname,settings)
}


function check()
{
	var varCurrent;
	varCurrent = document.frmHotelSearch.CmbBxCurrency.value;
	document.frmHotelSearch.hdnCurrType.value = varCurrent;
	return varCurrent;
}


// Function to display the calendar
	function openCal(i)
	{
		if(i==1)
		w=window.open("Calendar.asp?dt=6/21/2005&id=1","win2","toolbars=no,height=197,width=328,resizable=no,location=no,left=475,top=165");
		else
		w=window.open("Calendar.asp?dt=6/22/2005&id=2","win2","toolbars=no,height=197,width=328,resizable=no,location=no,left=475,top=191");
	}

// Function to be called on combo change
	function submitChange()
	{
		document.frmHotelSearch.action="default.asp";
		document.frmHotelSearch.submit();
	}

function isValidDate(obj,dt)
{
	newdt=new Date(dt);
	str=(newdt.getMonth()+1)+"/"+newdt.getDate()+"/"+newdt.getFullYear();
	if(dt==str) return true;
	alert("Invalid date.");
	//obj.focus();
	return false;
}

