
	var awardSearch = false;
	//load form elements depending on user selection i.e. award or revenue.
	function onLoadForm(currForm) {
		//One-way
		var showOneWay = showOrHideReturnDate(currForm);
		//award or revenue form
		var redeemMilesChecked = isRedeemMilesChecked(currForm);

		//setting div ids that need to be swapped depending
		// on user selection, award or revenue,one way or round trip

		var awardSearchCriteria = "non_revenue1";
		var revenueSearchCriteria = "revenue1";
		var multiCity = "multiCity";
		var returnDateId = "returnDate";
		var returnCalendarId = "returnCalendar";
		var returnMonthId = "returnMonth";
		var returnDayId = "returnDay";
		var returnYearId = "returnYear";
		var returnDateLabelId ="returnDateLabel";
		var awardAdvancedSearch = "awardAdvancedSearchText";
		var revAdvancedSearch = "revAdvancedSearchText";
		var matrixCabinClassOptions = "matrixCabinClassOptions";
		var awardCabinClassOptions = "awardCabinClassOptions";
		var cabinClassOptions = "cabinClassOptions";
		var awardTripPreferances = "awardTripPreferances";
		var revenueTripPreferances = "revenueTripPreferances";
		var originAlternateAirportDistance="originAlternateAirportDistance";
		var destinationAlternateAirportDistance="destinationAlternateAirportDistance";
		var promotionCode = "discountCode";
		var numberOfFlights = "numberOfFlights";
		var numberOfStops = "numberOfStops";

		//hide return date if one way.
		if(showOneWay) {
			showHide(returnDateId,showOneWay);
			showHide(returnDateLabelId,showOneWay);
			showHide(returnCalendarId,showOneWay);
			showHide(returnMonthId,showOneWay);
			showHide(returnYearId,showOneWay);
			showHide(returnDayId,showOneWay);
		}
		// if Redeem miles checked, then display the corresponding attributes.
		if(redeemMilesChecked) {
			//search criteria
			swapSearchCriteria(awardSearchCriteria,revenueSearchCriteria );
			swapSearchCriteria(awardAdvancedSearch,revAdvancedSearch );

			//multi-city
			//showHide(multiCity,redeemMilesChecked);
			showHide(originAlternateAirportDistance,redeemMilesChecked);
			showHide(destinationAlternateAirportDistance,redeemMilesChecked);
			hideBlock(promotionCode);
			hideBlock("promotionLabel");
			hideBlock("promotionInfo");
			hideBlock(numberOfStops);
			
		} else {
			swapSearchCriteria(revenueSearchCriteria,awardSearchCriteria );
			showBlock(promotionCode);
			showBlock("promotionLabel");
			showBlock("promotionInfo");
			showBlock(numberOfStops);
		}
		if (isMatrixSearch(currForm)) {
			swapCabinClassPrefs(matrixCabinClassOptions,cabinClassOptions,awardCabinClassOptions);
			hide(numberOfFlights);
		}
		//calculate total no of psgrs
		calcTotalNoOfPsgrs(currForm);
		if(document.toggleLocaleForm != null) {
			if(redeemMilesChecked) {
				awardSearch = true;
			} else {
				if (getAAirpassSearchType(currForm.aairpassSearchType)) {
			    	hideBlock("datesFlexibleDiv");
			    	hideBlock("flightSearchForm.carrierAAOneWorld");
			    	hideBlock(promotionCode);
					hideBlock("promotionLabel");
					hideBlock("promotionInfo");
			    	checkCarrierRadioButton(currForm);
			    } else {
			    	showBlock("datesFlexibleDiv");
			    	showBlock("flightSearchForm.carrierAAOneWorld");
			    }
/*				if(document.toggleLocaleForm.locale.value == "en_US" && !redeemMilesChecked) {
					currForm.searchCategory.disabled = true;
				}
				else {
					document.toggleLocaleForm.toggleSubmitButton.disabled = false;
					document.toggleLocaleForm.toggleSubmitButton.className = "aaBtnAutoHot";
				}*/
			}
		}
		showBlock("childSenior");
	}

	// is 'Redeem Advantage Miles' checkbox checked.
	function isRedeemMilesChecked(currForm) {
		var redeemMilesChecked = false;
		if(currForm.searchCategory.checked == true){
			redeemMilesChecked = true;
		}
		return redeemMilesChecked;
	}
	
	function getAAirpassSearchType(aairpassSearch) {
		var length = aairpassSearch.length;
		for(var i = 0; i < length; i++) {
			if(aairpassSearch[i].checked)
				return aairpassSearch[i].checked;
			else
				return false;
		}
	}		
	
	function showHidePromotionCode(currForm) {
		if(isRedeemMilesChecked(currForm)) {
			currForm.searchCategory.checked = false;
		}
		swapForms(currForm);
		if(getAAirpassSearchType(currForm.aairpassSearchType)){
			hideBlock("discountCode");
			hideBlock("promotionLabel");
			hideBlock("promotionInfo");
		} else { 
			showBlock("discountCode");
			showBlock("promotionLabel");
			showBlock("promotionInfo");
		}
	}

	//swap search criteria when redeem miles is checked/unchecked
	function swapForms(currForm) {
		
		var redeemMilesChecked = false;
		var awardSearchCriteria = "non_revenue1";
		var revenueSearchCriteria = "revenue1";
		var multiCity = "multiCity";
		var returnDateId = "returnDate";
		var returnCalendarId = "returnCalendar";
		var returnMonthId = "returnMonth";
		var returnDayId = "returnDay";
		var returnYearId = "returnYear";
		var awardAdvancedSearch = "awardAdvancedSearchText";
		var revAdvancedSearch = "revAdvancedSearchText";
		var matrixCabinClassOptions = "matrixCabinClassOptions";
		var awardCabinClassOptions = "awardCabinClassOptions";
		var cabinClassOptions = "cabinClassOptions";
		var awardTripPreferances = "awardTripPreferances";
		var revenueTripPreferances = "revenueTripPreferances";
		var commonTripPreferances = "commonTripPreferances";
		var originAlternateAirportDistance="originAlternateAirportDistance";
		var destinationAlternateAirportDistance="destinationAlternateAirportDistance";
		var numberOfFlights = "numberOfFlights";
	    var promotionCode = "discountCode";
	    var expandedModeId = "expandedMode";
	  var numberOfStops = "numberOfStops"
		
		//award or revenue form
		redeemMilesChecked = isRedeemMilesChecked(currForm);
		fareSearch = isFareSearch(currForm);
		
		// if Redeem miles checked, then display the corresponding attributes.
		if(redeemMilesChecked) {
			// Uncheck AAirpass search option 
			if(getAAirpassSearchType(currForm.aairpassSearchType)) {
				currForm.aairpassSearchType[0].checked = false;
			}

			//search criteria
			swapSearchCriteria(awardSearchCriteria,revenueSearchCriteria );
			if(document.getElementById(commonTripPreferances).style.display == 'block') {
				swapCabinClassPrefs(awardCabinClassOptions,cabinClassOptions,matrixCabinClassOptions);
				swapSearchCriteria(awardTripPreferances,revenueTripPreferances );
			} else {
				swapSearchCriteria(awardAdvancedSearch,revAdvancedSearch );

			}

			//multi-city
			//showHide(multiCity,redeemMilesChecked);
			//alternate airport distance
			showHide(originAlternateAirportDistance,redeemMilesChecked);
			showHide(destinationAlternateAirportDistance,redeemMilesChecked);
			//discountCodeField
			hideBlock(promotionCode);
			hideBlock("promotionLabel");
			hideBlock("promotionInfo");
			hideBlock(numberOfStops);
		} else {
			//search criteria
			swapSearchCriteria(revenueSearchCriteria,awardSearchCriteria );
			if(document.getElementById(commonTripPreferances).style.display == 'block') {
				if (isMatrixSearch(currForm)) {
					swapCabinClassPrefs(matrixCabinClassOptions,cabinClassOptions,awardCabinClassOptions);
					hide(numberOfFlights);					
				} else {
					swapCabinClassPrefs(cabinClassOptions,awardCabinClassOptions,matrixCabinClassOptions);
				}
				swapSearchCriteria(revenueTripPreferances,awardTripPreferances);
				//number of flights to display.
				if (isScheduleSearch(currForm)) {
					show(numberOfFlights);
				} else {
					hide(numberOfFlights);				
				}
				// extra space for discountCodeField
				showBlock(expandedModeId);	
			} else {
				swapSearchCriteria(revAdvancedSearch,awardAdvancedSearch);
			}

			//multi-city
			//showHide(multiCity,redeemMilesChecked);
			//alternate airport distance
			showHide(originAlternateAirportDistance,redeemMilesChecked);
			showHide(destinationAlternateAirportDistance,redeemMilesChecked);
			//discountCodeField
			showBlock(promotionCode);
			showBlock("promotionLabel");
			showBlock("promotionInfo");
			showBlock(numberOfStops);
		 	if (getAAirpassSearchType(currForm.aairpassSearchType)) {
		    	hideBlock("datesFlexibleDiv");
		    	hideBlock("flightSearchForm.carrierAAOneWorld");
		    	checkCarrierRadioButton(currForm);
		    } else {
		    	showBlock("datesFlexibleDiv");
		    	showBlock("flightSearchForm.carrierAAOneWorld");
		    }

		}
		if(document.toggleLocaleForm != null) {
			document.toggleLocaleForm.toggleSubmitButton.disabled = false;
			document.toggleLocaleForm.toggleSubmitButton.className = "aaBtnAutoHot";
		}
	}

	//calculate total no of psgrs from the passenger types entered.
	//on change in # of any of passenger types ,recalculate this field
	function calcTotalNoOfPsgrs(currForm) {
		var numPsgrs = 0;
		numPsgrs =  parseInt(currForm.adultPassengerCount.value)
		+ parseInt(currForm.seniorPassengerCount.value)
		+ parseInt(currForm.youngAdultPassengerCount.value)
		+ parseInt(currForm.childPassengerCount.value) 
		+ parseInt(currForm.infantPassengerCount.value) ;
		currForm.passengerCount.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 psgrs as total # of psgrs selected
	function calcAdultPsgrs(currForm) {
		var numPsgrs=0; adultPsgrs = 0;numPsgrs = currForm.passengerCount.value;
		adultPsgrs =  numPsgrs;
		/*if (currForm.seniorPassengerCount.value==null)  {currForm.seniorPassengerCount.value=0;}if (currForm.youngAdultPassengerCount.value==null)  {currForm.youngAdultPassengerCount.value=0;}if (currForm.childPassengerCount.value==null)  {currForm.childPassengerCount.value=0;}if (currForm.infantPassengerCount.value==null)  {currForm.infantPassengerCount.value=0;}if (currForm.adultPassengerCount.value==null)  {currForm.adultPassengerCount.value=0;} numPsgrs=parseInt(currForm.adultPassengerCount.value)
		+parseInt(currForm.seniorPassengerCount.value)
		+parseInt(currForm.childPassengerCount.value)
		+parseInt(currForm.infantPassengerCount.value)
		+parseInt(currForm.youngAdultPassengerCount.value);if(numPsgrs>6){numPsgrs=6;currForm.adultPassengerCount.value=6;currForm.seniorPassengerCount.value=0;currForm.youngAdultPassengerCount.value=0;currForm.childPassengerCount.value=0;currForm.infantPassengerCount.value=0;currForm.adultPassengerCount2.value=6;currForm.seniorPassengerCount2.value=0;currForm.youngAdultPassengerCount2.value=0;currForm.childPassengerCount2.value=0;currForm.infantPassengerCount2.value=0;	}
		*/
		currForm.adultPassengerCount.value = adultPsgrs;
		currForm.seniorPassengerCount.value = 0;
		currForm.childPassengerCount.value = 0;
		currForm.infantPassengerCount.value = 0;
		currForm.youngAdultPassengerCount.value = 0;
	}
	function calcAdultPsgrs(currForm) {
		var numPsgrs = 0;
		var adultPsgrs = 0;
		numPsgrs = currForm.passengerCount.value;
		adultPsgrs =  numPsgrs;
		/*-
		 (  parseInt(currForm.seniorPassengerCount.value)
		 +  parseInt(currForm.childPassengerCount.value) 
		+  parseInt(currForm.infantPassengerCount.value) ) ;
		if(adultPsgrs < 0 ) {
			adultPsgrs = numPsgrs;
		}*/
		currForm.adultPassengerCount.value = adultPsgrs;
		currForm.seniorPassengerCount.value = 0;
		currForm.childPassengerCount.value = 0;
		currForm.infantPassengerCount.value = 0;
	}
	function syncAdultPassengerCount(currForm){ 
		if (currForm.adultPassengerCount.value!=currForm.adultPassengerCount2.value) currForm.adultPassengerCount.value=currForm.adultPassengerCount2.value;calcTotalNoOfPsgrs(currForm);
	}
	function syncAdultPassengerCount2(currForm){ 
		if (currForm.adultPassengerCount.value!=currForm.adultPassengerCount2.value) currForm.adultPassengerCount2.value=currForm.adultPassengerCount.value;calcTotalNoOfPsgrs(currForm);
	}
	function syncYoungAdultPassengerCount(currForm){ 
		if (currForm.youngAdultPassengerCount.value!=currForm.youngAdultPassengerCount2.value) currForm.youngAdultPassengerCount.value=currForm.youngAdultPassengerCount2.value;calcTotalNoOfPsgrs(currForm);
	}
	function syncYoungAdultPassengerCount2(currForm){ 
		if (currForm.youngAdultPassengerCount.value!=currForm.youngAdultPassengerCount2.value) currForm.youngAdultPassengerCount2.value=currForm.youngAdultPassengerCount.value;calcTotalNoOfPsgrs(currForm);
	}
	function syncSeniorPassengerCount(currForm){ 
		if (currForm.seniorPassengerCount.value!=currForm.seniorPassengerCount2.value) currForm.seniorPassengerCount.value=currForm.seniorPassengerCount2.value;calcTotalNoOfPsgrs(currForm);
	}
	function syncSeniorPassengerCount2(currForm){ 
		if (currForm.seniorPassengerCount.value!=currForm.seniorPassengerCount2.value) currForm.seniorPassengerCount2.value=currForm.seniorPassengerCount.value;calcTotalNoOfPsgrs(currForm);
	}
	function syncChildPassengerCount(currForm){ 
		if (currForm.childPassengerCount.value!=currForm.childPassengerCount2.value) currForm.childPassengerCount.value=currForm.childPassengerCount2.value;calcTotalNoOfPsgrs(currForm);
	}
	function syncChildPassengerCount2(currForm){ 
		if (currForm.childPassengerCount.value!=currForm.childPassengerCount2.value) currForm.childPassengerCount2.value=currForm.childPassengerCount.value;calcTotalNoOfPsgrs(currForm);
	}
	function syncInfantPassengerCount(currForm){ 
		if (currForm.infantPassengerCount.value!=currForm.infantPassengerCount2.value) currForm.infantPassengerCount.value=currForm.infantPassengerCount2.value;calcTotalNoOfPsgrs(currForm);
	}
	function syncInfantPassengerCount2(currForm){ 
		if (currForm.infantPassengerCount.value!=currForm.infantPassengerCount2.value) currForm.infantPassengerCount2.value=currForm.infantPassengerCount.value;calcTotalNoOfPsgrs(currForm);
	}
	function collapseExpandOptions(bSwapForm,currForm,showChildSeniorDetails) {
		collapseExpand(bSwapForm,currForm);
		if (showChildSeniorDetails) {
			showBlock("adultPassenger");hideBlock("passengerDetails");
			showBlock("childSenior");
			showBlock("advancedSearch");
		}
		else {
			hideBlock("adultPassenger");showBlock("passengerDetails");
			hideBlock("childSenior");
			hideBlock("childSenior1");
			hideBlock("childSenior2");
			hideBlock("childSenior21");
			hideBlock("childSenior22");
			hideBlock("childSenior23");
			hideBlock("childSenior24");
			hideBlock("childSenior25");
			hideBlock("advancedSearch");
			hideBlock("advancedSearch");
		} 
	}
function collapseExpandChildSenior(hide)
{if (hide) {hideBlock("childSenior1"); hideBlock("childSenior2"); 			hideBlock("childSenior21");
hideBlock("childSenior22");
hideBlock("childSenior23");
hideBlock("childSenior24");
hideBlock("childSenior25");
hideBlock("advancedSearch");
showBlock("childSenior"); hideBlock("passengerDetails");} else {showBlock("childSenior1");showBlock("childSenior2");			showBlock("childSenior21");
showBlock("childSenior22");
showBlock("childSenior23");
showBlock("childSenior24");
showBlock("childSenior25");hideBlock("passengerDetails");hideBlock("childSenior");}}

	//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,currForm) {
		var id = "commonTripPreferances";
		var psgrId = "passenger";
		var advancedSearchId = "advancedSearch";		
		var revenueid = "revenueTripPreferances";;
		var awardid = "awardTripPreferances";
		var awardAdvancedSearch = "awardAdvancedSearchText";
		var revAdvancedSearch = "revAdvancedSearchText";
		var matrixCabinClassOptions = "matrixCabinClassOptions";
		var awardCabinClassOptions = "awardCabinClassOptions";
		var cabinClassOptions = "cabinClassOptions";
		var numberOfFlights = "numberOfFlights";
		var expandedModeId = "expandedMode";		
		var bRedeemMilesChecked = isRedeemMilesChecked(currForm);
		var numberOfFlightsid = "numberOfFlights";
		var bFareSearch = isFareSearch(currForm);

		var displayTripPrefsid = revenueid;
		var cabinClassOptionsid = cabinClassOptions;
		var advSearchTextid = revAdvancedSearch;

        var advSearchField = "advancedSearchSelected";

		if(bRedeemMilesChecked) {
			displayTripPrefsid = awardid;
			cabinClassOptionsid = awardCabinClassOptions;
			advSearchTextid = awardAdvancedSearch;
			bFareSearch = true;
		} else if (isMatrixSearch(currForm)) {
			cabinClassOptionsid = matrixCabinClassOptions;
			bFareSearch = true;
		}
		
	 	if (getAAirpassSearchType(currForm.aairpassSearchType)) {
	    	hideBlock("datesFlexibleDiv");
	    	hideBlock("flightSearchForm.carrierAAOneWorld");
	    	checkCarrierRadioButton(currForm);
	    } else {
	    	showBlock("datesFlexibleDiv");
	    	if (!bRedeemMilesChecked) {
	    		showBlock("flightSearchForm.carrierAAOneWorld");
	    	}
	    }		

		if (document.getElementById) { // DOM3 = IE5, NS6
			//if expanding the advanced search section
			document.getElementById(cabinClassOptions).style.display = 'none';
			document.getElementById(awardCabinClassOptions).style.display = 'none';
			document.getElementById(matrixCabinClassOptions).style.display = 'none';
			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';
				//display number of flights to display field only if schedule search
				if(!bFareSearch) {
					document.getElementById(numberOfFlightsid).style.visibility = 'visible';	
				} else {
					document.getElementById(numberOfFlightsid).style.visibility = 'hidden';	
				}
				//remove the total # of passengers section and the advanced
				//search header
				//hide(psgrId);
                changeElementValue(advSearchField, "true");
				document.getElementById(advancedSearchId).style.display = 'none';
				document.getElementById(awardAdvancedSearch).style.display = 'none';
				document.getElementById(revAdvancedSearch).style.display = 'none';
				if(!bRedeemMilesChecked) {
					showBlock(expandedModeId);
				}
				//recalculate Adult Psgrs
				//calcAdultPsgrs(currForm);
			} else {
				//collapse common trip prefarances and award/revenue trip prefarances
				document.getElementById(id).style.display = 'none';	
				document.getElementById(awardid).style.display = 'none';
				document.getElementById(revenueid).style.display = 'none';
				document.getElementById(cabinClassOptionsid).style.display = 'none';
				document.getElementById(awardCabinClassOptions).style.display = 'none';
				document.getElementById(matrixCabinClassOptions).style.display = 'none';
				document.getElementById(numberOfFlights).style.visibility = 'hidden';
				//show the total # of Psgrs section and advanced search header.
				//show(psgrId);
                changeElementValue(advSearchField, "false");
				document.getElementById(advancedSearchId).style.display = 'block';
				document.getElementById(advSearchTextid).style.display = 'block';
				document.getElementById(expandedModeId).style.display = 'none';
				
				//recalculate total # of Psgrs
				calcTotalNoOfPsgrs(currForm);
			}	
		} else { 
			if (document.layers) {
				document.getElementById(cabinClassOptions).style.display = 'none';
				document.getElementById(awardCabinClassOptions).style.display = 'none';
				document.getElementById(matrixCabinClassOptions).style.display = 'none';
				if (document.id.display == "none"){
					document.getElementById(id).style.display = 'block';
					document.getElementById(displayTripPrefsid).style.display = 'block';
					document.getElementById(cabinClassOptions).style.display = 'block';
					//display number of flights to display field only if schedule search
					if(!bRedeemMilesChecked && isScheduleSearch(currForm)) {
						document.getElementById(numberOfFlights).style.display = 'block';	
					}
					//remove the total # of passengers section and the advanced
					//search header
					//hide(psgrId);
                    changeElementValue(advSearchField, "true");
					document.getElementById(advancedSearchId).style.display = 'none';
					document.getElementById(awardAdvancedSearch).style.display = 'none';
					document.getElementById(revAdvancedSearch).style.display = 'none';
					if(!bRedeemMilesChecked) {
						showBlock(expandedModeId);
					}
				} else {
					//collapse common trip prefarances and award/revenue trip prefarances
					document.getElementById(id).style.display = 'none';	
					document.getElementById(awardid).style.display = 'none';
					document.getElementById(revenueid).style.display = 'none';
					document.getElementById(cabinClassOptionsid).style.display = 'none';
					document.getElementById(awardCabinClassOptions).style.display = 'none';
					document.getElementById(matrixCabinClassOptions).style.display = 'none';
					document.getElementById(numberOfFlights).style.display = 'none';
					//show the total # of Psgrs section and advanced search header.
					//show(psgrId);
                    changeElementValue(advSearchField, "false");
					document.getElementById(advancedSearchId).style.display = 'block';
					document.getElementById(advSearchTextid).style.display = 'block';
					document.getElementById(expandedModeId).style.display = 'none';

					//recalculate total # of Psgrs
					calcTotalNoOfPsgrs(currForm);
				}
			} else {
				document.getElementById(cabinClassOptions).style.display = 'none';
				document.getElementById(awardCabinClassOptions).style.display = 'none';
				document.getElementById(matrixCabinClassOptions).style.display = 'none';			
				if (document.all.id.style.display == "none"){
					document.getElementById(id).style.display = 'block';
					document.getElementById(displayTripPrefsid).style.display = 'block';
					document.getElementById(cabinClassOptionsid).style.display = 'block';
					//display number of flights to display field only if schedule search
					if(!bRedeemMilesChecked && isScheduleSearch()) {
						document.getElementById(numberOfFlights).style.display = 'block';	
					}
					//remove the total # of passengers section and the advanced
					//search header
					//hide(psgrId);
                    changeElementValue(advSearchField, "true");
					document.getElementById(advancedSearchId).style.display = 'none';
					document.getElementById(awardAdvancedSearch).style.display = 'none';
					document.getElementById(revAdvancedSearch).style.display = 'none';
					if(!bRedeemMilesChecked) {
						showBlock(expandedModeId);
					}					
				} else {
					//collapse common trip prefarances and award/revenue trip prefarances
					document.getElementById(id).style.display = 'none';	
					document.getElementById(awardid).style.display = 'none';
					document.getElementById(revenueid).style.display = 'none';
					document.getElementById(cabinClassOptionsid).style.display = 'none';
					document.getElementById(awardCabinClassOptions).style.display = 'none';
					document.getElementById(matrixCabinClassOptions).style.display = 'none';
					document.getElementById(numberOfFlights).style.display = 'none';
					//show the total # of Psgrs section and advanced search header.
					//show(psgrId);
                    changeElementValue(advSearchField, "false");
					document.getElementById(advancedSearchId).style.display = 'block';
					document.getElementById(advSearchTextid).style.display = 'block';
					document.getElementById(expandedModeId).style.display = 'none';

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

    function changeElementValue(pElementId, pValue) {
        document.getElementById(pElementId).value = pValue;
    }

	//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';
				}
			}
		}

	}

	//showId- div to show
	function showBlock(showId) {
		if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(showId).style.display = 'block';
		} else { 
			if (document.layers) {	
				document.showId.display = 'block';
			} else {
				document.all.showId.style.display = 'block';
			}
		}
	}
	
	//hideId- div to hide
	function hideBlock(hideId) {
		if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(hideId).style.display = 'none';
		} else { 
			if (document.layers) {	
				document.hideId.display = 'none';
			} else {
				document.all.hideId.style.display = 'none';
			}
		}
	}
	
	//showId- div to show
	function show(showId) {
		if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(showId).style.visibility = 'visible';
		} else { 
			if (document.layers) {	
				document.showId.visibility = 'visible';
			} else {
				document.all.showId.style.visibility = 'visible';
			}
		}
	}
	
	//hideId- div to hide
	function hide(hideId) {
		if (document.getElementById) { // DOM3 = IE5, NS6
			document.getElementById(hideId).style.visibility = 'hidden';
		} else { 
			if (document.layers) {	
				document.hideId.visibility = 'hidden';
			} else {
				document.all.hideId.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';
				}
			}
		}

	}

	//Search Criteria Block
	//displayId - div to be displayed.
	//removedId1 - div to be removed.
	//removedId2 - div to be removed.
	function swapCabinClassPrefs(displayId,removeId1,removeId2) {

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

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

		return showOneWay;
	}
	
	// Is 'Schedule-Search' chosen?.
	function  isScheduleSearch(currForm) {
		var fareSearch = false;
		for (var i=0; i < currForm.searchTypeMode.length; i++) {
		   if (currForm.searchTypeMode[i].checked) {
			var selVal = currForm.searchTypeMode[i].value;
			if(selVal == 'schedule') {
				fareSearch = true;
			}
		      }
		   }

		return fareSearch;
	}	

	// Is 'Fare-Search' chosen?.
	function  isFareSearch(currForm) {
		var fareSearch = false;
		for (var i=0; i < currForm.searchTypeMode.length; i++) {
		   if (currForm.searchTypeMode[i].checked) {
			var selVal = currForm.searchTypeMode[i].value;
			if(selVal == 'fare') {
				fareSearch = true;
			}
		      }
		   }

		return fareSearch;
	}
	
	// Is 'Matrix-Search' chosen?.
	function  isMatrixSearch(currForm) {
		var fareSearch = false;
		for (var i=0; i < currForm.searchTypeMode.length; i++) {
		   if (currForm.searchTypeMode[i].checked) {
			var selVal = currForm.searchTypeMode[i].value;
			if(selVal == 'matrix') {
				fareSearch = true;
			}
		      }
		   }

		return fareSearch;
	}

    //to submit the form when Multi-City ,'My Dates are Flexible' links
	// are clicked.
	function submitForm(field) {
		var submit = "flightSearchForm.button.reSubmit";//submit button on the form.
		if (document.getElementById) { // DOM3 = IE5, NS6
			field.disabled = false; // to set hidden variable 'Multi-City' or 'datesFlexible'
			document.getElementById(submit).click();
		}
	}
	
	function setSearchCategory(currForm) {
		var redeemMilesChecked = isRedeemMilesChecked(currForm);
		if(document.getElementById && !redeemMilesChecked) {
			var input = document.createElement('INPUT');
			input.setAttribute('type', 'hidden');
			input.setAttribute('name', 'searchCategory');
			input.setAttribute('value', null);
			currForm.appendChild(input);
		}
	}

	function onSearchTypeChange(currForm) {
		var fareSearch = isFareSearch(currForm);
		var numberOfFlights = "numberOfFlights";
		var commonTripPreferances = "commonTripPreferances";
		var cabinClassOptions = "cabinClassOptions";
		var matrixCabinClassOptions = "matrixCabinClassOptions";
		var awardCabinClassOptions = "awardCabinClassOptions";		
		if(document.getElementById(commonTripPreferances).style.display == 'block') {
			showHide(numberOfFlights,fareSearch);
		}
		if (isMatrixSearch(currForm)) {
			swapCabinClassPrefs(matrixCabinClassOptions,cabinClassOptions,awardCabinClassOptions);
			hide(numberOfFlights);
	    } else {
			swapCabinClassPrefs(cabinClassOptions,matrixCabinClassOptions,awardCabinClassOptions);
	    }
	}

	function showHideReturnDate(currForm,bShow) {
				
		var returnDateId = "returnDate";
		var returnCalendarId = "returnCalendar";
		var returnMonthId = "returnMonth";
		var returnDayId = "returnDay";
		var returnYearId = "returnYear";
		var returnDateLabelId ="returnDateLabel";
		showHide(returnDateId,bShow);
		showHide(returnDateLabelId,bShow);
		showHide(returnCalendarId,bShow);
		showHide(returnMonthId,bShow);
		showHide(returnYearId,bShow);
		showHide(returnDayId,bShow);
	}
	
	// turn radio button on
	function checkCarrierRadioButton(currForm) {
		var radioGrp = currForm.carrierPreference;
		for(i=0; i < radioGrp.length; i++){
			if (radioGrp[i].value == 'T') {
				radioGrp[i].click();
				break;
			}
		}
	}

