var form;

/*
 * Called on NewSearch page to initialize controls during page load
 */
function on_load ( value )
{
	changeSearchScenario(value);
	selectChangeYourSearchForm();
}


function selectChangeYourSearchForm()
{
	if ( document.getElementsByName("AirSearchForm").length === 1 )
		form = document.AirSearchForm;
	else	
		form = document.AirSearchForm[1];
}

/*
 * 1)
 *   If search date type is open dates, then build URL for BestFareFinder.
 * 2)
 *   If not open date search:
 *   Called when form is submitted to ensure the onblur function, if focus is on a field
 *   that has an onblur handler defined, has time to process before the form is submitted.
 */
function doSubmit ( jid )
{
	
  if ( typeof(form) == 'undefined' )
	selectChangeYourSearchForm();
  
  // set/clear the Navigator Filters
  if ( form.airlineSearchPref )
  {
    var value = form.airlineSearchPref.value;
    copyAirlinePref( value );
    setFilterStops();
  }

  // handle prefill date fields
  if ( form.leavingDate4 )
  {
    if ( form.leavingDate4.value == 'mm/dd/yyyy' ||
         form.leavingDate4.value == 'dd/mm/yyyy'  )
    {
      form.leavingDate4.value = '';
    }
  }
  if ( form.leavingDate3 )
  {
    if ( form.leavingDate3.value == 'mm/dd/yyyy' ||
         form.leavingDate3.value == 'dd/mm/yyyy'  )
    {
      form.leavingDate3.value = '';
    }
  }
  if ( form.leavingDate2 )
  {
    if ( form.leavingDate2.value == 'mm/dd/yyyy' ||
         form.leavingDate2.value == 'dd/mm/yyyy'  )
    {
      form.leavingDate2.value = '';
    }
  }
  if ( form.leavingDate1 )
  {
    if ( form.leavingDate1.value == 'mm/dd/yyyy' ||
         form.leavingDate1.value == 'dd/mm/yyyy'  )
    {
      form.leavingDate1.value = '';
    }
  }
  if ( form.flightType && form.flightType[0].checked )
  {
    if ( typeof( form.dateTypeSelect )  != 'undefined' ) 
    {
    	
      if ( form.leavingDate.value == '' )
      {
        copyLeavingDate( form.leavingDateExact.value );
      }
      if ( form.returningDate.value == '' )
      {
        copyReturningDate( form.returningDateExact.value );
      }
    }
    else if ( form.dateTypeSelect && form.dateTypeSelect[1].checked )
    {
      if ( form.leavingDate.value == '' )
      {
        copyLeavingDate( form.leavingDatePlusMinus.value );
      }
      if ( form.returningDate.value == '' )
      {
        copyReturningDate( form.returningDatePlusMinus.value );
      }
    }
  }
  // setup the returningDate...
  // For OneWay, the returningDate should be the same as the leavingDate
  if ( form.flightType && form.flightType[1].checked == true )
  {
    form.returningDate.value = form.leavingDate.value;
  }
  else // for multicity, the returningDate should be the last depart date

  if ( form.flightType && form.flightType[2].checked == true )
  {
    var lastDepartDate = form.leavingDate4.value;

    if ( lastDepartDate != '' )
    {
      form.returningDate.value = lastDepartDate;
    }
    else
    {
      lastDepartDate = form.leavingDate3.value;

      if ( lastDepartDate != '' )
      {
        form.returningDate.value = lastDepartDate;
      }
      else
      {
        lastDepartDate = form.leavingDate2.value;

        if ( lastDepartDate != '' )
        {
          form.returningDate.value = lastDepartDate;
        }
        else
        {
          lastDepartDate = form.leavingDate1.value;

          if ( lastDepartDate != '' )
          {
            form.returningDate.value = lastDepartDate;
          }
        }
      }
    }
  }
  // add parameters to the URL for Open Dates
  if ( ( form.dateTypeSelect  ) &&  ( form.dateTypeSelect[2] )  )
    {
      if ( form.dateTypeSelect[2].checked  )
  {
    form.action = "/flights/FlexibleDatesAction.do";
    if ( jid )
    {
      form.action = form.action + ";jsessionid=" + jid;
    }
    form.submit();
  }
  else
  {
    setTimeout( 'form.submit()', 10 );
  }
    }
    else
    {
      setTimeout( 'form.submit()', 10 );
    }
}

/*
 * Called when when focus leaves one of the fields below to ensure all of these fields
 * contain the same value.
 */
function copyLeavingFrom( value )
{
	form.leavingFrom.value = value;
	form.leavingFrom1.value = value;
}

/*
 * Called when when focus leaves one of the fields below to ensure all of these fields
 * contain the same value.
 */
function copyGoingTo( value )
{
	form.goingTo.value = value;
	form.goingTo1.value = value;

}

/*
 * Called when focus leaves the airlineSearchPref field to copy the value to
 * the filterAirline field
 */
function copyAirlinePref( value )
{

	  if ( form.airlineSearchPref.value != 'searchAll' )
	  {
		  form.filterAirline.value = value;
	  }
	  else
	  {
		  form.filterAirline.value = "";
	  }
	  

	  
}

/*
 * Called when maxConnections is changed
 */
function setFilterStops()
{
	  
  if ( form.maxConnections.checked )
  {
	  form.filterStops.value = "0";
  }
  else
  {
	  form.filterStops.value = "";
  }
}

/*
 * Called when when focus leaves one of the fields below to ensure all of these fields
 * contain the same value.
 */
function copyLeavingDate( value )
{
	
	form.leavingDate.           value = value;
	form.leavingDate1.          value = value;
	form.leavingDateDepart.     value = value;
	form.leavingDateExact.      value = value;
	 if ( typeof( form.leavingDatePlusMinus)  != 'undefined' ) 
	form.leavingDatePlusMinus.  value = value;

	
}

/*
 * Called when when focus leaves one of the fields below to ensure all of these fields
 * contain the same value.
 */
function copyLeavingTime( value )
{

	form.dateLeavingTime.       value = value;
	form.leavingTimeDepart.     value = value;
	form.leavingTime1.          value = value;

}

/*
 * Called when when focus leaves one of the fields below to ensure all of these fields
 * contain the same value.
 */
function copyReturningDate( value )
{

	form.returningDate.         value = value;
	form.returningDateExact.    value = value;
	if ( typeof( form.returningDatePlusMinus)  != 'undefined' ) 
	form.returningDatePlusMinus.value = value;

}

/*
 * Called when when focus leaves one of the fields below to ensure all of these fields
 * contain the same value.
 */
function copyReturningTime( value )
{

	form.dateReturningTime.     value = value;
	form.leavingTime2.          value = value;
}

function redirectToTotalTrip( )
{
  form.action = "/trips/InitialSearch.do?fromFlights=true";
  form.submit( );
}

/*
 *  Called when the user selects a control that changes the appearance
 *  of the Search Page.
 *
 *  These controls are:
 *    Flight Types:    RoundTrip, OneWay, MultiCity radio buttons
 *    Cross-Sell:      Air Only, Air + Hotel radio buttons
 *    Nearby Airports: Nearby Airportcheckbox
 *    Dates:           Exact Dates, PlusMinus Dates, Open Dates
 *
 *  This method will determine which scenario should be setup.
 */
function changeSearchScenario( value )
{
  if ( typeof(form) == 'undefined' )
	  selectChangeYourSearchForm();

	
  // setup nextAction as non-CrossSell
  form.nextAction.value = 'airOnly&breadcrumbStart=1';

  // if Round Trip is selected...
  if ( form.flightType[0].checked == true )
  {
	 // no dateTypeSelect radio buttons
	 if ( ( typeof( form.dateTypeSelect)  != 'undefined' ) && ( form.dateTypeSelect.value == 'exactDates' ) )
	{
		 setupSearchScenario1(value);
	}	  

	 // if Exact Dates selected...
    
	else 
	  
	if ( form.dateTypeSelect[0].checked == true )
    {
      // if CrossSell is selected
      if ( form.tripType[1].checked == true )
      {
        setupSearchScenario2();
      }
      else // if NearbyAirport is selected
      if ( hasNearbyAirportsCheckbox() && form.nearbyAirports.checked == true )
      {
        setupSearchScenario3();
      }
      else // CrossSell and Nearby Airport are NOT selected
      {
        setupSearchScenario1(value);
      }
    }
    else // if PlusMinus dates selected
    if ( form.dateTypeSelect[1].checked == true )
    {
      setupSearchScenario4();
    }
    else if ( form.dateTypeSelect[2] && form.dateTypeSelect[2].checked == true )
    {
      setupSearchScenario5();
    }
    else
    {
      alert( 'no Date Option selected for RoundTrip' );
    }

  }
  else // if OneWay selected
	  
  if ( form.flightType[1].checked == true )
  {
    if ( ( typeof( form.dateTypeSelect)  != 'undefined' ) && ( form.dateTypeSelect.value == 'exactDates' ) )
    {
    	setupSearchScenario9();
    	
    }
    
    else
	 {
	  // if PlusMinus date is selected, then select Exact Date instead
    if ( form.dateTypeSelect[1].checked == true )
    {
    	form.dateTypeSelect[1].checked = false;
    	form.dateTypeSelect[0].checked = true;
    }

    // if Exact Dates selected...
    if ( form.dateTypeSelect[0].checked == true )
    {
      setupSearchScenario6();
    }
    else if ( form.dateTypeSelect[2] && form.dateTypeSelect[2].checked == true )
    {
      setupSearchScenario7();
    }
    else
    {
      alert( 'no Date Option selected for OneWay' );
    
    
    }
	 }
  }
  else // MultiCity selected
  if ( form.flightType[2].checked == true )
  {
    setupSearchScenario8();
  }
  else
  {
    alert( 'no Flight Type selected' );
  }
}


/*
 * Setup Search Scenario 1
 *   RoundTrip      selected
 *   CrossSell      not selected
 *   Nearby Airport not selected
 *   Exact Dates    selected
 */
function setupSearchScenario1(value)
{
  //alert( 'in setupSearchScenario1' );

  // show/hide the appropriate Origin/Destination fields
  noneBlock( "roundtripForm!1" );     // oneway and roundtrip origin/destination
  noneBlock( "multiCityForm!0" );     // multicity origin/destination

  // the nearbyAirportPanel contains the nearby checkbox and crosssell radios
  noneBlock( "nearbyAirportPanel!1" );

  // hide/show the cross sell fields
  if (value == 1)
  {
    if( document.getElementById( "crossSellForm" ) )noneBlock( "crossSellForm!0" )
  }
  else
  {
    noneBlock( "crossSellForm!1" );
  }

  // hide/show the nearby airport fields
  noneBlock( "nearbyAirportForm!1" );

  // hide/show the date options Section
  noneBlock( "tfDF!1" );

  // hide/show the date radio buttons
  noneBlock( "idRadioContainer!1" );
  if( document.getElementById( "idExactLi" ) )noneBlock( "idExactLi!1" );
  if( document.getElementById( "idFlexibleLi" ) )noneBlock( "idFlexibleLi!1" );
  if( document.getElementById( "idOpenLi" ) )noneBlock( "idOpenLi!1" );


  // hide/show the date fields
  noneBlock( "idExactDates!1" );     // exact dates for roundtrip
  noneBlock( "idPlusMinusDates!0" ); // plus minus dates for roundtrip
  if( document.getElementById( "idFlexibleDates" ) )noneBlock( "idFlexibleDates!0" );
 
  noneBlock( "oneWayForm!0" );       // exact dates for oneway

  // hide/show the Preference Option fields
  noneBlock( "idAdditionalOptions!1" ); // all Preferences
  noneBlock( "tfMore!1" );              // COS/FareType
  noneBlock( "tfConnections!1" );
  noneBlock( "idFareTypeLabel!4" );
  noneBlock( "idFareTypeValue!4" );
  setVisibility( "idClassOfServiceLabel!1" );
  setVisibility( "idClassOfServiceValue!1" );


  // set the font for the flight type buttons
  cssSwitch( "roundtripRadio&SelectRadioFont" );
  cssSwitch( "oneWayRadio&NSelectRadioFont" );
  cssSwitch( "multiCityRadio&NSelectRadioFont" );

  // set the font for the cross sell fields
  if( document.getElementById( "idAirOnly" ) )cssSwitch( "idAirOnly&formBold");
  if( document.getElementById( "idAirPlusHotel" ) )cssSwitch( "idAirPlusHotel&");
  
  // set the background for the date radio buttons
  if( document.getElementById( "idExactLi" ) )cssSwitch( "idExactLi&datesSelectRadioBG");
  if( document.getElementById( "idFlexibleLi" ) )cssSwitch( "idFlexibleLi&datesNSelectRadioBG");
  if( document.getElementById( "idOpenLi" ) )cssSwitch( "idOpenLi&datesNSelectRadioBG");


  // set the font for the date radio buttons
  if( document.getElementById( "idExactRadio" ) )cssSwitch( "idExactRadio&SelectRadioFont");
  if( document.getElementById( "idFlexibleRadio" ) )cssSwitch( "idFlexibleRadio&NSelectRadioFont");
  if( document.getElementById( "idOpenRadio" ) )cssSwitch( "idOpenRadio&NSelectRadioFont");


  // set the background for the date options
  if( document.getElementById( "tfDateFlexibility" ) )cssSwitch( "tfDateFlexibility&selectedBG");

  // set the section numbers
  fltrObj( "step4|4" );
  fltrObj( "step5|5" );


  // set nextAction value
  form.nextAction.value = 'airOnly&breadcrumbStart=1';


  setButtonText( );
}


/*
 * Setup Search Scenario 2
 *   RoundTrip      selected
 *   CrossSell      selected
 *   Nearby Airport not selected
 *   Exact Dates    selected
 */
function setupSearchScenario2()
{
  //alert( 'in setupSearchScenario2' );

  // show/hide the appropriate Origin/Destination fields
  noneBlock( "roundtripForm!1" );     // oneway and roundtrip origin/destination
  noneBlock( "multiCityForm!0" );     // multicity origin/destination

  // the nearbyAirportPanel contains the nearby checkbox and crosssell radios
  noneBlock( "nearbyAirportPanel!1" );

  // hide/show the cross sell fields
  noneBlock( "crossSellForm!1" );

  // hide/show the nearby airport fields
  noneBlock( "nearbyAirportForm!0" );

  // hide/show the date options Section
  noneBlock( "tfDF!1" );

  // hide/show the date radio buttons
  noneBlock( "idRadioContainer!0" );
  noneBlock( "idExactLi!0" );
  if( document.getElementById( "idFlexibleLi" ) )noneBlock( "idFlexibleLi!0" );
  if( document.getElementById( "idOpenLi" ) )noneBlock( "idOpenLi!0" );


  // hide/show the date fields
  noneBlock( "idExactDates!1" );     // exact dates for roundtrip
  noneBlock( "idPlusMinusDates!0" ); // plus minus dates for roundtrip
  if( document.getElementById( "idFlexibleDates" ) )noneBlock( "idFlexibleDates!0" );
  noneBlock( "oneWayForm!0" );       // exact dates for oneway


  // hide/show the Preference Option fields
  noneBlock( "idAdditionalOptions!0" ); // all Preferences
  noneBlock( "tfMore!0" );              // COS/FareType
  noneBlock( "tfConnections!0" );
  setVisibility( "idClassOfServiceLabel!0" );
  setVisibility( "idClassOfServiceValue!0" );


  // set the font for the flight type buttons
  cssSwitch( "roundtripRadio&SelectRadioFont" );
  cssSwitch( "oneWayRadio&NSelectRadioFont" );
  cssSwitch( "multiCityRadio&NSelectRadioFont" );

  // set the font for the cross sell fields
  if( document.getElementById( "idAirOnly" ) )cssSwitch( "idAirOnly&");
  if( document.getElementById( "idAirPlusHotel" ) )cssSwitch( "idAirPlusHotel&formBold");

  // set the background for the date radio buttons
  if( document.getElementById( "idExactLi" ) )cssSwitch( "idExactLi&datesSelectRadioBG");
  if( document.getElementById( "idFlexibleLi" ) )cssSwitch( "idFlexibleLi&datesNSelectRadioBG");
  if( document.getElementById( "idOpenLi" ) )cssSwitch( "idOpenLi&datesNSelectRadioBG");


  // set the font for the date radio buttons
  if( document.getElementById( "idExactRadio" ) )cssSwitch( "idExactRadio&SelectRadioFont");
  if( document.getElementById( "idFlexibleRadio" ) )cssSwitch( "idFlexibleRadio&NSelectRadioFont");
  if( document.getElementById( "idOpenRadio" ) )cssSwitch( "idOpenRadio&NSelectRadioFont");

 
  // set the background for the date options
  cssSwitch( "tfDateFlexibility&" );


  // set the section numbers
  fltrObj( "step4|4" );
  fltrObj( "step5|5" );


  // set nextAction value
  form.nextAction.value = 'airPlusHotel&breadcrumbStart=1';

  setButtonText( );
}

/*
 * Setup Search Scenario 3
 *   RoundTrip      selected
 *   CrossSell      not selected
 *   Nearby Airport selected
 *   Exact Dates    selected
 */
function setupSearchScenario3()
{
  //alert( 'in setupSearchScenario3' );

  // show/hide the appropriate Origin/Destination fields
  noneBlock( "roundtripForm!1" );     // oneway and roundtrip origin/destination
  noneBlock( "multiCityForm!0" );     // multicity origin/destination

  // the nearbyAirportPanel contains the nearby checkbox and crosssell radios
  noneBlock( "nearbyAirportPanel!1" );

  // hide/show the cross sell fields
  noneBlock( "crossSellForm!0" );

  // hide/show the nearby airport fields
  noneBlock( "nearbyAirportForm!1" );

  // hide/show the date options Section
  noneBlock( "tfDF!1" );

  // hide/show the date radio buttons
  noneBlock( "idRadioContainer!0" );
  noneBlock( "idExactLi!0" );
  if( document.getElementById( "idFlexibleLi" ) )noneBlock( "idFlexibleLi!0" );
  if( document.getElementById( "idOpenLi" ) )noneBlock( "idOpenLi!0" );


  // hide/show the date fields
  noneBlock( "idExactDates!1" );     // exact dates for roundtrip
  noneBlock( "idPlusMinusDates!0" ); // plus minus dates for roundtrip
  if( document.getElementById( "idFlexibleDates" ) )noneBlock( "idFlexibleDates!0" );
  
  noneBlock( "oneWayForm!0" );       // exact dates for oneway

  // hide/show the Preference Option fields
  noneBlock( "idAdditionalOptions!1" ); // all Preferences
  noneBlock( "tfMore!1" );              // COS/FareType
  noneBlock( "tfConnections!0" );
  noneBlock( "idFareTypeLabel!4" );
  noneBlock( "idFareTypeValue!4" );
  setVisibility( "idClassOfServiceLabel!0" );
  setVisibility( "idClassOfServiceValue!0" );


  // set the font for the flight type buttons
  cssSwitch( "roundtripRadio&SelectRadioFont" );
  cssSwitch( "oneWayRadio&NSelectRadioFont" );
  cssSwitch( "multiCityRadio&NSelectRadioFont" );

  // set the font for the cross sell fields
  if( document.getElementById( "idAirOnly" ) )cssSwitch( "idAirOnly&formBold");
  if( document.getElementById( "idAirPlusHotel" ) )cssSwitch( "idAirPlusHotel&");

  // set the background for the date radio buttons
  if( document.getElementById( "idExactLi" ) )cssSwitch( "idExactLi&datesSelectRadioBG");
  if( document.getElementById( "idFlexibleLi" ) )cssSwitch( "idFlexibleLi&datesNSelectRadioBG");
  if( document.getElementById( "idOpenLi" ) )cssSwitch( "idOpenLi&datesNSelectRadioBG");


  // set the font for the date radio buttons
  if( document.getElementById( "idExactRadio" ) )cssSwitch( "idExactRadio&SelectRadioFont");
  if( document.getElementById( "idFlexibleRadio" ) )cssSwitch( "idFlexibleRadio&NSelectRadioFont");
  if( document.getElementById( "idOpenRadio" ) )cssSwitch( "idOpenRadio&NSelectRadioFont");


  // set the background for the date options
  cssSwitch( "tfDateFlexibility&" );


  // set the section numbers
  fltrObj( "step4|4" );
  fltrObj( "step5|5" );


  // set nextAction value
  form.nextAction.value = 'airOnly&breadcrumbStart=1';

  setButtonText( );
}

/*
 * Setup Search Scenario 4
 *   RoundTrip         selected
 *   Plus/Minus Dates  selected
 */
function setupSearchScenario4()
{
  //alert( 'in setupSearchScenario4' );

  // show/hide the appropriate Origin/Destination fields
  noneBlock( "roundtripForm!1" );     // oneway and roundtrip origin/destination
  noneBlock( "multiCityForm!0" );     // multicity origin/destination

  // the nearbyAirportPanel contains the nearby checkbox and crosssell radios
  noneBlock( "nearbyAirportPanel!0" );

  // hide/show the cross sell fields
  noneBlock( "crossSellForm!0" );

  // hide/show the nearby airport fields
  noneBlock( "nearbyAirportForm!0" );

  // hide/show the date options Section
  noneBlock( "tfDF!1" );

  // hide/show the date radio buttons
  noneBlock( "idRadioContainer!1" );
  noneBlock( "idExactLi!1" );
  if( document.getElementById( "idFlexibleLi" ) )noneBlock( "idFlexibleLi!1" );
  if( document.getElementById( "idOpenLi" ) )noneBlock( "idOpenLi!1" );


  // hide/show the date fields
  noneBlock( "idExactDates!0" );     // exact dates for roundtrip
  noneBlock( "idPlusMinusDates!1" ); // plus minus dates for roundtrip
  if( document.getElementById( "idFlexibleDates" ) )noneBlock( "idFlexibleDates!0" );
  noneBlock( "oneWayForm!0" );       // exact dates for oneway

  // hide/show the Preference Option fields
  noneBlock( "idAdditionalOptions!1" ); // all Preferences
  noneBlock( "tfMore!1" );              // COS/FareType
  noneBlock( "tfConnections!0" );
  noneBlock( "idFareTypeLabel!4" );
  noneBlock( "idFareTypeValue!4" );
  setVisibility( "idClassOfServiceLabel!0" );
  setVisibility( "idClassOfServiceValue!0" );


  // set the font for the flight type buttons
  cssSwitch( "roundtripRadio&SelectRadioFont" );
  cssSwitch( "oneWayRadio&NSelectRadioFont" );
  cssSwitch( "multiCityRadio&NSelectRadioFont" );

  // set the font for the cross sell fields
  if( document.getElementById( "idAirOnly" ) )cssSwitch( "idAirOnly&formBold");
  if( document.getElementById( "idAirPlusHotel" ) )cssSwitch( "idAirPlusHotel&");
  
  // set the background for the date radio buttons
   if( document.getElementById( "idExactLi" ) )cssSwitch( "idExactLi&datesNSelectRadioBG");
  if( document.getElementById( "idFlexibleLi" ) )cssSwitch( "idFlexibleLi&datesSelectRadioBG");
  if( document.getElementById( "idOpenLi" ) )cssSwitch( "idOpenLi&datesNSelectRadioBG");


  // set the font for the date radio buttons
  if( document.getElementById( "idExactRadio" ) )cssSwitch( "idExactRadio&NSelectRadioFont");
  if( document.getElementById( "idFlexibleRadio" ) )cssSwitch( "idFlexibleRadio&SelectRadioFont");
  if( document.getElementById( "idOpenRadio" ) )cssSwitch( "idOpenRadio&NSelectRadioFont");


  // set the background for the date options
  cssSwitch( "tfDateFlexibility&selectedBG" );


  // set the section numbers
  fltrObj( "step4|4" );
  fltrObj( "step5|5" );


  // set nextAction value
  form.nextAction.value = 'airOnly&breadcrumbStart=1';

  setButtonText( );
}


/*
 * Setup Search Scenario 5
 *   RoundTrip      selected
 *   Open Dates     selected
 */
function setupSearchScenario5()
{
  //alert( 'in setupSearchScenario5' );

  // show/hide the appropriate Origin/Destination fields
  noneBlock( "roundtripForm!1" );     // oneway and roundtrip origin/destination
  noneBlock( "multiCityForm!0" );     // multicity origin/destination

  // the nearbyAirportPanel contains the nearby checkbox and crosssell radios
  noneBlock( "nearbyAirportPanel!0" );

  // hide/show the cross sell fields
  noneBlock( "crossSellForm!0" );

  // hide/show the nearby airport fields
  noneBlock( "nearbyAirportForm!0" );

  // hide/show the date options Section
  noneBlock( "tfDF!1" );

  // hide/show the date radio buttons
  noneBlock( "idRadioContainer!1" );
  noneBlock( "idExactLi!1" );
  if( document.getElementById( "idFlexibleLi" ) )noneBlock( "idFlexibleLi!1" );
  if( document.getElementById( "idOpenLi" ) )noneBlock( "idOpenLi!1" );

  // hide/show the date fields
  noneBlock( "idExactDates!0" );     // exact dates for roundtrip
  noneBlock( "idPlusMinusDates!0" ); // plus minus dates for roundtrip
  if( document.getElementById( "idFlexibleDates" ) )noneBlock( "idFlexibleDates!1" );
  noneBlock( "oneWayForm!0" );       // exact dates for oneway

  // hide/show the Preference Option fields
  noneBlock( "idAdditionalOptions!1" ); // all Preferences
  noneBlock( "tfMore!0" );              // COS/FareType
  noneBlock( "tfConnections!0" );
  noneBlock( "idFareTypeLabel!0" );
  noneBlock( "idFareTypeValue!0" );
  setVisibility( "idClassOfServiceLabel!0" );
  setVisibility( "idClassOfServiceValue!0" );


  // set the font for the flight type buttons
  cssSwitch( "roundtripRadio&SelectRadioFont" );
  cssSwitch( "oneWayRadio&NSelectRadioFont" );
  cssSwitch( "multiCityRadio&NSelectRadioFont" );

  // set the font for the cross sell fields
  if( document.getElementById( "idAirOnly" ) )cssSwitch( "idAirOnly&formBold");
  if( document.getElementById( "idAirPlusHotel" ) )cssSwitch( "idAirPlusHotel&");
  
  // set the background for the date radio buttons
  if( document.getElementById( "idExactLi" ) )cssSwitch( "idExactLi&datesNSelectRadioBG");
  if( document.getElementById( "idFlexibleLi" ) )cssSwitch( "idFlexibleLi&datesNSelectRadioBG");
  if( document.getElementById( "idOpenLi" ) )cssSwitch( "idOpenLi&datesSelectRadioBG");

  // set the font for the date radio buttons
  if( document.getElementById( "idExactRadio" ) )cssSwitch( "idExactRadio&NSelectRadioFont");
  if( document.getElementById( "idFlexibleRadio" ) )cssSwitch( "idFlexibleRadio&NSelectRadioFont");
  if( document.getElementById( "idOpenRadio" ) )cssSwitch( "idOpenRadio&SelectRadioFont");

  // set the background for the date options
  cssSwitch( "tfDateFlexibility&selectedBG" );


  // set the section numbers
  fltrObj( "step4|4" );
  fltrObj( "step5|5" );


  // set nextAction value
  form.nextAction.value = 'airOnly&breadcrumbStart=1';

  setButtonText( );
}

/*
 * Setup Search Scenario 6
 *   OneWay         selected
 *   Exact Dates    selected
 */
function setupSearchScenario6()
{
  // show/hide the appropriate Origin/Destination fields
  noneBlock( "roundtripForm!1" );     // oneway and roundtrip origin/destination
  noneBlock( "multiCityForm!0" );     // multicity origin/destination

  // the nearbyAirportPanel contains the nearby checkbox and crosssell radios
  noneBlock( "nearbyAirportPanel!0" );

  // hide/show the cross sell fields
  noneBlock( "crossSellForm!0" );

  // hide/show the nearby airport fields
  noneBlock( "nearbyAirportForm!0" );

  // hide/show the date options Section
  noneBlock( "tfDF!1" );

  // hide/show the date radio buttons
  noneBlock( "idRadioContainer!1" );
  if( document.getElementById( "idExactLi" ) )noneBlock( "idExactLi!1" );
  if( document.getElementById( "idFlexibleLi" ) )noneBlock( "idFlexibleLi!0" );
  if( document.getElementById( "idOpenLi" ) )noneBlock( "idOpenLi!1" );


  // hide/show the date fields
  if( document.getElementById( "idExactDates" ) )noneBlock( "idExactDates!0" );
  if( document.getElementById( "idPlusMinusDates" ) )noneBlock( "idPlusMinusDates!0" );
  if( document.getElementById( "idFlexibleDates" ) )noneBlock( "idFlexibleDates!0" );
  noneBlock( "oneWayForm!1" );       // exact dates for oneway

  // hide/show the Preference Option fields
  noneBlock( "idAdditionalOptions!1" ); // all Preferences
  noneBlock( "tfMore!1" );              // COS/FareType
  noneBlock( "tfConnections!1" );
  noneBlock( "idFareTypeLabel!4" );
  noneBlock( "idFareTypeValue!4" );
  setVisibility( "idClassOfServiceLabel!1" );
  setVisibility( "idClassOfServiceValue!1" );


  // set the font for the flight type buttons
  cssSwitch( "roundtripRadio&NSelectRadioFont" );
  cssSwitch( "oneWayRadio&SelectRadioFont" );
  cssSwitch( "multiCityRadio&NSelectRadioFont" );

  // set the font for the cross sell fields
  if( document.getElementById( "idAirOnly" ) )cssSwitch( "idAirOnly&formBold");
  if( document.getElementById( "idAirPlusHotel" ) )cssSwitch( "idAirPlusHotel&");

  // set the background for the date radio buttons
  if( document.getElementById( "idExactLi" ) )cssSwitch( "idExactLi&datesSelectRadioBG");
  if( document.getElementById( "idFlexibleLi" ) )cssSwitch( "idFlexibleLi&datesNSelectRadioBG");
  if( document.getElementById( "idOpenLi" ) )cssSwitch( "idOpenLi&datesNSelectRadioBG");


  // set the font for the date radio buttons
  if( document.getElementById( "idExactRadio" ) )cssSwitch( "idExactRadio&SelectRadioFont");
  if( document.getElementById( "idFlexibleRadio" ) )cssSwitch( "idFlexibleRadio&NSelectRadioFont");
  if( document.getElementById( "idOpenRadio" ) )cssSwitch( "idOpenRadio&NSelectRadioFont");

  // set the background for the date options
  cssSwitch( "tfDateFlexibility&selectedBG" );


  // set the section numbers
  fltrObj( "step4|4" );
  fltrObj( "step5|5" );


  // set nextAction value
  form.nextAction.value = 'airOnly&breadcrumbStart=1';

  setButtonText( );
}

/*
 * Setup Search Scenario 7
 *   OneWay         selected
 *   Open Dates     selected
 */
function setupSearchScenario7()
{
  //alert( 'in setupSearchScenario7' );

  // show/hide the appropriate Origin/Destination fields
  noneBlock( "roundtripForm!1" );     // oneway and roundtrip origin/destination
  noneBlock( "multiCityForm!0" );     // multicity origin/destination

  // the nearbyAirportPanel contains the nearby checkbox and crosssell radios
  noneBlock( "nearbyAirportPanel!0" );

  // hide/show the cross sell fields
  noneBlock( "crossSellForm!0" );

  // hide/show the nearby airport fields
  noneBlock( "nearbyAirportForm!0" );

  // hide/show the date options Section
  noneBlock( "tfDF!1" );

  // hide/show the date radio buttons
  noneBlock( "idRadioContainer!1" );
  noneBlock( "idExactLi!1" );
  if( document.getElementById( "idFlexibleLi" ) )noneBlock( "idFlexibleLi!0" );
  if( document.getElementById( "idOpenLi" ) )noneBlock( "idOpenLi!1" );


  // hide/show the date fields
  noneBlock( "idExactDates!0" );     // exact dates for roundtrip
  noneBlock( "idPlusMinusDates!0" ); // plus minus dates for roundtrip
  if( document.getElementById( "idFlexibleDates" ) )noneBlock( "idFlexibleDates!1" );
  
  noneBlock( "oneWayForm!0" );       // exact dates for oneway

  // hide/show the Preference Option fields
  noneBlock( "idAdditionalOptions!1" ); // all Preferences
  noneBlock( "tfMore!0" );              // COS/FareType
  noneBlock( "tfConnections!0" );
  noneBlock( "idFareTypeLabel!0" );
  noneBlock( "idFareTypeValue!0" );
  setVisibility( "idClassOfServiceLabel!0" );
  setVisibility( "idClassOfServiceValue!0" );


  // set the font for the flight type buttons
  cssSwitch( "roundtripRadio&NSelectRadioFont" );
  cssSwitch( "oneWayRadio&SelectRadioFont" );
  cssSwitch( "multiCityRadio&NSelectRadioFont" );

  // set the font for the cross sell fields
  if( document.getElementById( "idAirOnly" ) )cssSwitch( "idAirOnly&formBold");
  if( document.getElementById( "idAirPlusHotel" ) )cssSwitch( "idAirPlusHotel&");
  
  // set the background for the date radio buttons
  if( document.getElementById( "idExactLi" ) )cssSwitch( "idExactLi&datesNSelectRadioBG");
  if( document.getElementById( "idFlexibleLi" ) )cssSwitch( "idFlexibleLi&datesNSelectRadioBG");
  if( document.getElementById( "idOpenLi" ) )cssSwitch( "idOpenLi&datesSelectRadioBG");

  // set the font for the date radio buttons
  if( document.getElementById( "idExactRadio" ) )cssSwitch( "idExactRadio&NSelectRadioFont");
  if( document.getElementById( "idFlexibleRadio" ) )cssSwitch( "idFlexibleRadio&NSelectRadioFont");
  if( document.getElementById( "idOpenRadio" ) )cssSwitch( "idOpenRadio&SelectRadioFont");


  // set the background for the date options
  cssSwitch( "tfDateFlexibility&selectedBG" );


  // set the section numbers
  fltrObj( "step4|4" );
  fltrObj( "step5|5" );


  // set nextAction value
  form.nextAction.value = 'airOnly&breadcrumbStart=1';

  setButtonText( );
}

/*
 * Setup Search Scenario 8
 *   MultiCity      selected
 */
function setupSearchScenario8()
{
  //alert( 'in setupSearchScenario8' );

  // show/hide the appropriate Origin/Destination fields
  noneBlock( "roundtripForm!0" );     // oneway and roundtrip origin/destination
  noneBlock( "multiCityForm!1" );     // multicity origin/destination

  // the nearbyAirportPanel contains the nearby checkbox and crosssell radios
  noneBlock( "nearbyAirportPanel!0" );

  // hide/show the cross sell fields
  noneBlock( "crossSellForm!0" );

  // hide/show the nearby airport fields
  noneBlock( "nearbyAirportForm!0" );

  // hide/show the date options Section
  noneBlock( "tfDF!0" );

  // hide/show the date radio buttons
  noneBlock( "idRadioContainer!1" );
  noneBlock( "idExactLi!1" );
  if( document.getElementById( "idFlexibleLi" ) )noneBlock( "idFlexibleLi!1" );
  if( document.getElementById( "idOpenLi" ) )noneBlock( "idOpenLi!1" );


  // hide/show the date fields
  noneBlock( "idExactDates!0" );     // exact dates for roundtrip
  noneBlock( "idPlusMinusDates!0" ); // plus minus dates for roundtrip
  if( document.getElementById( "idFlexibleDates" ) )noneBlock( "idFlexibleDates!0" );
 
  noneBlock( "oneWayForm!0" );       // exact dates for oneway

  // hide/show the Preference Option fields
  noneBlock( "idAdditionalOptions!1" ); // all Preferences
  noneBlock( "tfMore!1" );              // COS/FareType
  noneBlock( "tfConnections!1" );
  noneBlock( "idFareTypeLabel!4" );
  noneBlock( "idFareTypeValue!4" );
  setVisibility( "idClassOfServiceLabel!1" );
  setVisibility( "idClassOfServiceValue!1" );


  // set the font for the flight type buttons
  cssSwitch( "roundtripRadio&NSelectRadioFont" );
  cssSwitch( "oneWayRadio&NSelectRadioFont" );
  cssSwitch( "multiCityRadio&SelectRadioFont" );

  // set the font for the cross sell fields
//  cssSwitch( "idAirOnly&formBold" );
//  cssSwitch( "idAirPlusHotel&" );

  // set the background for the date radio buttons
//  cssSwitch( "idExactLi&datesSelectRadioBG" );
//  cssSwitch( "idFlexibleLi&datesNSelectRadioBG" );
//  cssSwitch( "idOpenLi&datesNSelectRadioBG");

  // set the font for the date radio buttons
//  cssSwitch( "idExactRadio&SelectRadioFont" );
//  cssSwitch( "idFlexibleRadio&NSelectRadioFont" );
//  cssSwitch( "idOpenRadio&NSelectRadioFont");

  // set the background for the date options
//  cssSwitch( "tfDateFlexibility&selectedBG" );


  // set the section numbers
  fltrObj( "step4|3" );
  fltrObj( "step5|4" );


  // set nextAction value
  form.nextAction.value = 'airOnly&breadcrumbStart=1';

  setButtonText( );
}

/*
 * Setup Search Scenario 9
 *   OneWay         selected
 *   Exact Dates    selected
 *   No tabs 
 */
function setupSearchScenario9()
{
  setupSearchScenario6();

//  noneBlock( "roundtripForm!1" );     // oneway and roundtrip origin/destination
//  noneBlock( "multiCityForm!0" );     // multicity origin/destination
//  noneBlock( "oneWayForm!1" );       // exact dates for oneway
  // hide/show the date options Section
//  noneBlock( "tfDF!0" );

}

function hasDateTypeSelectAsRadioButton()
{
	result = false;
	dateTypeSelect = document.AirSearchForm.dateTypeSelect;
	if (  typeof( dateTypeSelect )  != 'undefined' &&  typeof( dateTypeSelect.length ) === 'number' )
		result = true;
	return result;
}

function hasNearbyAirportsCheckbox()
{
	result = false;
	nearbyAirportsCheckbox = document.AirSearchForm.nearbyAirports;
	if (  typeof( nearbyAirportsCheckbox )  != 'undefined'  )
		result = true;
	return result;
}

