                                                                                                                                                                                                                                                                                                                                                                                                                                                                               var dDT = new Date();
var wlt = dDT.getTime();
var wdt = '1800';


function handleAirWinOnload(evt) {
  
	defPopEvts();
  
     if (document.all['strAirItin_CitySearchCopy'] == null) {
	   airTripSelectionDefault();
	 } 
  
}


function gCFD(sDate, sOff) {
var dDate = new Date(sDate);
 if(isNaN(dDate)) {
 dDate = new Date();
 }
var sOff = String(sOff);
var aO = sOff.split("/");
var iMO = parseInt(aO[0]);
var iDO = parseInt(aO[1]);
var iYO = parseInt(aO[2]);
var dNew = new Date(dDate);
dNew.setDate(dNew.getDate() + iDO);
dNew.setMonth(dNew.getMonth() + iMO);

if (dNew.getYear() < 100)
{
dNew.setYear(dNew.getYear() + 2000 + iYO);
}
else
{
dNew.setYear(dNew.getFullYear() + iYO);
}

var sFD = String(dNew.getMonth() + 1) + "/" + String(dNew.getDate()) + "/" + String(dNew.getFullYear());
return(sFD);
}

var gIntMonth = 0;
var gIntDate = 0;
var gIntYear = 0;
var gSourceField = null;
var gSourceFieldValue = "";

function updateDependentDate(oBox2,sDate1,sOffset) {
var d1 = new Date(sDate1);
var d2 = new Date(oBox2.value);
 if(isNaN(d1)) {
 return;
 }
var sNew = gCFD(sDate1, sOffset);
 if(isNaN(d2)) {
 oBox2.value = sNew;
 return;
 }
 if(d1 >= d2) {
 oBox2.value = sNew;
 return;
 }
}

function cleanDigits(strDigits) {
var strResult = "0";
 for(var i = 0; i < strDigits.length; i++){
 var strC = strDigits.charAt(i);
  if(isDigit(strC)) {
  strResult += "" + strC;
  }
 }
var iResult = parseInt(strResult,10);
return(iResult);
}

function isDigit(ch) {
return(ch >= '0' && ch <= '9');
}

function GetDaysInMonth(intMonth, intYear) {
var arrDaysInMonth = new Array(31,28,31,30,31,30,31,31,30,31,30,31);
var intCount = arrDaysInMonth[intMonth-1];
 if(intMonth == 2) {
  if((intYear%4) == 0 ) {	// post-2000 leap year - ignore 2100 etc.
  intCount++;
  }
 }
return intCount;
}

function IsValidDate(intDate, intMonth, intYear) {
 if( (intYear > 2050) || (intYear < 1900) ) {return false;}
 if( (intMonth > 12) || (intMonth < 1) ) {return false;}
 if(intDate < 1) {return false;}
var intMaxDate = GetDaysInMonth(intMonth, intYear);
 if(intDate > intMaxDate) {return false;}
return true;
}

function GetInputDate(strDate){
var lenDateString = strDate.length;
if(lenDateString == 0) {return(false);}

arrDate = strDate.split("/");
if(arrDate.length < 3) {return(false);}

var intMonth = cleanDigits(arrDate[0]);
var intDate = cleanDigits(arrDate[1]);
var intYear = cleanDigits(arrDate[2]);
if (intYear.length < 4){
	intYear = parseint("20" + string(intYear))
	}  


if(IsValidDate(intDate, intMonth, intYear)) {
 gIntMonth = intMonth;
 gIntDate = intDate;
 gIntYear = intYear;
}else{
 var dToday = new Date();
 gIntMonth = dToday.getMonth() + 1;
 gIntDate = dToday.getDate();
 gIntYear = dToday.getFullYear();
 }
return(true);
}

function ShowCalendar(launchButton,dateInputField,datePrevField,strEarliestDate,strLatestDate,strEarliestOffset,strLatestOffset){
var calDocumentAll=document.all.CalFrame;
var oCalFrame = window.frames.CalFrame;

//alert("test 1");
if(oCalFrame.gblnCalendarLoaded == null || oCalFrame.gblnCalendarLoaded == false){
 alert("Calendar:" + oCalFrame.gblnCalendarLoaded + "\r\nUnable to load popup calendar.\r\nPlease reload the page.");
return;
}

var strStartRange = strEarliestDate;
var strEndRange = strLatestDate;

if(datePrevField != null) {
 if(String(dateInputField.value) != "") {
 var sDate = String(datePrevField.value);
  if(strEarliestOffset != "") {
  strStartRange = gCFD(sDate, strEarliestOffset);
    }
  if(strLatestOffset != "") {
  strEndRange = gCFD(sDate, strLatestOffset);
  }
 }
}
oCalFrame.SetDateRange(new Date(strStartRange),new Date(strEndRange));

if(dateInputField == gSourceField && calDocumentAll.style.display == "block"){
 if(gSourceFieldValue != dateInputField.value && GetInputDate(dateInputField.value)){
 oCalFrame.SetInputDate(gIntDate, gIntMonth, gIntYear);
 oCalFrame.SetDate(gIntDate, gIntMonth, gIntYear);
 gSourceFieldValue = dateInputField.value;
 }
 else
 calDocumentAll.style.display = "none";
}else{
 if(GetInputDate(dateInputField.value)){
 dateInputField.value = String(gIntMonth) + "/" + String(gIntDate) + "/" + String(gIntYear);
 oCalFrame.SetInputDate(gIntDate, gIntMonth, gIntYear);
 oCalFrame.SetDate(gIntDate, gIntMonth, gIntYear);
 } else if(null != datePrevField && GetInputDate(datePrevField.value)){
 oCalFrame.SetInputDate(gIntDate, gIntMonth, gIntYear);
 oCalFrame.SetDate(gIntDate, gIntMonth, gIntYear);
 }else{
 var dDate = new Date(strEarliestDate);
 oCalFrame.SetInputDate(-1, -1, -1);
 oCalFrame.SetDate(dDate.getDate(), dDate.getMonth()+1, dDate.getFullYear());
}

var intCalLeft = 0;
var intCalTop = 0;

 for(var p = launchButton; p && p.tagName!='BODY'; p = p.offsetParent){
 intCalLeft += p.offsetLeft;
 intCalTop += p.offsetTop;
 }

var intLaunchButtonHeight = launchButton.offsetHeight;
var intDocHeight = calDocumentAll.style.pixelHeight;
var intScrollTop = document.body.scrollTop;
calDocumentAll.style.left = intCalLeft;

 if( (intCalTop - intDocHeight >= intScrollTop) && (intCalTop + intLaunchButtonHeight + intDocHeight > document.body.clientHeight + intScrollTop) )
 calDocumentAll.style.top = intCalTop - intDocHeight;
 else
 calDocumentAll.style.top = intCalTop+intLaunchButtonHeight;
  if(calDocumentAll.style.display == "none")
  calDocumentAll.style.display = "block";
  gSourceField = dateInputField;
  gSourceFieldValue = dateInputField.value;
 }
}

function SetDate(intDate, intMonth, intYear){
gSourceField.focus();
gSourceField.value = (intMonth + "/" + intDate + "/" + String(intYear));
gSourceFieldValue = gSourceField.value;
}

var lsUseDHTML = 'Y';
var lsAirTripType = 'RT';
var lsASO = 'N';

function airTripSelectionDefault() {
 
 airTripSelection(lsAirTripType);
 
}
function airTripSelection(sTrip) {
  if (sTrip=="OW") {
	if (document.all['divAirItinOneWay'] != null) {
		document.all['divAirItinRoundTrip'].style.display='none';
		document.all['divAirItinMultiCity'].style.display='none';
		document.all['divAirItinOneWay'].style.display='block';
	}
	if (document.all['spanLinkOneWay'] != null) {
		document.all.spanLinkOneWay.innerHTML = '<b style="color:#FFFFFF">One-Way</b>';
		document.all.spanLinkRoundTrip.innerHTML = "<a href=\"JavaScript:airTripSelection('RT')\" class='airfare-link'>Round-Trip</a>";
		document.all.spanLinkMultiCity.innerHTML = "<a href=\"JavaScript:airTripSelection('MD')\" class='airfare-link'>Multi-Destination</a>";
	}
	if (document.all['AirTripType'] != null) {
		document.all.AirTripType(1).checked = true;
	}
	if (document.all['divAirItinNavOW'] != null) {
		document.all['divAirItinNavRT'].style.display='none';
		document.all['divAirItinNavMD'].style.display='none';
		document.all['divAirItinNavOW'].style.display='block';
	}
	if (document.all['divAirItinNyop'] != null) {
		document.all['divAirItinNyop'].style.display='none';
	}
	if (document.all['divAirItinTC1'] != null) {
		document.all['divAirItinTC2'].style.display='block';
		document.all['divAirItinTC1'].style.display='none';
	}
  } else if (sTrip=="MD") {
	if (document.all['divAirItinMultiCity'] != null) {
		document.all['divAirItinRoundTrip'].style.display='none';
		document.all['divAirItinOneWay'].style.display='none';
		document.all['divAirItinMultiCity'].style.display='block';
	}
	if (document.all['spanLinkOneWay'] != null) {
		document.all.spanLinkMultiCity.innerHTML = '<b style="color:#FFFFFF">Multi-Destination</b>';
		document.all.spanLinkOneWay.innerHTML = "<a href=\"JavaScript:airTripSelection('OW')\" class='airfare-link'>One-Way</a>";
		document.all.spanLinkRoundTrip.innerHTML = "<a href=\"JavaScript:airTripSelection('RT')\" class='airfare-link'>Round-Trip</a>";
			
	}
	if (document.all['AirTripType'] != null) {
		document.all.AirTripType(2).checked = true;
	}
	if (document.all['divAirItinNavMD'] != null) {
		document.all['divAirItinNavRT'].style.display='none';
		document.all['divAirItinNavOW'].style.display='none';
		document.all['divAirItinNavMD'].style.display='block';
	}
	if (document.all['divAirItinNyop'] != null) {
		document.all['divAirItinNyop'].style.display='none';
	}
	if (document.all['divAirItinTC1'] != null) {
		document.all['divAirItinTC2'].style.display='block';
		document.all['divAirItinTC1'].style.display='none';
	}
  } else {
	if (document.all['divAirItinRoundTrip'] != null) {
		document.all['divAirItinOneWay'].style.display='none';
		document.all['divAirItinMultiCity'].style.display='none';
		document.all['divAirItinRoundTrip'].style.display='block';
	}
	if (document.all['spanLinkOneWay'] != null) {
		document.all.spanLinkRoundTrip.innerHTML = '<b style="color:#FFFFFF">Round-Trip</b>';
		document.all.spanLinkOneWay.innerHTML = "<a href=\"JavaScript:airTripSelection('OW')\" class='airfare-link'>One-Way</a>";
		document.all.spanLinkMultiCity.innerHTML = "<a href=\"JavaScript:airTripSelection('MD')\" class='airfare-link'>Multi-Destination</a>";
	}
	if (document.all['AirTripType'] != null) {
		document.all.AirTripType(0).checked = true;
	}
	if (document.all['divAirItinNavRT'] != null) {
		document.all['divAirItinNavOW'].style.display='none';
		document.all['divAirItinNavMD'].style.display='none';
		document.all['divAirItinNavRT'].style.display='block';
	}
	if (document.all['divAirItinNyop'] != null) {
		document.all['divAirItinNyop'].style.display='block';
	}
	if (document.all['divAirItinTC1'] != null) {
		document.all['divAirItinTC1'].style.display='block';
		document.all['divAirItinTC2'].style.display='none';
	}
  }
}

function airASO(sTrip) { 
 if (document.all['divAso'+sTrip] != null) {
  document.all['divAslRT'].style.display='none';
  document.all['divAsoRT'].style.display='block';
  document.all['divAslOW'].style.display='none';
  document.all['divAsoOW'].style.display='block';
  document.all['divAslMD'].style.display='none';
  document.all['divAsoMD'].style.display='block'; 
  document.all['divAsoDtRT'].style.display='block';
  document.all['divAsoRtRT'].style.display='block';
  document.all['divAsoDtOW'].style.display='block'; 
  for (var i=1; i<=Number(5); i++) {
    document.all['divAsoDtMD'+i].style.display='block'; 
  }
  if (sTrip=="RT") { 
	document.airItinRT['Navigation/Required/Advanced_Search_Option'].value='Y';	
  }
  if (sTrip=="OW") { 
   document.airItinOW['Navigation/Required/Advanced_Search_Option'].value='Y';	
  }
  if (sTrip=="MD") { 
  	document.airItinMD['Navigation/Required/Advanced_Search_Option'].value='Y';	
  }
 }
}                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               
//  ******************* CLIENT_SIDE SNIFFER CODE ******************* 
//	stylesheet selection removed - used for some DHTML stuff that is not on every page, but is on 
//	enough to justify being in global file

// comment out this line when doing javascript debugging
self.onerror = function() {return true;}

var agt=navigator.userAgent.toLowerCase(); 

//  BROWSER VERSION 
// Note: On IE5, these return 4, so use is_ie5up to detect IE5. 
var is_major = parseInt(navigator.appVersion); 
var is_minor = parseFloat(navigator.appVersion); 

//  BROWSER TYPE 
var is_nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
            && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
            && (agt.indexOf('webtv')==-1));
var is_nav4up = (is_nav && (is_major >= 4 && is_major < 5));
var is_nav6 = (is_nav && (is_major >= 5 ));  
var is_ie   = (agt.indexOf("msie") != -1); 
var is_ie3  = (is_ie && (is_major < 4)); 
var is_ie4  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")==-1) );
var is_ie4up  = (is_ie  && (is_major >= 4));
var is_ie5  = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );  
var is_ie5up  = (is_ie  && !is_ie3 && !is_ie4);  

//  PLATFORM 
var is_win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) );
var is_mac    = (agt.indexOf("mac")!=-1);
var is_linux = (agt.indexOf("inux")!=-1);
var is_unix  = ((agt.indexOf("x11")!=-1) || is_linux);

// DATE FUNCTIONALITY
var today = new Date();
var thisDay = today.getDate();
var thisMonth = today.getMonth();
var thisYear = y2k(today.getYear());

var monthArray = new Array('Jan','Feb','Mar','Apr','May','Jun','Jul','Aug','Sep','Oct','Nov','Dec');
var dayArray = new Array(31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31);

function y2k (number) {
	return (number < 1000) ? number + 1900 : number;
}

function setArrays() {
	if (((thisYear % 4 == 0) && (thisYear % 100 != 0)) || (thisYear % 400 == 0))
		dayArray[1] = 29;
}

// this function is currently irrelevent, and could be merged with changeDateGen,
// but i'm leaving here in case further abstraction is necessary down the road.
function changeDate (ddArray,whichDD) {
	if (ddArray.length >= 4) {
		var sMo = ddArray[0];
		var sDy = ddArray[1];
		var eMo = ddArray[2];
		var eDy = ddArray[3];
		if (whichDD != 3 && whichDD != 4) // put in because of in-stream change of date-chaning rules. 
			changeDateGen(sMo,sDy,eMo,eDy,whichDD);
	}
}

// generic date changing function
// only thing missing is safeguard against dates that don't exist (e.g. nov 31)
function changeDateGen (sMo,sDy,eMo,eDy,whichDD) {
	var sMoIndex = sMo.options.selectedIndex;
	var sDyIndex = sDy.options.selectedIndex;
	var eMoIndex = eMo.options.selectedIndex;
	var eDyIndex = eDy.options.selectedIndex;
	
	var sDate = getDDdate(sMo,sDy);
	var eDate = getDDdate(eMo,eDy);

	if (whichDD==0 && sDate>eDate) {
		if (whichCal==1) {
			setDDdate(eMo,eDy,addDays(sDate,tripLength));
		} else if (whichCal==2) {
			setDDdate(sMo,sDy,addDays(eDate,-1*tripLength));
		}
	} else if (sMoIndex>eMoIndex) {
		if (whichDD==1) {
			eMo.options.selectedIndex = sMoIndex;
			if (sDyIndex>eDyIndex) setDDdate(eMo,eDy,addDays(sDate,tripLength));
		} else if (whichDD==3) {
			sMo.options.selectedIndex = eMoIndex;
			if (sDyIndex>eDyIndex) setDDdate(sMo,sDy,addDays(eDate,-1*tripLength));
		}
	} else if (sMoIndex==eMoIndex && sDyIndex>eDyIndex) {
//		these two lines should be there instead of the two lines that follow.
//		if (whichDD==1 || whichDD==3) {
//			eDy.options.selectedIndex = Math.min(sDy.options.selectedIndex+tripLength,getMonthLength(eMo.options[eMoIndex].value)-1);
		if (whichDD==1) { // put in because of in-stream change of date-chaning rules. 
			setDDdate(eMo,eDy,addDays(sDate,tripLength));
		} else if (whichDD==2) {
			setDDdate(eMo,eDy,addDays(sDate,tripLength));
		} else if (whichDD==4) {
			setDDdate(sMo,sDy,addDays(eDate,-1*tripLength));
		}
	}
}

function getDDdate (moDD,dyDD) {
	var moYr = moDD.options[moDD.options.selectedIndex].value.split(" ");
	var mo = moYr[0].substr(0,3);
	var yr = (moYr.length > 1) ? moYr[1] : thisYear;
	var dy = dyDD.options[dyDD.options.selectedIndex].value;

	for (i=0;i<monthArray.length;i++) {
		if (monthArray[i] == mo) break;
	}
	return new Date(yr,i,dy);
}

function getMonthLength (mo) {
	mo = mo.substr(0,3).toLowerCase();
	for (var i=0;i<monthArray.length;i++) {
		if (monthArray[i].toLowerCase() == mo) break;
	}
	return dayArray[i];
	return 31;
}

function setDDdate (moDD,dyDD,theDate) {
	var maxMoYr = moDD.options[moDD.options.length-1].value;
	maxMoYr = maxMoYr.split(" ");
	var maxDy = getMonthLength(maxMoYr[0]);
	//BCL - temp js fix 
	//theDate = new Date(Math.min(new Date(maxMoYr[0]+" "+maxDy+", "+maxMoYr[1]),theDate));

	var yr = theDate.getFullYear();
	var mo = monthArray[theDate.getMonth()];
	var dy = theDate.getDate();
	var matchedMo = -1;

	var matchVal = (yr==thisYear) ? mo : mo + " " + yr;
	for (var i=0;i<moDD.options.length;i++) {
		if (moDD.options[i].value == matchVal) {
			matchedMo = i;
			break;
		}
	}
	if (matchedMo == -1) dy = 1;
	
	moDD.options.selectedIndex = Math.max(0,matchedMo);
	dyDD.options.selectedIndex = dy-1;
}

function addDays (theDate,days) {
	if (!days) days = 0;
	var mseconds = theDate.getTime() + 86400000 * days; 
	return new Date(mseconds);
}

var theForm;
var dateDDs = new Array();
var whichCal = 0;
var tripLength = 7;

function selectDate (dy,moYr) {
	moYr = moYr.split(" ");
	var mo = moYr[0].substr(0,3);
	var yr = moYr[1];
	var theDate = new Date(mo + " " + dy + ", " + yr);

	var moDD, dyDD;
	moDD = dateDDs[(whichCal*2)-2];
	dyDD = dateDDs[(whichCal*2)-1];
	setDDdate (moDD,dyDD,theDate,0);
	
	if (dateDDs.length == 4) changeDateGen (dateDDs[0],dateDDs[1],dateDDs[2],dateDDs[3],0);
	else if (dateDDs.length > 4) changeMultiDate(whichCal,0);
	whichCal = 0;
}

function changeMultiDate (whichDate,whichDD) {
	var whichMoDD = (whichDate-1)*2;
 	var whichDyDD = whichMoDD+1;
	var dateDiff = 0;
	var i, firsti, whichDDofFour;
	whichCal=2;
	for (i=firsti=whichDate-1;i>=1;i--) {
		dateDiff = (firsti-i) * 2;
		whichDDofFour = (i==firsti && whichDD>0) ? whichDD+2 : 0;
		changeDateGen(dateDDs[whichMoDD-dateDiff-2],dateDDs[whichDyDD-dateDiff-2],dateDDs[whichMoDD-dateDiff],dateDDs[whichDyDD-dateDiff],whichDDofFour);
	}
	whichCal=1;
	for (i=firsti=whichDate+1;i<=(dateDDs.length/2);i++) {
		dateDiff = (i-firsti) * 2;
		whichDDofFour = (i==firsti && whichDD>0) ? whichDD : 0;
		changeDateGen(dateDDs[whichMoDD+dateDiff],dateDDs[whichDyDD+dateDiff],dateDDs[whichMoDD+dateDiff+2],dateDDs[whichDyDD+dateDiff+2],whichDDofFour);
	}
	whichCal=0;
}

// ONFOCUS & ONBLUR FUNCTIONALITY
// how to call: [onFocus="textFocus(this);" onBlur="textBlur(this);"]
function textFocus (el,val) {
	if (val) {
		el.defaultValue = val;
		if (el.value == val) el.value = "";
	}
	else if (el.value != "") {
		el.defaultValue = el.value;
		el.value = "";
	}
}

function textBlur (el,val) {
	if (val) el.defaultValue = val;
	if (el.value == "") {
		el.value = el.defaultValue;
	}
}


//reloads the window if Nav4 resized
function MM_reloadPage (init) {  
 	if (init) with (navigator) {
 		if ((appName=="Netscape") &&(parseInt(appVersion)==4)) {
			document.MM_pgW=innerWidth;
			document.MM_pgH=innerHeight;
			onresize=MM_reloadPage;
		}
	} else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) {
		location.reload();
	}
}

//img swap
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-1); i+=2) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+1];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

MM_reloadPage(true);

// general popup - specify href, width, and height in function call
function popUpGen (page,w,h,id,globalProps) {
	if (!id) id="popup";
	if (!globalProps) globalProps = "resizable=yes,menubar=no,status=no,scrollbars=yes,toolbar=no,directories=no,location=no";
	var win;
	if (navigator.appName == 'Netscape') {			 	
		win = window.open(page,id,'width='+w+',height='+h+','+globalProps+',screenX=0,screenY=0');
	} else {
		win = window.open(page,id,'width='+w+',height='+h+','+globalProps+',top=0,left=0');
	}
	win.focus();
    return false;
}

//	hotwire popup
function popUpHotwire(page) {
	return popUpGen(page,760,620,'hotwire','resizable=yes,menubar=yes,status=yes,scrollbars=yes,toolbar=yes,directories=yes,location=yes');
}


function popUpPrintItin(url){
	return popUpGen(url, 635,600,'print','resizable=yes,menubar=yes,status=no,scrollbars=yes,toolbar=no,directories=no,location=no');
	}

// standard popup
function popUp(page) {
	return popUpGen('/'+page+'.jsp',420,400,'popup');
}

// specialized popup functions
function popUpHelp (page) {
	return popUpGen('/help/'+page+'.jsp',420,400,'popuphelp');
}

var calendarLink = "/App/Home?view=calendar";
function popUpCal (n) {
	whichCal = n;
	var setMonth = "";
	setMonth = dateDDs[(n-1)*2].options[dateDDs[(n-1)*2].options.selectedIndex].value.split(" ");
	var setYear = setMonth[1] ? setMonth[1] : "";
	setMonth = setMonth[0];
	return popUpGen(calendarLink+"&n="+n+"&setMonth="+setMonth+"&setYear="+setYear,200,390,'popupcal','resizable=yes,menubar=no,status=no,scrollbars=no,toolbar=no,directories=no,location=no');
}

function popUpAirCode() {		
	return popUpGen('/global/airportCodes.jsp',600,725,'popupaircode');
}

function popUpLearnMore (url) {
	return popUpGen(url,500,400,'popuplearnmore');
}

// privacy and terms
function popUpReg(page) {
	return popUpGen('/App/global/legal/'+page+'.jsp',550,500);
}

// close window
function closeWin () {
	window.close();
	return true;
} 

//Used for dynamically generated booking path section numbers
var sCount=0;
function stepCount(){
	sCount++;
	document.write(sCount);
}

var field_length=0;

function tabNext (obj,event,len,next_field) {
	if (event == "down") {field_length=obj.value.length;}
	else if (event == "up") {
		if (obj.value.length != field_length) {
			field_length=obj.value.length;
			if (field_length == len) {next_field.focus();}
		}
	}
}

// onkeyup="tabNext(this,'up',3,this.form.elements['NEXTFIELD'])" onkeydown="tabNext(this,'down',3)"

function selectCheck(formName,checkName){
	if (document.forms[formName].elements[checkName].checked){document.forms[formName].elements[checkName].checked=false;}
	else {document.forms[formName].elements[checkName].checked=true;}
}

// Netscape style sheet modifications
var text = "";
text += '<style type="text/css">\n';
text += 'td			{font-family: arial, sans-serif; font-size: 12px;}\n';
text += 'p			{font-family: arial, sans-serif; font-size: 12px;}\n';
text += 'input		{font-family: arial, sans-serif; font-size: 12px; margin: 0px;}\n';
text += 'select		{font-family: arial, sans-serif; font-size: 12px; margin: 0px}\n';
text += '.t1		{font-family: arial, sans-serif; font-size: 10px;}\n';
text += '.t2		{font-family: arial, sans-serif; font-size: 11px;}\n';
text += '.t3		{font-family: arial, sans-serif; font-size: 12px;}\n';
text += '.dealList	{padding-bottom: 0px; padding-right: 0px; line-height: normal;}\n';
text += '</style>';

if (document.layers) {document.write(text);}

//	Windows IE stylesheet mods

var ieStyle = "";
ieStyle += '<style type="text/css">\n';
ieStyle += '.radioOutdent	{margin-left: -6px;}\n'
ieStyle += '.checkOutdent	{margin-left: -4px;}\n'
ieStyle += '</style>';

if (is_ie4up && is_win) {document.write(ieStyle);}


// NN 6+ stylesheet mods

var nnStyle = "";
nnStyle += '<style type="text/css">\n';
nnStyle += '.radioMargin	{margin-right: 6px;}\n'
nnStyle += '</style>';

if (is_nav6 && is_win) {document.write(nnStyle);}



function bonusDays (el,legs) {
	// unsure why this function is needed. i don't think it's ever called.
	if (el.checked) {
		dateDDs[0].selectedIndex = 0;
		dateDDs[1].selectedIndex = 0;
		if (legs == 2) {
			dateDDs[2].selectedIndex = 0;
			dateDDs[3].selectedIndex = 0;
		}
	}
}

function toggleCheckbox (el) {
	el.checked = !el.checked;
}

function changeStatus (txt) {
	if (!txt) txt="";
	window.status=txt;
	return true;
}

function stripYears(x) {
	for (var i = x.options.length - 1; i >= 0; i--)  {
		noYear = x.options[i].text.split(' ');
		x.options[i].text = noYear[0];
	}
}

function pageInit () {
	//will be redefined on any page that needs it.
}

function init () {
	setArrays();
	pageInit();
}

var isDynamicPackage=false;
var nothing="";//don't ask


//--------------------------------------------------------
// Use for long select boxes

var alphabet = new Array("A","B","C","D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X","Y","Z");

//Jumps down select box to first option text that starts with letter

function goToLetter(selectBox,letter) {
    var idx;
    for (var n = 0; n < selectBox.options.length; n ++) {
        var firstLetter = selectBox.options[n].text.charAt(0).toUpperCase();
        if (firstLetter == letter) {
            idx = n;
            var scroll = selectBox.options.length - 1;
           //This places selected option at top of select box
            selectBox.selectedIndex = scroll;
            selectBox.selectedIndex = idx;
            break;
        } else if (n == selectBox.options.length - 1) {
            if (letter == "A") {
                selectBox.selectedIndex = 0;
            } else if (letter == "Z") {
                selectBox.selectedIndex = selectBox.options.length - 1;
            } else {
                for (var t = 0; t < alphabet.length; t ++) { 
                    if (alphabet[t] == letter) {
                        var newLetter = alphabet[t + 1];
                    }
                }
                //IF no options begin with letter, display option that begins with next letter in alphabet
                goToLetter(selectBox,newLetter);
            }
        }
    }  
}

function toggleCkbox(id){ 
	if(document.getElementById){
			document.getElementById(id).checked=true;
			}
		}


//--------------------------------------------------------

//global catch for the exit app
var runUnLoadActivity=true;

// declaring exitapp functions as blank, they get redefined by exitApp.js, 
// but this way, if they are called by a page that doesn't call exitApp.js, 
// they won't cause errors. - this eliminates the need for switches in the
// body tag.
function unLoadActivity(){};
function onLoadActivity(){};
function noEA(){
	runUnLoadActivity=false;
}


