﻿// JScript File

function TabControllerClass() {
    var me = this;
    
    this.VisibleContainer = null;
    this.VisibleLink = null;
    
    this.ActivateLink = function() {
        me.VisibleContainer.style.display = "";               // set anchor's tab container visible
        me.VisibleLink.parentNode.className = "tabbarbutton activebutton";
    }
    
    this.DeActivateLink = function() {
        if (me.VisibleContainer != null) {
            me.VisibleContainer.style.display = "none";     // hide it
            me.VisibleLink.parentNode.className = "tabbarbutton";
        }
    }
    
    // UPDATED: 29-Dec-2010
    // Previously we had a limitation that we can only set visible the
    // first tab. But now we are setting it up in this way that we can
    // set visible any tab
    this.SetupDefaultTab = function(sIDVisibleContainer, sIDVisibleLink) {
        me.VisibleContainer = document.getElementById(sIDVisibleContainer);
        me.VisibleLink = document.getElementById(sIDVisibleLink);
        
        me.ActivateLink();
    }
}

TabControllerClass.prototype.AddTab = function(sIDButton, sIDTabPage) {
    var me = this;
    var a;
    a = document.getElementById(sIDButton);                 // get anchor
    a.TabContainer = document.getElementById(sIDTabPage);   // get tab page
    a.onclick = function() {                                // when anchor is clicked
        me.DeActivateLink();
        
        me.VisibleContainer = this.TabContainer;            // now again set the current visibe tab
        me.VisibleLink = this;
        
        me.ActivateLink();
                    
        return false;                                       // cancel the click event
    }
};
