//Javascript for Booking Component//

function submitFunctionCrerar(){
	if(document.getElementById('HotelID')[document.getElementById('HotelID').selectedIndex].value != "all"){
		document.form1.action=" https://reservations.ihotelier.com/istay.cfm "
		document.form1.method="get";
	}
}

function updateStart(cal)
{
    var date = document.getElementById("DateIn");
    var arr = date.value.split("/");
    var selectedYear = "";
    
    document.getElementById('MM1').selectedIndex = arr[0]-1;
    document.getElementById('DD1').selectedIndex = arr[1]-1;
  
    for(i=0; i<2; i++){
    if(document.getElementById('YY1').options[i].text == arr[2]){
           
          document.getElementById('YY1').selectedIndex = i;
      }
   }
}

function assembleDate() {
         var theMonth= document.getElementById('MM1')[document.getElementById('MM1').selectedIndex].value;
         var theDay= document.getElementById('DD1')[document.getElementById('DD1').selectedIndex].value;
         var theYear= document.form1.YY1[document.form1.YY1.selectedIndex].text;

         document.getElementById('DateIn').value = theMonth + "/" + theDay + "/" + theYear;

}

   /* function openCalendar(FormElement) {
        var calendarwindow;
        url = "calendar_1.html?formname=form1&formelement=" + FormElement; 
        calendarwindow = window.open(url)//,"thewindow","toolbar=no,LEFT=300,TOP=250,WIDTH=170, HEIGHT=140,status=no,scrollbars=no,resize=no,menubar=no");
        calendarwindow.focus();
}*/


//set todays date

Now = new Date();

NowDay = Now.getDate();

NowMonth = Now.getMonth();

NowYear = Now.getYear();

if (NowYear < 2000) NowYear += 1900; //for Netscape



// set tomorrows date

var tomorrow = new Date(Now.getTime() + (1 * 86400000));

tDay = tomorrow.getDate();

tMonth = tomorrow.getMonth();

tYear = tomorrow.getYear();

if (tYear < 2000) tYear += 1900; //for Netscape



//function for returning how many days there are in a month including leap years

function DaysInMonth(WhichMonth, WhichYear)

{

var DaysInMonth = 31;

if (WhichMonth == "Apr" || WhichMonth == "Jun" || WhichMonth == "Sep" || WhichMonth == "Nov") DaysInMonth = 30;

if (WhichMonth == "Feb" && (WhichYear/4) != Math.floor(WhichYear/4))DaysInMonth = 28;

if (WhichMonth == "Feb" && (WhichYear/4) == Math.floor(WhichYear/4))DaysInMonth = 29;

return DaysInMonth;

}



//function to change the available days in a months

function ChangeOptionDays()

{

DaysObject = eval("document.form1.DD1");

MonthObject = eval("document.form1.MM1");

YearObject = eval("document.form1.YY1");


Month = MonthObject[MonthObject.selectedIndex].text;

Year = YearObject[YearObject.selectedIndex].text;

DaysForThisSelection = DaysInMonth(Month, Year);

CurrentDaysInSelection = DaysObject.length;

if (CurrentDaysInSelection > DaysForThisSelection)

{

for (i=0; i<(CurrentDaysInSelection-DaysForThisSelection); i++)

{

DaysObject.options[DaysObject.options.length - 1] = null

}

}

if (DaysForThisSelection > CurrentDaysInSelection)

{

for (i=0; i<(DaysForThisSelection-CurrentDaysInSelection); i++)

{

NewOption = new Option(DaysObject.options.length + 1);

DaysObject.options.add(NewOption);

}

}

if (DaysObject.selectedIndex < 0) DaysObject.selectedIndex == 0;


assembleDate();
}



//function to set options to tomorrow

function SetToToday()
{

DaysObject = eval("document.form1.DD1");

MonthObject = eval("document.form1.MM1");

YearObject = eval("document.form1.YY1");



YearObject[0].selected = true;

MonthObject[tMonth].selected = true;

ChangeOptionDays();

DaysObject[tDay-1].selected = true;

assembleDate();
}



//function to write option years plus x

function WriteYearOptions(YearsAhead)

{

line = "";

for (i=0; i<YearsAhead; i++)

{

line += "<OPTION>";

line += NowYear + i;

line += "</OPTION>";

}

return line;

}

/*
 * Booking Function Update to resolve Google Analytics Nov 2008 - Eddie Foreman, Ezone Software
 */

	function sendbooking()
	{
		var theMonth= document.getElementById('MM1')[document.getElementById('MM1').selectedIndex].value;
		var theDay= document.getElementById('DD1')[document.getElementById('DD1').selectedIndex].value;
		var theYear= document.form1.YY1[document.form1.YY1.selectedIndex].text;
		var nights= document.form1.Length[document.form1.Length.selectedIndex].text;
		var rooms= document.form1.Rooms[document.form1.Rooms.selectedIndex].text;
		var adults= document.form1.Adults[document.form1.Adults.selectedIndex].text;
		var DateIn = theMonth +"%2F"+ theDay + "%2F" +theYear;
		var hotelId = document.getElementById('HotelID')[document.getElementById('HotelID').selectedIndex].value;
		if(hotelId == "all"){
			document.form1.action="http://reservations.ihotelier.com/areasearch/default.cfm?PortalSymbol=CRH";
		}else{
			document.form1.action="https://reservations.ihotelier.com/crs/step1.cfm?hotelid="+hotelId+"&DD1="+theDay+"&MM1="+theMonth+"&YY1="+theYear+"&DateIn="+DateIn+"&Length="+nights+"&Rooms="+rooms+"&Adults="+adults+"&Children=0&LanguageID=1&search=Check";
		}
	}
	
	function sendbookingEnglish()
	{
		var theMonth= document.getElementById('MM1')[document.getElementById('MM1').selectedIndex].value;
		var theDay= document.getElementById('DD1')[document.getElementById('DD1').selectedIndex].value;
		var theYear= document.form1.YY1[document.form1.YY1.selectedIndex].text;
		var nights= document.form1.Length[document.form1.Length.selectedIndex].text;
		var rooms= document.form1.Rooms[document.form1.Rooms.selectedIndex].text;
		var adults= document.form1.Adults[document.form1.Adults.selectedIndex].text;
		var DateIn = theMonth +"%2F"+ theDay + "%2F" +theYear;
		var hotelId = document.getElementById('HotelID')[document.getElementById('HotelID').selectedIndex].value;
		if(hotelId == "all"){
			document.form1.action="http://reservations.ihotelier.com/areasearch/default.cfm?PortalSymbol=CRH";
		}else{
			document.form1.action="https://reservations.ihotelier.com/crs/step1.cfm?hotelid="+hotelId+"&DD1="+theDay+"&MM1="+theMonth+"&YY1="+theYear+"&DateIn="+DateIn+"&Length="+nights+"&Rooms="+rooms+"&Adults="+adults+"&Children=0&LanguageID=1&search=Check";
		}
	}
	
	function sendbookingDutch()
	{
		var theMonth= document.getElementById('MM1')[document.getElementById('MM1').selectedIndex].value;
		var theDay= document.getElementById('DD1')[document.getElementById('DD1').selectedIndex].value;
		var theYear= document.form1.YY1[document.form1.YY1.selectedIndex].text;
		var nights= document.form1.Length[document.form1.Length.selectedIndex].text;
		var rooms= document.form1.Rooms[document.form1.Rooms.selectedIndex].text;
		var adults= document.form1.Adults[document.form1.Adults.selectedIndex].text;
		var DateIn = theMonth +"%2F"+ theDay + "%2F" +theYear;
		var hotelId = document.getElementById('HotelID')[document.getElementById('HotelID').selectedIndex].value;
		if(hotelId == "all"){
			document.form1.action="http://reservations.ihotelier.com/areasearch/default.cfm?PortalSymbol=CRH";
		}else{
			document.form1.action="https://reservations.ihotelier.com/crs/step1.cfm?hotelid="+hotelId+"&DD1="+theDay+"&MM1="+theMonth+"&YY1="+theYear+"&DateIn="+DateIn+"&Length="+nights+"&Rooms="+rooms+"&Adults="+adults+"&Children=0&LanguageID=10&search=Check";
		}
	}
	
	function sendbookingFrench()
	{
		var theMonth= document.getElementById('MM1')[document.getElementById('MM1').selectedIndex].value;
		var theDay= document.getElementById('DD1')[document.getElementById('DD1').selectedIndex].value;
		var theYear= document.form1.YY1[document.form1.YY1.selectedIndex].text;
		var nights= document.form1.Length[document.form1.Length.selectedIndex].text;
		var rooms= document.form1.Rooms[document.form1.Rooms.selectedIndex].text;
		var adults= document.form1.Adults[document.form1.Adults.selectedIndex].text;
		var DateIn = theMonth +"%2F"+ theDay + "%2F" +theYear;
		var hotelId = document.getElementById('HotelID')[document.getElementById('HotelID').selectedIndex].value;
		if(hotelId == "all"){
			document.form1.action="http://reservations.ihotelier.com/areasearch/default.cfm?PortalSymbol=CRH";
		}else{
			document.form1.action="https://reservations.ihotelier.com/crs/step1.cfm?hotelid="+hotelId+"&DD1="+theDay+"&MM1="+theMonth+"&YY1="+theYear+"&DateIn="+DateIn+"&Length="+nights+"&Rooms="+rooms+"&Adults="+adults+"&Children=0&LanguageID=3&search=Check";
		}
	}
	
	function sendbookingGerman()
	{
		var theMonth= document.getElementById('MM1')[document.getElementById('MM1').selectedIndex].value;
		var theDay= document.getElementById('DD1')[document.getElementById('DD1').selectedIndex].value;
		var theYear= document.form1.YY1[document.form1.YY1.selectedIndex].text;
		var nights= document.form1.Length[document.form1.Length.selectedIndex].text;
		var rooms= document.form1.Rooms[document.form1.Rooms.selectedIndex].text;
		var adults= document.form1.Adults[document.form1.Adults.selectedIndex].text;
		var DateIn = theMonth +"%2F"+ theDay + "%2F" +theYear;
		var hotelId = document.getElementById('HotelID')[document.getElementById('HotelID').selectedIndex].value;
		if(hotelId == "all"){
			document.form1.action="http://reservations.ihotelier.com/areasearch/default.cfm?PortalSymbol=CRH";
		}else{
			document.form1.action="https://reservations.ihotelier.com/crs/step1.cfm?hotelid="+hotelId+"&DD1="+theDay+"&MM1="+theMonth+"&YY1="+theYear+"&DateIn="+DateIn+"&Length="+nights+"&Rooms="+rooms+"&Adults="+adults+"&Children=0&LanguageID=7&search=Check";
		}
	}
	
	function sendbookingItalian()
	{
		var theMonth= document.getElementById('MM1')[document.getElementById('MM1').selectedIndex].value;
		var theDay= document.getElementById('DD1')[document.getElementById('DD1').selectedIndex].value;
		var theYear= document.form1.YY1[document.form1.YY1.selectedIndex].text;
		var nights= document.form1.Length[document.form1.Length.selectedIndex].text;
		var rooms= document.form1.Rooms[document.form1.Rooms.selectedIndex].text;
		var adults= document.form1.Adults[document.form1.Adults.selectedIndex].text;
		var DateIn = theMonth +"%2F"+ theDay + "%2F" +theYear;
		var hotelId = document.getElementById('HotelID')[document.getElementById('HotelID').selectedIndex].value;
		if(hotelId == "all"){
			document.form1.action="http://reservations.ihotelier.com/areasearch/default.cfm?PortalSymbol=CRH";
		}else{
			document.form1.action="https://reservations.ihotelier.com/crs/step1.cfm?hotelid="+hotelId+"&DD1="+theDay+"&MM1="+theMonth+"&YY1="+theYear+"&DateIn="+DateIn+"&Length="+nights+"&Rooms="+rooms+"&Adults="+adults+"&Children=0&LanguageID=8&search=Check";
		}
	}
	
	function sendbookingSpanish()
	{
		var theMonth= document.getElementById('MM1')[document.getElementById('MM1').selectedIndex].value;
		var theDay= document.getElementById('DD1')[document.getElementById('DD1').selectedIndex].value;
		var theYear= document.form1.YY1[document.form1.YY1.selectedIndex].text;
		var nights= document.form1.Length[document.form1.Length.selectedIndex].text;
		var rooms= document.form1.Rooms[document.form1.Rooms.selectedIndex].text;
		var adults= document.form1.Adults[document.form1.Adults.selectedIndex].text;
		var DateIn = theMonth +"%2F"+ theDay + "%2F" +theYear;
		var hotelId = document.getElementById('HotelID')[document.getElementById('HotelID').selectedIndex].value;
		if(hotelId == "all"){
			document.form1.action="http://reservations.ihotelier.com/areasearch/default.cfm?PortalSymbol=CRH";
		}else{
			document.form1.action="https://reservations.ihotelier.com/crs/step1.cfm?hotelid="+hotelId+"&DD1="+theDay+"&MM1="+theMonth+"&YY1="+theYear+"&DateIn="+DateIn+"&Length="+nights+"&Rooms="+rooms+"&Adults="+adults+"&Children=0&LanguageID=2&search=Check";
		}
	}


