
		// ---------------------------------------------
		// NEW DATE STRUCTURE
		// Declaring valid date character, minimum year and maximum year
			var cur = new Date();
			var dtCh= "/";
			var minYear= cur.getFullYear();
			var maxYear=(cur.getFullYear()+1);
			
		//	var dtCh= "/";
		//	var minYear=2005;
		//	var maxYear=2006;

	// -----------------------------------------
		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;
	}
	// -----------------------------------------
		function stripCharsInBag(s, bag) {
			var i;
			var returnString = "";
    // Search through string's characters one by one.
    // If character is not in bag, append to returnString.
    	for (i = 0; i < s.length; i++) {   
        	var c = s.charAt(i);
        if (bag.indexOf(c) == -1) returnString += c;
    }
    return returnString;
	}
	// -----------------------------------------
		function daysInFebruary (year) {
		// February has 29 days in any year evenly divisible by four,
    	// EXCEPT for centurial years which are not also divisible by 400.
    	return (((year % 4 == 0) && ( (!(year % 100 == 0)) || (year % 400 == 0))) ? 29 : 28 );
	}
	// -----------------------------------------
		function DaysArray(n) {
			for (var i = 1; i <= n; i++) {
		this[i] = 31
		if (i==4 || i==6 || i==9 || i==11) {this[i] = 30}
		if (i==2) {this[i] = 29}
   } 
   return this
}
	// -----------------------------------------
		function isDate(dtStr) {
		var daysInMonth = DaysArray(12)
		var pos1=dtStr.indexOf(dtCh)
		var pos2=dtStr.indexOf(dtCh,pos1+1)
	// -----------------------------------------
	// SWITCH VAR TO OUTPUT 'dd/mm/yyyy' 
	//var strDay=dtStr.substring(0,pos1)
	//var strMonth=dtStr.substring(pos1+1,pos2)
	// -----------------------------------------	
		var strMonth=dtStr.substring(0,pos1)
		var strDay=dtStr.substring(pos1+1,pos2)
		var strYear=dtStr.substring(pos2+1)
		
		strYr=strYear
		
		if (strDay.charAt(0)=="0" && strDay.length>1) strDay=strDay.substring(1)
		if (strMonth.charAt(0)=="0" && strMonth.length>1) strMonth=strMonth.substring(1)
		
		for (var i = 1; i <= 3; i++) {
		if (strYr.charAt(0)=="0" && strYr.length>1) strYr=strYr.substring(1)
		}
		
		month=parseInt(strMonth)
		day=parseInt(strDay)
		year=parseInt(strYr)
	
	if (pos1==-1 || pos2==-1) {
		// alert("The date format should be : mm/dd/yyyy")
		return false
	}
	if (strMonth.length<1 || month<1 || month>12){
		alert("Please enter a valid month")
		return false
	}
	if (strDay.length<1 || day<1 || day>31 || (month==2 && day>daysInFebruary(year)) || day > daysInMonth[month]) {
		alert("Please enter a valid day")
		return false
	}
	if (strYear.length != 4 || year==0 || year<minYear || year>maxYear){
	//	alert("Please enter a valid 4 digit year from "+minYear+" or "+maxYear)
		return false
	}
	if (dtStr.indexOf(dtCh,pos2+1)!=-1 || isInteger(stripCharsInBag(dtStr, dtCh))==false) {
	//	alert("Please enter a valid date")
		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);
		// *********************************************
	}

	// -----------------------------------------
	// Start Datefield validation code
	var DepartDate = "";
	var ReturnDate = "";
	// -----------------------------------------
	function InitSaveVariables(fieldDepartDate,fieldReturnDate) {
	DepartDate = fieldDepartDate.value;
	ReturnDate = fieldReturnDate.value;
}

/*
	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 = 7;
	//INTERISLAND_STAY_DAYS = 1;
	INBOUND_STAY_DAYS = 4;
	//INBOUND_STAY_DAYS = 7;

	// -----------------------------------------
	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=INTERISLAND_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;
	}
}
	// -----------------------------------------
	/* See the above routine */
	function ReturnChecker(fieldDepartDate,fieldReturnDate) {
		dtDepart=new Date(fieldDepartDate.value);
		dtReturn=new Date(fieldReturnDate.value);
/*
	// This code allows for the validation scheme to automatically
	// place the Departure Date one day before the Return Date.
	// It has been commented out for now. NY - 06/25/2002.

	day = dtReturn.getDate();
	month = dtReturn.getMonth();
	year = dtReturn.getYear();
	dtReturn.setDate(day - 1);
	newReturn = (dtReturn.getMonth() + 1) + "/" + dtReturn.getDate() + "/" + dtReturn.getYear();

	if (dtReturn < dtDepart) {
		fieldDepartDate.value = newReturn;
	}
*/

	if (dtReturn < dtDepart) {
		fieldDepartDate.value = fieldReturnDate.value;
	}
}
	// -----------------------------------------
	// CREATED BY CW - 08/04/2004
	function submitForm(object) {
		var strConfirm='';
		var now = new Date();
		// ---------------------------------------------
		// *** CREATE TODAY'S DATE BASED ON BROWSER TYPE ***
		if (navigator.appName == 'Microsoft Internet Explorer') {
			var today = parseInt(now.getMonth()+1, 10) + '/' + now.getDate() + '/' + parseInt(now.getYear(), 10);
		} else if (navigator.appName == 'Netscape') {
			var today = parseInt(now.getMonth()+1, 10) + '/' + now.getDate() + '/' + parseInt(now.getYear()+1900, 10);
		} else {
			var today = parseInt(now.getMonth()+1, 10) + '/' + now.getDate() + '/' + parseInt(now.getYear()+1900, 10);
		}
		// ---------------------------------------------
		// *** CHECK THAT DEP & ARR CITIES HAVE VALUES ENTERED ***
		if (!document.TravelRequestForm.from.value) {
			strConfirm += 'Please enter your departure location' + '\n';
		}
		if (!document.TravelRequestForm.to.value) {
			strConfirm += 'Please select your destination location' + '\n';
		}

		// ---------------------------------------------
		// *** CHECK THAT DEP & ARR CITIES ARE DIFFERENT ***
		if (document.TravelRequestForm.from.value && document.TravelRequestForm.to.value) {
		
			var Current = document.TravelRequestForm.to.selectedIndex;

			if (document.TravelRequestForm.from.value==document.TravelRequestForm.to.value || document.TravelRequestForm.from.value==document.TravelRequestForm.to.options[Current].text
			) {
				strConfirm += 'Departing and Arrival cities must be different' + '\n';
			}
		}
		// ---------------------------------------------
		// *** VALID DEP & ARR DATES? ***
		// *** COMMENTED BY JOE USES THE 'isDate' Function
		/*if (!checkdate(document.TravelRequestForm.itineraryStartDate)) {
			strConfirm += 'Departure Date is not filled in correctly' + '\n';
		}

		if (!checkdate(document.TravelRequestForm.itineraryEndDate)) {
			strConfirm += 'Return Date is not filled in correctly' + '\n';
		}*/
		// THE 'isDate' Function
		// ---------------------------------------------
		
		
		/* 09-0306 ATR: CHANGE SHORT YEAR TO LONG YEAR (09 TO 2009) */
		var depdate=document.TravelRequestForm.itineraryStartDate.value
		var retdate=document.TravelRequestForm.itineraryEndDate.value

		var pos=depdate.indexOf(dtCh,depdate.indexOf(dtCh)+1)
		var strYear=depdate.substring(pos+1)		
		if (strYear.length==2) { depdate=depdate.substring(0,pos)+'/20'+strYear }

		var pos=retdate.indexOf(dtCh,retdate.indexOf(dtCh)+1)
		var strYear=retdate.substring(pos+1)		
		if (strYear.length==2) { retdate=retdate.substring(0,pos)+'/20'+strYear }
		/* 09-0306 ATR: CHANGE SHORT YEAR TO LONG YEAR (09 TO 2009) */


// --------------------------------------------
		if (!isDate(depdate)) {
			strConfirm += 'Departure Date is not filled in correctly' + '\n';
			} 
		// ---------------------------------------------
		if (!isDate(retdate)) {	
			strConfirm += 'Return Date is not filled in correctly' + '\n';
		}
		
		// ---------------------------------------------
		// *** ARE DEP & ARR DATES GREATER THAN TODAY? ***

		if (daysElapsed(depdate, today)<=0) {
			strConfirm += 'Departure Date should be greater than today' + '\n';
		}

		if (daysElapsed(retdate, today)<=0) {
			strConfirm += 'Return Date should be greater than today' + '\n';
			
		}
		// ---------------------------------------------
		// *** IS DEP DATE EARLIER THAN ARR DATE? ***
		// COMMENTED BY JOE - 11/02/2005
		
		if (daysElapsed(retdate, depdate)<=0) {
			strConfirm += 'Return Date should be greater than the Departure Date' + '\n';
			// COMMENTED BY CW - 09/14/2004
//			strConfirm += 'Departure Date should be greater than today' + '\n';
		}
		
		// ---------------------------------------------
		// *** IF DEP DATE AND ARR DATE SAME? CHECK TIME ***			
		/*if (daysElapsed(document.TravelRequestForm.itineraryStartDate.value, today) == daysElapsed(document.TravelRequestForm.itineraryEndDate.value, today)
			&& (document.TravelRequestForm.departureTime.value==document.TravelRequestForm.returnTime.value)) {			
			strConfirm += 'Return time must be after departure time' + '\n';
		}
		*/
		// ---------------------------------------------
		// *** ARE DEP & ARR DATES WITHIN 330 DAYS OF TODAY? ***
		if (daysElapsed(date_diff(today), depdate)<0) {
			strConfirm += 'Please set the Departure Date within 330 days from today' + '\n';
		}

		if (daysElapsed(date_diff(today), retdate)<0) {
			strConfirm += 'Please set the Return Date within 330 days from today' + '\n';
		}
		// ---------------------------------------------
		// *** FINAL CHECK ***
		if (strConfirm.length > 0) {
			alert(strConfirm);
		} else {
		
		if (checkNumOfPassengers()) {
			/* 09-0307 ATR: CHANGE DATE IN FORM BEFORE SUBMITTING INTO GET2 */
			document.TravelRequestForm.itineraryStartDate.value=depdate
			document.TravelRequestForm.itineraryEndDate.value=retdate
			/* -------------------------------------------------------------*/	
			document.TravelRequestForm.action='http://pts.get2hawaii.com/ots/Index.do';
			document.TravelRequestForm.submit();
		}
	}
}

	// -----------------------------------------
	function trim(str) {
		str.replace(/^\s*/, '').replace(/\s*$/, '');
		return str;
	}
		
	// -------------------------------
	// HAWAII RESIDENT WARNING
	// -------------------------------
	function MM_findObj(n, d) { 
		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() { 
		var i,p,v,obj,args=MM_showHideLayers.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')?'visible':(v=='hide')?'hidden':v; }
		obj.visibility=v; }
	}
	// -------------------------------
	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;
	}
}
	// -------------------------------
	function MM_displayLayers() { //v3.0
		var i,p,v,obj,args=MM_displayLayers.arguments;
		for (i=0; i<(args.length-2); i+=3)
	if ((obj=MM_findObj(args[i]))!=null) {
		d=args[i+2];
    if (obj.style) {
		obj=obj.style;
	}
   obj.display=d;
	}
}
	// -------------------------------
	function show(object) {
		if (document.getElementById && document.getElementById(object) != null)
			node = document.getElementById(object).style.visibility='visible';
		else if (document.layers && document.layers[object] != null)
			document.layers[object].visibility = 'visible';
		else if (document.all)
			document.all[object].style.visibility = 'visible';
	}
	// -------------------------------
	function hide(object) {
		if (document.getElementById && document.getElementById(object) != null)
			node = document.getElementById(object).style.visibility='hidden';
		else if (document.layers && document.layers[object] != null)
			document.layers[object].visibility = 'hidden';
		else if (document.all)
			document.all[object].style.visibility = 'hidden';
	}

	// -------------------------------
    //Hide or display child age selection.
    //Excuted when numberOfChildren is changed
	function changeNumberOfChildren() {
		var countChildren = document.TravelRequestForm.numberOfChildren.value;
		var age;
		for (var i=0; i< 6; i++) {
	if (i < countChildren) {
	
		displayLayers('divchild' + i,'','show');
		age = getValueOfSelectObject("childAge" + i);
		
	if (age != "" && age == "0")
	
		displayLayers('divinfant' + i,'','show');
		
	} else {

		displayLayers('divchild' + i,'','hide');
		displayLayers('divinfant' + i,'','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;
	for (var i=0; i< countChildren; i++) {
	
		age = getValueOfSelectObject("childAge" + i);
		
	if (age != "" && age == "0")
	
		displayLayers('divinfant' + i,'','show');
		
	else
	
		displayLayers('divinfant' + i,'','hide');
	}
}
	// -------------------------------
	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 "";
	}
	// -------------------------------
	// Return false if the number of passengers is greater than 7
	// Check Number of Passenger 
	function checkNumOfPassengers() {
	    //no travellers for car only
  //  	if(isCarOnlyPackage())
 //           return true;
		var countChildren = document.TravelRequestForm.numberOfChildren.value;
		var countAdults = document.TravelRequestForm.numberOfAdults.value;
		var tripTypeValue = document.TravelRequestForm.packageAttrStr.value;
		var countLapInfants = 0;
		var age;
		var inf;
		
		for (var i=0; i< countChildren; i++) {
		
			age = getValueOfSelectObject("childAge" + i);
			
		if (Number(countAdults) + Number(countChildren) > 6) {
			alert("The total number of people must not be greater than 6.");
			return false;			
		}
		
		if (age == "" ) {
				alert("Please specify the age of the child.");
				return false;
			}
			if (age != "" && age == "0") {
			
				inf = getValueOfRadioObject("infant" + i);
				
				if (inf == "") {
					alert("Please select infant in seat or lap.");
					return false;
				}
				if (inf == "lap") {
					countLapInfants ++;
				}
			}
		}
		if (countAdults < countLapInfants) {
			alert("The number of infants in laps must not be greater than the number of adults traveling");
			return false;
		}
		return true;

	}

	// -------------------------------
	function selectForm(link) {
		var url=link;
      if (  (url != "")  &&  (url != null)  )
      window.location=url;
  	 else
      alert("\nYou must make a selection.");
	}

	// -------------------------------
	// TOOL TIP
   //Toggle Alt Mandatory notation
   //switch layers for different browsers
	var ie4 = (document.all) ? true : false;
	var ns4 = (document.layers) ? true : false;
	var ns6 = (document.getElementById && !document.all) ? true : false;
	function hidelayer(lay) {
	if (ie4) {document.all[lay].style.visibility = "hidden";}
	if (ns4) {document.layers[lay].visibility = "hide";}
	if (ns6) {document.getElementById([lay]).style.display = "none";}
	}
	function showlayer(lay) {
	if (ie4) {document.all[lay].style.visibility = "visible";}
	if (ns4) {document.layers[lay].visibility = "show";}
	if (ns6) {document.getElementById([lay]).style.display = "block";}
	}
	// -------------------------------
	
	
	