﻿
/*--------------------------------------------------------------------------------------------------
/ TabStrip Object
/*--------------------------------------------------------------------------------------------------*/
var tabStrip = new TabStrip();

function TabStrip() {

    this.tabs = new Array();
    this.tabsByName = new Array();

} // function TabStrip(){




TabStrip.prototype.Add = function(tabObject) {

    tabObject.text = (this.tabs.length + 1) + ". " + tabObject.text;
    tabObject.index = this.tabs.length;
    this.tabs.push(tabObject);
    this.tabsByName[tabObject.id] = tabObject;

}  // TabStrip.prototype.Add = function(tabObject) {




TabStrip.prototype.Render = function() {

    var html = '';
    for (var i = 0; i < this.tabs.length; i++) {
        html += this.tabs[i].Html();
    } //for

    return html;

}    // TabStrip.prototype.Render = function() {




TabStrip.prototype.DisableAll = function() {
    for (var i = 0; i < this.tabs.length; i++) {
        this.tabs[i].Disable();
    } //for
}//DisableAll


/*--------------------------------------------------------------------------------------------------
/ Tab Object
/*--------------------------------------------------------------------------------------------------*/

function Tab(id, text, contentLocation) {

    this.id = id;
    this.text = text;
    this.enabled = true;
    this.contentLocation = contentLocation;
    this.index;

} // function Tab(id, text) {




Tab.prototype.Html = function() {

    return "<div class=\"Tab-Container\"><div id=" + this.id + " class=\"Tab\">" + this.text + "<br><img src=\"../Images/blank.gif\" width=\"142px\ height\"1\" /></div></div>";

} // Tab.prototype.Html = function() {




Tab.prototype.Disable = function() {

    $("#" + this.id).addClass("Tab-Disabled");
    this.enabled = false;

} // Tab.prototype.Disable = function() {




Tab.prototype.Enable = function() {

    $("#" + this.id).removeClass("Tab-Disabled");
    this.enabled = true;

} // Tab.prototype.Enable = function() {

/*--------------------------------------------------------------------------------------------------
/ End Tab Object
/*--------------------------------------------------------------------------------------------------*/




function HiliteTab(obj) {

    //Hilite the tab
    if (!$(obj).hasClass("Tab-Disabled")) {
        $(obj).addClass("Tab-Hilite");
    } //if       
} //HiliteTab




function DeHiliteTab(obj) {
    $(obj).removeClass("Tab-Hilite");
} //DeHiliteTab




function SelectTab(obj) {
    if (!$(obj).hasClass("Tab-Disabled")) {
        DoSelectTab(obj);
    } //if                     
} //SelectTab



function DoSelectTab(obj) {

    $(".Tab").removeClass("Tab-Selected");
    $(obj).addClass("Tab-Selected");

    //Get the position of the tab, so we can move the background tab image ( this gives the rounded look on the bottom )
    var tabPosition = $(obj).position();
    var tabFixerContainer = $("#Tab-Fixer-Container");
    var tabFixerContainerRight = $("#Tab-Fixer-Container-Right");
    
    tabFixerContainer.css("left", tabPosition.left - 3).css("top", 52);
    
    //obj is 142px
    var rightLeft = 166 - $(obj).width();
    rightLeft = rightLeft + tabPosition.left;
    
    
    tabFixerContainerRight.css("left", rightLeft ).css("top", 52);
        

    if (tabPosition.left == 0) {
        tabFixerContainer.addClass("Tab-Fixer-Left");
        tabFixerContainer.removeClass("Tab-Fixer");
    } else {
        tabFixerContainer.addClass("Tab-Fixer");
        tabFixerContainer.removeClass("Tab-Fixer-Left");
    } //if

    DoSelectTabFunction(obj);

} // DoSelectTab()


