
function currencyWindow(popurl)
	{
	currWindow = window.open(popurl, 'CurrencyConverter', 'width=460,height=380');
	currWindow.focus;
	}

function changeForm(id)
{ 
	var f; 
	f=document.search;
	//alert(id);
	turn_off_all_boxes();
	 if(id == 3)
	 {
		lastmindealsbox.style.display='block';
		clickstay('id5');

	 }
	 else if(id == 4)
	 {
		 carbox.style.display='block';
		 clickstay('id4');
		 //alert(document.hotsrchbox.dod_dd.selectedIndex);
		 if(hotsrchbox){
			 document.CarSearch.pudate_mo.options.selectedIndex = document.hotsrchbox.doa_mm.options.selectedIndex;
			 document.CarSearch.pudate_dy.options.selectedIndex = document.hotsrchbox.doa_dd.options.selectedIndex;
			 document.CarSearch.dodate_mo.options.selectedIndex = document.hotsrchbox.dod_mm.options.selectedIndex;
			 document.CarSearch.dodate_dy.options.selectedIndex = document.hotsrchbox.dod_dd.options.selectedIndex;
		 }
	 }
	 else if(id == 6)
	 {
		 hotelairbox.style.display='block';
		 clickstay('id3');
	 }
	 else 
	 {
		hotelbox.style.display='block';
		clickstay('id1');
	 }
}

function turn_off_all_boxes(){
	if(hotelbox){
		hotelbox.style.display='none';
	}
	if(lastmindealsbox){
		lastmindealsbox.style.display='none';
	}
	if(carbox){
		carbox.style.display='none';
	}
	if(hotelairbox){
		hotelairbox.style.display='none';
	}
}

function IsLeapYear(yrStr)
{
 var leapYear = false;
 var year = parseInt(yrStr, 10);
 if (year%4 == 0) 
  { 
	leapYear = true;
	if (year%100 == 0)
	 {
	  leapYear = false;
	  if (year%400 == 0)
	   {
	    leapYear = true;
		}
	  }
   }
  return leapYear;
 }


function getDaysInMonth(mthIdx, yrStr) 
{
 var maxDays = 31;
 if (mthIdx == 1)
	{
	 if (IsLeapYear(yrStr))
	   { 
	    maxDays = 29;
	   }
	 else
		{
		  maxDays = 28;
		}
     }
 if (mthIdx == 3 || mthIdx == 5 || mthIdx == 8 || mthIdx == 10)
	{
	 maxDays = 30;
	 }
 return maxDays;
}

function adjustDate(mthIdx, Dt, initDate)
{
var value = 0;

var today = new Date();
var theYear = parseInt(today.getYear(),10);

if (mthIdx < today.getMonth()) {
	theYear = (parseInt(today.getYear(),10) + 1);
}

if (theYear < 100) {
	theYear = "19" + theYear;
	}
else {
	if ((theYear - 100) < 10) {
		theYear = "0" + (theYear - 100);
		}
	else 
		{
		theYear = (theYear - 100) + "";
		}
	theYear = "20" + theYear
}

var numDays = getDaysInMonth(mthIdx, theYear);

 
// checks whether to initialize date or not.
if (initDate == 1) 
	{
	  if ((numDays - Dt)==7)
		{

		//checks if month is December
		if (mthIdx==11) {
			document.hotsrchbox.doa_mm.options.selectedIndex = mthIdx;
			document.hotsrchbox.dod_mm.options.selectedIndex = 0;
			document.hotsrchbox.dod_yy.options.selectedIndex =+1;

			document.CarSearch.pudate_mo.options.selectedIndex = mthIdx;
			document.CarSearch.dodate_mo.options.selectedIndex = 0;
		} else {
			document.hotsrchbox.doa_mm.options.selectedIndex = mthIdx;
			document.hotsrchbox.dod_mm.options.selectedIndex = mthIdx+1;

			document.CarSearch.pudate_mo.options.selectedIndex = mthIdx;
			document.CarSearch.dodate_mo.options.selectedIndex = mthIdx+1;
		}

		//hotel search box
	    document.hotsrchbox.doa_dd.options.selectedIndex = numDays - 1;
	    document.hotsrchbox.dod_dd.options.selectedIndex =  7 - (numDays - Dt);

		//car search box
		document.CarSearch.pudate_dy.options.selectedIndex = numDays - 1;
		document.CarSearch.dodate_dy.options.selectedIndex = 7 - (numDays - Dt);

		}
		else if ((numDays-Dt)<7)
				{

				if (mthIdx==11) {
					document.hotsrchbox.doa_mm.options.selectedIndex = 0;
					document.hotsrchbox.dod_mm.options.selectedIndex = 
					document.hotsrchbox.doa_mm.options.selectedIndex;
					document.hotsrchbox.doa_yy.options.selectedIndex =+1;
					document.hotsrchbox.dod_yy.options.selectedIndex =+1;

					document.CarSearch.pudate_mo.options.selectedIndex = 0;
					document.CarSearch.dodate_mo.options.selectedIndex = 
					document.CarSearch.pudate_mo.options.selectedIndex;
				} else {
					document.hotsrchbox.doa_mm.options.selectedIndex = mthIdx + 1;
					document.hotsrchbox.dod_mm.options.selectedIndex = document.hotsrchbox.doa_mm.options.selectedIndex;	

					document.CarSearch.pudate_mo.options.selectedIndex = mthIdx + 1;
					document.CarSearch.dodate_mo.options.selectedIndex = document.CarSearch.pudate_mo.options.selectedIndex;
				}					

				//hotel search box
				document.hotsrchbox.doa_dd.options.selectedIndex = 6 - (numDays - Dt);
				document.hotsrchbox.dod_dd.options.selectedIndex = 7 - (numDays - Dt);	

				//car search box
				document.CarSearch.pudate_dy.options.selectedIndex = 6 - (numDays - Dt);
				document.CarSearch.dodate_dy.options.selectedIndex = 7 - (numDays - Dt);

				}
		else
			{ 
			//hotel search box
			document.hotsrchbox.doa_mm.options.selectedIndex = mthIdx;
			document.hotsrchbox.doa_dd.options.selectedIndex = (Dt - 1) + 7;
			document.hotsrchbox.dod_mm.options.selectedIndex = document.hotsrchbox.doa_mm.options.selectedIndex;
			document.hotsrchbox.dod_dd.options.selectedIndex = (Dt - 1) + 8;

			//car search box
			document.CarSearch.pudate_mo.options.selectedIndex = mthIdx;
			document.CarSearch.pudate_dy.options.selectedIndex = (Dt - 1) + 7;
			document.CarSearch.dodate_mo.options.selectedIndex = document.CarSearch.pudate_mo.options.selectedIndex;
			document.CarSearch.dodate_dy.options.selectedIndex = (Dt - 1) + 8;
			}
		}
else
	{		
	if (mthIdx == 1)
		{
		if (Dt.options.selectedIndex + 1 < numDays) 
			{
			return 0;
			}
		else
			{
			Dt.options.selectedIndex=numDays - 1;
			if (numDays == 29)
				{
				return 99;
				}
			else
				{
				return 1;
				}
			}
		}
	 if (Dt.options.selectedIndex + 1 < numDays)
		{
		value = 0;
		}
	 else
		{
		if (Dt.options.selectedIndex + 1 > numDays)
			{
			Dt.options.selectedIndex--;
			value = 3;
			}
		else
			{
			value = 2;
			}
		}
	 return value;
	}
}


function amadChange(inM, inD, outM, outD)
{
 var res = adjustDate(inM.options.selectedIndex, inD, 0);
 if (res != 0 )
	{
		outD.options.selectedIndex = 0;
		if (outM.options.selectedIndex == 11) {
			outM.options.selectedIndex = 0;
			}
		else {
			outM.options.selectedIndex = inM.options.selectedIndex + 1;
			}
		}
 else
	{
	outM.options.selectedIndex = inM.options.selectedIndex;
	outD.options.selectedIndex = inD.options.selectedIndex + 1;
	}
return;
}

function initDate()
{
	var today = new Date();
	var currMth = today.getMonth();
	var currDate = today.getDate();

	var mth = document.hotsrchbox.doa_dd.options.selectedIndex = currMth;
	var Dt = document.hotsrchbox.doa_dd.options.selectedIndex = currDate;
	adjustDate(mth, Dt, 1);
}
	
function waitBox()
{
  var popup = window.open('http://www.res99.com/wait.html','wait','height=125 ,width=330,left=330,top=330');
}

function showCal(url)
	{
	calWindow = window.open(url, 'Calendar', 'scrollbars=YES, width=550,height=225');
	calWindow.focus;
	}

function disclaimerWin(tnc)
	{
	tncWindow = window.open(tnc, 'TermsAndConditions', 'width=325,height=500');
	tncWindow.focus;
	}

function airportCodes(url)
	{
	arptWindow = window.open(url, 'AirportCodes', 'width=450,height=350');
	arptWindow.focus;
	}

var anyopen = "id1";
function clickstay(tdid) {
	document.all[anyopen].className = "tabOff";
	document.all[tdid].className = "tabOn";
	anyopen=tdid;
	}

function add_options_to_month_select(){
	document.write('<option value="01" >January');
	document.write('<option value="02" >February');
	document.write('<option value="03" >March');
	document.write('<option value="04" >April');
	document.write('<option value="05" >May');
	document.write('<option value="06" >June');
	document.write('<option value="07" >July');
	document.write('<option value="08" >August');
	document.write('<option value="09" >September');
	document.write('<option value="10" >October');
	document.write('<option value="11" >November');
	document.write('<option value="12" >December');
}

function add_options_to_car_time() {
	document.write('<option value="12A">12:00am</option>');
	document.write('<option value="1A">1:00am</option>');
	document.write('<option value="2A">2:00am</option>');
	document.write('<option value="3A">3:00am</option>');
	document.write('<option value="4A">4:00am</option>');
	document.write('<option value="5A">5:00am</option>');
	document.write('<option value="6A">6:00am</option>');
	document.write('<option value="7A">7:00am</option>');
	document.write('<option value="8A">8:00am</option>');
	document.write('<option value="9A">9:00am</option>');
	document.write('<option value="10A">10:00am</option>');
	document.write('<option value="11A">11:00am</option>');
	document.write('<option value="12P" selected>12:00pm</option>');
	document.write('<option value="1P">1:00pm</option>');
	document.write('<option value="2P">2:00pm</option>');
	document.write('<option value="3P">3:00pm</option>');
	document.write('<option value="4P">4:00pm</option>');
	document.write('<option value="5P">5:00pm</option>');
	document.write('<option value="6P">6:00pm</option>');
	document.write('<option value="7P">7:00pm</option>');
	document.write('<option value="8P">8:00pm</option>');
	document.write('<option value="9P">9:00pm</option>');
	document.write('<option value="10P">10:00pm</option>');
	document.write('<option value="11P">11:00pm</option>');
}

function add_options_to_car_type_select(){
		document.write('<option value="">No Preference');
		document.write('<option value="B-EC" selected>Economy Car');
		document.write('<option value="C-CC" >Compact Car');
		document.write('<option value="D-SC" >Standard Car');
		document.write('<option value="E-IC" >Intermediate Car');
		document.write('<option value="F-FC" >Full Size Car');
		document.write('<option value="G-PC" >Premium Car');
		document.write('<option value="H-LC" >Luxury Car');
		document.write('<option value="I-ASPT" >Sports Car');
		document.write('<option value="J-ACNV" >Convertible');
		document.write('<option value="K-MV" >Mini Van');
		document.write('<option value="L-FV" >Full Size Van');
		document.write('<option value="M-APUP" >Pick-up Truck ');
		document.write('<option value="N-AFWD" >Sport Utility (SUV)');
		document.write('<option value="O-ATRV" >All Terrain');
		document.write('<option value="P-AWGN" >Station Wagon');
		document.write('<option value="Q-ASPC" >Special Car');
}

function add_options_to_ct_time_select(){
		document.write('<option value="12:00am">12:00am</option>');
		document.write(' <option value="1:00am">1:00am</option>');
		document.write(' <option value="2:00am">2:00am</option>');
		document.write(' <option value="3:00am">3:00am</option>');
		document.write(' <option value="4:00am">4:00am</option>');
		document.write(' <option value="5:00am">5:00am</option>');
		document.write(' <option value="6:00am">6:00am</option>');
		document.write(' <option value="7:00am">7:00am</option>');
		document.write(' <option value="8:00am">8:00am</option>');
		document.write(' <option value="9:00am">9:00am</option>');
		document.write(' <option value="10:00am">10:00am</option>');
		document.write(' <option value="11:00am">11:00am</option>');
		document.write(' <option value="12:00pm">12:00pm</option>');
		document.write(' <option value="1:00pm">1:00pm</option>');
		document.write(' <option value="2:00pm">2:00pm</option>');
		document.write(' <option value="3:00pm">3:00pm</option>');
		document.write(' <option value="4:00pm">4:00pm</option>');
		document.write(' <option value="5:00pm">5:00pm</option>');
		document.write(' <option value="6:00pm">6:00pm</option>');
		document.write(' <option value="7:00pm">7:00pm</option>');
		document.write(' <option value="8:00pm">8:00pm</option>');
		document.write(' <option value="9:00pm">9:00pm</option>');
		document.write(' <option value="10:00pm">10:00pm</option>');
		document.write(' <option value="11:00pm">11:00pm</option>');
		document.write(' <option value="Morning">Morning</option>');
		document.write(' <option value="Noon">Noon</option>');
		document.write(' <option value="Evening">Evening</option>');
		document.write(' <option value=" " selected="selected">Anytime</option>');
}

function add_options_to_day_select(){
	var newnumber;
	for(var  ivar = 1;ivar < 32; ivar++){
		if(ivar < 10){
			newnumber = "0" + ivar;
		}else{
			newnumber = "" +  ivar;
		}
		document.write('<option value="' + newnumber + '">' + newnumber);
	}
}



////////////////////////////////////////
  var bLEAVING           = false;
  var bRETURNING         = true;
  
  // initialize JavaScript variable from action form
  var dateLeavingMonth   = '';
  var dateLeavingDate    = '';
  var dateReturningMonth = '';
  var dateReturningDate  = '';
  var date;

  // if date fields not initialized, then initialize to today's date + 21 days and today + 24 days
  if ((dateLeavingMonth   == "") || (dateLeavingDate   == ""))
  {
    date = new Date ( );
    date = new Date (date.getTime( ) + 21*24*60*60*1000);  // add 21 days
    dateLeavingMonth   = date.getMonth ( ) + 1;
    dateLeavingDate    = date.getDate  ( );
  }
  if ((dateReturningMonth == "") || (dateReturningDate == ""))
  {
    date = new Date ( );
    date = new Date (date.getTime( ) + 24*24*60*60*1000);  // add 24 days
    dateReturningMonth = date.getMonth ( ) + 1;
    dateReturningDate  = date.getDate  ( );
  }

  function initDaysInMonth (form, bReturningLeaving)
  {
    var current = new Date ();
    var curDay = current.getDate();
    var month = current.getMonth() + 1;
    var year    = current.getYear ();
    var days;
    var options;
    var depMonth = parseInt( form.elements["dateLeavingMonth"].value );
    var depDate = parseInt( form.elements["dateLeavingDay"].value );
    var depYear;
    var retMonth = parseInt( form.elements["dateReturningMonth"].value );
    var retDate = parseInt( form.elements["dateReturningDay"].value );
    var retYear;

	depYear = year;
	retYear = year;
    if (bReturningLeaving == bLEAVING)
    {
      days    = getDaysInMonth (depMonth, depYear);
      options = form.elements["dateLeavingDay"].options;
      initDaysArray (days, options);
    }
    else
    {
      days    = getDaysInMonth (retMonth, retYear);
      options = form.elements["dateReturningDay"].options;
      initDaysArray (days, options);
    }
    glbDepartureYear = depYear;
    glbArrivalYear = retYear;
    return (days);
  }


  function updateDaysInMonth (form, bReturningLeaving)
  {
    var days;
    var date;

    if (bReturningLeaving == bLEAVING)
    {
      dateLeavingMonth   = form.elements["dateLeavingMonth"]  .value;
      date               = form.elements["dateLeavingDay"]    .value;
    }
    else
    {
      dateReturningMonth = form.elements["dateReturningMonth"].value;
      date               = form.elements["dateReturningDay"]  .value;
    }

    days = initDaysInMonth (form, bReturningLeaving);

    if (date > days)
    {
      date = days;
    }
    if (bReturningLeaving == bLEAVING)
    {
      form.elements["dateLeavingDay"].value = date;
    }
    else
    {
      form.elements["dateReturningDay"].value = date;
    }
  }

  // initialize an option object array to hold the days for a select drop down
  function initDaysArray (days, options)
  {
    var ndx = 0;

    for (ndx = 0; ndx < days; ndx++)
      options[ndx] = new Option ( "" + (ndx + 1),  "" + (ndx + 1));
    options.length = days;
  }

  function getDaysInMonth (month, year)
  {
    var days = 31;

    if ((month == 4) || (month == 6) || (month == 9) || (month == 11))
      days = 30;
    if (month == 2)
    {
      days    = 28;
      if ((year % 4) == 0)
        days = 29;
    }

    return (days);
  }

winCal        = null;
winCal_closed = false;
xPos=0;
yPos=0;
 currTopMonIdx = 0;
 firstMon = 0;
 firstYear = 0;
 pickupMon = 0;
 currMidMonIdx = 0;    
 currBtmMonIdx = 0;
var daysInMonth = new Array(12);

function randomNum(number)
{
  rnd.today=new Date();
  rnd.seed=rnd.today.getTime();
  return Math.ceil(rnd()*number);
}

function rnd() {
  rnd.seed = (rnd.seed*9301+49297) % 233280;
  return rnd.seed/(233280.0);
};

function dateBoxes(name1,name2,dateType,yPosAdj, formname)
{
  this.box1Name      = name1;       // month
  this.box2Name      = name2;       // dayOfMonth
  this.boxesDateType = dateType;    // "CP" for pickup date or "CD" dropoff date
  this.boxesyPosAdj  = yPosAdj;
  this.formName      = formname;
} // end dateBoxes

function getMousePos(capEvent)
{
  if (document.layers) {
    xPos=this.screenX + 170
    yPos=capEvent.screenY - 115
  }
  else if (window.event) {
    xPos=this.screenLeft + 165
    yPos=window.event.clientY - 5
  }
  else {
    xPos=0
    yPos=0
  }
} // end getMousePos(capEvent)

function initVariables(selObj)
{
   var d = new Date();
   firstMon = d.getMonth() + 1;
   firstYear = d.getFullYear();
   pickupMon = selObj.options[selObj.selectedIndex].value;
   var temp =0;
   currTopMonIdx = 0;

    
   if ( pickupMon >= firstMon )
   {
     currTopMonIdx = ( pickupMon - firstMon );
   }
   else
   {
     currTopMonIdx = ( 12 + pickupMon ) - firstMon;
   }
 
   currTopMonIdx = parseInt(currTopMonIdx, 36);
   if (currTopMonIdx > 9)
   {
     currTopMonIdx = 9;
   }
   currMidMonIdx = currTopMonIdx + 1;
   currBtmMonIdx = currTopMonIdx + 2;

   daysInMonth[1]  = 31;
   daysInMonth[2]  = 28 + (isLeapYear(firstMon, firstYear)? 1 : 0);
   daysInMonth[3]  = 31;
   daysInMonth[4]  = 30;
   daysInMonth[5]  = 31;
   daysInMonth[6]  = 30;
   daysInMonth[7]  = 31;
   daysInMonth[8]  = 31;
   daysInMonth[9]  = 30;
   daysInMonth[10] = 31;
   daysInMonth[11] = 30;
   daysInMonth[12] = 31;
}

function isLeapYear(firstMon, firstYear)
{
  if ( (firstYear % 400) == 0)
  {
    return 1;
  }
  if (( (firstYear % 4) == 0 ) && ( (firstYear % 100) != 0) )
  {
    return 1;
  }
  return 0;
}

function selectDate(gridNum,monIdx)
{
  with(winCal.loadMonthImg[monIdx]) {
    var dateSelected = gridNum - firstDayGridNum;
    if(dateSelected >= 1 && dateSelected <= daysInMonth[monNumber]) {
       var selectedForm = currBoxes.formName;
       with(getRightForm(currBoxes.box1Name, selectedForm)) {
        with(currBoxes) {
          elements[box1Name].selectedIndex = monNumber - 1;
          if(elements[box1Name].onchange) elements[box1Name].onchange();
          elements[box2Name].selectedIndex = dateSelected - 1;
          if(elements[box2Name].onchange) elements[box2Name].onchange();
          if (monIdx < 9) 
          {
            currTopMonIdx = monIdx;
          }
          else
          {
            currTopMonIdx = 9;
          }
          currMidMonIdx = currTopMonIdx + 1;
          currBtmMonIdx = currMidMonIdx + 1;
          winCal.close();
        }
      }
    }
  }
} // end selectDate(gridNum,monIdx)

function changeMonths(numMonths)
{
   with(this.document)
   {
      if((currTopMonIdx != 0 && numMonths == -1) || (currBtmMonIdx != 11 && numMonths == 1) || (numMonths != -1 && numMonths != 1))
      {
         with (winCal.document)
         {
            images["topMonDates"].src = winCal.loadMonthImg[currTopMonIdx + numMonths].datesImg.src;
            images["topMonName"].src = winCal.loadMonthImg[currTopMonIdx + numMonths].nameImg.src;
            images["midMonDates"].src = winCal.loadMonthImg[currMidMonIdx + numMonths].datesImg.src;
            images["midMonName"].src = winCal.loadMonthImg[currMidMonIdx + numMonths].nameImg.src;
            images["btmMonDates"].src = winCal.loadMonthImg[currBtmMonIdx + numMonths].datesImg.src;
            images["btmMonName"].src = winCal.loadMonthImg[currBtmMonIdx + numMonths].nameImg.src;
            currTopMonIdx += numMonths;
            currMidMonIdx += numMonths;
            currBtmMonIdx += numMonths;
            images["moreDown"].src = (currBtmMonIdx == 11) ? winCal.calDownOff.src : winCal.calDownOn.src;
            images["moreUp"].src = (currTopMonIdx == 0) ? winCal.calUpOff.src : winCal.calUpOn.src;
            winCal.focus();
         }
      }
   }
}

function getRightForm(objNameInForm, reqForm)
{
  var selectedForm = findRightForm( reqForm );
  if ( !selectedForm )
  {
    with(this.document) 
    {
      for(var i = 0; i < forms.length; i++) {
        with(forms[i]) {
          for(var j = 0; j < elements.length; j++) {
            if(elements[j].name == objNameInForm){
               return this.document.forms[i];
            }
          }
        }
      }
    }
  }
  return selectedForm;
} // end getRightForm(objNameInForm, reqForm)

function findRightForm(reqForm)
{
  if ( reqForm )
  {
   with(this.document)
   {
      for(var i = 0; i < forms.length; i++) 
      {
        if ( forms[i].name == reqForm )
        {
          return forms[i];
        }
      }
    }
  }
  return null;
} // end findRightForm(reqForm)

  
  function populateDays(objForm,monthField,dayField)
  {
    currentDate = new Date();
    selectedYear = currentDate.getYear();
    selectIndex = objForm[monthField].selectedIndex;
    timeA = new Date(selectedYear, selectIndex+1,1);
    selectedMonth = selectIndex;
    if (selectedMonth < currentDate.getMonth())
    {
      selectedYear++;
    }
    timeDifference = timeA - 86400000;
    timeB = new Date(timeDifference);
    var daysInMonth = timeB.getDate();
    for (var i = 0; i < objForm[dayField].length; i++)
    {
      objForm[dayField].options[0] = null;
    }
    for (var i = 0; i < daysInMonth; i++)
    {
      objForm[dayField].options[i] = new Option(i+1);
    }
    objForm[dayField].options[0].selected = true;
  }

  function addDays(strDate,iDays)
  {
    strDate = Date.parse(strDate);
    strDate = parseInt(strDate, 10);
    strDate = strDate + iDays*(24*60*60*1000);
    strDate = new Date(strDate);

    return strDate;
  }

  function showHideDive(divMoreAmenities)
  {
      document.getElementById("divMoreAmenities").style.display= (document.getElementById("divMoreAmenities").style.display=='block') ? 'none' : 'block';
  }

  function dateChangeListener(objForm,monthField,dayField,targetMonthField,targetDayField,offset)
  {
    currentDate = new Date();
    selectedYear = currentDate.getYear();
    selectedMonth = objForm[monthField].selectedIndex + 1 ;
    selectedDay =  objForm[dayField].selectedIndex;

    if (selectedMonth < currentDate.getMonth())
    {
      selectedYear++;
    }

    targetOffset = addDays(selectedMonth+"/"+selectedDay+"/"+selectedYear,offset);

    objForm[targetMonthField].selectedIndex=targetOffset.getMonth();
    populateDays(objForm,targetMonthField,targetDayField);

    objForm[targetDayField].selectedIndex=targetOffset.getDate();
  }

  function dateBoxes(name1,name2,dateType,yPosAdj)
  {
    this.box1Name      = name1;       // month
    this.box2Name      = name2;       // dayOfMonth
    this.boxesDateType = dateType;    // "CP" for pickup date or "CD" dropoff date
    this.boxesyPosAdj  = yPosAdj;
  } // end dateBoxes

  var dates1 = new dateBoxes( "dateLeavingMonth" , "dateLeavingDay" , "AD",  0);
  var dates2 = new dateBoxes( "dateReturningMonth", "dateReturningDay", "AR", 25);

////////////////////////////////////////
  function showHideDiv(showHide) {
    for(i=0;i < showHideDiv.arguments.length;i++){
      o_showHide = document.getElementById(showHideDiv.arguments[i])
      s_showHide = (o_showHide.style.display!="") ? o_showHide.style.display : "none";
      o_showHide.style.display = (s_showHide=="none") ? (o_showHide.nodeName=="SPAN") ? "inline" : "block" : "none";
    }
  }
  function navModuleChange(navModuleName) {
	document.getElementById('cbFlightHotels').style.display = 'block';
    (navigator.userAgent.indexOf("5.2")>-1) ? a_modOptions = document.getElementById(navModuleName).getElementsByTagName("select") : a_modOptions=false;
    if(a_modOptions)for(i=0;i< a_modOptions.length;i++){
      a_modOptions[i].focus();
      a_modOptions[i].blur();
    }
  }
  function hotelModuleChange(hotelModuleName) {
    document.getElementById('cbHotelUs').style.display = 'none';
    document.getElementById('cbHotelAll').style.display = 'none';
    document.getElementById(hotelModuleName).style.display = 'block';
  }
  function radioSelect(selectId) {
    var rdo = document.cbRadioNav.rdo_prod;
    if (selectId == "cbFlightHotels") {rdo[1].checked=true;}
    else if (selectId == "cbHotelOnly") {rdo[0].checked=true;}
  }
  function cbSync(){
	navModuleChange('cbFlightHotels');
  }
  // new code below
function setImage (imgName, newImage)
{
	if (document.all)
		document.all.item(imgName).src = eval (newImage+'.src');
	else
		eval ('document.images["'+imgName+'"].src = '+newImage+'.src');	
}
function setAlt (imgName, altText)
{
	if (document.all)
		document.all.item(imgName).alt = altText;
	else
		eval ('document.images["'+imgName+'"].alt = "' + altText + '"');	
}
function setRequiredStates ()
{
	var	ndxLoop;

	for (ndxLoop = 0; ndxLoop < arrayRequired.length; ndxLoop++)
	{
		setImage	(arrayRequired[ndxLoop], "imgError");
	}
}
  function getDivObject ( nameDiv, bStyle )
  {
    var obj;

    if ( document.all )
    {
      obj = document.all[nameDiv];
      if (bStyle)
        obj = obj.style;
    }
    else
    {
      if ( document.layers )
        obj = document.layers[nameDiv];
      else
      {
        obj = document.getElementById (nameDiv);
        if (bStyle)
          obj = obj.style;
      }
    }

    return (obj);
  }
  var adults   = '';
  var seniors  = '';
  var children = '';
  var stops    = '';
  function init_customtrip ()
  {
    // initialize date drop downs
    initDaysInMonth     (document.InitialSearchForm, bLEAVING  );
    initDaysInMonth     (document.InitialSearchForm, bRETURNING);

    document.InitialSearchForm.elements["dateLeavingMonth"]  .options.selectedIndex = dateLeavingMonth   - 1;
    document.InitialSearchForm.elements["dateLeavingDay"]    .options.selectedIndex = dateLeavingDate    - 1;
    document.InitialSearchForm.elements["dateReturningMonth"].options.selectedIndex = dateReturningMonth - 1;
    document.InitialSearchForm.elements["dateReturningDay"]  .options.selectedIndex = dateReturningDate  - 1;

    // if not traveler already given, default to 1 adult
    if (((adults + seniors + children) == "") || (parseInt (adults + seniors + children) == 0))
    {
      document.InitialSearchForm.elements["adults"].options.selectedIndex = 1;
    }
    if ( stops == "" )
    {
      document.InitialSearchForm.elements["stops"].options.selectedIndex = 1;
    }

    // initialize validation error indicators
    //resetRequiredStates ( );
    //setRequiredStates   ( );
    
    //if (document.InitialSearchForm.elements["leavingFrom"].value == "")
    //  document.InitialSearchForm.elements["leavingFrom"].focus ();
        
    //if ((document.all) || (document.getElementById))
    //{
     // var objButtonDiv = getDivObject ("buttonDiv", true);
     // objButtonDiv.visibility = "visible";
    //}
  }


