Page.HoldingPage = Class.create({
    initialize: function() {
        this.currentVendorIndex = 0;
        this.timeoutHandler   = null;
        this.vendors          = null;
        this.imageId = "holdPageVendorLogo";
    },
    animate: function(start) {
        var start = start || false;
        PrimaryLayout.getInstance().renderBottomLinks();
        if (start) {
            if (!this.vendors || !this.vendors.length) {
                this.fillLogos();
            }
            if (this.vendors && this.vendors.length > 0) {
                if (this.currentVendorIndex == this.vendors.length) {
                    this.currentVendorIndex = 0;
                }
                var vendor = this.vendors[this.currentVendorIndex++];
                var imageUrl = vendor.isDirect()
                             ? "/publicMedia/airlines/logos/" + vendor.airline + ".gif"
                             : vendor.getLogo();
                $("plane2").src = $("plane2").src;
                $(this.imageId).setAttribute("alt", vendor.getName());
                $(this.imageId).setAttribute("title", vendor.getName());
                $(this.imageId).src = imageUrl;
            }
            this.timeoutHandler = setTimeout(function() {
                this.animate(true);
            }.bind(this), 3500);
        } else {
            clearTimeout(this.timeoutHandler);
            this.vendors = null;
            this.currentVendorIndex = 0;
        }
    },
    fillLogos: function() {
        this.vendors = Page.getInstance().getFlights().getData().getVendors();
    },
    show: function() {
        if ($A($$('.js_holdingPageLink')).size() > 0) {
            $$('.js_holdingPageLink').first().show();
        }
        $(this.imageId).src = "/common/i/activity_indicator.gif";
        $(this.imageId).hide();
        $("airlinesInformation") && $("airlinesInformation").hide();
        try {
            $("flights_title").update($("searchingSign").firstChild.nodeValue);
        } catch (e) {
            dispatchException(e);
        }

        ["l_col", "flights_container", "searching_page", 'banner'].each(Effect.Appear);
        setTimeout(function() {
            Effect.Appear(this.imageId);
        }.bind(this), 500);
        Effect.Appear("page");
        $("c_col").addClassName("narrow_col");
        try {
            ["spotlight_block", "subscribe_block"].each(Effect.Fade);
        } catch (e) {
            dispatchException(e);
        }
        Page.getInstance().getMatrix().hide();
        this.animate(true);
    },
    hide: function() {
        this.animate(false);
        ["searching_page", "flights_container", "banner"].each(Element.hide);
        if ($A($$('.js_holdingPageLink')).size() > 0) {
            $$('.js_holdingPageLink').first().hide();
        }
        $("c_col").removeClassName("narrow_col");
    }
});
