////////////////////////////////////////
  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(objFormName)
  {
	// initialize date drop downs
	initDaysInMonth     (objFormName, bLEAVING  );
	initDaysInMonth     (objFormName, bRETURNING);

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

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

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

//number children is changed
function childChange(inN)
{
document.getElementById("divAge1").style.display = 'none';
document.getElementById("divAge2").style.display = 'none';
document.getElementById("divAge3").style.display = 'none';
document.getElementById("divAge4").style.display = 'none';
if (inN == 0)
{
	document.getElementById("multichildLabel").style.display = 'none';
}
else
{
	document.getElementById("multichildLabel").style.display = 'inline';
	for(var i = 0; i < inN; i++)
	{
		document.getElementById("divAge"+(i+1)).style.display = 'inline';
	}
}
 true;
}


