﻿/// <reference name="MicrosoftAjax.js"/>

Type.registerNamespace("BandSite");

BandSite.BandSite = function(element) {
    BandSite.BandSite.initializeBase(this, [element]);
}

BandSite.BandSite.prototype = {
    initialize: function() {
        BandSite.BandSite.callBaseMethod(this, 'initialize');
        
        // Add custom initialization here
        var that = this;
        
        this._menuPanel.add_pageSelected(
            function(sender, e) {
                that._mainPanel.showPage(e.pageID);
                switch (e.pageName) {
                    case "Shows":
//                        $find("ShowSection").resetSection();
                        break;
                    case "Photos":
                        $find("PhotoSection").resetSection();
                        break;
                    case "Forum":
                        $find("ForumSection").resetSection();
                        break;
                    case "Guestbook":
                        $find("GuestbookSection").resetSection();
                        break;
                }
                
                // This is to make sure the footer stays at the bottom in IE 6/7
                // (If it works, we should pass through the footerpanel ClientID rather than hardcoding it like this)
                // (And really we only need to do it for IE <= 7)
                //$get('BandSite_footerpanel').style.bottom = '1px';
                //$get('BandSite_footerpanel').style.bottom = '0px';
            }
        );
    
        this._contactUsButton.add_buttonClicked(
            function(sender, e) {
                $find("MenuPanel").unselectMenuButtons();
                $find("ContactUsSection").resetSection();
                that._mainPanel.showSitePagePanel("ContactUsPanel");
            }
        );
    
//        if (this._viewCartButton) {
//            this._viewCartButton.add_buttonClicked(
//                function(sender, e) {
//                    $find("MenuPanel").unselectMenuButtons();
//                    that._mainPanel.showSitePagePanel("ShoppingCartPanel");
//                }
//            );
//        }
        
        if (this._enterSiteButton) {
            this._enterSiteButton.add_buttonClicked(
                function(sender, e) {
                    that._sitePanelSet.showPanel("SitePanel");
                }
            );
        }

        // This is to make sure the footer stays at the bottom in IE 6/7
        // (If it works, we should pass through the footerpanel ClientID rather than hardcoding it like this)
        //alert("!");
        //$get('BandSite_footerpanel').style.bottom = '1px';
        //$get('BandSite_footerpanel').style.bottom = '0px';
    },
    dispose: function() {        
        //Add custom dispose actions here
        BandSite.BandSite.callBaseMethod(this, 'dispose');
    },
    
    visitAction: function(actionType, actionData) {
        if (this._visitID) {
            var friendID = null;
            if ($find("SignInPanel")._friend) {
                friendID = $find("SignInPanel")._friend.ID;
            }
            VisitorService.RegisterVisitAction(this._visitID, friendID, actionType, actionData);
        }
    }
    
}
BandSite.BandSite.createProperty("bandID");
BandSite.BandSite.createProperty("sitePanelSet");
BandSite.BandSite.createProperty("menuPanel");
BandSite.BandSite.createProperty("mainPanel");
BandSite.BandSite.createProperty("visitorAddress");
BandSite.BandSite.createProperty("contactUsButton");
BandSite.BandSite.createProperty("viewCartButton");
BandSite.BandSite.createProperty("enterSiteButton");
BandSite.BandSite.createProperty("visitID");
// BandSite.BandSite.createProperty("musicSection");
BandSite.BandSite.registerClass('BandSite.BandSite', Sys.UI.Control);

if (typeof(Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
