// JavaScript Document




// Scripts specific to Reservation.aspx page

// Note on calendar values
    // Changing dropdown values will set txtCheckinDate (or txtCheckoutDate) values
    // onchange event of the txtCheckinDate (or txtCheckoutDate) will set txtCheckinDate2 (or txtCheckoutDate2)
    // txtCheckinDate (or txtCheckoutDate2) is for the calendar control
    // txtCheckinDate2 (or txtCheckoutDate2) is for the validation control
    
    
    function setRoomTypeText()
	{
	    document.getElementById('txtRoomType').value = document.getElementById('ddlRoomType').options[document.getElementById('ddlRoomType').selectedIndex].value;
	}
	
	// Set the check-in date dropdowns based on selected date on the calendar control
	function setCheckinDateDdl()
    {
        if (!document.getElementById(setCheckinDateDdl.JACSid).dateReturned)
            return;
        var selectedDate = document.getElementById(setCheckinDateDdl.JACSid).outputDate;
        var selectedDay = selectedDate.getDate();
        var selectedMonth = selectedDate.getMonth()+1;
        var selectedYear = selectedDate.getYear();
        document.getElementById('ddlCheckinDay').options[selectedDay].selected = true;
        document.getElementById('ddlCheckinMonth').options[selectedMonth].selected = true;
        var selectedYearIndex = 0;
        for (var i=0; i < document.getElementById('ddlCheckinYear').options.length; i++)
        {
            if (document.getElementById('ddlCheckinYear').options[i].value == selectedYear)
            {
                selectedYearIndex = i;
                break;
            }
        }
        document.getElementById('ddlCheckinYear').options[selectedYearIndex].selected = true;
    }
    
    // Set the check-out date dropdowns based on selected date on the calendar control
	function setCheckoutDateDdl()
    {
        if (!document.getElementById(setCheckoutDateDdl.JACSid).dateReturned)
            return;
        var selectedDate = document.getElementById(setCheckoutDateDdl.JACSid).outputDate;
        var selectedDay = selectedDate.getDate();
        var selectedMonth = selectedDate.getMonth()+1;
        var selectedYear = selectedDate.getYear();
        document.getElementById('ddlCheckoutDay').options[selectedDay].selected = true;
        document.getElementById('ddlCheckoutMonth').options[selectedMonth].selected = true;
        var selectedYearIndex = 0;
        for (var i=0; i < document.getElementById('ddlCheckoutYear').options.length; i++)
        {
            if (document.getElementById('ddlCheckoutYear').options[i].value == selectedYear)
            {
                selectedYearIndex = i;
                break;
            }
        }
        document.getElementById('ddlCheckoutYear').options[selectedYearIndex].selected = true;
    }
    
    
	// Set the check-in date based on selected values in the dropdown list
	function setCheckinDateText()
	{
	    var selectedDay = document.getElementById('ddlCheckinDay').options[document.getElementById('ddlCheckinDay').selectedIndex].value;
	    var selectedMonth = document.getElementById('ddlCheckinMonth').options[document.getElementById('ddlCheckinMonth').selectedIndex].value;
	    var selectedYear = document.getElementById('ddlCheckinYear').options[document.getElementById('ddlCheckinYear').selectedIndex].value;
	    if (selectedDay > 0 &&  selectedMonth.length > 0 && selectedYear > 0)
	    {
	        var selectedDate = selectedDay + '-' + selectedMonth + '-' + selectedYear;
	        // Set the value of the txtCheckinDate which is used by the Calendar javascript control
	        // so that the control displays the date selected in dropdown lists
	        document.getElementById('txtCheckinDate').value = selectedDate;
	    }
    }
    
    // Set the check-out date based on selected values in the dropdown list
	function setCheckoutDateText()
	{
	    var selectedDay = document.getElementById('ddlCheckoutDay').options[document.getElementById('ddlCheckoutDay').selectedIndex].value;
	    var selectedMonth = document.getElementById('ddlCheckoutMonth').options[document.getElementById('ddlCheckoutMonth').selectedIndex].value;
	    var selectedYear = document.getElementById('ddlCheckoutYear').options[document.getElementById('ddlCheckoutYear').selectedIndex].value;
	    if (selectedDay > 0 && selectedMonth.length > 0 && selectedYear > 0)
	    {
	        var selectedDate = selectedDay + '-' + selectedMonth + '-' + selectedYear;
	        // Set the value of the txtCheckoutDate which is used by the Calendar javascript control
	        // so that the control displays the date selected in dropdown lists
	        document.getElementById('txtCheckoutDate').value = selectedDate;
	    }
    }    

    
// End scripts specific to Reservation.aspx page