<!--
//Calender Starts From Here
var monthName = new Array ( "January","February","March","April",
						    "May","June","July","August",
							"September","October","November","December")
//opens a new window for the calendar

// MOE: changing the variable io to fix IE bug 11-02-2000
// function createCalendar(month,year,io) {
// var inout = io;

function createCalendar(month,year,inputOutput) {
var d1=new Date();


var inout = inputOutput;
if (!isBrowserSupp()) {

	alert("Your browser appears to be outdated and does not support this feature.")
 	return;
	}
if (navigator.appVersion.indexOf("Mac",0) != -1)
	{
    	calendarWindow = window.open("","Calendar","width=230,height=250,resizable=no,scrollbars=no");
  	}
else
	{
	calendarWindow = window.open("","Calendar","width=220,height=215,resizable=no,scrollbars=no");
  	}
var mthIdx = month.options.selectedIndex
// var mthVal = getMonthNumber(month.options[mthIdx].text)
var yearVal = year.options[year.options.selectedIndex].text

// call the function to populate the window
// the variable io seem to have a problem with IE. Changed so that it will not use it.
// MOE: Changed it back again but instead of io inputOutput 11-02-2000
//generateCalendar(calendarWindow,mthIdx,yearVal)

generateCalendar(calendarWindow,mthIdx,yearVal,inout);

}


//generates the meat of the calendar
// Moe: Added the inputOutput parameter to replace io 11-02-2000
//function generateCalendar(target,mthIdx,year) {

function generateCalendar(target,mthIdx,year,inputOutput) {

if (target.opener == null) target.opener = self;
		target.focus();

	if (!isBrowserSupp()) {
		return;
	}

//begin table for calendar
target.document.open()
calendar = "<html><head><title>calendar</title></head><body bgcolor=ffffff><!--<center><img src='logo.gif' border=0></center>-->"
calendar +="<table border=0 cellspacing=0 cellpadding=0 width=200>"
calendar +="<tr valign=top>"

// var mthIdx = parseInt(month);
var endday = getDaysInMonth(mthIdx, year)

//month header
calendar +="<td colspan=7 align=center bgcolor=#C0C0C0>"
calendar +="<b><font face='Helvetica,Arial,Futura'>" + monthName[mthIdx] + " " + year + "</font></b></td></tr>"

//writes in the day of the week labels
calendar +="</tr><tr align=center>"
calendar +="<td width=10><font face='Helvetica,Arial,Futura' color='#FF0000'>&nbsp;<b>S</b></font></td>"
calendar +="<td width=10><font face='Helvetica,Arial,Futura'>&nbsp;<b>M</b></font></td>"
calendar +="<td width=10><font face='Helvetica,Arial,Futura'>&nbsp;<b>T</b></font></td>"
calendar +="<td width=10><font face='Helvetica,Arial,Futura'>&nbsp;<b>W</b></font></td>"
calendar +="<td width=10><font face='Helvetica,Arial,Futura'>&nbsp;<b>T</b></font></td>"
calendar +="<td width=10><font face='Helvetica,Arial,Futura'>&nbsp;<b>F</b></font></td>"
calendar +="<td width=10><font face='Helvetica,Arial,Futura' color='#FF0000'>&nbsp;<b>S</b></font></td>"
calendar +="</tr>"

// month = mthIdx + 1;
// wholeDate = month + "/01/" + year
// thedate = new Date(wholeDate)
thedate = new Date (year, mthIdx, 1);
firstDay = thedate.getDay()

selectedmonth = mthIdx;
var today = new Date();
var thisyear = today.getYear() + 1900;
//adb selectedyear = document.frm_search.inyear.options.selectedIndex
selectedyear = year

var lastDay = (endday + firstDay+1)

calendar +="<tr>"
for (var i = 1; i < lastDay; i++)
	{
	if (i <= firstDay)
		{
		// 'empty' boxes prior to first day
		calendar +="<td>&nbsp;</td>"
		}
	else
		{
		// enter date number
		// Changed to not to use "io"--Hardcoded 'In' instead.
		// IE seem to have a trouble with this variable.
		// Moe: Adding the "inputOutput" variable to make it dynamic
		
		//Nafraz:	reversed the update above to make it dynamic
	
		//calendar +="<td align=center><a href='JavaScript:self.close();opener.closeCalendarIn("+(i-firstDay) + ")'> "+(i-firstDay)+"</a></td>"

		//if date before todays disable hyperlink
		if (((selectedmonth==today.getMonth()) && ((i-firstDay)>=today.getDate()))||(selectedmonth>today.getMonth())||(year>today.getFullYear()))
		{
			calendar +="<td align=center><a href='JavaScript:self.close();opener.closeCalendar"+inputOutput+"("+(i-firstDay) + ")'> "+(i-firstDay)+"</a></td>"
		}
		else
		{
			calendar +="<td align=center> "+(i-firstDay)+"</td>"
		}

		}
	//must start new row after each week
	if (i % 7 == 0 &&  i != lastDay)
		{
		calendar +="</tr><tr>"
		}
	}
calendar +="</tr>"

//separator line
calendar +="<tr><td colspan=7 align=center width=200><hr noshade></td></tr>"

// next month and previous month buttons
var goPrevMonth = prevMonth(mthIdx)
var goNextMonth = nextMonth(mthIdx)

//alert(goPrevMonth);

var d=new Date();
//alert(d.getMonth());

var nextYear = changeYear( "next", mthIdx, parseInt(year) )
var prevYear = changeYear( "prev", mthIdx, parseInt(year) )
//alert(prevYear);



if( navigator.userAgent.indexOf('MSIE',0) != -1 ) {


	calendar +="<tr><td align=left colspan=3 bgcolor=#A7CCDC>"
	if (((parseInt(year)==d.getFullYear()) && (mthIdx>d.getMonth()))||(parseInt(year)>d.getFullYear())){
	calendar +="<a href='javascript:opener.generateCalendar(self,"+goPrevMonth+","+prevYear+",\""+inputOutput+"\")'><font face=arial>prev</font></a>"
	}
	calendar +="</td>"
	calendar +="<td align=center colspan=1 bgcolor=#A7CCDC>&nbsp;</td>"
	calendar +="<td align=right colspan=3 bgcolor=#A7CCDC>"
	if (nextYear!=d.getFullYear()+2){
	calendar +="<a href='javascript:opener.generateCalendar(self,"+goNextMonth+","+nextYear+",\""+inputOutput+"\")'><font face=arial>next</font></a>"
	}
	calendar +="</td></tr>"
	
	calendar +="</table></body></html>"
	target.document.close()
} else {
	calendar +="<td align=left colspan=3 bgcolor=#A7CCDC>"
	if (((parseInt(year)==d.getFullYear()) && (mthIdx>d.getMonth()))||(parseInt(year)>d.getFullYear())){
	calendar +="<a href='javascript:opener.generateCalendar(opener.calendarWindow,"+goPrevMonth+","+prevYear+",\""+inputOutput+"\")'><font face=arial>prev</font></a>"
	}
	else
	{
	calendar +="&nbsp;"
	}
	calendar +="</td>"
	calendar +="<td align=center colspan=1 bgcolor=#A7CCDC>&nbsp;</td>"
	calendar +="<td align=right colspan=3 bgcolor=#A7CCDC>"
	if (nextYear!=d.getFullYear()+2){
	calendar +="<a href='javascript:opener.generateCalendar(opener.calendarWindow,"+goNextMonth+","+nextYear+",\""+inputOutput+"\")'><font face=arial>next</font></a>"
	}
	else
	{
	calendar +="&nbsp;"
	}
	calendar +="</td></tr>"
	calendar +="</table></body></html>"
}

target.document.write(calendar);
target.document.close()
}

//sets the default departure date when the page loads
function setDefaultDepDate(arrDay, month, year)
{
	selectedmonth = month;
	selectedyear = year;
	closeCalendarIn(arrDay);
}

//changes date when a date is clicked
function closeCalendarIn(day)
{
var arrMonthField = document.frm_search.arrivalMonth;var arrDayField = document.frm_search.arrivalDay;var arrYearField = document.frm_search.arrivalYear;var depMonthField = document.frm_search.departureMonth;var depDayField = document.frm_search.departureDay;var depYearField = document.frm_search.departureYear;

var yrIdx = getIndex (selectedyear,arrYearField );

arrMonthField.options.selectedIndex=selectedmonth;
arrYearField.options.selectedIndex= yrIdx;
arrDayField.options.selectedIndex=parseInt(day) - 1;
var res = adjustDate(selectedmonth, arrDayField, arrYearField);
if (res != 0)
	{
	if (!(depMonthField.options.selectedIndex > arrMonthField.options.selectedIndex))
	{
		depDayField.options.selectedIndex=0;
		depMonthField.options.selectedIndex = arrMonthField.options.selectedIndex+1;
	}
	}
else
	{
	//check if departure > arrival date. if true leave departure unchanged
	//added by:	Nafraz
	//date;		28/04/2005
	if (!((depMonthField.options.selectedIndex == arrMonthField.options.selectedIndex) && (depDayField.options.selectedIndex > arrDayField.options.selectedIndex)) && 
		!(depMonthField.options.selectedIndex > arrMonthField.options.selectedIndex))
		{
			depMonthField.options.selectedIndex = arrMonthField.options.selectedIndex;
			depDayField.options.selectedIndex = arrDayField.options.selectedIndex+1;
		}
	}
depYearField.options.selectedIndex = arrYearField.options.selectedIndex;
if ((arrMonthField.options.selectedIndex == 11) && (arrDayField.options.selectedIndex == 30))
	{
	depMonthField.options.selectedIndex=0;
	depYearField.options.selectedIndex++;
	}
return;
}

function closeCalendarOut(day)
{
var depMonthField = document.frm_search.departureMonth;var depDayField = document.frm_search.departureDay;var depYearField = document.frm_search.departureYear;

var yrIdx = getIndex (selectedyear,depYearField );
depMonthField.options.selectedIndex=selectedmonth;
depYearField.options.selectedIndex=yrIdx;
depDayField.options.selectedIndex=parseInt(day) - 1;
var res = adjustDate(selectedmonth, depDayField, depYearField);
}

// Checks if browser is Netscape 2.0x since the options array properties don't work with Netscape 2.0x
function isBrowserSupp() {

    // Get the version of the browser
    version =  parseFloat( navigator.appVersion );

    if ( ( version >= 2.0 ) && ( version < 2.1 ) && ( navigator.appName.indexOf( "Netscape" ) != -1 ) ) {
        return false;
    }
    else {
	return true;
    }
}



function getDaysInMonth(mthIdx, YrStr)
{
// all the rest have 31
var maxDays=31
// expect Feb. (of course)
if (mthIdx==1)
	{
	if (isLeapYear(YrStr))
		{
		maxDays=29;
		}
	else
		{
		maxDays=28;
		}
	}
// thirty days hath...
if (mthIdx==3 || mthIdx==5 || mthIdx==8 || mthIdx==10)
	{
	maxDays=30;
	}
return maxDays;
}

//Calendar Section

//calculation functions
function nextMonth(month) {
	if (month==11) {
		return 0;
	} else {
		return (month+1);
	}
}


function prevMonth(month)
{
var prevMonth = (month-1)
if (month==0)
	{
	prevMonth = 11;
	}
return prevMonth
}

//increments or decrements month when it goes past Jan or Dec
function changeYear(direction,month,year) {
var theYear = year
if ( direction=="next" ) {
	if (month == 11) {
		theYear = (year+1)
	}
}
if (direction=="prev") {
	if (month == 0) {
		theYear = (year-1)
	}
}

return theYear
}


// Get the index of the corresponding option in the field's list
function getIndex (val, field) {
	var i;
	for (i = 0; i < field.length; i++) {
		if (val == field.options[i].text) {
			return i;
		}
	}
	return -1;
}

function adjustDate(mthIdx, Dt, Yr)
{
var value=0;
var numDays=getDaysInMonth(mthIdx, Yr.options[Yr.options.selectedIndex].text);

if (mthIdx==1)
	{
	if (Dt.options.selectedIndex + 1 < numDays)
		{
		return 0;
		}
	else
		{
		Dt.options.selectedIndex=numDays - 1;
		//check for leap year
		if (numDays==29)
			{
			return 99;
			}
		else
			{
			return 1;
			}
		}
	}
if (Dt.options.selectedIndex + 1 < numDays)
	{
	value=0;
	}
else
	{
	if (Dt.options.selectedIndex + 1 > numDays)
		{
		Dt.options.selectedIndex--;
		value=3;
		}
	else
		{
		//index is 31 or 30
		value=2;
		}
	}
return value;
}


function isLeapYear(yrStr)
{
var leapYear=false;
var year = parseInt(yrStr, 10);
// every fourth year is a leap year
if (year%4 == 0)
	{
	leapYear=true;
	// unless it's a multiple of 100
	if (year%100 == 0)
		{
		leapYear=false;
		// unless it's a multiple of 400
		if (year%400 == 0)
			{
			leapYear=true;
			}
		}
	}
return leapYear;
}


//changes departure month when arrival month is changed
function inMonthChange( inM, outM, inD, outD, inY, outY ) {

	if ( !isBrowserSupp() ) {

		return;
	}

	var res = adjustDate(inM.options.selectedIndex, inD,inY);

	if ( res != 0 ) {
		outD.options.selectedIndex=0;
		outM.options.selectedIndex = inM.options.selectedIndex + 1;
	} else {
		outM.options.selectedIndex = inM.options.selectedIndex;
		outD.options.selectedIndex = inD.options.selectedIndex + 1;
	}

	// Set the out year to the same as the in year
	outY.options.selectedIndex = inY.options.selectedIndex;

	var currentMonth = ( new Date() ).getMonth();

	// If the in date is 12/31/?? set the out date to 01/01/??
	if ( ( inM.options.selectedIndex == 11 ) && ( inD.options.selectedIndex == 30 ) ) {
		outM.options.selectedIndex=0;
		outY.options.selectedIndex++;
	}

	// If the selected month is before the current month, increment the in year.
	if ( inM.options.selectedIndex < currentMonth ) {

		// First make sure it is a valid selection
		if ( inY.selectedIndex < ( inY.options.length - 1 ) )
			inY.options.selectedIndex++;

		// Now set the out year to the same as the in year
		outY.options.selectedIndex = inY.options.selectedIndex;
	}

	return;
}


//changes departure day when arrival day is changed
function inDayChange(inD, outD, inM, outM, inY, outY)
{
if (!isBrowserSupp())
	{
 	return;
	}
var Inmth = inM.options.selectedIndex;

var res =adjustDate(Inmth, inD, inY)
if (res != 0)
	{
	outD.options.selectedIndex=0;
	outM.options.selectedIndex=inM.options.selectedIndex + 1;
	}
else
	{
	outM.options.selectedIndex = inM.options.selectedIndex;
	outD.options.selectedIndex = inD.options.selectedIndex+1;
	}
outY.options.selectedIndex = inY.options.selectedIndex;
if ((inM.options.selectedIndex == 11) && (inD.options.selectedIndex == 30))
	{
	outM.options.selectedIndex=0;
	outY.options.selectedIndex++;
	}
return;
}


//changes departure year when arrival year is changed
function inYearChange(inY, outY, inM, outM, inD, outD) {

	if (!isBrowserSupp()) {
		return;
	}

	// Special Handling for December 31
	if ( inD.options.selectedIndex == 30 && inM.options.selectedIndex == 11 ) {
 		outY.options.selectedIndex = inY.options.selectedIndex + 1;
	} else {
 		outY.options.selectedIndex = inY.options.selectedIndex;
	}

	adjustDate(inM.options.selectedIndex, inD,inY);
	return;
}

function outMonthChange(outM, outD, outY) {

	if ( !isBrowserSupp() ) {
		return;
	}

	adjustDate( outM.options.selectedIndex, outD, outY );

	return;
}
function outMonthChange(outM, outD, outY) {

	if ( !isBrowserSupp() ) {
		return;
	}

	adjustDate( outM.options.selectedIndex, outD, outY );

	return;
}


function outDayChange(outD, outM, outY)
{
if (!isBrowserSupp())
	{
	return;
	}

adjustDate(outM.options.selectedIndex,outD,outY);
return;
}


function outYearChange(outY, outM, outD)
{
if (!isBrowserSupp())
	{
	return;
	}

adjustDate(outM.options.selectedIndex,outD,outY);
return;
}

//End --- Calender



// Function which handles checking the entire res form for errors before submitting


function validateResrv(formData) {

var validity=true;
var arrMonthField = formData.arrivalMonth;
var arrDayField = formData.arrivalDay;
var arrYearField = formData.arrivalYear;
var depMonthField = formData.departureMonth;
var depDayField = formData.departureDay;
var depYearField = formData.departureYear;

if ( !isBrowserSupp() ) {
	return validity;
}

var inMIdx = arrMonthField.options.selectedIndex;
var outMIdx = depMonthField.options.selectedIndex;
var inDIdx = arrDayField.options.selectedIndex;
var outDIdx = depDayField.options.selectedIndex;
var inYrIdx = arrYearField.options.selectedIndex;
var outYrIdx = depYearField.options.selectedIndex;

// Check to make sure a valid departure year was selected.
if ( outYrIdx == -1 ) {
	alert( "The Departure date selected is invalid." );
	return false;
}

inDate = new Date (parseInt(arrYearField.options[inYrIdx].text), inMIdx, inDIdx + 1);
outDate = new Date (parseInt(depYearField.options[outYrIdx].text), outMIdx, outDIdx + 1);

var inDtVal = inDate.getTime();
var outDtVal = outDate.getTime();

// Create a String representation of the current month day year.
var currentTime = new Date();
var dateString = "";

// Check to see if the getYear() method returns the 4 character year.
// If not, add 1900 to the returned year.
if ( currentTime.getYear().toString().length != 4 ) {
	dateString = monthName[ currentTime.getMonth() ] + " " + currentTime.getDate() + ", " + ( currentTime.getYear() + 1900 );
} else {
	dateString = monthName[ currentTime.getMonth() ] + " " + currentTime.getDate() + ", " + ( currentTime.getYear() );
}

// Get the current time in milliseconds.
var curDtVal = ( new Date( dateString ) ).getTime();

// Validate the arrival and departure dates
if ( inDtVal > outDtVal ) {

	alert("The Departure date selected is invalid." );
	validity= false;

} else if ( ( inDtVal < curDtVal ) && ( outDtVal < curDtVal ) ) {

	alert( "The arrival and departure dates are invalid." );
	validity= false;

} else if ( inDtVal < curDtVal ) {

	alert( "The Arrival date selected is invalid." );
	validity= false;

} else if ( outDtVal < curDtVal ) {

	alert( "The Departure date selected is invalid." );
	validity= false;

} //else {

	// Check to make sure they are booking a room for more than the
	// allowed number of consecutive days.
	//var numDays = Math.round( (outDtVal-inDtVal) / (1000*60*60*24) );
	//if ( numDays > 100 ) {
	//	alert("We are sorry.  You cannot make reservations for more than 21 days.\nPlease adjust your arrival and departure dates and resubmit your request.");
	//	validity= false;
	//}
//}

//-------------------SIVA
/*if
((inDate.getDate() == 13 || inDate.getDate() == 14 || inDate.getDate() == 15) && inDate.getMonth() == 1 && inDate.getYear() == 2005){

	if((outDate.getDate() - inDate.getDate()) < 2 && inDate.getMonth() == outDate.getMonth() && inDate.getYear() == outDate.getYear()){
		alert("Sorry. Minimum 2 nights bookings needed for this period.");
		validity = false;
	}   
}*/
//-------------------SIVA


return validity;
}
-->