﻿//TabPanel Class
//=========================================================================
TabPanel = function(panelID, titleID, linkID, index, name){
    this.m_panel = document.getElementById(panelID);
    this.m_title = document.getElementById(titleID);
    this.m_link = document.getElementById(linkID);
    this.m_index = index;
    this.m_name = name;
    this.GetPanel = function(){ return this.m_panel; }
    this.GetTitle = function(){ return this.m_title; }
    this.GetLink = function(){ return this.m_link; }
    this.GetIndex = function(){ return this.m_index; }    
    this.GetName = function(){ return this.m_name; }    
}
TabPanel.prototype.Show = function(){
    this.m_panel.style.display = 'block';
    this.m_title.style.display = document.addEventListener ? 'table-cell' : 'inline';
    this.m_title.className = 'current';
    this.m_link.style.display = 'none';
    Mian.Lib.EventManager.Instance.RaiseEvent("show", this);
}
TabPanel.prototype.Hide = function(){
    this.m_panel.style.display = 'none';
    this.m_title.style.display = 'none';
    this.m_title.className = '';
    this.m_link.style.display = document.addEventListener ? 'table-cell' : 'inline';
}
//TabContainer Class
//=========================================================================
TabContainer = function(panels){
    this.m_panels = panels;
}
TabContainer.prototype.SetActiveTab = function(setIndex){
    var findPanel = false;
    var panel = null;
    for(index in this.m_panels){
        if(panel == null) panel=this.m_panels[index];
        if(this.m_panels[index].GetIndex()==setIndex){
            this.m_panels[index].Show();
            findPanel = true;
        }
        else
            this.m_panels[index].Hide();
    }
    if(!findPanel && panel!=null) panel.Show();
}
TabContainer.prototype.SetActiveTabByName = function(name){
    var findPanel = false;
    var panel = null;
    for(index in this.m_panels){
        if(panel == null) panel=this.m_panels[index];
        if(this.m_panels[index].GetName()==name){
            this.m_panels[index].Show();
            findPanel = true;
        }
        else
            this.m_panels[index].Hide();
    }
    if(!findPanel && panel!=null) panel.Show();
}
TabContainer.prototype.GetTabByName = function(name){
    var findPanel = false;
    var panel = null;
    for(index in this.m_panels){
        if(panel == null) panel=this.m_panels[index];
        if(this.m_panels[index].GetName()==name)
            return this.m_panels[index];
    }
    return null;
}