﻿/// <reference name="MicrosoftAjax.js"/>

Type.registerNamespace("WebControls");

WebControls.PanelSet = function(element) {
    WebControls.PanelSet.initializeBase(this, [element]);
}

WebControls.PanelSet.prototype = {
    initialize: function() {
        WebControls.PanelSet.callBaseMethod(this, 'initialize');

        var that = this;

    },
    dispose: function() {
        //Add custom dispose actions here
        WebControls.PanelSet.callBaseMethod(this, 'dispose');
    },

    hideAllPanels: function() {
        for (var i in this._displayPanelIDs) {
            $get(this._displayPanelIDs[i]).style.display = 'none';
        }
    },

    showPanel: function(panelName) {

        //  alert("showing panel " + panelName + "( id: " + this._displayPanelIDs[panelName] + ") in " + this.get_id());
        
        this.selectedPanel = panelName;
        
        var that = this;
        
        if (this._fade) {
            $('#' + this._element.id).fadeOut("slow", function() {
                that.hideAllPanels();
                if (!that._displayPanelIDs[panelName]) {
                    alert("Panel " + panelName + " not found");
                }
                $get(that._displayPanelIDs[panelName]).style.display = 'block';        
            });
            $('#' + this._element.id).fadeIn("slow");        
        } else {
            this.hideAllPanels();
            if (!this._displayPanelIDs[panelName]) {
                alert("Panel " + panelName + " not found");
            }
            $get(this._displayPanelIDs[panelName]).style.display = 'block';        
        }                
        
//        this.hideAllPanels();
//        if (!this._displayPanelIDs[panelName]) {
//            alert("Panel " + panelName + " not found");
//        }
//        $get(this._displayPanelIDs[panelName]).style.display = 'block';
    },
    
    get_selectedPanelID: function() {
        return this.selectedPanel;
    }

}
WebControls.PanelSet.createProperty("displayPanelIDs");
WebControls.PanelSet.createProperty("fade");
WebControls.PanelSet.registerClass('WebControls.PanelSet', Sys.UI.Control);

if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();

if(typeof(Sys)!=='undefined')Sys.Application.notifyScriptLoaded();