// Javascript associated with qsearch.xsl style-sheet for Splurge and Grunge.
// Tries to avoid JavaScript 1.2 features, such as Date.getFullYear().

// pre-load the two small calendar gifs for rollovers
smallcal1 = new Image;
smallcal1.src = '/images/calendar1.gif';
smallcal2 = new Image;
smallcal2.src = '/images/calendar2.gif';

// basic do-it-yourself date info
mon_nam = new Array('Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec');
mon_len = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);
nam_mon = new Array(12);

nam_mon['Jan'] = 0;
nam_mon['Feb'] = 1;
nam_mon['Mar'] = 2;
nam_mon['Apr'] = 3;
nam_mon['May'] = 4;
nam_mon['Jun'] = 5;
nam_mon['Jul'] = 6;
nam_mon['Aug'] = 7;
nam_mon['Sep'] = 8;
nam_mon['Oct'] = 9;
nam_mon['Nov'] = 10;
nam_mon['Dec'] = 11;

// where are we now: YYYY, MM (0-11), DD (1-31)
myDat = new Date();
myYer = myDat.getYear();
if (myYer < 1000) myYer+= 1900;
myMon = myDat.getMonth();
myDay = myDat.getDate();
if (myDay < 10) myDay = '0'+myDay;

// minimum date for viewCalendar
minDate = myDay + '-' + mon_nam[myMon] + '-' + myYer;

if (navigator.appName != 'Netscape') {
  bw=new checkBrowser();
}

function checkBrowser(){
	this.ver=navigator.appVersion;
	this.dom=document.getElementById?1:0;
	this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom)?1:0;
	this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom)?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.bw=(this.ie5 || this.ie4 || this.ie6);
	return this;
}

//Shows the div
function show(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 
	obj.visibility='visible';
}

//Hides the div
function hide(div,nest){
	obj=bw.dom?document.getElementById(div).style:bw.ie4?document.all[div].style:bw.ns4?nest?document[nest].document[div]:document[div]:0; 
	obj.visibility='hidden';
}

function writetolayer(id) {

  text = "<table width='100%' height='650' bgcolor='#FFFFCC' border='0' cellpadding='0' cellspacing='0'>"+
  "<tr><td valign='top'><table align='center' width='400' height='200' cellpadding='0' cellspacing='0' border='0'><tr><td>"+
  "<tr><td><image src='http://www.all-hotels.com/images/clear.gif' border='0' height='30' alt=''></td></tr>"+
  "<tr><td valign='top' align='center'><img src='http://www.all-hotels.com/images/1/ah-logo-animate.gif' alt=''></td></tr>"+
  "<tr><td><image src='http://www.all-hotels.com/images/clear.gif' border='0' height='30' alt=''></td></tr>"+
  "<tr><td valign='top' align='center' class='big-green-heading'>SEARCHING .... PLEASE WAIT</td></tr>"+
  "<tr><td><image src='http://www.all-hotels.com/images/clear.gif' border='0' height='15' alt=''></td></tr>"+
  "<tr><td class='dark-green-heading'><p align='center'><b>77,000 hotels in 10,000 destinations worldwide!</p></td></tr>"+
  "<tr><td align='center'><image src='http://www.all-hotels.com/images/special.gif' border='0' height='60' width='75' </td></tr>"+
  "<tr><td><p align='center'><b>Look for hotels with our all-hotels Special logo. We have negotiated discounts on rooms at these hotels to provide you with a selection of the best deals on the Internet.</b></p></td></tr>"+
  "<tr><td><image src='http://www.all-hotels.com/images/clear.gif' border='0' height='15' alt=''></td></tr>"+
  "<tr><td bgcolor='#339933'><image src='http://www.all-hotels.com/images/clear.gif' border='0' height='2' alt=''></td></tr>"+
  "<tr><td><image src='http://www.all-hotels.com/images/clear.gif' border='0' height='15' alt=''></td></tr>"+
  "<tr><td valign='top' align='justify' class='black'><p align='justify'>All our bookings are protected by Secure Socket Layer (SSL) technology - Look for this <img src='/images/padlock-ie.gif' alt='' border=''> on your booking screen to know your payments are secure.</p></td></tr>"+
  "<tr><td><image src='http://www.all-hotels.com/images/clear.gif' border='0' height='20' alt=''></td></tr>"+
  "<tr><td valign='top' align='center'><img src='http://www.all-hotels.com/images/about_us/privacypolicy.gif' alt='' border='0'></td></tr>"+
  "</table></tr></td>"+
  "</table>";
  document.all[id].innerHTML = text;
}


// initialise quick search - called by onLoad
function init_qs()
{
  // get cookies
  getFields();

  // update menus
  updateSelections();

  // form element indices needed by viewCalendar
  indexArr = findElementIndex('txtArrivalDate1');
  indexDep = findElementIndex('txtDepartureDate1');

//This focus line MUST be commented out when there is a pop-up for the promotion
  // focus on the text entry
  // document.frmEntry.txtLocation.focus();
}

// Set a cookie.
function setCookie(name, value)
{
  // Expiry date.
  var expDate = new Date();
  var delay = 1000 * 60 * 30; // 30 minutes in milliseconds
  expDate.setTime(expDate.getTime() + delay);

  // Site wide visibility.
  var path = '/';

  // Adjust value so it's not the empty string.
  if (value=='') value = ' ';

  // Set.
  document.cookie =
    name + "=" + escape(value) + ';' +
    "expires=" + expDate.toGMTString() + ';' +
    "path=" + path;
}

// Get a cookie from somewhere in the string of cookie values.
function getCookie(name)
{
  var result = null;
  var myCookie = " " + document.cookie + ";";
  var searchName = " " + name + "=";
  var startOfCookie = myCookie.indexOf(searchName)
  var endOfCookie;
  if (startOfCookie != -1)
  {
    startOfCookie += searchName.length; //skip past cookie name
    endOfCookie = myCookie.indexOf(";", startOfCookie);
    result = unescape(myCookie.substring(startOfCookie, endOfCookie));
  }
  if (result == ' ') result = null;
  return result
}

// Set frmEntry fields from cookies.
function getFields()
{
  var locID = getCookie('location');
  var arrival = getCookie('arrivalDate');
  var departure = getCookie('departureDate');
  var splurge = getCookie('splurgeUrl');
  var last = getCookie('lastLocation');
  var adults = getCookie('adults');
  var category = getCookie('category');
  var hotelname = getCookie('hotelname');
  if (locID != null) document.frmEntry.locationID.value = locID;
  if (arrival != null) document.frmEntry.txtArrivalDate1.value = arrival;
  if (departure != null) document.frmEntry.txtDepartureDate1.value = departure;
  if (splurge != null) document.frmEntry.splurgeUrl.value = splurge;
  /* Quicksearch starts at 1 adult but choosedates and advanced search start
  at 0 adults so we need to adjust the index */
  var adult_adjuster=-1;
  if (document.frmEntry.number_of_adults1.length==6)
  {
    adult_adjuster=0;
  }
  if (document.frmEntry.number_of_adults1.length==7)
  {
    adult_adjuster=1;
  }
  if (adults != null)
  {  
    adults = parseInt(adults) + parseInt(adult_adjuster);
    document.frmEntry.number_of_adults1.selectedIndex = adults;
  }
  else
  {
    document.frmEntry.number_of_adults1.selectedIndex = 2 + adult_adjuster; 
  }

  if (category != null) document.frmEntry.cboPriceCategory.selectedIndex = category;
  if (hotelname != null) document.frmEntry.hotel_name.value = hotelname;
  if (last != null)
  {
    document.frmEntry.lastLocation.value = last;
    document.frmEntry.txtLocation.value = last;
  }
}

// Do a location search from the left side.
function goLocation()
{ 
  // Transfer the search text to the (invisible) 'search' form.
  document.search.filter.value = document.frmEntry.txtLocation.value;

  // Call the function which uses the 'search' form.
  popup_sr();  

} 

// Do a location search from the right side.
function goLocation2()
{ 
  // Transfer the search text to the (visible) 'search2' form.
  document.search2.filter.value = document.frmEntry.txtLocation.value;

  // Call the function which uses the 'search2' form.
  popup_sr2();
} 

// Perform validation on search form and depending on
// which data has been entered will either:
//   * fail due to insufficient information and popup a message
//   * go to relevent splurge page if only location entered
//   * perform an availability check on hotel if dates are also supplied
function doSearch()
{
  // Reset location ID if text has changed.
  window.open('', 'emot', 'toolbar=0,location=0,status=0,menubar=0,scrollbars=0,resizable=1,width=400,height=230');
  
  if (document.frmEntry.txtLocation.value != document.frmEntry.lastLocation.value)
  {
    document.frmEntry.locationID.value = 0;
    document.frmEntry.splurgeUrl.value = '';
  }

  // What have we got?
  var gotLoc = document.frmEntry.txtLocation.value != '' && document.frmEntry.txtLocation.value != ' ';
  var gotLid = document.frmEntry.locationID.value != 0;
  var gotUrl = document.frmEntry.splurgeUrl.value != '' && document.frmEntry.splurgeUrl.value != ' ';
  var gotMonYer = document.frmEntry.cboArrivalMonths.selectedIndex != 0;
  var gotDay = document.frmEntry.cboArrivalDays.selectedIndex != 0;
  var gotNum = document.frmEntry.cboNights.selectedIndex != 0;

  // Decide what to do.
  if (gotLid && gotUrl)
  {
    // Make sure they're saved.
    setCookie('location', document.frmEntry.locationID.value);
    setCookie('splurgeUrl', document.frmEntry.splurgeUrl.value);
    setCookie('lastLocation', document.frmEntry.lastLocation.value);

    if (gotMonYer && gotDay && gotNum)
    {
      // Enough for an ABook search. Change splurge page too?
      // window.location = document.frmEntry.splurgeUrl.value;

      //Call this to ensure dates stored in cookies
      updateDates();
      // Point the gun and fire.
      document.frmEntry.action = "/xbook/servlet/list-available-hotels?quick=y";
      if ((navigator.appName != 'Netscape')&&(navigator.appVersion.indexOf('Mac') == -1))
      {
        hide('maindiv');
	window.scroll(0,0);
        document.frmEntry.submit();
        writetolayer('newdiv');
        show('newdiv');
      }
      else
      {
        document.frmEntry.submit();
      }
    }
    else if (!gotMonYer && !gotDay && !gotNum)
    {
      // Treat as location search and go to Splurge page.
      window.location = document.frmEntry.splurgeUrl.value;
      // alert('Please choose your arrival date and number of nights.');
    }
    else if (!gotMonYer || !gotDay)
    {
      alert('Please choose your arrival date.');
    }
    else
    {
      alert('Please choose a number of nights.');
    }
  }
  else
  { 
    if (gotLoc)
    {
      // We need a location id - do a location search then call back here.
      document.search.callback.value = 'opener.doSearch()';
      goLocation();
    }
    else
    {
      // The user has not supplied location text.
      alert('Please enter a location name in the "Where?" box.');     
    }
  }
}

// Go to the advanced search facilities.
function advancedSearch()
{
  var gotLoc = document.frmEntry.txtLocation.value != '' && document.frmEntry.txtLocation.value != ' ';
  if ((gotLoc)&&(document.frmEntry.txtLocation.value != document.frmEntry.lastLocation.value))
  {
    // We need a location id - do a location search then call back here.
    document.search.callback.value = 'opener.advancedSearch()';
    goLocation();
  }
  else
  {
    //save any location info we have
    setCookie('location', document.frmEntry.locationID.value);
    setCookie('splurgeUrl', document.frmEntry.splurgeUrl.value);
    setCookie('lastLocation', document.frmEntry.lastLocation.value);
    // Point the form at the right servlet and fire.
    document.frmEntry.action = "/xbook/servlet/searchable-data";
    document.frmEntry.submit(); 
  }
} 

// When the arrival month changes.
function changeArrivalMonth()
{
  updateArrivalDayMenu();
  updateDates();
}

// When the arrival day changes.
function changeArrivalDay()
{
  updateDates();
}

// When the number of nights changes.
function changeNights()
{
  updateDates();
}

// When the price category changes.
function changeCategory()
{
  // Save it.
  setCookie('category', document.frmEntry.cboPriceCategory.selectedIndex);

  // Can't have category and name.
  if (document.frmEntry.cboPriceCategory.selectedIndex != 0)
  {
    document.frmEntry.hotel_name.value = '';
    setCookie('hotelname', document.frmEntry.hotel_name.value);
  }
}

// When the number of adults changes.
function changeAdults()
{
  // Remember the number of adults.
  var iAds = document.frmEntry.number_of_adults1.selectedIndex;
  var adult_adjuster=0;
  if (document.frmEntry.number_of_adults1.length==4)
  {
    adult_adjuster=1;
  }
  if (document.frmEntry.number_of_adults1.length==7)
  {
    adult_adjuster=-1;
    if (iAds==1) { iAds=0 ;}
  }
  var nAds = parseInt(adult_adjuster)+parseInt(iAds);
  setCookie('adults', nAds);
  // Adjust the number of beds accordingly.
  var nBds = Math.ceil(nAds/2);
  document.frmEntry.number_of_beds1.value = nBds;
}

// When the number of adults changes.
function changeHotelName()
{
  // Save the new value.
  setCookie('hotelname', document.frmEntry.hotel_name.value);

  // Can't have name and category.
  if (document.frmEntry.hotel_name.value != '')
  {
    document.frmEntry.cboPriceCategory.selectedIndex = 0;
    setCookie('category', document.frmEntry.cboPriceCategory.selectedIndex);
  }
}

// Set arrival date and number of nights menus from txtArrivalDate1 and txtDepartureDate1.
// Used after txtArrivalDate1 and txtDepartureDate1 are read from cookies.
function updateSelections()
{
  if (document.frmEntry.txtArrivalDate1.value.indexOf('-') != -1)
  {
    var sDat = document.frmEntry.txtArrivalDate1.value; 

    // Ensure the right month is selected.
    var sMonYer = sDat.substring(sDat.indexOf('-')+1);  
    for (var j=0; j<document.frmEntry.cboArrivalMonths.length; j++)
    {
      if (document.frmEntry.cboArrivalMonths[j].value == sMonYer)
      {
        document.frmEntry.cboArrivalMonths[j].selected = 1;
        break;
      }
    }

    // Ensure right day menu is presented.
    updateArrivalDayMenu();

    // Ensure the right day is selected.
    var sDay = sDat.substring(0, sDat.indexOf('-'));
    for (var j=0; j<document.frmEntry.cboArrivalDays.length; j++)
    {
      if (document.frmEntry.cboArrivalDays[j].value == sDay)
      {
        document.frmEntry.cboArrivalDays[j].selected = 1;
        break;
      }
    }

    // Ensure the right number of nights is selected.
    if (document.frmEntry.txtDepartureDate1.value.indexOf('-') != -1)
    {
      var iDay = parseInt(sDay,10);
      var iMon = nam_mon[sMonYer.substring(0,sMonYer.indexOf('-'))];
      var iYer = parseInt(sMonYer.substring(sMonYer.indexOf('-')+1),10);
      var dStr = document.frmEntry.txtDepartureDate1.value;
      var dDay = parseInt(dStr.substring(0,dStr.indexOf('-')),10);
      var dMonYer = dStr.substring(dStr.indexOf('-')+1);
      var dMon = nam_mon[dMonYer.substring(0,dMonYer.indexOf('-'))];
      var dYer = parseInt(dMonYer.substring(dMonYer.indexOf('-')+1),10);
      var iDat = new Date(iYer, iMon, iDay);
      var dDat = new Date(dYer, dMon, dDay);
      var nDay = Math.round((dDat.getTime() - iDat.getTime())/86400000);
      if (nDay > 0 && nDay < 31)
      {
        document.frmEntry.cboNights[nDay].selected = 1;
      }
      else
      {
        document.frmEntry.cboNights[0].selected = 1;
      }
    }
  }
}

// Set arrival date and txtDepartureDate1 from number of nights and txtArrivalDate1.
// Used after call to viewCalendar.
function updateSelections2()
{
  if (document.frmEntry.txtArrivalDate1.value.indexOf('-') != -1)
  {
    var tDat = document.frmEntry.txtArrivalDate1.value; 

    // Ensure the right month is selected.
    var tMonYer = tDat.substring(tDat.indexOf('-')+1);  
    for (var j=0; j<document.frmEntry.cboArrivalMonths.length; j++)
    {
      if (document.frmEntry.cboArrivalMonths[j].value == tMonYer)
      {
        document.frmEntry.cboArrivalMonths[j].selected = 1;
        break;
      }
    }

    // Ensure right day menu is presented.
    updateArrivalDayMenu();

    // Ensure the right day is selected.
    var tDay = tDat.substring(0, tDat.indexOf('-'));
    for (var j=0; j<document.frmEntry.cboArrivalDays.length; j++)
    {
      if (document.frmEntry.cboArrivalDays[j].value == tDay)
      {
        document.frmEntry.cboArrivalDays[j].selected = 1;
        break;
      }
    }

    // Ensure txtDepartureDate1 is updated.
    var numNite = document.frmEntry.cboNights.selectedIndex;
    if (numNite == 0)
    {
      document.frmEntry.txtDepartureDate1.value = ' ';
    }
    else
    {
      // Get start date as Date object.
      var sDay = parseInt(tDay,10);
      var sMon = nam_mon[tMonYer.substring(0, tMonYer.indexOf('-'))];
      var sYer = parseInt(tMonYer.substring(tMonYer.indexOf('-')+1),10);
      var sDat = new Date(sYer, sMon, sDay);
      var sTim = sDat.getTime();

      // keep incrementing by day's worth of msecs
      while (numNite--) sTim+= 86400000;

      // reset the end date
      sDat.setTime(sTim);

      // get parts of date we need
      var dDay = sDat.getDate();
      if (dDay < 10) dDay = '0' + dDay;
      var dMon = mon_nam[sDat.getMonth()];
      var dYer = sDat.getYear();
      if (dYer < 1000) dYer+= 1900;

      // reconstruct the departure date
      document.frmEntry.txtDepartureDate1.value = dDay + '-' + dMon + '-' + dYer;
    }
  }
}

// Update the arrival days menu after the month changes.
function updateArrivalDayMenu() 
{
  var iMonYer = document.frmEntry.cboArrivalMonths.selectedIndex;
  var iDay = document.frmEntry.cboArrivalDays.selectedIndex;
  var xDay = document.frmEntry.cboArrivalDays.options[iDay].text;
  var sDay, nDay;

  // is month selected
  if (iMonYer == 0)
  {
    // start day = 1, number of days = 31
    sDay = 1;
    nDay = 31;
    // restart the days menu
    document.frmEntry.cboArrivalDays.selectedIndex = 0;
    xDay = document.frmEntry.cboArrivalDays.options[0].text;
    // restart the nights menu
    document.frmEntry.cboNights.selectedIndex = 0;
  }
  else
  {
    // use month to determine sDay and nDay
    var tMonYer = document.frmEntry.cboArrivalMonths.options[iMonYer].text;
    var tMon = tMonYer.substring(0,tMonYer.indexOf('-'));
    var tYer = parseInt(tMonYer.substring(tMonYer.indexOf('-')+1),10);
    nDay = mon_len[nam_mon[tMon]];
    if (tMon == 'Feb' && tYer % 4 == 0) nDay++;
    sDay = iMonYer == 1 ? parseInt(myDay,10) : 1;
  }

  // reset menu length (remember first entry is 'DD')
  document.frmEntry.cboArrivalDays.length = nDay - sDay + 2;

  // set remaining options
  var n=1;
  for (i=sDay; i<=nDay; i++)
  {
    var tDay = i < 10 ? ('0' + i) : i;
    document.frmEntry.cboArrivalDays.options[n].text = tDay;
    document.frmEntry.cboArrivalDays.options[n].value = tDay;
    if (xDay == tDay) document.frmEntry.cboArrivalDays[n].selected = 1;  
    n++;
  }
}

// Update txtArrivalDate1 and txtDepartureDate1 if appropriate.
function updateDates()
{
  // arrival date
  var arrDay = document.frmEntry.cboArrivalDays.selectedIndex;
  var arrMonYer = document.frmEntry.cboArrivalMonths.selectedIndex;
  if (arrDay == 0 || arrMonYer == 0)
  {
    document.frmEntry.txtArrivalDate1.value = ' ';
    document.frmEntry.txtDepartureDate1.value = ' ';
  }
  else
  {
    // okay, set the arrival date
    var tDay = document.frmEntry.cboArrivalDays.options[arrDay].text;
    var tMonYer = document.frmEntry.cboArrivalMonths.options[arrMonYer].text;
    document.frmEntry.txtArrivalDate1.value = tDay + '-' + tMonYer;

    // departure date
    var numNite = document.frmEntry.cboNights.selectedIndex;
    if (numNite == 0)
    {
      document.frmEntry.txtDepartureDate1.value = ' ';
    }
    else
    {
      // get start date
      var tMon = nam_mon[tMonYer.substring(0, tMonYer.indexOf('-'))];
      var tYer = parseInt(tMonYer.substring(tMonYer.indexOf('-')+1),10);
      var tDat = new Date(tYer, tMon, tDay);
      var tTim = tDat.getTime();

      // keep incrementing by day's worth of msecs
      while (numNite--) tTim+= 86400000;

      // reset the end date
      tDat.setTime(tTim);

      // get parts of date we need
      var dDay = tDat.getDate();
      if (dDay < 10) dDay = '0' + dDay;
      var dMon = mon_nam[tDat.getMonth()];
      var dYer = tDat.getYear();
      if (dYer < 1000) dYer+= 1900;

      // reconstruct the departure date
      document.frmEntry.txtDepartureDate1.value = dDay + '-' + dMon + '-' + dYer;
    }
  }

  // save the dates now, no matter what we got
  setCookie('arrivalDate', document.frmEntry.txtArrivalDate1.value);
  setCookie('departureDate', document.frmEntry.txtDepartureDate1.value);
}

// Write an HTML month menu into the page.
function initDateDropdowns(sName, action)
{
  // Initialise (globals).
  var nMon = myMon;
  var nYer = myYer;

  // The <select> element and it's first option.
  var sMonths = '<select name="' + sName + '" size="1" class="black" ' + action + '>';
  sMonths+= '<option value="0">MM - YY</option>';

  // Subsequent options.
  for (var m=1; m<=16; m++)
  {
    if (nMon > 11)
    {
      nMon=0;
      nYer++;
    }
    sMonths+= '<option value="' + mon_nam[nMon] + '-' + nYer + '">' + mon_nam[nMon] + '-' + nYer + '</option>';
    nMon+= 1;
  }

  // The end of the <select>.
  sMonths += "</select>";

  // Write it.
  document.write(sMonths);
}

// Get the index of a named element in frmEntry.
function findElementIndex(elementName) {
  var numElements = document.frmEntry.elements.length;
  var index = -1;
  for (var i=0; i<numElements; i++) {
    if (document.frmEntry.elements[i].name == elementName) {        
      index = i;
      break;
    }
  }
  return index;
}

// Call the Calendars servlet.
function viewCalendar(schID)
{
  // The servlet needs a start date.
  var staDate = document.frmEntry.txtArrivalDate1.value;

  // Default start today.
  if (staDate.indexOf('-') == -1) staDate = minDate;

  // It also needs a maximum date.
  var limMsec = 32140800000; // 12 * 31 days = 1 year (in milliseconds).
  var theDay = parseInt(staDate.substring(0,staDate.indexOf('-')),10);
  var theMonYer = staDate.substring(staDate.indexOf('-')+1);
  var theMon = nam_mon[theMonYer.substring(0,theMonYer.indexOf('-'))];
  var theYer = parseInt(theMonYer.substring(theMonYer.indexOf('-')+1),10);
  var theDat = new Date(theYer, theMon, theDay);
  theDat.setTime(theDat.getTime() + limMsec);
  theDay = theDat.getDate(); if (theDay < 10) theDay = '0' + theDay;
  theMon = mon_nam[theDat.getMonth()];
  theYer = theDat.getYear(); if (theYer < 1000) theYer = theYer + 1900;
  var maxDate = theDay + '-' + theMon + '-' + theYer;

  // Finally, call the servlet.
  strURL = "/xbook/servlet/Calendar2?StaDate=" + staDate + "&MinDate=" + minDate + "&MaxDate=" + maxDate + "&schID=" + schID;
  var intLeft = (screen.width-300)/2;
  var intTop = (screen.height-220)/2;
  var calWindow = window.open(strURL,"popDialog","top="+intTop+",left="+intLeft+",height=220,width=300,scrollbars=no,resizable=no,resizeable=no,status=no,location=no,toolbar=no");
  if (calWindow.opener == null) calWindow.opener = self;
}

// Called by javascript in servlet called by viewCalendar.
function updateMonths()
{
  // Update the arrival menu and departure date.
  updateSelections2();

  // Save the (possibly) new dates.
  setCookie('arrivalDate', document.frmEntry.txtArrivalDate1.value);
  setCookie('departureDate', document.frmEntry.txtDepartureDate1.value);
}

// Cause any location text box to search when return is pressed.
// Doesn't work in NN. Not needed if there's only one box in form.
function handleKey(myevent)
{
  var keycode;
  if (window.event) keycode = window.event.keyCode;
  else if (myevent) keycode = myevent.which;
  else return true;
  if (keycode == 13)
  {
    // Enter has been pressed.
    doSearch();
    return false;
  }
  else return true;
}

// Roll over function (used for calendar images).
function rollOver(nam, num)
{
  document[nam].src = eval(nam + num + '.src');
}
