<!--
function selectValueInField(theField,theValue)
{
   for (var x = 0; x < theField.options.length; x++)
   {
      if (theField.options[x].value == theValue)
      {
         theField.options[x].selected = true;
      }
   }
}

var cal15 = new CalendarPopup();
cal15.setReturnFunction("setMultipleValues4");

function setMultipleValues4(y,m,d) 
{

  var daysInMonth = new Array('nan','31','28','31','30','31','30','31','31','30','31','30','31');
  var rollBackYear = "false";
  
  if( y > document.forms['CheckAvailabilityForm'].arrivalYear.options[document.forms['CheckAvailabilityForm'].arrivalYear.options.length-1].value )
  {
       document.forms['CheckAvailabilityForm'].arrivalYear.selectedIndex = 0;
       rollBackYear = "true";
       
  }
  else if(y < document.forms['CheckAvailabilityForm'].arrivalYear.options[0].value)
  {
  		document.forms['CheckAvailabilityForm'].arrivalYear.selectedIndex = 0;
  }
 
  else
  {
       	document.forms['CheckAvailabilityForm'].arrivalYear.value=y;
  }

  
  document.forms['CheckAvailabilityForm'].arrivalMonth.selectedIndex=m-1;
  
  for (var i=0; i<document.forms['CheckAvailabilityForm'].arrivalDay.options.length; i++) 
  {  
    if (document.forms['CheckAvailabilityForm'].arrivalDay.options[i].value==d) 
    {
      document.forms['CheckAvailabilityForm'].arrivalDay.selectedIndex=i;
    }
  }
  
  //inc. the day by one if there are days left in the month.
  
   	if( (m!=2) || (((m == 2) && (d != 29)) || ( (m == 2) && (d != 28) ) ))
   	{
   		if( d+1 <= daysInMonth[m])
   		{ 
   			d++;
   			if(rollBackYear=="true")
   			{
   				
   	    	 	y = document.forms['CheckAvailabilityForm'].arrivalYear.options[0].value;
   			}
   			
   			setDepartDate(y,m,d);
   			return;
   		}
   		else if(d+1 > daysInMonth[m])
   		{ 
   	 	 d=1;
   	  
   	 	 
   	 	 if(daysInMonth.length == m+1)
   	  	 {
   	     	
   	     	m = 1; //skip 'nan' b/c months start
   	    	 		
   	    	 	if(y+1 <= document.forms['CheckAvailabilityForm'].arrivalYear.options[document.forms['CheckAvailabilityForm'].arrivalYear.options.length-1].value)
   	    	 	{	
   	    	 	  	y+=1;
   	    	 	}
   	    	 	else
   	    	 	{
   	    	 	   	
   	    	 		y = document.forms['CheckAvailabilityForm'].arrivalYear.options[0].value;
   	    	 	}
   	  		} 
   	  	  	else
   	  	   	{
   	  		  m++;
   	  	   	}
   	  	 setDepartDate(y,m,d);
   	  	 return;
   		}
   	}   
 }
 
function setDepartDate(y,m,d)
{
	document.forms['CheckAvailabilityForm'].departureYear.value = y;

	document.forms['CheckAvailabilityForm'].departureMonth.selectedIndex=m-1;
	
	for (var i=0; i<document.forms['CheckAvailabilityForm'].departureDay.options.length; i++) 
	{
    	if (document.forms['CheckAvailabilityForm'].departureDay.options[i].value==d) 
   		 {
        	document.forms['CheckAvailabilityForm'].departureDay.selectedIndex=i;
    	 }
    }
}
  
var cal16 = new CalendarPopup();
cal16.setReturnFunction("setMultipleValues5");
function setMultipleValues5(y,m,d) 
{

 	if( y > document.forms['CheckAvailabilityForm'].departureYear.options[document.forms['CheckAvailabilityForm'].departureYear.options.length-1].value )
 	{
    	document.forms['CheckAvailabilityForm'].departureYear.selectedIndex = 0;
       	rollBackYear = "true";
       
 	}
 	else if(y < document.forms['CheckAvailabilityForm'].departureYear.options[0].value)
 	{
  	
  		document.forms['CheckAvailabilityForm'].departureYear.selectedIndex = 0;
 	}
 
 	else
 	{
       	document.forms['CheckAvailabilityForm'].departureYear.value=y;
 	}

  
  	document.forms['CheckAvailabilityForm'].departureMonth.selectedIndex=m-1;
  
  
  
  	for (var i=0; i<document.forms['CheckAvailabilityForm'].departureDay.options.length; i++) 
  	{    
    	if (document.forms['CheckAvailabilityForm'].departureDay.options[i].value==d) 
    	{
        	document.forms['CheckAvailabilityForm'].departureDay.selectedIndex=i;
     	}
   	}
    
 } 
  
function getDateString(y_obj,m_obj,d_obj) 
{
  	var y = y_obj.options[y_obj.selectedIndex].value;
  	var m = m_obj.options[m_obj.selectedIndex].value;
 	 var d = d_obj.options[d_obj.selectedIndex].value;
  	if (y=="" || m=="") 
  	{ 
  		return null; 
  	}
  	if (d=="") 
  	{ 
  		d=1; 
  	}
  	var str= y+'-'+m+'-'+d;
  
  	return str;
}
  
var fixedYears=false;
function fixCheckAvailabilityYears()
{
	var today = new Date();
	var thisYear = today.getFullYear();
	var nextYear = thisYear+1;
	
	if(fixedYears==false)
	{
		//make sure that options contains the right values
		document.forms['CheckAvailabilityForm'].arrivalYear.length = 0;
		document.forms['CheckAvailabilityForm'].arrivalYear.options[0] = new Option(thisYear,thisYear,false,false);
		document.forms['CheckAvailabilityForm'].arrivalYear.options[1] = new Option(nextYear,nextYear,false,false);
		document.forms['CheckAvailabilityForm'].departureYear.length = 0;
		document.forms['CheckAvailabilityForm'].departureYear.options[0] = new Option(thisYear,thisYear,false,false);
		document.forms['CheckAvailabilityForm'].departureYear.options[1] = new Option(nextYear,nextYear,false,false);
		fixedYears=true;
	}
	
	
	var selectedMonth = document.forms['CheckAvailabilityForm'].arrivalMonth.options[document.forms['CheckAvailabilityForm'].arrivalMonth.selectedIndex].value;
	var selectedDay = document.forms['CheckAvailabilityForm'].arrivalDay.options[document.forms['CheckAvailabilityForm'].arrivalDay.selectedIndex].value;
	var selectedDateString = selectedMonth + '/' + selectedDay + '/' + thisYear;
	var selectedDate = new Date(selectedDateString);
	if(selectedDate<today && !(today.toDateString() == selectedDate.toDateString()))
	{
		//Set to next year
		document.forms['CheckAvailabilityForm'].arrivalYear.value=nextYear;
		document.forms['CheckAvailabilityForm'].departureYear.value=nextYear;
	}
	else
	{
		//Set to next year
		document.forms['CheckAvailabilityForm'].arrivalYear.value=thisYear;
		document.forms['CheckAvailabilityForm'].departureYear.value=thisYear;
	}

}

  
function changeCheckOutDate()
{  
    //added to do two things - 1: make sure years have valid values (this year and next) and 2: to increment year based on month selected
    fixCheckAvailabilityYears(); 
  
    var month = document.forms['CheckAvailabilityForm'].arrivalMonth.options[document.forms['CheckAvailabilityForm'].arrivalMonth.selectedIndex].value;
    var day = document.forms['CheckAvailabilityForm'].arrivalDay.options[document.forms['CheckAvailabilityForm'].arrivalDay.selectedIndex].value;
    var year = document.forms['CheckAvailabilityForm'].arrivalYear.options[document.forms['CheckAvailabilityForm'].arrivalYear.selectedIndex].value;
   
   
    var checkIn = new Date();
    checkIn.setYear(year);
    checkIn.setDate(day);
    checkIn.setMonth(month-1);
    
	var checkInUTC = checkIn.getTime();
	var checkOutUTC = checkInUTC + (24*60*60*1000);
	checkIn = new Date();
	checkIn.setTime(checkInUTC);
	var checkOut = new Date();
	checkOut.setTime(checkOutUTC);
	
	document.forms['CheckAvailabilityForm'].departureMonth.selectedIndex = checkOut.getMonth();
	document.forms['CheckAvailabilityForm'].departureYear.value= checkOut.getYear();
	selectValueInField(document.forms['CheckAvailabilityForm'].departureYear,checkOut.getYear());
	
	
	for (var i=0; i<document.forms['CheckAvailabilityForm'].departureDay.options.length; i++) 
	{
    	if (document.forms['CheckAvailabilityForm'].departureDay.options[i].value==checkOut.getDate())
    	 {
        	document.forms['CheckAvailabilityForm'].departureDay.selectedIndex=i;
    	 }
    }
    
    //the last year listed in the dropdown box.
    var lastYear =  document.forms['CheckAvailabilityForm'].arrivalYear.options[document.forms['CheckAvailabilityForm'].arrivalYear.options.length-1].value;
    
    //If the user selects December and the year they selected is the 
    //last one in the dropdown box then set the departure year to the first one in the dropdown box.
    //This is done as error checking.  If it isn't done then the calendar popup will
    //cause a javascript error.
    
    
    if((month == 12) && (year == lastYear) && (day == 31))
    {	
    	document.forms['CheckAvailabilityForm'].departureYear.selectedIndex= 0;
    	document.forms['CheckAvailabilityForm'].departureMonth.selectedIndex = 0;
		document.forms['CheckAvailabilityForm'].departureDay.selectedIndex=0;
		
    }
	
	else if((month == 12) && (year == lastYear ) && (day != 31))
	{
	   document.forms['CheckAvailabilityForm'].departureYear.value= checkOut.getYear();
	}
		
	else if((month == 12) && (year != lastYear ) && (day == 31))
	{
		document.forms['CheckAvailabilityForm'].departureYear.selectedIndex= 1;
    	document.forms['CheckAvailabilityForm'].departureMonth.selectedIndex = 0;
		document.forms['CheckAvailabilityForm'].departureDay.selectedIndex=0;		
	}
	
	
	if(month == 2 && (day == 30 || day == 31 || day == 29))
	{
		if((day == 31) || (day == 30))
		{
			document.forms['CheckAvailabilityForm'].departureMonth.selectedIndex = 2;
			document.forms['CheckAvailabilityForm'].departureDay.selectedIndex=0;
		
			if ( ((year%4==0)&&(year%100 != 0) ) || (year%400==0) )
			{
				document.forms['CheckAvailabilityForm'].arrivalDay.selectedIndex = 28;
			} 
			else
			{
				document.forms['CheckAvailabilityForm'].arrivalDay.selectedIndex = 27;
			}
		}
		else if (day == 29 && !(((year%4==0)&&(year%100 != 0) ) || (year%400==0)))
		{
			document.forms['CheckAvailabilityForm'].arrivalDay.selectedIndex = 27;
			document.forms['CheckAvailabilityForm'].departureMonth.selectedIndex = 2;
			document.forms['CheckAvailabilityForm'].departureDay.selectedIndex=0;
		}
	}
	
	//only 30 days in these months, so we must need.
	if((month == 9 || month == 11 || month == 6 || month == 4) && (day == 31))
	{
		document.forms['CheckAvailabilityForm'].departureMonth.selectedIndex = document.forms['CheckAvailabilityForm'].arrivalMonth.selectedIndex +1;
		document.forms['CheckAvailabilityForm'].arrivalDay.selectedIndex = 29;
		document.forms['CheckAvailabilityForm'].departureDay.selectedIndex=0;
	}
	else
	{
		if((month !=12) && (month != 9 || month != 11 || month != 6 || month != 4) && (day == 31))
		{
			document.forms['CheckAvailabilityForm'].departureDay.selectedIndex = 0;
			document.forms['CheckAvailabilityForm'].departureMonth.selectedIndex = document.forms['CheckAvailabilityForm'].arrivalMonth.selectedIndex +1 ;
				
		}
	}
	
	enableBookNow();
}

// function setTodayDate()
// Description: Setting current date in the Check In Select Boxes
// Author: Sailesh Raghavan
// Dated: April 21, 2006 

function setTodayDate(){
	
	if(document.getElementById("arrivalMonth") && document.getElementById("arrivalDay")){
	//creating a new date object - extracting current date and month from this.
	var date = new Date();
	var currentmonth = date.getMonth();
	var currentdate  = date.getDate();
	var currentyear = date.getFullYear();
	
	// Mapping the CurrentMonth and Currentdate to the Checkin Month & Day Dropdowns.
	document.getElementById("arrivalMonth").selectedIndex=currentmonth;

	// Commented below in order to change checkIn and checkOut dates to tomorrow and day after tomm.
	document.getElementById("arrivalDay").selectedIndex=currentdate-1;
	
	
	// Calling the changecheckoutdate function to set the Checkout date as one date after the checkin date.
	changeCheckOutDate();
	}
}

// function setTomorrowDate()
// Description: Setting current date + 1 in the Check In Select Boxes
// Dated: December 18, 2006 

function setTomorrowDate(){
	
	if(document.getElementById("arrivalMonth") && document.getElementById("arrivalDay")){
	//creating a new date object - extracting current date and month from this.
	var date = new Date();
	//add a day to the date
	date.setDate(date.getDate() + 1);
	var currentmonth = date.getMonth();
	var currentdate  = date.getDate();
	var currentyear = date.getFullYear();

	
	// Mapping the CurrentMonth and Currentdate to the Checkin Month & Day Dropdowns.
	document.getElementById("arrivalMonth").selectedIndex=currentmonth;

	// Commented below in order to change checkIn and checkOut dates to tomorrow and day after tomm.
	document.getElementById("arrivalDay").selectedIndex=currentdate-1;

	selectValueInField(document.forms['CheckAvailabilityForm'].arrivalYear,currentyear);
	
	// Calling the changecheckoutdate function to set the Checkout date as one date after the checkin date.
	changeCheckOutDate();
	}
}

function enableBookNow(){
	/*alert(document.getElementById("bookNowButton").className);*/
	if(document.getElementById("bookNowButton"))
	{
		document.getElementById("bookNowButton").className="bookNow showText"
	}
}

//--> 
if(arrOnLoad){
	arrOnLoad.push("setTomorrowDate()");	
}