﻿var FlightDealGrid = new function() {

    this.ArrivalAirportChange = function(sLevel, iLevelID, iMonths, iLookAheadFromYear, iLookAheadFromMonth, iLookAheadMonths) {
        var iArrivalAirportID = dd.GetValue('ddlFlightDealGridArrivalAirport');
        var dLookAheadFromDate = new Date(iLookAheadFromYear, iLookAheadFromMonth - 1);
        FlightDealGrid.GetPrices.Go(sLevel, iLevelID, iArrivalAirportID, iMonths, dLookAheadFromDate, '', iLookAheadMonths);
    }


    this.Back = function(sLevel, iLevelID, iArrivalAirportID, iMonths, iLookAheadFromYear, iLookAheadFromMonth, iLookAheadMonths) {
        var dLookAheadFromDate = new Date(iLookAheadFromYear, iLookAheadFromMonth - 1);
        FlightDealGrid.GetPrices.Go(sLevel, iLevelID, iArrivalAirportID, iMonths, dLookAheadFromDate, 'Back', iLookAheadMonths);
    }
    this.Forward = function(sLevel, iLevelID, iArrivalAirportID, iMonths, iLookAheadFromYear, iLookAheadFromMonth, iLookAheadMonths) {
        var dLookAheadFromDate = new Date(iLookAheadFromYear, iLookAheadFromMonth - 1);
        FlightDealGrid.GetPrices.Go(sLevel, iLevelID, iArrivalAirportID, iMonths, dLookAheadFromDate, 'Forward', iLookAheadMonths);
    }


    this.GetPrices = new WebService();
    this.GetPrices.Go = function(Level, LevelID, ArrivalAirportID, Months, LookAheadFromDate, LookAheadDirection, LookAheadMonths) {
        var aParams = new Array(['Level', Level], ['LevelID', LevelID], ['ArrivalAirportID', ArrivalAirportID], ['Months', Months],
            ['LookAheadFromDate', LookAheadFromDate], ['LookAheadDirection', LookAheadDirection], ['LookAheadMonths', LookAheadMonths]);

        this.RunWebService('/webservices/support.asmx', 'http://intuitivesystems', 'FlightDealGridPrices', aParams, this, false);
    }
    this.GetPrices.Done = function(oXML) {
        var sHTML = this.GetTagValue(oXML, 'FlightDealGridPricesResult');
        f.SetHTML('divFlightDealGridPrices', sHTML);
    }

}



var PopularFlights = new function() {

    this.ToggleMore = function() {
        f.Toggle('aPopularFlightsMore');
        f.Toggle('aPopularFlightsLess');
    
        var aTableRows = f.GetElementsByClassName('tr', 'moreorless', 'tblPopularFlights');
        for (var i = 0; i < aTableRows.length; i++) {
            f.Toggle(aTableRows[i]);
        }
    }

}



var FlightLinksBottom = new function() {

    this.ClickThrough = function(oDiv) {
        var oLinkObject = oDiv.getElementsByTagName('a')[0];
        oLinkObject.click();
    }

}
