Type.registerNamespace("uSwitch.Web.UI.WebControls");

// Constructor
uSwitch.Web.UI.WebControls.Button = function(element) {
    uSwitch.Web.UI.WebControls.Button.initializeBase(this, [element]);

    this._validateDelegate = null;
    this._MultipleGroupValidation = false;
    this._ValidationGroup = "";
    this._CausesValidation = false;
    this._elementId = null;
}
uSwitch.Web.UI.WebControls.Button.prototype = {
    get_MultipleGroupValidation: function() {
        return this._MultipleGroupValidation;
    },
    set_MultipleGroupValidation: function(value) {
        this._MultipleGroupValidation = value;
    },

    get_ValidationGroup: function() {
        return this._ValidationGroup;
    },
    set_ValidationGroup: function(value) {
        this._ValidationGroup = value;
    },

    get_CausesValidation: function() {
        return this._CausesValidation;
    },
    set_CausesValidation: function(value) {
        this._CausesValidation = value;
    },

    // Bind and unbind to click event.
    add_click: function(handler) {
        this.get_events().addHandler('click', handler);
    },
    remove_click: function(handler) {
        this.get_events().removeHandler('click', handler);
    },

    _validateClick: function(event) {
        if (this.control.get_CausesValidation()) {
            var jE = $('#' + this.control._elementId);
            var element = jE.get(0);
                        
            var groups;

            if (this.control.get_MultipleGroupValidation()) {
                groups = this.control.get_ValidationGroup().split(',');
            } else {
                groups = new Array();
                groups[0] = this.control.get_ValidationGroup();
            }

            var valids = new Array();
			if (typeof(Page_Validators)!="undefined") {
            for (var j = 0; j < Page_Validators.length; j++) { //reset this so we know if something has already been marked invalid in this validation session
                var validator = Page_Validators[j];

                var element = $('#' + validator.controltovalidate);

                if (typeof (element[0]) !== 'undefined') {
                    element[0].hookIsInvalid = false;
                }
            }
            }
            if (typeof(Page_ClientValidate)!="undefined") {
                for (var i = 0; i < groups.length; i++) {

                valids[i] = Page_ClientValidate(groups[i].trim()); //validate all groups in the list
            }

            var allValid = true;

            var firstInvalidSummary = null;

            for (var x = 0; x < valids.length; x++) {
                if (!valids[x]) {
                    allValid = false;

                    var summary = null;

                    for (var y = 0; y < Page_ValidationSummaries.length; y++) {
                        if (IsValidationGroupMatch(Page_ValidationSummaries[y], groups[x].trim())) {
                            summary = Page_ValidationSummaries[y];
                            break;
                        }
                    }

                    if (summary != null) {
                        summary.style.display = "";

                        if (firstInvalidSummary == null) {
                            firstInvalidSummary = summary;
                        }
                    }
                }
            }

            if (firstInvalidSummary != null && !allValid) {
                $.scrollTo(firstInvalidSummary, 500, { offset: -70 });
				Page_BlockSubmit = true;
            }
            }
        }
    },

    initialize: function() {
        uSwitch.Web.UI.WebControls.Button.callBaseMethod(this, 'initialize');

        var that = this;
        
        this._elementId = this.get_element().id;
        
        var init = function () {
            var element = $('#' + that._elementId);
            
            $(element).click(that._validateClick);
        };

        var prm = Sys.WebForms.PageRequestManager.getInstance();
        if (prm != null) {
            prm.add_endRequest(function() {
                var element = $('#' + that._elementId);
                
                if (element.length > 0) {
                    element.get(0).control = that;
                    init();
                }
            });
        }
        
        $(document).ready(function () {
            init();
        });
    },

    // Release resources before control is disposed.
    dispose: function() {
        var element = this.get_element();

        /*if (this._validateDelegate) {
            Sys.UI.DomEvent.removeHandler(element, 'click', this._validateDelegate);
            delete this._validateDelegate;
        }*/

        uSwitch.Web.UI.WebControls.Button.callBaseMethod(this, 'dispose');
    }
}
uSwitch.Web.UI.WebControls.Button.registerClass('uSwitch.Web.UI.WebControls.Button', Sys.UI.Control);
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();
/* ----------------------------------------------------------------------------------------------------

	DoublePanel

---------------------------------------------------------------------------------------------------- */

Type.registerNamespace("uSwitch.Web.UI.WebControls");

uSwitch.Web.UI.WebControls.DoublePanel = function(element) {
    uSwitch.Web.UI.WebControls.DoublePanel.initializeBase(this, [element]);

    this._divDoublePanel = null;
    this._divPanels = null;
    this._divPanelLeft = null;
    this._divPanelRight = null;

    this._timerDelegate = null;
}

uSwitch.Web.UI.WebControls.DoublePanel.prototype = {
    initialize: function() {
        uSwitch.Web.UI.WebControls.DoublePanel.callBaseMethod(this, 'initialize');

        this._divDoublePanel = $(this.get_element());
        this._divPanels = new Array();

        var that = this;

        this._divDoublePanel.find("div[class*='us-panel']").each(function() {
            that._divPanels.push($(this));
        })

        if (this._divPanels.length < 2)
            return;

        this._divPanelLeft = this._divPanels[0].find("div[class='inner-content']");
        this._divPanelRight = this._divPanels[1].find("div[class='inner-content']");

        this._timerDelegate = Function.createDelegate(this, this.resetPanelHeights);

        $(window).load(this._timerDelegate);

        var that = this;

        var prm = Sys.WebForms.PageRequestManager.getInstance();
        if (prm != null) {
            prm.add_endRequest(function() {
                that.resetPanelHeights();
            });
        }
    },

    resetPanelHeights: function() {
        this._divPanelLeft.height('');
        this._divPanelRight.height('');
    
        if (this._divPanelLeft.height() < this._divPanelRight.height())
            this._divPanelLeft.height(this._divPanelRight.height());
        else
            this._divPanelRight.height(this._divPanelLeft.height());
    },

    dispose: function() {
        var element = this.get_element();

        delete this._timerDelegate;

        uSwitch.Web.UI.WebControls.DoublePanel.callBaseMethod(this, 'dispose');
    }
}

uSwitch.Web.UI.WebControls.DoublePanel.registerClass("uSwitch.Web.UI.WebControls.DoublePanel", Sys.UI.Control);
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();Type.registerNamespace("uSwitch.Web.UI.WebControls");

// Constructor
uSwitch.Web.UI.WebControls.HyperLink = function(element) {
    uSwitch.Web.UI.WebControls.HyperLink.initializeBase(this, [element]);
    
    this._clickDelegate = null;
    this._isPopup = null;
    this._popupWidth = null;
}
uSwitch.Web.UI.WebControls.HyperLink.prototype = {

    get_PopupSize: function() {
        return this._popupSize;
    },
    set_PopupSize: function(value) {
        this._popupSize = value;
    },

    get_IsPopup: function() {
        return this._isPopup;
    },
    set_IsPopup: function(value) {
        this._isPopup = value;
    },

    _popUpClicked: function(eventElement) {
        var element = this.get_element();

        showPopup(element, this.get_PopupSize());
        
        eventElement.preventDefault();
    },

    initialize: function() {
        uSwitch.Web.UI.WebControls.HyperLink.callBaseMethod(this, 'initialize');

        var element = this.get_element();

        if (this._clickDelegate === null) {
            this._clickDelegate = Function.createDelegate(this, this._popUpClicked);
        }
        Sys.UI.DomEvent.addHandler(element, 'click', this._clickDelegate);

        if (this.get_IsPopup()) {
            this.get_events().addHandler('click', this._clickDelegate);
        }
    },

    // Release resources before control is disposed.
    dispose: function() {
        var element = this.get_element();

        if (this._clickDelegate) {
            Sys.UI.DomEvent.removeHandler(element, 'click', this._clickDelegate);
            delete this._clickDelegate;
        }

        uSwitch.Web.UI.WebControls.HyperLink.callBaseMethod(this, 'dispose');
    }
}
uSwitch.Web.UI.WebControls.HyperLink.registerClass('uSwitch.Web.UI.WebControls.HyperLink', Sys.UI.Control);
if (typeof (Sys) !== 'undefined') Sys.Application.notifyScriptLoaded();Type.registerNamespace("uSwitch.Web.UI.WebControls");

// Constructor
uSwitch.Web.UI.WebControls.HelpLink = function(element) {
    uSwitch.Web.UI.WebControls.HelpLink.initializeBase(this, [element]);
    this._mouseoverDelegate=null;
    this._mouseoutDelegate=null;
    this._hoverText=null;
    this._bubbleWidth=null;
    this._bubble=null;
    this._bubbleID=null;
    this._offsetX = 17;
}

uSwitch.Web.UI.WebControls.HelpLink.prototype = {
    get_HoverText: function() {
        return this._hoverText;
    },

    set_HoverText: function(value) {
        this._hoverText = value;
    },

    get_BubbleWidth: function() {
        return this._bubbleWidth;
    },

    set_BubbleWidth: function(value) {
        this._bubbleWidth = value;
    },

    get_BubbleID: function() {
        return this._bubbleID;
    },

    set_BubbleID: function(value) {
        this._bubbleID = value;
    },

    _mouseOver: function(eventElement) {
        var element = this.get_element();

        if (this._hoverText != null && this._bubbleID != null) {
            this._bubble = Sys.UI.DomElement.getElementById(this._bubbleID);

            if (this._bubble) {
                Sys.UI.DomElement.removeCssClass(this._bubble, "hidden");

                if (this._bubbleWidth != null) {
                    this._bubble.style.width = 