var BestFares_Storage = Class.create({
  _storage: false,
  _client: false,
  _currentDepartureCity: 0,
  _currentDestinationCity: 0,
  _uniqueElement: false,
  _flagInitStorage: {departureCity: false, destinationCity: false},
  getCurrentDepartureCity: function() {
      return this._currentDepartureCity;
  },
  getCurrentDestinationCity: function() {
      return this._currentDestinationCity;
  },
  _storageName: 'bestFaresStorage',
  initialize: function() {
      document.observe('dom:loaded', this._init.bind(this));
  },
  _conf: {
      url: {
          loadSrorage: false
      }
    },
  _init: function() {
      this._client = $H(String(window.location.href).toQueryParams()).get('client');
      this._createUniqueElement();
      this._initObserver();
      this._initConf();
      this._loadBestFares();
      
  },
  _initObserver: function() {
      document.observe('bestFaresDepartureCityStorage:load',
                       this._loadCompleteDepartureCityStorage.bind(this));
                       
      document.observe('bestFaresDestinationCityStorage:load',
                       this._loadCompleteDestinationCityStorage.bind(this));
      document.observe('tabs:click', function(e){
        if (e.memo.activeTab != 'flightTab') $('bestFaresView').hide()
      }.bind(this))
  },
  _loadCompleteDepartureCityStorage: function() {
      this._flagInitStorage.departureCity = true;
      this._startView();
  },
  _loadCompleteDestinationCityStorage: function() {
      this._flagInitStorage.destinationCity = true;
      this._startView();
  },
  _startView: function() {
      if (!this._flagInitStorage.departureCity || !this._flagInitStorage.destinationCity) {
          return false;
      }
      var storageName = this.getStorageName();
      
      setTimeout(function() {
          $(this._uniqueElement).fire(storageName + ':renderView', {});
      }.bind(this), 0);
  },
  
  
  
  _initConf: function() {
      this._initUrl();
  },
  _initUrl: function() {
      var urlPrefix;
      this._conf
          .url
          .loadSrorage = "./?action=BestFaresAjax.flightsBestFares"
                          
           urlPrefix = window.location.search != ''
                       && window.location.search.charAt(0) == '?'
                       ? window.location.search.substring(1)
                       : window.location.search;
                          
           this._conf.url.loadSrorage = this._conf.url.loadSrorage
                                        + '&'
                                        + urlPrefix;
  },
  _loadBestFares: function() {
      var request;
      request = new Ajax.Request(
          this._conf.url.loadSrorage,
          {
              onComplete: this._completeLoadStorage.bind(this),
              onException: function(r, e) {console.log(e);},
              onFailure: function (e, r) {console.log(e);}
          }
      );
  },
  _completeLoadStorage: function(transport) {
      if (!transport.responseJSON) {
          return false;
      }
      
      this._storage = transport.responseJSON;
      
      if (this._isEmptyBestFares()) {
          return false;
      }
      
      this._flightsBestFeresStorogoLoadComplete();
  },
  _isEmptyBestFares: function() {
        if ($A(this._storage.storage.bestFares).size() > 0) {
            return false;
        } else {
            return true;
        }
  },
  _flightsBestFeresStorogoLoadComplete: function() {
      var storageName = this.getStorageName();
      $(this._uniqueElement).fire(storageName + ':load',
                                  {
                                      storage: this
                                  });
  },
  getStorageName: function() {
      return this._storageName;
  },
  getAllDepartureCitiesId: function() {
      var cities;
      cities = this._storage.index.allDepartureCityId;
      return cities;
  },
  getAllDestinationCitiesId: function() {
      var cities;
      cities = this._storage.index.allDestinationCityId;
      return cities;
  },
  getCurrentDepartureCity: function() {
      return this._currentDepartureCity;
  },
  getCurrentDestinationCity: function() {
      return this._currentDestinationCity;
  },
  setCurrentDestinationCity: function(cityId) {
      var storageName = this.getStorageName();
      this._currentDestinationCity = cityId;
      $(this._uniqueElement).fire(storageName + ':changeCurrentDestinationCity',
                                  {
                                      currentDestinationCityId: this._currentDestinationCity
                                  });
      
      this._changeCurrentCity();
  },
  setCurrentDepartureCity: function(cityId) {
      var storageName = this.getStorageName();
      this._currentDepartureCity = cityId;
      $(this._uniqueElement).fire(storageName + ':changeCuurentDepartureCity',
                                  {
                                      currentDepartureCityId: this._currentDepartureCity
                                  });
      this._changeCurrentCity();
  },
  _changeCurrentCity: function() {
      var storageName = this.getStorageName();
      $(this._uniqueElement).fire(storageName + ':changeCurrentCity',
                                  {
                                      currentDepartureCityId: this._currentDepartureCity,
                                      currentDestinationCityId: this._currentDestinationCity
                                  });
  },
  getCityInfo: function(cityId) {
      return this._storage.storage.citys[cityId];
  },
  getBestFare: function(bestFaresId) {
      return this._storage.storage.bestFares[bestFaresId];
  },
  getCriteria: function(criteriaId) {
    return this._storage.storage.criterias[criteriaId];
  },
  getVendor: function(vendorId) {
      return this._storage.storage.vendors[vendorId];
  },
  getAirline: function(airlineId) {
      return this._storage.storage.airlines[airlineId];
  },
  getCurrency: function(currencyId) {
      return this._storage.storage.currencys[currencyId];
  },
  getPrice: function(priceId) {
      return this._storage.storage.prices[priceId];
  },
  getBestFaresIdByDirections: function(departureCityId, destinationCityId) {
      return this._storage
                 .index
                 .directionCity2bestFaresId[departureCityId][destinationCityId];
  }

}, Control_Abstract);
var bestFaresStorage = new BestFares_Storage();

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







var BestFares_CityStorage_Abstract = Class.create({
  _storage: false,
  _initCities: function(citiesId) {
      this._cities = citiesId;
  },
  _init: function(event) {
      this._createUniqueElement();
      this._storage = event.memo.storage;
      
  },
  setCurrentCity: function(cityId) {
      if (this._currentCity == cityId) {
          return false;
      }
      this._currentCity = cityId;
      this._refreshStorage();
      return true;
  },
  getStorageName: function() {
      return this._storageName;
  },

  getCities: function() {
      return this._cities;
  },
  getCityInfo: function(cityId) {
      return this._storage.getCityInfo(cityId);
  },
  
  getCurrentCity: function() {
      return this._currentCity;
  },
  
  getBestFareByDirection: function(depCityId, destCityId) {
      return this._storage._storage.index.directionCity2bestFaresId[depCityId][destCityId]
  },
  
  getBestFareInfo: function(bestFareId) {
      return this._storage._storage.storage.bestFares[bestFareId];
  },
  getCityInfo: function(cityId) {
    return this._storage._storage.storage.citys[cityId];
  },
  
  getCriteriaInfo: function(criteriaId) {
    return this._storage._storage.storage.criterias[criteriaId];
  },
  getPriceInfo: function(priceId) {
      return this._storage._storage.storage.prices[priceId];
  },
  getCurrencyInfo: function(currencyId) {
      return this._storage._storage.storage.currencys[currencyId];
  },
  _storageLoadComplete: function() {
      var storageName = this.getStorageName();
      $(this._uniqueElement).fire(storageName + ':load',
                                  {
                                      storage: this
                                  });
  }
  
  
  
}, Control_Abstract);


//****************************************************************************//
var BestFares_CityStorage_Departure_Abstract = Class.create(BestFares_CityStorage_Abstract, {
  _cities: false,
  _currentCity: false,
  _uniqueElement: false,
  _storageName: 'bestFaresDepartureCityStorage',
  initialize: function() {
      document.observe('bestFaresStorage:load', this._init.bind(this));
  },
  _init: function($super, event) {
      $super(event);
      this._initCities(this._storage.getAllDepartureCitiesId());
      this._initObserver();
      
      this._currentCity = this._cities.first();
      this._storage._currentDepartureCity = this._currentCity;
      this._storageLoadComplete();
  },
  _initObserver: function() {
      document.observe('bestFaresStorage:changeCurrentDestinationCity',
                       this._changeCurrentDestinationCity
                           .bind(this));
  },
  _changeCurrentDestinationCity: function(event) {
      if (this._typeStorage == 'master') {
          return;
      }
      var destCity = event.memo.currentDestinationCityId;
      this._cities = this._storage
                         .index
                         .destinationCityId2DepartureCityId[destCity];
      var storageName = this.getStorageName();
      $(this._uniqueElement).fire(storageName + ':refreshDestinationCitiesList',
                                  {
                                      storage: this._storage
                                  });
  },
  _refreshStorage: function() {
      this._storage.setCurrentDepartureCity(this._currentCity);
  },

  setCity: function(cityId) {
      this._storage.setCurrentDepartureCity(cityId);
  }
  

}, Control_Abstract);

//****************************************************************************//
var BestFares_CityStorage_Departure_Master = Class.create(BestFares_CityStorage_Departure_Abstract, {
    _typeStorage: 'master'
});


var bestFaresCityStorageDepartureMaster = new BestFares_CityStorage_Departure_Master();








//****************************************************************************//
var BestFares_CityStorage_Destination_Abstract = Class.create(BestFares_CityStorage_Abstract, {
  _storage: false,
  _cities: false,
  _currentCity: false,
  _uniqueElement: false,
  _storageName: 'bestFaresDestinationCityStorage',
  initialize: function() {
      document.observe('bestFaresDepartureCityStorage:load', this._init.bind(this));
  },
  _init: function($super, event) {
      this._createUniqueElement();
      this._storage = event.memo.storage._storage;
      var depCity;
      
      depCity = this._storage.getCurrentDepartureCity();
      
      this._initCities(this._storage._storage.index.departureCityId2DestinationCityId[depCity]);
      this._initObserver();
      
      this._currentCity = this._cities.first();
      this._storage._currentDestinationCity = this._currentCity;
      this._storageLoadComplete();
  },
  _initObserver: function() {
      document.observe('bestFaresStorage:changeCuurentDepartureCity',
                       this._changeDepartureCity
                           .bind(this));
  },
  _changeDepartureCity: function(event) {
      if (this._typeStorage == 'master') {
          return;
      }
      var departCity = event.memo.currentDepartureCityId;
      this._cities = this._storage
                         ._storage
                         .index
                         .departureCityId2DestinationCityId[departCity];
                         
      var storageName = this.getStorageName();
      $(this._uniqueElement).fire(storageName + ':refreshDepartureCitiesList',
                                  {
                                      storage: this._storage
                                  });
  },
  _refreshStorage: function() {
      this._storage.setCurrentDestinationCity(this._currentCity);
  },
  getCurrentDepCity: function() {
      return this._storage.getCurrentDepartureCity();
  },
  setCity: function(cityId) {
    
      this._storage.setCurrentDestinationCity(cityId);
  }
}, Control_Abstract);




//****************************************************************************//
var BestFares_CityStorage_Destination_Slave = Class.create(BestFares_CityStorage_Destination_Abstract, {
    _typeStorage: 'slave'
});


var bestFaresCityStorageDestinationSlave = new BestFares_CityStorage_Destination_Slave();



















//****************************************************************************//
var BestFares_View_Departure_Select = Class.create({
  _storage: false,
  _conf: {
      _elem: {
          select: false
      }
  },
  initialize: function() {
      document.observe('bestFaresDepartureCityStorage:load', this._init.bind(this));
  },
  _init: function(event) {
      this._storage = event.memo.storage;
      this._initConf();
      this._initObserver();
      
  },
  _initObserver: function() {
      document.observe('bestFaresStorage:renderView',
                       this._startRender
                           .bind(this));
                           
      $(this._conf
            ._elem
            .select).observe('change',
                             this._changeCity
                                 .bindAsEventListener(this));
  },
  _changeCity: function(event) {
      var cityId, currentCityId;
      cityId = $F($(this._conf._elem.select));
      this._storage.setCity(cityId);
  },
  _startRender: function() {
      this._createOptions();
  },
  _initConf: function() {
      this._initElem();
  },
  _initElem: function() {
      this._conf._elem.select = $('selectCity');
  },
  _createOptions: function() {
      var cities;
      cities = this._storage.getCities();
      cities.each(function(cityId) {
        var city = this._storage.getCityInfo(cityId);
        $(this._conf._elem.select).insert(
            new Element('option', 
                        {
                            value: cityId
                        }).update(city['name'])
        
        );
      }.bind(this));
  }
  
}, Control_Abstract);

var bestFaresViewDepartureSelect = new BestFares_View_Departure_Select();
























//****************************************************************************//
var BestFares_View_Destination_TableList = Class.create({
  _storage: false,
  _uniqueElement: false,
  _conf: {
      _elem: {
        rows: false,
        activeTrDiv: false
      },
      cssClass: {
          detectTable: false
      }
  },
  initialize: function() {
      
      document.observe('bestFaresDestinationCityStorage:load', this._init.bindAsEventListener(this));
  },
  
  
  
  _init: function(event) {
      this._createUniqueElement();
      this._storage = event.memo.storage;
      this._initConf();
      this._initObserver();
      
  },
  _initObserver: function() {
      document.observe('bestFaresStorage:renderView',
                       this._startRender
                           .bind(this));
      $A(this._conf
             ._elem
             .rows).invoke('observe',
                           'mouseover',
                           this._priceTdMouseOver
                               .bindAsEventListener(this));

      $(this._conf
            ._elem
            .rows).invoke('select',
                          'td.price').flatten()
                                     .invoke('observe', 'click', this._priceTdClick
                                                                     .bindAsEventListener(this));
                               
      
                           
      document.observe('bestFaresDestinationCityStorage:refreshDepartureCitiesList',
                       this._refreshDepartureCitiesList
                           .bind(this));
                           
                           
  },
  _priceTdClick: function(event) {
      var currentTr;
      if (!Event.element(event).hasClassName('priceFilled')) {
          return;
      }
      currentTr = $(Event.element(event)).up('tr');
      this._startRenderPriceDetails(currentTr);
      $(this._uniqueElement).fire('viewDestinationTableList:clickPrice');
  },
  _startRenderPriceDetails: function(currentTr) {
      var isPriceTd, currentTrId, bestFaresId;
      currentTrId = $(currentTr).identify();
      
      isPriceTd = String(currentTrId).include('bestFaresId_');
      if (!isPriceTd) {
          return;
      }
      var bestFareId = String(currentTrId).split('_').last();
      var bestFareInfo = this._storage.getBestFareInfo(bestFareId);
      var destinationCityId = bestFareInfo['destinationCityId'];
      
      this._storage.setCity(destinationCityId);
      
  },
  _refreshDepartureCitiesList: function(event) {
      this._clearBestFeresElements();
      this._renderBestFares();
      this._priceTdMouseOverAcivate($A(this._conf._elem.rows).first());
      this._startRenderPriceDetails($A(this._conf._elem.rows).first());
      $(this._uniqueElement).fire('viewDestinationTableList:activeFirstPrice');
  },
  
  _priceTdMouseOver: function(event) {
      var currentTr;
      currentTr = $(Event.element(event)).up('tr');
      this._priceTdMouseOverAcivate(currentTr);

  },
  _priceTdMouseOverAcivate: function(currentTr) {
      var isPriceTd, leftTr, topTr, currentTrId;
      currentTrId = $(currentTr).identify();
      isPriceTd = String(currentTrId).include('bestFaresId_');
      if (!isPriceTd) {
          return;
      }

      leftTr  = currentTr.cumulativeOffset()[0];
      topTr  = currentTr.cumulativeOffset()[1];
      
      
      $(this._conf._elem.activeTrDiv).setStyle({top: topTr + 'px', left: (leftTr-3)+ 'px'});
      if (!$(this._conf._elem.activeTrDiv).visible()) {
          $(this._conf._elem.activeTrDiv).show();
      }
  },
  
  _startRender: function(event) {
      this._renderBestFares();
  },
  _initConf: function() {
      this._initCssClass();
      this._initElem();
  },
  _initCssClass: function() {
        this._conf.cssClass.detectTable = 'flightsBestFareTableDetect';
  },
  _initElem: function() {
      var tables, orderTableElements, elements;
      
      tables = $$('.' + this._conf.cssClass.detectTable);
      
      orderTableElements = new Array();
      tables.each(function(table) {
          var id, prioritet;
          id = $(table).identify();
          prioritet = String(id).split('_').last();
          orderTableElements[prioritet] = table;
      }.bind(this));
      
      elements = new Array();
      orderTableElements.each(function(elem, index) {
        
            if (elem) {
                $(elem).select('tbody tr').each(function(elem) {
                    elements.push(elem); 
                }.bind(this));
            }
      }.bind(this));
      this._conf._elem.rows = elements;
      
      this._conf._elem.activeTrDiv = $('activeTrDiv');
  },
  _renderBestFares: function() {
      var index, cities, maxIndex;
      cities = this._storage.getCities();
      maxIndex = $A(this._conf._elem.rows).size();
      cities.each(function(cityId, index) {
          if (index >= maxIndex) {
              return;
          }
          var tr = this._conf._elem.rows[index];
          this._updateBestFaresElem(cityId, tr);
      }.bind(this));
  },
  _updateBestFaresElem: function(destCityId, tr) {
      var depCity, destCity, bestFareId, bestFareInfo, destinationCityName;
      var depDate, price, currency, destinationCityTd, depDateTd, priceTd;
      depCity = this._storage.getCurrentDepCity();
      
      bestFareId = this._storage.getBestFareByDirection(depCity, destCityId).first();
      
      bestFareInfo = this._storage.getBestFareInfo(bestFareId);

      
      destinationCityName = this._storage.getCityInfo(destCityId)['name'];
      depDate = this._storage
                    .getCriteriaInfo(bestFareInfo['criteriaId'])['departureDateAndShortNameMonth'];
      price = this._storage
                    .getPriceInfo(bestFareInfo['priceId'])['price'];

      currency = this._storage
                    .getCurrencyInfo(bestFareInfo['currencyId']);
      currency = currency['html'] ? currency['html'] : currency['code'];
      
      destinationCityTd = $(tr).select('td.destination').reduce();
      depDateTd = $(tr).select('td.depDate').reduce();
      priceTd = $(tr).select('td.price').reduce();
      
      destinationCityTd.update(destinationCityName);
      depDateTd.update(depDate);
      priceTd.update(currency + price).addClassName('priceFilled');
      
      $(tr).writeAttribute({id: 'bestFaresId_' + bestFareId});
  },
  _clearBestFeresElements: function() {
      $(this._conf._elem.rows).invoke('select', 'td').flatten().invoke('update', '');
      
      $(this._conf._elem.rows).invoke('select', 'td.priceFilled')
                              .flatten()
                              .invoke('removeClassName', 'priceFilled');
      
      ///this._conf._elem.rows.invoke('removeAttribute', 'id');
      //FIXME problem in invoke /braser IE
      $A(this._conf._elem.rows).each(function(elem) {
          $(elem).removeAttribute('id');
      });
  }
  
}, Control_Abstract);

var bestFaresViewDestinationTableList = new BestFares_View_Destination_TableList();





























//*****************************************************************************//
var BestFares_View_PriceDetails = Class.create({
  _storage: false,
  _isRender: false,
  _conf: {
      _elem: {
          detailsDepartDate: false,
          detailsReturnDate: false,
          detailsAirline: false,
          detailsVendor: false,
          detailsPrice: false,
          recheckButton: false,
          detailsBlock: false,
          welcomeText: false
      }
  },
  initialize: function() {
      document.observe('bestFaresStorage:load', this._init.bind(this));
  },
  _init: function(event) {
      this._storage = event.memo.storage;
      this._initConf();
      this._initObserver();
      
  },
  _initObserver: function() {
      document.observe('viewDestinationTableList:clickPrice',
                       this._clickPriceEvent
                           .bind(this));
                                                  
      document.observe('viewDestinationTableList:activeFirstPrice',
                       this._activeFirstPriceEvent
                           .bind(this));
                                                  
                                                  
  },
  _clickPriceEvent: function(event) {
      this._isRender = true;
      this._priceDetailsRender(event);
  },
  _activeFirstPriceEvent: function(event) {
      if (this._isRender) {
          this._priceDetailsRender(event);
      }
  },
  _priceDetailsRender: function(event) {
      var bestFareId, outboundDate, inboundDate, bestFare, criteriaId, criteria;
      var vendorId, vendor, vendorName, airlineId, currencyId, deepLink;
      var vaendorLogoPath, airlineLogoPath;
      
      bestFareId =  this._storage
                        .getBestFaresIdByDirections(this._storage
                                                        .getCurrentDepartureCity(),
                                                    this._storage
                                                        .getCurrentDestinationCity())
      
      
      bestFare = this._storage.getBestFare(bestFareId);
      criteriaId = bestFare['criteriaId'];
      
      criteria = this._storage.getCriteria(criteriaId);
      
      outboundDate = criteria['departureDateAndShortNameMonth'];
      inboundDate = criteria['destinationDateAndShortNameMonth'];
      
      
      vendorId = bestFare['vendorId'];
      vendor = this._storage.getVendor(vendorId);
      vendorName = vendor['name'];
      vaendorLogoPath = '/publicMedia/vendors/'
                        + vendorName.toLowerCase()
                        + '.gif';
      
      
      airlineId = bestFare['outboundAirlineId'];
      var airline = this._storage.getAirline(airlineId);
      var airlineName = airline['code'];
      airlineLogoPath = '/publicMedia/airlines/logos/'
                        + airlineName
                        + '.gif'
      
      currencyId = bestFare['currencyId'];
      var currency = this._storage.getCurrency(currencyId);
      var currencyName = currency['html'] ? currency['html'] : currency['code'];
      
      var priceId = bestFare['priceId'];
      var price = this._storage.getPrice(priceId);
      var priceValue = price['price'];
      
      deepLink = bestFare['deepLink'] + '&uniteCss=false';
      
      this._conf._elem.detailsDepartDate.update(outboundDate);
      this._conf._elem.detailsReturnDate.update(inboundDate);
      this._conf._elem.detailsVendor.writeAttribute('src', vaendorLogoPath);
      this._conf._elem.detailsAirline.writeAttribute('src', airlineLogoPath);
      this._conf._elem.detailsPrice.update(currencyName + priceValue);
      this._conf._elem.recheckButton.writeAttribute('href', deepLink);
      
      if (this._conf._elem.welcomeText.visible()) {
            this._conf._elem.welcomeText.hide();
            this._conf._elem.detailsBlock.show();
            this._conf._elem.recheckBlock.show();
            this._conf._elem.recheckButton.setStyle({visibility: 'visible'});
      }
  },
  _initConf: function() {
      this._initElem();
  },
  _initElem: function() {
      this._conf._elem.detailsDepartDate = $$('.detailsDepartDate strong').reduce();
      this._conf._elem.detailsReturnDate = $$('.detailsReturnDate strong').reduce();
      this._conf._elem.detailsAirline = $$('.detailsAirline img').reduce();
      this._conf._elem.detailsVendor = $$('.detailsVendor img').reduce();
      this._conf._elem.detailsPrice = $$('.detailsPrice strong').reduce();
      this._conf._elem.recheckButton = $$('div.recheck a').first();
      this._conf._elem.detailsBlock = $$('.detailsBlock').reduce();
      this._conf._elem.welcomeText = $$('.welcomeText').reduce();
      this._conf._elem.recheckBlock = $$('div.recheck').reduce();
      
  }
  
}, Control_Abstract);

var bestFaresViewPriceDetails = new BestFares_View_PriceDetails();






































//*****************************************************************************//
var BestFares_View_SwitchView = Class.create({
  _conf: {
      _elem: {
          switchFlights2BestFares: false,
          switchBestFares2Flights: false,
          bestFaresView: false,
          flightsView: false
      }
  },
  _duration: 0.8,
  initialize: function() {
      document.observe('dom:loaded', this._init.bind(this));
  },
  _init: function(event) {
      this._initConf();
      this._initObserver();
      
  },
  _initObserver: function() {
      $(this._conf
            ._elem
            .switchFlights2BestFares).observe('click',
                                              this._clickOnSwitchFlights2BestFaresButton
                                                  .bind(this));
                                                  
      $(this._conf
            ._elem
            .switchBestFares2Flights).observe('click',
                                              this._clickOnBestFares2SwitchFlightsButton
                                                  .bind(this));
                                                  
      
  },
  _initConf: function() {
      this._initElem();
  },
  _clickOnSwitchFlights2BestFaresButton: function(event) {
      this._hideFlightView();
      this._showBestFaresView();
  },
  _clickOnBestFares2SwitchFlightsButton: function(event) {
      this._hideBestFaresView();
      this._showFlightView();
    
  },
  _initElem: function() {
      this._conf._elem.switchFlights2BestFares =$('bestFaresButton');
      this._conf._elem.switchBestFares2Flights = $$('.backSearch').reduce();
      this._conf._elem.bestFaresView = $('bestFaresView');
      this._conf._elem.flightsView = $('flightView');
  },
  _hideFlightView: function() {
      new Effect.Fade(this._conf
                          ._elem
                          .flightsView, 
                      {
                          duration: this._duration,
                          queue: 'end'
                      });
  },
  _showFlightView: function() {
      new Effect.Appear(this._conf
                          ._elem
                          .flightsView, 
                        {
                            duration: this._duration,
                            queue: 'end'
                        });
  },
  _hideBestFaresView: function() {
      new Effect.Fade(this._conf
                          ._elem
                          .bestFaresView, 
                        {
                            duration: this._duration,
                            queue: 'end'
                        });
  },
  _showBestFaresView: function() {
      new Effect.Appear(this._conf
                            ._elem
                            .bestFaresView, 
                        {
                            duration: this._duration,
                            queue: 'end'
                        });
  }
  
}, Control_Abstract);

var BestFaresViewSwitchView = new BestFares_View_SwitchView();

