	
//load form elements depending on user selection i.e. award or revenue.
	function onLoadForm() {
	
	if(document.awardFlightSearchForm != null) {
			//One-way
			var showOneWay = showOrHideReturnDate();
			var returnDateId = "returnDate";
			var returnDateLabelId ="returnDateLabel";
			//hide return date if one way.
			if(showOneWay) {
				showHide(returnDateId,showOneWay);
				showHide(returnDateLabelId,showOneWay);
			}

			//calculate total no of psgrs
			calcTotalNoOfPsgrs();
			//show Award search types
			document.getElementById('non_revenue1').style.display = 'block';
		}
	}


	//calculate total no of psgrs from the passenger types entered.
	//on change in # of any of passenger types ,recalculate this field
	function calcTotalNoOfPsgrs() {
		var numPsgrs = 0;
		numPsgrs =  parseInt(document.awardFlightSearchForm.adultPassengerCount.value)
		+ parseInt(document.awardFlightSearchForm.seniorPassengerCount.value)
		+ parseInt(document.awardFlightSearchForm.childPassengerCount.value) 
		+ parseInt(document.awardFlightSearchForm.infantPassengerCount.value) ;
		if(numPsgrs > 6 ) {
		 
		  numPsgrs = 6;
		  document.awardFlightSearchForm.adultPassengerCount.value = 6;
		  document.awardFlightSearchForm.seniorPassengerCount.value = 0;
		  document.awardFlightSearchForm.childPassengerCount.value = 0;
		  document.awardFlightSearchForm.infantPassengerCount.value = 0;
		}
		document.awardFlightSearchForm.numberOfPassengers.value  = numPsgrs;

	}

	//calculate # of Adult psgrs if total # of psgrs is changed
	//on change of "total # of psgrs" calculate this field,reset the # of psgrs
	//for all psgr types except Adult psgrs.set Adult spsgrs as total # of psgrs selected
	function calcAdultPsgrs() {

		var numPsgrs = 0;
		var adultPsgrs = 0;
		numPsgrs = document.awardFlightSearchForm.numberOfPassengers.value;
		
		adultPsgrs =  numPsgrs;
		/*-
		 (  parseInt(document.awardFlightSearchForm.seniorPassengerCount.value)
		 +  parseInt(document.awardFlightSearchForm.childPassengerCount.value) 
		+  parseInt(document.awardFlightSearchForm.infantPassengerCount.value) ) ;
		if(adultPsgrs < 0 ) {
			adultPsgrs = numPsgrs;
		}*/
		document.awardFlightSearchForm.adultPassengerCount.value = adultPsgrs;
		document.awardFlightSearchForm.seniorPassengerCount.value = 0;
		document.awardFlightSearchForm.childPassengerCount.value = 0;
		document.awardFlightSearchForm.infantPassengerCount.value = 0;
	}


	//display or remove Advanced Trip Preferances .
	//if "Redeem Advantage Miles" is checked then expand Award Trip
	// Preferances else expand revenue trip preferances.
	// if it is already expanded collapse it.
	//Advanced Trip Preferances
	function collapseExpand(bSwapForm) {
		var id = "commonTripPreferancesOld";
		var psgrId = "passenger";
		var advancedSearchId = "advancedSearchOld";		
		var awardid = "awardTripPreferancesOld";
		var awardAdvancedSearch = "awardAdvancedSearchText";
		var awardCabinClassOptions = "awardCabinClassOptions";

		var displayTripPrefsid = awardid;
		var cabinClassOptionsid = awardCabinClassOptions;
		var advSearchTextid = awardAdvancedSearch;


		if (document.getElementById) { // DOM3 = IE5, NS6
			//if expanding the advanced search section
			if ((!bSwapForm && document.getElementById(id).style.display == 'none') ||
				(bSwapForm && document.getElementById(id).style.display == 'block')){

				//show common trip prefarances and award or revenue trip prefarances
				//as applicable
				document.getElementById(id).style.display = 'block';
				document.getElementById(displayTripPrefsid).style.display = 'block';
				document.getElementById(cabinClassOptionsid).style.display = 'block';
				//remove the total # of passengers section and the advanced
				//search header
				document.getElementById(psgrId).style.display = 'none';
				document.getElementById(advancedSearchId).style.display = 'none';
				//recalculate Adult Psgrs
				//calcAdultPsgrs();
			} else {
				//collapse common trip prefarances and award/revenue trip prefarances
				document.getElementById(id).style.display = 'none';	
				document.getElementById(awardid).style.display = 'none';
				document.getElementById(cabinClassOptionsid).style.display = 'none';
				//show the total # of Psgrs section and advanced search header.
				document.getElementById(psgrId).style.display = 'block';
				document.getElementById(advancedSearchId).style.display = 'block';
				
				//recalculate total # of Psgrs
				calcTotalNoOfPsgrs();
			}	
		} else { 
			if (document.layers) {	
				if (document.id.display == "none"){
					document.getElementById(id).style.display = 'block';
					document.getElementById(displaytripprefsid).style.display = 'block';
					document.getElementById(cabinClassOptions).style.display = 'block';
					document.getElementById(psgrId).style.display = 'none';
					document.getElementById(advancedSearchId).style.display = 'none';
					document.getElementById(awardAdvancedSearch).style.display = 'none';
					document.getElementById(revAdvancedSearch).style.display = 'none';
					//recalculate Adult Psgrs
					//calcAdultPsgrs();
				} else {
					document.getElementById(id).style.display = 'none';	
					document.getElementById(awardid).style.display = 'none';
					document.getElementById(revenueid).style.display = 'none';
					document.getElementById(cabinClassOptions).style.display = 'none';
					document.getElementById(awardCabinClassOptions).style.display = 'none';
					document.getElementById(psgrId).style.display = 'block';
					document.getElementById(advancedSearchId).style.display = 'block';
					document.getElementById(advSearchText).style.display = 'block';

					//recalculate total # of Psgrs
					calcTotalNoOfPsgrs();
				}
			} else {
				if (document.all.id.style.display == "none"){
					document.getElementById(id).style.display = 'block';
					document.getElementById(displaytripprefsid).style.display = 'block';
					document.getElementById(cabinClassOptions).style.display = 'block';
					document.getElementById(psgrId).style.display = 'none';
					document.getElementById(advancedSearchId).style.display = 'none';
					document.getElementById(awardAdvancedSearch).style.display = 'none';
					document.getElementById(revAdvancedSearch).style.display = 'none';
					//recalculate Adult Psgrs
					//calcAdultPsgrs();
				} else {
					document.getElementById(id).style.display = 'none';	
					document.getElementById(awardid).style.display = 'none';
					document.getElementById(revenueid).style.display = 'none';
					document.getElementById(cabinClassOptions).style.display = 'none';
					document.getElementById(awardCabinClassOptions).style.display = 'none';
					document.getElementById(psgrId).style.display = 'block';
					document.getElementById(advancedSearchId).style.display = 'block';
					document.getElementById(advSearchText).style.display = 'block';

					//recalculate total # of Psgrs
					calcTotalNoOfPsgrs();
				}
			}
		}
	}

	//Return Date block, Multi-City
	//showId- div to show or hide
	//bHide - to show or hide.
	function showHide(showId,bHide) {
		if (document.getElementById) { // DOM3 = IE5, NS6
			if (!bHide && document.getElementById(showId).style.visibility == "hidden"){
				document.getElementById(showId).style.visibility = 'visible';
			} else if(bHide) {
				document.getElementById(showId).style.visibility = 'hidden';			
			}	
		} else { 
			if (document.layers) {	
				if (bHide && document.showId.visibility == "hidden"){
					document.showId.visibility = 'visible';
				} else if(!bHide){
					document.showId.visibility = 'hidden';
				}
			} else {
				if (bHide && document.all.showId.style.visibility == "hidden"){
					document.all.showId.style.visibility = 'visible';
				} else if(!bHide) {
					document.all.showId.style.visibility = 'hidden';
				}
			}
		}

	}

	//Passengers Block
	//displayId - div to display or remove
	//bDisplay - display or remove the element.
	function removeElement(displayId,bDisplay) {
		if (document.getElementById) { // DOM3 = IE5, NS6
			if (bDisplay && document.getElementById(displayId).style.display == "none"){
				document.getElementById(displayId).style.display = 'block';
			} else if(!bDisplay) {
				document.getElementById(displayId).style.display = 'none';			
			}	
		} else { 
			if (document.layers) {	
				if (bDisplay && document.displayId.display == "none"){
					document.displayId.display = 'block';
				} else if(!bDisplay) {
					document.displayId.display = 'none';
				}
			} else {
				if (bDisplay && document.all.displayId.style.display == "none"){
					document.all.displayId.style.display = 'block';
				} else if(!bDisplay) {
					document.all.displayId.style.display = 'none';
				}
			}
		}

	}

	//Search Criteria Block
	//displayId - div to be displayed.
	//removedId - div to be removed.
	function swapSearchCriteria(displayId,removeId) {

		if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(displayId).style.display = 'block';
			document.getElementById(removeId).style.display = 'none';
		} else { 
			if (document.layers) {	
				if (document.displayId.display == "none"){
					document.getElementById(displayId).style.display = 'block';
					document.getElementById(removeId).style.display = 'none';
				}
			} else {
				if (document.all.displayId.style.display == "none"){
					document.getElementById(displayId).style.display = 'block';
					document.getElementById(removeId).style.display = 'none';
				}
			}
		}

	}

	// Is 'One-Way' chosen?.
	function  showOrHideReturnDate() {
		var showOneWay = false;
		for (var i=0; i < document.awardFlightSearchForm.tripType.length; i++) {
		   if (document.awardFlightSearchForm.tripType[i].checked) {
			var selVal = document.awardFlightSearchForm.tripType[i].value;
			if(selVal == 'oneWay') {
				showOneWay = true;
			}
		      }
		   }

		return showOneWay;
	}

