submitted = 0;
pagePosn = history.length;
function checkDoubleClick () {
if (!submitted) {
submitted = 1;
return true;
} else {
submitted = 0;
if (history.length > pagePosn) {
return true
} else {
return false;
}
}
}

var focusSet = false;
function setFocus (fldIdx,highlt) {
if(!focusSet) {
focusOn = fldIdx;  
focusSet = true;
focusOn.focus();
if(highlt) 
focusOn.select();
}        
}   

var alertMessage = "";
var focusOn = "";
var focusSet = false;
var yes = true;
var no = false;
var selectBox = true;
var otherBox = false;
var selected = true;
var errorVals = new Array();
var country = "";
var msDays330 = 60*1000*60*24*330;
var msPerDay = 60*1000*60*24;


function getFormIndexNum(currForm,objName) {
for(var i = 0; i < currForm.length; i++) {
if(currForm[i].name == objName)
return (new String(i));
}
return objName;
}

function getFormElementValue(elementObjName,selectOption) {
for(var idxElemntObj = 0; idxElemntObj < thisForm.length; idxElemntObj++) {
if(thisForm[idxElemntObj].name == elementObjName) {
if(selectOption) {
if (thisForm[idxElemntObj].options[thisForm[idxElemntObj].selectedIndex].text == null)
return ""
else
return thisForm[idxElemntObj].options[thisForm[idxElemntObj].selectedIndex].text;
} else {
return thisForm[idxElemntObj].value;
}
}
}
return "";
}



var daysInMonth = new Array(12);
daysInMonth[1] = 31;
daysInMonth[2] = 28;
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 setStartDayVars(monthInput) {
startDay = "";
startMonth = monthInput.options.selectedIndex + 1;
startYear = startMonth < sysMonth ? (sysYear+1) : sysYear;
adjStartYear = startYear < 2000 ? (startYear -1900) : startYear;
}

function checkStartDay(dayInput) {
var errorFound = false;
with(dayInput) {
startDay = parseInt(options[options.selectedIndex].text,10);
startDate = new Date(adjStartYear,(startMonth - 1),startDay);
errFound = (check330MaxDays(startDate,this) ||
validDayMonth(startDay,startMonth,startYear,this) ||
compareToSysDay(startDay,startMonth,this));
}
return errFound;
}

function setEndDayVars(monthInput) {
endDay = "";
endMonth = monthInput.options.selectedIndex + 1;
endYear = endMonth < sysMonth ? (sysYear+1) : sysYear;
adjEndYear = endYear < 2000 ? (endYear -1900) : endYear;
}

function checkEndDay(dayInput) {
var errFound = false;
with(dayInput) {
if(tripOption == "roundtrp") {
endDay =  parseInt(options[options.selectedIndex].text,10);
endDate = new Date(adjEndYear,(endMonth - 1),endDay);
errFound = (compareToSysDay(endDay,endMonth,this) ||
checkDates(startDate,endDate,this) ||
validDayMonth(endDay,endMonth,endYear,this) ||
checkMaxDaysDiff(startDate,endDate,this.max,this));
}
}
return errFound;
}

function checkDates(firstDay,secondDay,properties) {
if(!check330MaxDays(secondDay,properties) && (secondDay.getTime() < firstDay.getTime()) ) {
if (firstDay.getYear() < 1000)
var Year = firstDay.getYear() + 1900
else
var Year = firstDay.getYear()
alertMessage += properties.boxLabel + notEarlierTxt + (firstDay.getMonth()+1) +"/" + firstDay.getDate() + "/" + Year+"n";
return true;
}
else return false;
}

function check330MaxDays(dateToCheck,properties) {
if((dateToCheck.getTime() - todayDate.getTime()) > msDays330 || (dateToCheck.getTime() - todayDate.getTime()) < 0) {
alertMessage += properties.boxLabel + tooAdvTxt;
return true;
}
else return false;
}

function checkMaxDaysDiff(date1,date2,maxDays,properties)
{
	if((date2.getTime() - date1.getTime()) > (maxDays*msPerDay)) 
	{
		if(maxDays > 1 || (maxDays == 1 && (date2.getTime() - date1.getTime()) > 60*1000*60*25)) 
		{
			//alertMessage += properties.boxLabel + cantExceedTxt + (date1.getMonth() + 1) + "/" + date1.getDate() + byMoreThanTxt + maxDays + day
			//sTxt;
			return true;
		}
	}
	else
	{
		if ((date2.getTime() - date1.getTime()) < (properties.min*msPerDay)) 
		{
			if(properties.min == 1 && (date2.getTime() - date1.getTime()) < 60*1000*60*23) 
			{
				//alertMessage += properties.boxLabel + greaterThanTxt   + (date1.getMonth() + 1) + "/" + date1.getDate() +"n";
				return true;
			}
		}
		else 
			return false;
	}
}

function compareToSysDay(inputDay,inputMonth,properties) {
if(sysMonth == inputMonth && (sysDay-1) > inputDay) {
alertMessage += properties.boxLabel + invValueDtTxt;
return true;
}
else  return false;
}

function validDayMonth(dayNum,monthNum,yearNum,properties) {
if((dayNum > daysInMonth[monthNum]) || (dayNum == 0 || monthNum == 0) ||
(monthNum == 2) && (dayNum > daysInFeb(yearNum))) {
alertMessage += properties.boxLabel + invDtTxt;
return true;
}
else return false;
}

function daysInFeb(year) {
return (((year % 4 == 0) && ((!(year % 100 == 0)) || (year % 400 == 0))) ? 29:28);
}

function setSysDayVars() {
sysMonth = getFormElementValue("CMonth",no);
sysDay = getFormElementValue("CDayOfMonth",no);
sysYear = parseInt(getFormElementValue("CYear",otherBox),10);
adjSysYear = sysYear < 2000 ? (sysYear - 1900) : sysYear;
todayDate = new Date(adjSysYear,(sysMonth - 1),sysDay);
}

function setFormElementValue(boxObj,boxType,newVal) {
if(!boxType)
boxObj.value = newVal;
else
boxObj.selectedIndex = newVal;
}

winCal = null;
winCal_closed = false;
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 if(document.getElementById&&!document.all){
	xPos = capEvent.clientX+165;
	yPos = capEvent.clientY-5;
}else{
	xPos=0
	yPos=0
	}
}

function popOpenCal (theseBoxes) {
currBoxes=theseBoxes;
if (!winCal || winCal.closed) {
yPos += currBoxes.boxesyPosAdj;
url = "/calwindow/"
winCal = window.open(url+'0,,'+currTopMonIdx+'|'+currBoxes.boxesDateType+',00.html','winCal','height=145,width=380,screenX='+xPos+',screenY='+yPos+',left='+xPos+',top='+yPos+'');
if (winCal) winCal.homeWin = this;
} else {
winCal.focus();
}
winCal_closed = true;
}
function closePopupCalWin() {
if (winCal_closed) {
winCal_closed = false;
winCal.close();
} else {
return true;
}
}
function dateBoxes (name1,name2,dateType,yPosAdj) {
this.box1Name=name1;
this.box2Name=name2;
this.boxesDateType=dateType;
this.boxesyPosAdj=yPosAdj;
}
function moveMonths(monthBox) {
with(monthBox) {
var moveNumMonths = (selectedIndex >= (firstMon - 1)) ? selectedIndex - (firstMon - 1) - currTopMonIdx : 12 - (firstMon - 1) - (currTopMonIdx - selectedIndex);
if((currTopMonIdx + moveNumMonths) > 9) moveNumMonths = 9 - currTopMonIdx;
if((currTopMonIdx + moveNumMonths) < 0) moveNumMonths = 0 - currTopMonIdx;
if (winCal) {
if (!winCal.closed) {
changeMonths(moveNumMonths);
} else {
currTopMonIdx += moveNumMonths;
currMidMonIdx += moveNumMonths;
currBtmMonIdx += moveNumMonths;
}
} else {
currTopMonIdx += moveNumMonths;
currMidMonIdx += moveNumMonths;
currBtmMonIdx += moveNumMonths;
}
}
}
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 selectDate(gridNum,monIdx) {
var fltplushotel = currBoxes.box1Name;
if (fltplushotel == 'leaveMonth1') {
currBoxes.box1Name = 'leaveMonth';
} else if (fltplushotel == 'returnMonth1'){
currBoxes.box1Name = 'returnMonth';
}
if ((fltplushotel == 'leaveMonth1') || (fltplushotel == 'returnMonth1')){
	with(winCal.loadMonthImg[monIdx]) {
	var dateSelected = gridNum - firstDayGridNum;
	if(dateSelected >= 1 && dateSelected <= daysInMonth[monNumber]) {
	with(document.ExpressBk) {
	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 && monIdx != currTopMonIdx) {
	currTopMonIdx = monIdx;
	currMidMonIdx = currTopMonIdx;
	currBtmMonIdx = currMidMonIdx;
	}
	if (fltplushotel == 'leaveMonth1') {
	currBoxes.box1Name = 'leaveMonth1';
	} else if (fltplushotel == 'returnMonth1'){
	currBoxes.box1Name = 'returnMonth1';
	}
	winCal.close();
	}
	}
	}
	}
} else {
	with(winCal.loadMonthImg[monIdx]) {
	var dateSelected = gridNum - firstDayGridNum;
	if(dateSelected >= 1 && dateSelected <= daysInMonth[monNumber]) {
	with(getRightForm(currBoxes.box1Name)) {
	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();
	winCal.close();
	}
	}
	}
	}
	}
}
function getRightForm(objNameInForm) {
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 null
}


var winCal = ""
var firstMon = 2;

var currTopMonIdx = 0;
var currMidMonIdx = 1;
var currBtmMonIdx = 2;

function setRadioBtn (theForm,radioObjName,valOfBtnToSet) {
for (var i = 0; i < theForm[radioObjName].length; i++) {
if (theForm[radioObjName][i].value == valOfBtnToSet)
theForm[radioObjName][i].checked=true;
}
}

//=============================
function submitExpress( dep,arp,path ) {
p = path.toUpperCase();
if( (dep.value.length < 3) || (dep.value.length > 25) ) {
    (p == "A") ? (alertMsg = "Please enter a departure city of 3 to 25 characters.") : (alertMsg = "Please enter a city or an airport code.");
	alert(alertMsg);
	dep.focus()
	return false;
	}
if( (arp.value.length < 3) || (arp.value.length > 25) ) {
    (p == "A") ? (alertMsg = "Please enter an arrival city of 3 to 25 characters.") : (alertMsg = "Please enter a city or an airport code.");
	alert(alertMsg);
	arp.focus()
	return false;
	}
return true;
}
function popOpenCal (theseBoxes) {
currBoxes=theseBoxes;
if (!winCal || winCal.closed) {
	yPos += currBoxes.boxesyPosAdj;
	url = "/calwindow/"
	winCal = window.open(url+'0,,'+currTopMonIdx+'|'+currBoxes.boxesDateType+',00.html','winCal','height=145,width=380,screenX='+xPos+',screenY='+yPos+',left='+xPos+',top='+yPos+'');
	winCal ? (winCal.homeWin = this) : winCal.focus();
	winCal_closed = true;
}
}
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
	}
}
function setFormElementValue(boxObj,boxType,newVal) {
	(boxType) ? (boxObj.selectedIndex = newVal) : (boxObj.value = newVal);
} 

function addvars(url,formObj){
url1=new String(url);
elIn=6;
with(formObj){
url1=url1+"&expr_path="+elements[elIn++].value;
url1=url1+"&airport="+elements[elIn++].value;
(formObj.state) ? (url1=url1+"&state="+elements[elIn++].value) : (url1=url1+"&state="+"");
url1=url1+"&ckin_dt_mon="+elements[elIn++].value;
url1=url1+"&ckin_dt_dy="+elements[elIn++].value;
url1=url1+"&ckout_dt_mon="+elements[elIn++].value;
url1=url1+"&ckout_dt_dy="+elements[elIn++].value;
if (formObj.state){
url1=url1+"&pax_cnt="+elements[elIn].selectedIndex+1;
url1=url1+"&mode=1";}
else {
url1=url1+"&pax_cnt="+elements[elIn++].selectedIndex+1;
url1=url1+"&mode=2";
}
parent.window.location=url1;
}
}
function moveMonths(monthBox) {
with(monthBox) {
	var moveNumMonths = (selectedIndex >= (firstMon - 1)) ? selectedIndex - (firstMon - 1) - currTopMonIdx : 12 - (firstMon - 1) - (currTopMonIdx - selectedIndex);
	if((currTopMonIdx + moveNumMonths) > 9) moveNumMonths = 9 - currTopMonIdx;
	if((currTopMonIdx + moveNumMonths) < 0) moveNumMonths = 0 - currTopMonIdx;
	if (winCal) {
		if (!winCal.closed) {
			changeMonths(moveNumMonths);
		} else {
			currTopMonIdx += moveNumMonths;
			currMidMonIdx += moveNumMonths;
			currBtmMonIdx += moveNumMonths;
			}
	} else {
		currTopMonIdx += moveNumMonths;
		currMidMonIdx += moveNumMonths;
		currBtmMonIdx += moveNumMonths;
			}
		}
	}




function getDaysInMonth(month,year)  {
var days=31;
switch (month) 
{
  case 3:
  case 5:
  case 8:
  case 10: days=30; break;
  case 1:
	  (((year % 4)==0) && ((year % 100)!=0) || ((year % 400)==0)) ? days = 29 : days = 29;
}
return days;
}
function getDeptYear(deptMonth) {
   now = new Date();
   return (((deptMonth >= (now.getMonth() + 1)) && (deptMonth <=11)) ? now.getYear() : now.getYear()+1);
}
function AdvanceToXDays(dm_obj,rm_obj,dd_obj,rd_obj,days) {
  dm_sel = dm_obj.selectedIndex ;
  dd_sel = dd_obj.selectedIndex + 1; 
  dy     = getDeptYear(dm_sel);
  dim    = getDaysInMonth(dm_sel, dy);
  if (dd_sel > dim) dd_sel = dim;
  dd_obj.selectedIndex = dd_sel - 1;
  dd     = new Date(dy,dm_sel,dd_sel,0,0,0,0);
  rd     = ToXDays(dd,days);  
  rm_obj.selectedIndex = rd.getMonth();
  rd_obj.selectedIndex = rd.getDate() -1;
}
function ToXDays(dateobj, days) {
   dim = getDaysInMonth((dateobj.getMonth()), dateobj.getYear());   
   if ((dateobj.getDate() + days) < dim) {
      dateobj.setDate((dateobj.getDate() + days));
      return dateobj;
   } else {
      if (dateobj.getMonth() == 11) {
          
          dateobj.setYear(dateobj.getYear()+1);
          
          dateobj.setMonth(0);
      } else {
          
           
          dateobj.setMonth((dateobj.getMonth()+1));
      }
      daysleftinMonth = dim - dateobj.getDate();
      days = days - daysleftinMonth -1;
      dateobj.setDate(1);
      
      return ToXDays(dateobj,days);
   }
}

submitted = 0;
function checkDoubleClick () {
if (!submitted) {
submitted = 1;
return true;
} else {
submitted = 0;
return false;
}
}