function changeto(highlightcolor) {
	source = event.srcElement

	if (source.tagName == "TR" || source.tagName == "TABLE")
		return

	while (source.tagName != "TABLE")
		source = source.parentElement

	if (source.style.backgroundColor != highlightcolor && source.id != "ignore")
		source.style.backgroundColor = highlightcolor
}

function changeback(originalcolor) {
	if (event.fromElement.contains(event.toElement) || source.contains(event.toElement) || source.id == "ignore")
		return

	if (event.toElement != source)
		source.style.backgroundColor = originalcolor
}

//check if this is an interisland package. "1" is for interisland defined in PackageTravelRequestPdt.
/*function isInterislandPkg() {
	return (document.TravelRequestForm.packageAttrStr.value=="1");
}
*/
// Return false if there are more infants than adults specified
// Return false if there are more children than adults specified
function checkInfantsVersusAdults() {
	var nAdults = new Number(document.TravelRequestForm.numberOfAdults.value);
	var nInfants = new Number(document.TravelRequestForm.numberOfInfants.value);

	if (nAdults < nInfants)	{
		alert("The number of infants must not be greater than the number of adults traveling");
		return false;
	}
	return true;
}

// Return false if the number of passengers is greater than 7
// Return false if the number of adults is less than 1
function checkNumOfPassengers() {
	var nAdults = new Number(document.TravelRequestForm.numberOfAdults.value);
	var nChildren = new Number(document.TravelRequestForm.numberOfChildren.value);

	if (nAdults + nChildren > 7)	{
		alert("The total number of passengers must not be greater than 7.");
		return false;
	}

	if (nAdults < 1)	{
		alert("There must be at least 1 adult traveler in the party.");
		return false;
	}
	return true;
}

function carExpand(switchC, switchE, headerC, headerE, expArray, colArray) {
	MM_showHideLayers(switchC, '', 'hide');
	MM_showHideLayers(switchE, '', 'show');
	expandHeader(true, headerE, headerC);
	expandCar(true, expArray, colArray);
} // function carExpand

function carCollapse(switchC, switchE, headerC, headerE, expArray, colArray) {
	MM_showHideLayers(switchC, '', 'show');
	MM_showHideLayers(switchE, '', 'hide');
	expandHeader(false, headerE, headerC);
	expandCar(false, expArray, colArray);
}

INPUT_DATE_FORMAT = "MM/DD/YYYY" ;
var DepartDate = "";
var ReturnDate = "";

function checkdate(objName) {
	var datefield = objName;
	if (chkdate(objName) == false) {
			datefield.select();
			alert('That date is invalid. Please try again.');
			datefield.focus();
			return false;
	} else {
			return true;
	}
}

//Remove all but numbers
function cleanNumber(strNum) {
	var temp = strNum.replace(/[^\d]/g, '');
	return temp;
}

function checkDecimal(num) {
	var index = num.indexOf(".") - 0;

	if (index != -1)	{
		var temp = num.substring(index + 1);
		if (temp.length > 2) {
			return false;
		}
	}
	return true;
}

//Hide or display child age selection.
//Excuted when numberOfChildren is changed
function changeNumberOfChildren() {
	var countChildren = document.TravelRequestForm.numberOfChildren.value;
	var age;
	var hasInfant = false;

	for (var i = 0; i < 6; i++)
		{
		if (i < countChildren)	{
			displayLayers('divchild' + i, '', 'show');
			age = getValueOfSelectObject("childAge" + i);
			if (age != "" && age == "0" && includesAir())	{
				displayLayers('divinfant' + i, '', 'show');
				hasInfant = true;
			} else	{
				displayLayers('divinfant' + i, '', 'hide');
			}
		} else	{
			displayLayers('divchild' + i, '', 'hide');
			displayLayers('divinfant' + i, '', 'hide');
		}
		}

	if (countChildren > 0 && hasInfant == true) {
		displayLayers('infantInLapMsg', '', 'show');
	} else	{
		displayLayers('infantInLapMsg', '', 'hide');
	}
}

//Hide or display infant seat selection.
//Excuted when childAge is changed
function changeChildAge() {
	//infant selection does not apply to non-air
	var countChildren = document.TravelRequestForm.numberOfChildren.value;
	var age;
	var displayInfantMsg = false;

	for (var i = 0; i < countChildren; i++)
		{
		age = getValueOfSelectObject("childAge" + i);

		if (age != "" && age == "0" && includesAir())	{
			displayLayers('divinfant' + i, '', 'show');
			displayInfantMsg = true;
		} else	{
			displayLayers('divinfant' + i, '', 'hide');
		}
		}

	if (displayInfantMsg == true) {
		displayLayers('infantInLapMsg', '', 'show');
	} else	{
		displayLayers('infantInLapMsg', '', 'hide');
	}
}

//clean phone fields
//remove any blank strings from fields before validation
function cleanBlankStrPhoneFields() {
	var phoneFields =
		new Array('phoneCountry', 'phoneAreaCode', 'phoneNumber', 'businessPhoneCountry', 'businessPhoneAreaCode',
			'businessPhoneNumber', 'faxCountry', 'faxAreaCode', 'faxNumber');
	var fieldObj;

	for (j in phoneFields)
		{
		fieldObj = eval('document.OrderForm.' + phoneFields[j]);
		cleanBlankStr(fieldObj);
		}
}

//
function cleanBlankStr(field) {
	if ((field != null) && (field != undefined)) {
		field.value = trim(field.value);
	}
}

/*
MultiCityPackage Departure page
*/
function clickNeedComponent(cbComponent, selectDateDivName, component) {
	if (cbComponent.checked) {
		displayLayers(selectDateDivName, '', 'show');
	} else	{
		displayLayers(selectDateDivName, '', 'hide');
	}

	if ("hotel" == component) {
		displayHotelLayers();
	} else if ("car" == component) {
		displayCarLayers();
	}
}

/*
Depending on which radio button, hide or show the correct layer
Valid values are pkg, flight and end
When users choose to end, display confirmation page before going to
CustomCarDates or CustomHotelDates
*/
function clickNextOption(rbValue, destinationNo, hasCustomDates) {
	if (rbValue == "pkg")	{
		displayLayers('destination' + (destinationNo + 1), '', 'show');
		hideDestinations(destinationNo + 2);
		displayLayers('returnFlight', '', 'hide');
		document.TravelRequestForm.multiCityPkgLastIdx.value = destinationNo + 1;
	}

	else if (rbValue == "flight")
		{
		hideDestinations(destinationNo + 1);
		displayLayers('returnFlight', '', 'show');
		document.TravelRequestForm.multiCityPkgLastIdx.value = destinationNo;
		}

	else if (rbValue == "end")
		{
		hideDestinations(destinationNo + 1);
		displayLayers('returnFlight', '', 'hide');
		document.TravelRequestForm.multiCityPkgLastIdx.value = destinationNo;

		if (isCheckBoxSelected("needHotel" + destinationNo) || isCheckBoxSelected("needCar" + destinationNo))	{
			var cmpMsg;
			var currentComponent;
			var dtMsg;

			if (isCheckBoxSelected("needHotel" + destinationNo))	{
				cmpMsg = "hotel";
				dtMsg = "check-out";
				currentComponent = "hotel";
				if (isCheckBoxSelected("needCar" + destinationNo)) {
					currentComponent = "hotelcar"; //it used to set both
				}
			} else	{
				cmpMsg = "car";
				dtMsg = "drop-off";
				currentComponent = "car";
			}
			if (!hasCustomDates)	{
				if (confirm("To end your trip in " + getValueOfSelectObject('to' + destinationNo)
					+ ", please provide your " + cmpMsg + " " + dtMsg + " date at this destination." + '\n'
					+ "Click OK to specify the " + dtMsg
					+ " date at this destination or Cancel to reset your next action for this destination."))	{

					document.TravelRequestForm.submitAction.value = "EndTripDates";
					document.TravelRequestForm.currentDestination.value = destinationNo;
					document.TravelRequestForm.currentComponent.value = currentComponent;
					if (validateAndSubmit() == false) {
						deselectAllNextOption(destinationNo);
					}
				} else	{
					deselectAllNextOption(destinationNo);
				}
			}
		}
		}
}

/*
Called when radio button or link is clicked
CustomEndDate, customStartTime and customEndTime are not always available
*/
function changeHasCustomDate(rbFormName, newValue, startDateValue, endDateValue) {
	document.TravelRequestForm.customStartDate.value = startDateValue;

	if (document.TravelRequestForm.customEndDate) {
		document.TravelRequestForm.customEndDate.value = endDateValue;
	}

	if (document.TravelRequestForm.customStartTime) {
		document.TravelRequestForm.customStartTime.value = "3:00 PM";
	}

	if (document.TravelRequestForm.customEndTime) {
		document.TravelRequestForm.customEndTime.value = "3:00 PM";
	}

	//make radiobutton selected
	for (var i = 0; i < document.TravelRequestForm.elements.length; i++)
		{
		if ((document.TravelRequestForm.elements[i].name == rbFormName)
			&& (document.TravelRequestForm.elements[i].type == "radio")
				&& (document.TravelRequestForm.elements[i].value == newValue)) {

			document.TravelRequestForm.elements[i].checked = true;
		}
		}
}


//**********************************************************
//**********************************************************


// CREATED BY CW - 08/04/2004
function daysElapsed(date1, date2) {
	// CALL FUNCTION BY: daysElapsed(FormValue, 330Days)
	// ---------------------------------------------
	var dateArray1 = date1.split('/');
	var dateArray2 = date2.split('/');
	// ---------------------------------------------
	date1 = new Date(dateArray1[2], parseInt(dateArray1[0], 10) - 1, dateArray1[1]);
	date2 = new Date(dateArray2[2], parseInt(dateArray2[0], 10) - 1, dateArray2[1]);
	// ---------------------------------------------
	var difference = Date.UTC(y2k(date1.getYear()), date1.getMonth(), date1.getDate(), 0, 0, 0)
		- Date.UTC(y2k(date2.getYear()), date2.getMonth(), date2.getDate(), 0, 0, 0);
	// ---------------------------------------------
	return difference / 1000 / 60 / 60 / 24;
}

// CREATED BY CW - 08/04/2004
function date_diff(val) {
	// GET THE DATE 330 DAYS FROM TODAY
	var date330 = "";
	// parse val for month, day, year
	var dateArray = val.split('/');
	// ---------------------------------------------
	strDate = new Date(dateArray[2], parseInt(dateArray[0], 10) - 1, dateArray[1]);
	// ---------------------------------------------
	// figure out day, month, year 330 days from today
	date330 = new Date(strDate.getTime() + (330 * 86400000));

	// ---------------------------------------------
	if (navigator.appName == 'Microsoft Internet Explorer')	{
		var tmpYear = parseInt(date330.getYear(), 10);
	}

	else if (navigator.appName == 'Netscape')
		{
		var tmpYear = parseInt(date330.getYear() + 1900, 10);
		}

	else
		{
		var tmpYear = parseInt(date330.getYear() + 1900, 10);
		}
	// ---------------------------------------------
	// return value
	return(parseInt(date330.getMonth() + 1, 10)) + '/'
		+ date330.getDate() + '/'
		+ tmpYear
//			+ (parseInt(date330.getYear()+1900, 10));
}

/*
	Checks to see if the Kama'aina button has been pressed,if not - forward back to
	departure page.
*/
function discountChecker() {
	//if (includesHotel() && // revised 051404
	if (document.TravelRequestForm.localDiscount[0].checked == "0"
		&& document.TravelRequestForm.localDiscount[1].checked == "0")	{
		alert("Please make sure that you specify if you are a Hawaii resident.");
		return false;
	}
	return true;
}

//Erland Added + Nikolas Updated + Nikolas Fixed.

function dateChecker() {
	//if it is multiIsland, dont allow for 1 day.
	if (document.TravelRequestForm.typeOfPackage.value == "fullPackage"
		|| document.TravelRequestForm.typeOfPackage.value == "AIR-CAR-HOTEL")	{
		if (isInterislandPkg() && document.TravelRequestForm.typeOfTour[0].checked == "0"
			&& document.TravelRequestForm.typeOfTour[1].checked == "1")	{
			dtStart = new Date(document.TravelRequestForm.itineraryStartDate.value);
			dtEnd = new Date(document.TravelRequestForm.itineraryEndDate.value);
			endDay = new Date((dtEnd.getMonth() + 1) + "/" + dtEnd.getDate() + "/" + dtEnd.getFullYear());
			startDay = new Date((dtStart.getMonth() + 1) + "/" + (dtStart.getDate() + 2) + "/" + dtStart.getFullYear());
			if (endDay < startDay)	{
				alert(
					"Please make sure that the number of days you specify for this Multi-Island trip exceeds 1 day of travel.");
				return false;
			} else	{
				return true;
			}
		}
	}
	return true;
}

/*
	Compare the value stored in fieldDepartDate with that stored in fieldReturndate and,
	if the former is greater than the latter, set the value stored in fieldReturnDate
	to be the same as that for fieldDepartDate plus 1 day. NY - 06/25/2002.
*/
INTERISLAND_STAY_DAYS = 1;
INBOUND_STAY_DAYS = 7;
OUTBOUND_STAY_DAYS = 7;
INTERISLAND_PACKAGE_ATTR = 1;
INBOUND_PACKAGE_ATTR = 2;
OUTBOUND_PACKAGE_ATTR = 3;

function DepartChecker(fieldDepartDate, fieldReturnDate) {
	var leeDay;

	// alert("test");
	dtDepart = new Date(fieldDepartDate.value);
	dtReturn = new Date(fieldReturnDate.value);

	day = dtDepart.getDate();
	month = dtDepart.getMonth();
	year = dtDepart.getFullYear();

	leeDay = INBOUND_STAY_DAYS;

	/*	// COMMENTED OUT BY JOE
		if(document.forms[0].packageAttrStr.value==INBOUND_PACKAGE_ATTR) {
			leeDay = INBOUND_STAY_DAYS;
		} else if(document.forms[0].packageAttrStr.value==OUTBOUND_PACKAGE_ATTR) {
			leeDay = OUTBOUND_STAY_DAYS;
		} else {
			leeDay = INTERISLAND_STAY_DAYS;
		}
	*/
	//alert("leeday=" + leeDay + " packageAttrStr=" + document.forms[0].packageAttrStr.value);
	for (var i = 1; i <= leeDay; i++)
		{
		day++;
		}

	oldDepart = new Date(fieldDepartDate.value);
	oldDepart.setDate(day);
	newDepart = (oldDepart.getMonth() + 1) + "/" + oldDepart.getDate() + "/" + oldDepart.getFullYear();

	if (dtDepart > dtReturn) {
		fieldReturnDate.value = newDepart;
	}
}

INTERISLAND_STAY_DAYS = 1;
INBOUND_STAY_DAYS = 7;
OUTBOUND_STAY_DAYS = 7;
MAINLAND_STAY_DAYS = 7;
INTERNATIONAL_STAY_DAYS = 7;
INTERNATIONAL_DESTINATION = "domestic";

//setup display hotels
function displayHotels(destinationIdx, resKey) {
	document.TravelRequestForm.submitAction.value = "dsplHtls";
	document.TravelRequestForm.action = replaceActionName(document.TravelRequestForm.action, "DisplayHotels.do");
	document.TravelRequestForm.dtIdx.value = destinationIdx;
	document.TravelRequestForm.dtRes.value = resKey;
	document.TravelRequestForm.submit();
}

//setup display cars
function displayCars(destinationIdx, resKey) {
	document.TravelRequestForm.action = replaceActionName(document.TravelRequestForm.action, "DisplayCars.do");
	document.TravelRequestForm.submitAction.value = "dsplCars";
	document.TravelRequestForm.dtIdx.value = destinationIdx;
	document.TravelRequestForm.dtRes.value = resKey;
	document.TravelRequestForm.submit();
}

//setup display flights
function displayFlights() {
	document.TravelRequestForm.action = replaceActionName(document.TravelRequestForm.action, "DisplayFlights.do");
	document.TravelRequestForm.submitAction.value = "dsplFlts";
	document.TravelRequestForm.submit();
}

//display voucher on Confirmation.jsp
function displayVoucher(voucherCode, localeCode) {
	if (window.checkG2HPageTimeOut && checkG2HPageTimeOut()) {
		return;
	} else if (window.startG2HPageTimeOut) {
		startG2HPageTimeOut();
	}
	var w = 600;
	var h = 550;

	if (screen.width)	{
		var winl = (screen.width - w) / 2;
		var wint = (screen.height - h) / 2;
	} else	{
		winl = 0;
		wint = 0;
	}

	if (winl < 0)
		winl = 0;

	if (wint < 0)
		wint = 0;
	var settings = 'height=' + h + ',';
	settings += 'width=' + w + ',';
	settings += 'top=' + wint + ',';
	settings += 'left=' + winl + ',';
	settings += 'scrollbars=yes,';
	settings += 'resizable=yes';
	var strOpen = "ActivityVoucher.jsp?voucherCode=" + voucherCode;

	if (localeCode != "") {
		strOpen += "&lang=" + localeCode;
	}
	hotelWindow = window.open(strOpen, "replace", settings);
}

function displayLayers() {

	var i, p, v, obj, args = displayLayers.arguments;

	for (i = 0; i < (args.length - 2); i += 3)
		if ((obj = MM_findObj(args[i])) != null)	{
			v = args[i + 2];

			if (obj.style)	{
				obj = obj.style;
				v = (v == 'show') ? 'block' : (v = 'hide') ? 'none' : v;
			}

			obj.display = v;
		}
}


/*
Hotel layers are displayed if any destination need hotel
*/
function displayHotelLayers() {
	displayLayers("hotelRatingLayer", "", "hide");
	displayLayers("hotelRatingLayer1", "", "hide");
	displayLayers("numberOfRoomLayer", "", "hide");
	var lastDestination = document.TravelRequestForm.multiCityPkgLastIdx.value;
	var hasHotel = false;

	for (var i = 0; i < lastDestination + 1; i++)
		{
		if (isCheckBoxSelected("needHotel" + i))	{
			displayLayers("hotelRatingLayer", "", "show");
			displayLayers("hotelRatingLayer1", "", "show");
			displayLayers("numberOfRoomLayer", "", "show");
			hasHotel = true;
			return;
		}
		}

	if (!hasHotel && document.TravelRequestForm.numberOfRooms) {
		document.TravelRequestForm.numberOfRooms.value = '1';
	}
}

/*
Car layers are displayed if any destination need car
*/
function displayCarLayers() {
	displayLayers("carCompanyLayer", "", "hide");
	displayLayers("carTypeLayer", "", "hide");
	var lastDestination = document.TravelRequestForm.multiCityPkgLastIdx.value;

	for (var i = 0; i < lastDestination + 1; i++)
		{
		if (isCheckBoxSelected("needCar" + i))	{
			displayLayers("carCompanyLayer", "", "show");
			displayLayers("carTypeLayer", "", "show");
			return;
		}
		}
}

/*
Deselect nextOption radio button. It is called when users click on Cancel
*/
function deselectAllNextOption(destinationNo) {
	for (var i = 0; i < document.TravelRequestForm.elements.length; i++)
		{
		if ((document.TravelRequestForm.elements[i].name == ('nextOption' + destinationNo))
			&& (document.TravelRequestForm.elements[i].type == "radio")) {
			document.TravelRequestForm.elements[i].checked = false;
		}
		}
}


//**********************************************************
//**********************************************************

function expandCar(show, showArray, hideArray) {
	var i;
	var j;

	if (show)	{
		for (i = 0; i < showArray.length; i++)
			{
			for (j = 0; j < showArray[i].length; j++)
				{
				var o = getObj(showArray[i][j]);

				if (o != null)
					o.style.display = "block";
				}
			}
		for (i = 0; i < hideArray.length; i++)
			{
			for (j = 0; j < hideArray[i].length; j++)
				{
				var o = getObj(hideArray[i][j]);

				if (o != null)
					o.style.display = "none";
				}
			}
	} else	{
		for (i = 0; i < showArray.length; i++)
			{
			for (j = 0; j < showArray[i].length; j++)
				{
				var o = getObj(showArray[i][j]);

				if (o != null)
					o.style.display = "none";
				}
			}
		for (i = 0; i < hideArray.length; i++)
			{
			for (j = 0; j < hideArray[i].length; j++)
				{
				var o = getObj(hideArray[i][j]);

				if (o != null)
					o.style.display = "block";
				}
			}
	}
} // function expandCar

function expandHeader(show, showH, hideH) {
	if (show)	{
		var o = getObj(showH);

		if (o != null)
			o.style.display = "block";
		var h = getObj(hideH);
		if (h != null)
			h.style.display = "none";
	} else	{
		var o = getObj(showH);

		if (o != null)
			o.style.display = "none";
		var h = getObj(hideH);
		if (h != null)
			h.style.display = "block";
	}
} // function expandHeader

function getObj(objID) {
	if (document.getElementById) {
		return document.getElementById(objID);
	} else if (document.all) {
		//old msie versions work
		return document.all[objID];
	} else if (document.layers) {
		//nn4 woks
		return document.layers[objID];
	}
}

function getValueOfSelectObject(objectName) {
	for (var i = 0; i < document.TravelRequestForm.elements.length; i++)
		{
		if ((document.TravelRequestForm.elements[i].name == objectName)
			&& (document.TravelRequestForm.elements[i].type == "select-one")) {

			return document.TravelRequestForm.elements[i].value;
		}
		}
	//not found
	return "";
}

function getValueOfRadioObject(objectName) {
	for (var i = 0; i < document.TravelRequestForm.elements.length; i++)
		{
		if ((document.TravelRequestForm.elements[i].name == objectName)
			&& (document.TravelRequestForm.elements[i].type == "radio")
				&& (document.TravelRequestForm.elements[i].checked)) {
			return document.TravelRequestForm.elements[i].value;
		}
		}
	//not found
	return "";
}

function getValueOfTextObject(objectName)
	{
	return getValueOfTextObjectFromForm(document.TravelRequestForm, objectName);
	}

function getValueOfTextObjectFromForm(thisForm, objectName) {
	for (var i = 0; i < thisForm.elements.length; i++)
		{
		if ((thisForm.elements[i].name == objectName) && (thisForm.elements[i].type == "text")) {
			return thisForm.elements[i].value;
		}
		}
	//not found
	return "";
}

/*
	* This function only applied to hawaiian island. Since there is no map in javascipt, use
	* comparing island one by one though it is inefficient.
	* <option value="HNL">Honolulu, Oahu (HNL)</option>
	* <option value="LIH">Lihue, Kauai (LIH)</option>
	* <option value="OGG">Kahului, Maui (OGG)</option>
	* <option value="KOA">Kona, Hawaii (KOA)</option>
	* <option value="ITO">Hilo, Hawaii (ITO)</option>
	* <option value="LNY">Lanai City, Lanai (LNY)</option>
	* <option value="MKK">Hoolehua, Molokai (MKK)</option>
*/
function getHawaiianIslandByAirportCode(code) {
	switch (code) {
		case "HNL":
			return "Oahu";
			break;

		case "LIH":
			return "Kauai";
			break;

		case "OGG":
			return "Maui";
			break;

		case "KOA":
			return "Hawaii/Big Island";
			break;

		case "ITO":
			return "Hawaii/Big Island";
			break;

		case "LNY":
			return "Lanai";
			break;

		case "MKK":
			return "Molokai";
			break;

		default:
			alert("Airport code " + code + " is not Supported");
			return("Not Supported");
			break;
		}
/* COMMENTED BY CW - 08/03/2004
	if (code == "HNL") {
		return "Oahu";
	}else if (code == "LIH") {
		return "Kauai";
	}else if (code == "OGG") {
		return "Maui";
	}else if (code == "KOA") {
		return "Hawaii/Big Island";
	}else if (code == "ITO") {
		return "Hawaii/Big Island";
	}else if (code == "LNY") {
		return "Lanai";
	}else if (code == "MKK") {
		return "Molokai";
	}else {
		alert ( "Airport code " + code + " is not Supported");
		return ("Not Supported");
	}
*/
}


/*
Hide destinations starting from startDestination
*/
function hideDestinations(startDestination) {
	for (i = startDestination; i < 3; i++)
		{
		displayLayers('destination' + i, '', 'hide');
		}
}


//Return true if a hotel is included, false otherwise
function includesHotel() {
	if (document.TravelRequestForm.typeOfPackage[0].checked == "1"
		|| document.TravelRequestForm.typeOfPackage[2].checked == "1") {
		return true;
	}
	return false;
}


// Start Datefield validation code
var DepartDate = "";
var ReturnDate = "";

function InitSaveVariables(fieldDepartDate, fieldReturnDate) {
	DepartDate = fieldDepartDate.value;
	ReturnDate = fieldReturnDate.value;
}


//Return true if air is included, false otherwise
function includesAir() {
	var value = "";

	for (var i = 0; i < document.TravelRequestForm.typeOfPackage.length; i++)
		{
		if (document.TravelRequestForm.typeOfPackage[i].checked == "1") {
			value = document.TravelRequestForm.typeOfPackage[i].value;
		}
		}

	if (value == "HOTEL-ONLY" || value == "CAR-HOTEL" || value == "CAR-ONLY" || value == "") {
		return false;
	}
	return true;
}

//Return true if a hotel is included, false otherwise
function includesHotel() {
	var value = "";

	for (var i = 0; i < document.TravelRequestForm.typeOfPackage.length; i++)
		{
		if (document.TravelRequestForm.typeOfPackage[i].checked == "1") {
			value = document.TravelRequestForm.typeOfPackage[i].value;
		}
		}

	if (value == "AIR-ONLY" || value == "AIR-CAR" || value == "CAR-ONLY" || value == "") {
		return false;
	}
	return true;
}


//Determine if package includes car
function includesCar() {
	var value = "";

	for (var i = 0; i < document.TravelRequestForm.typeOfPackage.length; i++)
		{
		if (document.TravelRequestForm.typeOfPackage[i].checked == "1") {
			value = document.TravelRequestForm.typeOfPackage[i].value;
		}
		}

	if (value == "AIR-ONLY" || value == "AIR-HOTEL" || value == "HOTEL-ONLY" || value == "") {
		return false;
	}
	return true;
}


//Initialize hotel/car links for multicity package
function initMultiCityPackageDepartureCommon(lastDestinationIdx) {
	for (var i = 0; i <= lastDestinationIdx; i++)
		{
		displayLayers('destination' + i, '', 'show');

		if (isCheckBoxSelected("needHotel" + i)) {
			displayLayers('hotelDatesLinkShow' + i, '', 'show');
		} else	{
			displayLayers('hotelDatesLinkShow' + i, '', 'hide');
		}

		if (isCheckBoxSelected("needCar" + i)) {
			displayLayers('carDatesLinkShow' + i, '', 'show');
		} else	{
			displayLayers('carDatesLinkShow' + i, '', 'hide');
		}
		}
	hideDestinations(lastDestinationIdx + 1);

	if ("flight" == getValueOfRadioObject("nextOption" + lastDestinationIdx)) {
		displayLayers('returnFlight', '', 'show');
	}
	displayHotelLayers();
	displayCarLayers();
}

function isInteger(s) {
	var i;

	for (i = 0; i < s.length; i++)
		{
		// Check that current character is number.
		var c = s.charAt(i);

		if (((c < "0") || (c > "9")))
			return false;
		}

	// All characters are numbers.
	return true;
}
//Determine if package is air only
function isAirOnlyPackage() {
		var value = "";

		for (var i = 0; i < document.TravelRequestForm.typeOfPackage.length; i++)
			{
			if (document.TravelRequestForm.typeOfPackage[i].checked == "1") {
				value = document.TravelRequestForm.typeOfPackage[i].value;
			}
			}

		if (value == "AIR-ONLY") {
			return true;
		}
		return false;
	}

function isNumber(strString) {
		var strValidChars = "0123456789";
		var strChar;

		if (strString.length == 0)
			return true;

		for (i = 0; i < strString.length; i++)
			{
			strChar = strString.charAt(i);

			if (strValidChars.indexOf(strChar) == -1) {
				return false;
			}
			}
		return true;
	}

/*
To find out if a check box is selected
*/
function isCheckBoxSelected(objectName) {
		for (var i = 0; i < document.TravelRequestForm.elements.length; i++)
			{
			if ((document.TravelRequestForm.elements[i].name == objectName)
				&& (document.TravelRequestForm.elements[i].type == "checkbox")) {

				return document.TravelRequestForm.elements[i].checked;
			}
			}
		//not found
		return false;
	}

function isValidPhoneNumber(strString) {
		var strValidChars = " 0123456789-";
		var strChar;

		if (strString.length == 0)
			return false;

		for (i = 0; i < strString.length; i++)
			{
			strChar = strString.charAt(i);

			if (strValidChars.indexOf(strChar) == -1) {
				return false;
			}
			}
		return true;
	}

//valid area code -- 3 digits
function isValidAreaCode(strString) {
		//strString = cleanNumber(strString); //clean number first
		var strValidChars = "0123456789";
		var strChar;

		if (strString.length != 3)
			return false;

		for (i = 0; i < strString.length; i++)
			{
			strChar = strString.charAt(i);

			if (strValidChars.indexOf(strChar) == -1) {
				return false;
			}
			}
		return true;
	}

//valid phone segment -- digits only, clean
//international
function isValidAreaPhoneSegIntl(strString) {
		//strString = cleanNumber(strString); //clean number first
		var strValidChars = "0123456789";
		var strChar;

		for (i = 0; i < strString.length; i++)
			{
			strChar = strString.charAt(i);

			if (strValidChars.indexOf(strChar) == -1) {
				return false;
			}
			}
		return true;
	}

//valid phone number -- digits only, length > 4
//international
function isValidPhoneNumberIntl(strString) {
		var strValidChars = "0123456789-";
		var strChar;

		for (i = 0; i < strString.length; i++)
			{
			strChar = strString.charAt(i);

			if (strValidChars.indexOf(strChar) == -1) {
				return false;
			}
			}
		//clean number and count
		strString = cleanNumber(strString);

		if (strString.length < 5)
			return false;

		return true;
	}


//valid phone number -- 7 digits
function isValidPhoneNumber2(strString) {
		strString = cleanNumber(strString); //clean number first
		var strValidChars = "0123456789";
		var strChar;

		if (strString.length != 7)
			return false;

		for (i = 0; i < strString.length; i++)
			{
			strChar = strString.charAt(i);

			if (strValidChars.indexOf(strChar) == -1) {
				return false;
			}
			}
		return true;
	}


//Determine if travel type is one way
function isOneWay() {
		var value = 2;

		if (document.TravelRequestForm.travelType)	{
			for (var i = 0; i < document.TravelRequestForm.travelType.length; i++)
				{
				if (document.TravelRequestForm.travelType[i].checked == "1") {
					value = document.TravelRequestForm.travelType[i].value;
				}
				}
		}

		if (value == 1) {
			return true;
		}
		return false;
	}

//Determine if search is multi city
function isMultiCity() {
		var value;

		//some departure page, e.g., non air have no travelType
		if (document.TravelRequestForm.travelType)	{
			for (var i = 0; i < document.TravelRequestForm.travelType.length; i++)
				{
				if (document.TravelRequestForm.travelType[i].checked == "1") {
					value = document.TravelRequestForm.travelType[i].value;
				}
				}
			if (value == 3) {
				return true;
			} else	{
				return false;
			}
		} else	{
			return false;
		}
	}

//Return true is package is car only, false otherwise
function isCarOnlyPackage() {
		var value = "";

		for (var i = 0; i < document.TravelRequestForm.typeOfPackage.length; i++)
			{
			if (document.TravelRequestForm.typeOfPackage[i].checked == "1") {
				value = document.TravelRequestForm.typeOfPackage[i].value;
			}
			}

		if (value == "CAR-ONLY") {
			return true;
		}
		return false;
	}

//Determine is str is numeric
function isNumeric(strString) {
		var strValidChars = "0123456789.-";
		var strChar;

		if (strString.length == 0)
			return false;

		for (i = 0; i < strString.length; i++)
			{
			strChar = strString.charAt(i);

			if (strValidChars.indexOf(strChar) == -1) {
				return false;
			}
			}
		return true;
	}

function loadScript() {
	// *********************************************
	// ADDED BY CW - 06/28/2004; UPDATED BY CW - 08/17/2004
	var now = new Date();
	var startDate = new Date();
	newDate = new Date(now.getTime() + (3 * 24 * 60 * 60 * 1000));

	// ---------------------------------------------
	if ((newDate.getMonth() + 1) < 10) {
		startMonth = "0" + (newDate.getMonth() + 1);
	} else	{
		startMonth = (newDate.getMonth() + 1);
	}
	// ---------------------------------------------
	startDate = startMonth + "/" + newDate.getDate() + "/" + newDate.getFullYear();
	document.TravelRequestForm.itineraryStartDate.value = startDate;
	//alert("startDate = " + startDate);
	// ---------------------------------------------
	newDate = new Date(now.getTime() + (10 * 24 * 60 * 60 * 1000));

	// ---------------------------------------------
	if ((newDate.getMonth() + 1) < 10) {
		startMonth = "0" + (newDate.getMonth() + 1);
	} else	{
		startMonth = (newDate.getMonth() + 1);
	}
	// ---------------------------------------------
	endDate = startMonth + "/" + newDate.getDate() + "/" + newDate.getFullYear();
	//		endDate = (newDate.getMonth()+1) + "/" +  newDate.getDate() + "/" + newDate.getFullYear();
	document.TravelRequestForm.itineraryEndDate.value = endDate;
//alert("endDate = " + endDate);
// *********************************************
}
