    var isNav, isIE
    if (parseInt(navigator.appVersion) >= 4)
    { if (navigator.appName == "Netscape")
       { isNav = true }
       else
       { isIE = true }
    }

    function OpenWindow(file, name, width, height) {
        OpenWindow(file, name, width, height, false);
    }

    function OpenWindow(file, name, width, height, showLeftTopScrollbar) {
        var attr = "";
        if(showLeftTopScrollbar) {
            attr += "top=50,left=50,scrollbars=1,";
        }
        attr += "width=" + width + ",height=" + height + ",resizeable=1";
        window.open(file, name, attr);
    }

    function openWin(fileName) {
       thor = window.open(fileName,'thor','top=200,left=220,width=275,height=450,resizable=1,scrollbars=yes');
    }

	function openWindow(fileName)
	{
	   thor = window.open(fileName,'thor','top=200,left=220,width=275,height=450,resizable=1,scrollbars=yes');
	}

    function MM_openBrWindow(theURL,winName,features) { //v2.0
        window.open(theURL,winName,features);
    }

	function displayCruise(){ 
                if(isNav) {
			window.location.href='http://tokyo.netmemory.net/cgi-bin/new_fc/action.cgi?showPage=Cruise';
		}
                else {
			cruiseTable.style.visibility='visible';
			cruiseTable.style.display='block';
			indexSelect.cruise.checked='true';

			noCar();
			noFlight();
			noHotel();
		}
                

	}
	function displayHotel(){ 
                if(isNav) {
			window.location.href='http://tokyo.netmemory.net/cgi-bin/new_fc/action.cgi?showPage=Hotels';
		}
                else {
			hotelTable.style.visibility='visible';
			hotelTable.style.display='block';
			indexSelect.hotel.checked='true';

			noCruise();
			noCar();
			noFlight();
		}
	}
	function displayCar(){
                if(isNav) {
			window.location.href='http://tokyo.netmemory.net/cgi-bin/new_fc/action.cgi?showPage=Cars';
		}
                else {
			carTable.style.visibility='visible';
			carTable.style.display='block';
			indexSelect.car.checked='true';

			noCruise();
			noHotel();
			noFlight();
		}
	}
	function displayFlight(){
                if(isNav) {
			window.location.href='http://tokyo.netmemory.net/cgi-bin/new_fc/action.cgi?showPage=Flights';
		}
                else {
			flightTable.style.visibility='visible';
			flightTable.style.display='block';
			indexSelect.air.checked='true';

			noCruise();
			noCar();
			noHotel();
		}
	}


	function noCruise(){
		cruiseTable.style.display='none';
		cruiseTable.style.visibility='hidden';
	}

	function noCar(){
		carTable.style.display='none';
		carTable.style.visibility='hidden';
	}

	function noFlight(){
		flightTable.style.display='none';
		flightTable.style.visibility='hidden';
	}

	function noHotel(){
		hotelTable.style.display='none';
		hotelTable.style.visibility='hidden';
	}

    function newImage(arg) {
        if (document.images) {
            rslt = new Image();
            rslt.src = arg;
            return rslt;
        }
    }

    function changeImages() {
        if (document.images && (preloadFlag == true)) {
            for (var i=0; i<changeImages.arguments.length; i+=2) {
                document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
            }
        }
    }

    var preloadFlag = false;
    function preloadImages() {
        if (document.images) {
            stay_01_over = newImage("/images/stay_01.gif");
            stay_02_over = newImage("/images/stay_02.gif");
            fly_01_over = newImage("/images/fly_01.gif");
            fly_02_over = newImage("/images/fly_02.gif");
            drive_01_over = newImage("/images/drive_01.gif");
            drive_03_over = newImage("/images/drive_03.gif");
            preloadFlag = true;
        }
    }

        function go(loc) {
            window.location.href = loc;
        }

        function OpenDates(file,input) {
            window.open(file, input, 'width=300,height=300,resizable=1');
        }

        function OpenDates(file,input) {
            window.open(file, input, 'width=300,height=300,resizable=1');
        }

        function OpenCalendar(dayField, day, monthField, month, yearField, year, formName) {
              file = '/cgi-bin/calendar.cgi?formName=' + formName;
            if ( dayField != null )
              file += '&dayField=' + dayField + '&day=' + day;
            if ( monthField != null )
              file += '&monthField=' + monthField + '&month=' + month;
            if ( yearField != null )
              file += '&yearField=' + yearField + '&year=' + year;
            window.open( file, "dates", 'width=200,height=200,resizable=1');
        }


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

        var airAdvanceArrival = 14;
        var airAdvanceDeparture = 15;

        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 = 21;
        var hotelAdvanceDeparture = 23;

        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 loadCruiseDates() {
        var cruiseDeparture = new Date();

        var cruiseAdvanceDeparture = 15;

        cruiseDeparture.setDate( cruiseDeparture.getDate() + cruiseAdvanceDeparture );

        document.forms['cruiseForm'].departureMonth.value = cruiseDeparture.getMonth();
        document.forms['cruiseForm'].departureDay.value = cruiseDeparture.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 condoArrival = new Date();
        //var condoDeparture = new Date();
        var cruiseDeparture = new Date();

        var hotelAdvanceArrival = 21;
        var hotelAdvanceDeparture = 23;
        //var condoAdvanceArrival = 30;
        //var condoAdvanceDeparture = 37;
        var carAdvanceArrival = 7;
        var carAdvanceDeparture = 8;
        var airAdvanceArrival = 14;
        var airAdvanceDeparture = 15;
        var cruiseAdvanceDeparture = 15;

        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 );
        //condoArrival.setDate( condoArrival.getDate() + condoAdvanceArrival );
        //condoDeparture.setDate( condoDeparture.getDate() + condoAdvanceDeparture );
        cruiseDeparture.setDate( cruiseDeparture.getDate() + cruiseAdvanceDeparture );


        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();

        //document.forms['vacForm'].arrivalMonth.value = condoArrival.getMonth();
        //document.forms['vacForm'].departureMonth.value = condoDeparture.getMonth();
        //document.forms['vacForm'].arrivalDay.value = condoArrival.getDate();
        //document.forms['vacForm'].departureDay.value = condoDeparture.getDate();

        document.forms['cruiseForm'].departureMonth.value = cruiseDeparture.getMonth();
        document.forms['cruiseForm'].departureDay.value = cruiseDeparture.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;
        }
    }
    // This script is intended for use with a minimum of Netscape 4 or IE 4.


    function showLayer(layername)
    {
    if (isNav)
        { document.layers[layername].visibility = 'visible';}
        else //Must be IE
        { document.all[layername].style.visibility = 'visible';	}
    }

    function hideLayer(layername)
    {
        if (isNav)
        { document.layers[layername].visibility = 'hidden';	}
        else //Must be IE
        {document.all[layername].style.visibility = 'hidden';}
    }

    function OpenHTU(file,name,width,height) {
        attr = "width=350,height=300,resizeable=1";
        window.open(file, name, attr);
    }

    function openPromoDetails(promo,description) {
        url = '/popups/hotels/hotPromotion.jsp?promo=';
        escapedPromo = escape(promo);
        escapedDescription = escape(description);
        url = url + escapedPromo + '&description=' + escapedDescription;
        window.open(url, 'test', 'width=350,height=300,resizable=1');
    }

    function openconvert(file,input) {
        window.open(file, input, 'width=640,height=215,resizable=1');
    }

    function UpdateCityCode() {
        document.aForm.pickUpCity.value = document.aForm.cityCode.options[document.aForm.cityCode.selectedIndex].value;
    }
 
    function MapPopup(theURL,winName,features) {
        // should no longer be used after travelnow release 
        // goes live that includes hcom's maporama maps
        fileWindow = "/popups/maps/mapPopup.jsp?cmd=Find&HotelLyr=Off&ClickMode=Center";
        fileWindow += theURL;
        window.open(fileWindow,winName,features);
    }

    function MapPopup2(theURL,winName,features) {
        // BEGIN MAPORAMA CODE
        fileWindow = "http://www.hotels.com/map/map.jsp?";
        // END MAPORAMA CODE

        // BEGIN IMAP CODE
        //fileWindow = "/popups/maps/mapPopup.jsp?cmd=Find&HotelLyr=Off&ClickMode=Center";
        // END IMAP CODE

        fileWindow += theURL;
        window.open(fileWindow,winName,features);
    }

	function submitRules() {
	   document.rules.submit();
	}

    function openPromo(file,attributes) {
       thor = window.open(file,'thor',attributes);
    }

    function loadPromo(file) {
       thor2 = window.open(file,'thor2','top=50,left=50,width=620,height=600,resizable=1,status=1,scrollbars=1');
       thor2.blur();
    }

    function showPromo(file) {
        if (thor2 == undefined){
            var thor2;
            thor2 = window.open(file,'thor2','top=50,left=50,resizable=1,status=1,scrollbars=1');
        }else{
            if (thor2.closed) {
                thor2 = window.open(file,'thor2','top=50,left=50,resizable=1,status=1,scrollbars=1');
            } else {
                thor2.focus();
            }
        }
    }

    function OpenInfo(file,input) {
        window.open(file, "PropInfo", 'scrollbars=1,width=520,height=100%,resizable=1');
    }

    function OpenRes(theURL) {
        window.open(theURL, "RES", 'scrollbars=1,width=800,height=600,resizable=1,status=1');
    }

    function OpenRateRules(file) {
        window.open(file, 'RateRules', 'width=440,height=100%,resizable=1,scrollbars=1');
    }

    function subpop(s) {//DH added this for new popcal
        addWindow = window.open(s,"myform","width=270,height=150,resizable=1,status=1,menubar=0,scrollbars=0,fullscreen=0");
        addWindow.focus();
    }

    function openphotos(file,input,width,height) {
        attr = "top=5,left=75,width=" + width + ",height=" + height + ",resizable=1";
        window.open(file, input, attr);
    }

    //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';
        }
    }

    function openCondoWindow(file,input) {
        window.open(file, input,'width=300,height=540,resizable=1');
	}

    function openCancellationPolicy(file,input) {
        window.open(file, input, 'width=300,height=340, scrollbars = yes');
    }

    function checkDoubleSubmit(frm) {
        if (frm.frmsubmit.value == "Y" || frm.frmsubmit.value == "TWICE") {
            frm.frmsubmit.value = "TWICE";
            alert("You have already submitted this reservation once.  Please click 'OK' to continue. ");
            return(false);
        }
        frm.frmsubmit.value = "Y";
        return(true);
    }

    function OpenFAQ(file) {
        window.open(file, 'FAQ', 'width=500,height=300,resizable=1');
    }

    function OpenFAQBig(file) {
        window.open(file, 'FAQBig', 'width=830,height=630,resizable=1,scrollbars=1');
    }

    function OpenRateRules(file) {
        window.open(file, 'RateRules', 'width=440,height=480,resizable=1,scrollbars=1');
    }

    function OpenFAQ640(file) {
        window.open(file, 'FAQ', 'width=660,height=480,resizable=1,scrollbars=1');
    }

    function OpenFAQPopUp(file) {
        window.open(file, 'FAQ', 'width=500,height=275,resizable=1');
    }

    function editReservePage(fieldToJumpTo) {
        setCookie('reserveField',fieldToJumpTo)
        history.back();
    }

    function goToAnchor(reserveField) {
        window.location.hash=reserveField;
    }

    function setCookie(name, value, expires, path, domain, secure) {
      var curCookie = name + "=" + escape(value) +
          ((expires) ? "; expires=" + expires.toGMTString() : "") +
          ((path) ? "; path=" + path : "") +
          ((domain) ? "; domain=" + domain : "") +
          ((secure) ? "; secure" : "");
      document.cookie = curCookie;
    }

    function getCookie(name) {
      var dc = document.cookie;
      var prefix = name + "=";
      var begin = dc.indexOf(prefix);
      if (begin == -1)
        return null;
      var end = document.cookie.indexOf(";", begin);
      if (end == -1)
        end = dc.length;
      return unescape(dc.substring(begin + prefix.length, end));
    }

    function deleteCookie(name) {
        document.cookie = name + '=false; expires=Fri, 27 Jul 2001 02:47:11 UTC;path=/';
    }

	function opentnpr(file,input) {
        if (file == '/popups/airlines/valued_airline_popup.jsp') {
            window.open(file, input, 'width=300,height=200,resizable=1');
        } else if (file == '/popups/hotels/sir.jsp') {
            window.open(file, input,'width=300,height=500,resizable=1');
        } else if (file == '/popups/hotels/condo.jsp') {
            window.open(file, input,'width=300,height=540,resizable=1');
        } else {
            window.open(file, input,'width=300,height=450,resizable=1');
        }
	}