	var whichBrowser;
	var whichBrowserVersion;

	function getBrowser() {
	//returns browser name (eg Netscape, Explorer, Opera)	
		sRaw 	= navigator.userAgent.toLowerCase();
		sType 	= "unknown";
		if (sRaw.indexOf("mozilla") !=-1) {sType="Netscape"}
		if (sRaw.indexOf("msie") !=-1) {sType="Explorer"}
		if (sRaw.indexOf("opera") !=-1) {sType="Opera"}	
		return(sType);
	}
	whichBrowser=getBrowser();
	
	function getBrowserVersion() {
	//returns version of software (eg 5,5.5,6)	
		iRaw = parseFloat(navigator.appVersion);
		return(iRaw); 
	}
	whichBrowserVersion=getBrowserVersion();
	
    function showLayer(layername){
        if (whichBrowser=='Explorer'){ 		
			document.all[layername].style.visibility = 'visible';
			document.all[layername].style.display = 'block';	
		}else if (whichBrowser=='Netscape' && whichBrowserVersion>=5){			
			document.getElementById(layername).style.visibility = 'visible';
			document.getElementById(layername).style.display = 'block';
		}
    }
	
    function hideLayer(layername){
        if (whichBrowser=='Explorer'){
			document.all[layername].style.visibility = 'hidden';
			document.all[layername].style.display = 'none';
		}else if (whichBrowser=='Netscape' && whichBrowserVersion>=5){	
			document.getElementById(layername).style.visibility = 'hidden';
			document.getElementById(layername).style.display = 'none';
		} 
    }
	
	function changeInnerText(layername,innertext){
		if (whichBrowser=='Explorer'){
			document.all[layername].innerText = innertext;
		}else if (whichBrowser=='Netscape' && whichBrowserVersion>=5){				
			document.getElementById(layername).childNodes[0].nodeValue  = innertext;
		} 
	}
	
	function chooseForm(whichForm){
		if (whichBrowser=='Explorer'){
			eval("indexSelect."+whichForm+".checked='true'");
		}else if (whichBrowser=='Netscape' && whichBrowserVersion>=5){				
			//document.getElementById("indexSelect").car.checked='true';
		} 
	}	
	
	function displayHotel(){
		chooseForm('hotel');
		changeInnerText('searchHeader','Hotel Search');
		showLayer('hotelTable');
		hideLayer('carTable');
		hideLayer('flightTable');
		hideLayer('cruiseTable');	
	}
	
	function displayCar(){
		chooseForm('car');
		changeInnerText('searchHeader','Car Rental Search');
		showLayer('carTable');
		hideLayer('hotelTable');
		hideLayer('flightTable');
		hideLayer('cruiseTable');					
	}
	
	function displayFlight(){
		chooseForm('air');
		changeInnerText('searchHeader','Flight Search');
		showLayer('flightTable');
		hideLayer('hotelTable');
		hideLayer('carTable');
		hideLayer('cruiseTable');	
	}

	function displayCruise(){
		chooseForm('cruise');
		changeInnerText('searchHeader','Cruise Search');
		showLayer('cruiseTable');
		hideLayer('hotelTable');
		hideLayer('carTable');
		hideLayer('flightTable');	
	}    

   function loadAirDates() {
        var airArrival = new Date();
        var airDeparture = new Date();

        var airAdvanceArrival = 14;
        var airAdvanceDeparture = 19;

        airArrival.setDate( airArrival.getDate() + airAdvanceArrival );
        airDeparture.setDate( airDeparture.getDate() + airAdvanceDeparture );

        document.forms['airForm'].departureMonth.value = airArrival.getMonth();
        document.forms['airForm'].returnMonth.value = airDeparture.getMonth();
        document.forms['airForm'].departureDay.value = airArrival.getDate();
        document.forms['airForm'].returnDay.value = airDeparture.getDate();
    }

   function loadCarDates() {
        var carArrival = new Date();
        var carDeparture = new Date();

        var carAdvanceArrival = 7;
        var carAdvanceDeparture = 8;

        carArrival.setDate( carArrival.getDate() + carAdvanceArrival );
        carDeparture.setDate( carDeparture.getDate() + carAdvanceDeparture );

        document.forms['carForm'].pickUpMonth.value = carArrival.getMonth();
        document.forms['carForm'].dropOffMonth.value = carDeparture.getMonth();
        document.forms['carForm'].pickUpDay.value = carArrival.getDate();
        document.forms['carForm'].dropOffDay.value = carDeparture.getDate();
    }

   function loadHotelDates() {
        var hotelArrival = new Date();
        var hotelDeparture = new Date();

        var hotelAdvanceArrival = 14;
        var hotelAdvanceDeparture = 16;

        hotelArrival.setDate( hotelArrival.getDate() + hotelAdvanceArrival );
        hotelDeparture.setDate( hotelDeparture.getDate() + hotelAdvanceDeparture );

        document.forms['hotForm'].arrivalMonth.value = hotelArrival.getMonth();
        document.forms['hotForm'].departureMonth.value = hotelDeparture.getMonth();
        document.forms['hotForm'].arrivalDay.value = hotelArrival.getDate();
        document.forms['hotForm'].departureDay.value = hotelDeparture.getDate();
    }

   function loadDefaultDates() {
        var airArrival = new Date();
        var airDeparture = new Date();
        var carArrival = new Date();
        var carDeparture = new Date();
        var hotelArrival = new Date();
        var hotelDeparture = new Date();

        var hotelAdvanceArrival = 14;
        var hotelAdvanceDeparture = 16;
        var carAdvanceArrival = 7;
        var carAdvanceDeparture = 8;
        var airAdvanceArrival = 14;
        var airAdvanceDeparture = 19;

        airArrival.setDate( airArrival.getDate() + airAdvanceArrival );
        airDeparture.setDate( airDeparture.getDate() + airAdvanceDeparture );
        carArrival.setDate( carArrival.getDate() + carAdvanceArrival );
        carDeparture.setDate( carDeparture.getDate() + carAdvanceDeparture );
        hotelArrival.setDate( hotelArrival.getDate() + hotelAdvanceArrival );
        hotelDeparture.setDate( hotelDeparture.getDate() + hotelAdvanceDeparture );

        document.forms['airForm'].departureMonth.value = airArrival.getMonth();
        document.forms['airForm'].returnMonth.value = airDeparture.getMonth();
        document.forms['airForm'].departureDay.value = airArrival.getDate();
        document.forms['airForm'].returnDay.value = airDeparture.getDate();

        document.forms['carForm'].pickUpMonth.value = carArrival.getMonth();
        document.forms['carForm'].dropOffMonth.value = carDeparture.getMonth();
        document.forms['carForm'].pickUpDay.value = carArrival.getDate();
        document.forms['carForm'].dropOffDay.value = carDeparture.getDate();

        document.forms['hotForm'].arrivalMonth.value = hotelArrival.getMonth();
        document.forms['hotForm'].departureMonth.value = hotelDeparture.getMonth();
        document.forms['hotForm'].arrivalDay.value = hotelArrival.getDate();
        document.forms['hotForm'].departureDay.value = hotelDeparture.getDate();
    }

    function loadDates(){

        var calendar = new Date();
        var calendar2 = new Date();
        var cal;
        var cal2;
        var date;
        var month;
        var year;
        var date2;
        var month2;
        var year2;

        //Here is the variable to change for to advance the arrival Date
         var advanceArrival = 14;

        //Here is the variable to change for to advance the departure Date
         var advanceDeparture = 16;

        //Set the arrival Days
        calendar.setDate(calendar.getDate()+ advanceArrival);
        date = calendar.getDate();
        month = calendar.getMonth();

        //Set the Departure Days
        calendar2.setDate(calendar2.getDate()+advanceDeparture);
        date2 = calendar2.getDate();
        month2 = calendar2.getMonth();

        document.forms['myform'].arrivalMonth.value=month;
        document.forms['myform'].arrivalDay.value=date;
        document.forms['myform'].departureMonth.value=month2;
        document.forms['myform'].departureDay.value=date2;
    }

    function validateDepWindow(formName) {
        if (document.forms[formName].tempDepTime[document.forms[formName].tempDepTime.selectedIndex].value==('M')) {
            window.document.forms[formName].tripWindow.value='5';
            window.document.forms[formName].departureTime.value='7AM';
        } else if (document.forms[formName].tempDepTime[document.forms[formName].tempDepTime.selectedIndex].value==('A')) {
            window.document.forms[formName].tripWindow.value='5';
            window.document.forms[formName].departureTime.value='3PM';
        } else if (document.forms[formName].tempDepTime[document.forms[formName].tempDepTime.selectedIndex].value==('E')) {
            window.document.forms[formName].tripWindow.value='5';
            window.document.forms[formName].departureTime.value='8PM';
        } else if(document.forms[formName].tempDepTime[document.forms[formName].tempDepTime.selectedIndex].value==('ANT')) {
            window.document.forms[formName].tripWindow.value='9';
            window.document.forms[formName].departureTime.value='12PM';
        } else {
            window.document.forms[formName].tripWindow.value='5';
            window.document.forms[formName].departureTime.value=document.forms[formName].tempDepTime.value;
        }
    }

    function validateRetWindow(formName) {
        if (document.forms[formName].tempRetTime[document.forms[formName].tempRetTime.selectedIndex].value==('M')) {
            window.document.forms[formName].returnTime.value='7AM';
        } else if (document.forms[formName].tempRetTime[document.forms[formName].tempRetTime.selectedIndex].value==('A')) {
            window.document.forms[formName].returnTime.value='3PM';
        } else if (document.forms[formName].tempRetTime[document.forms[formName].tempRetTime.selectedIndex].value==('E')) {
            window.document.forms[formName].returnTime.value='8PM';
        } else if(document.forms[formName].tempRetTime[document.forms[formName].tempRetTime.selectedIndex].value==('ANT')) {
            window.document.forms[formName].returnTime.value='12PM';
        } else {
            window.document.forms[formName].returnTime.value=window.document.forms[formName].tempRetTime.value;
        }
    }
	

    //check the system date and set the time in advance if is equal to the same day as booking
    function checkTime(M,D,Y,obj){
        var calendar = new Date();
        var date = calendar.getDate();
        var month = calendar.getMonth();
        var year = calendar.getYear();
        var hour = calendar.getHours();
        var date2 = D.value;
        var month2 = M.value;
        var year2 = Y.value;
        var newTime;

        if (obj == document.forms['aForm'].dropOffTime) {hour += 3;}
		else{hour += 2;}

        if (month2 == month && date2 == date && year2 == year){
            if (hour == 0){
                newTime = '12AM';
            }else if (hour == 11){
                newTime = '12PM';
            }else if(hour < 11){
                newTime = hour + 'AM';
            }else if(hour > 11){
                hour -= 11;
                newTime = hour + 'PM';
            }
            obj.value=newTime;
        }else{
            obj.value='9AM';
        }
    }

