/*
  TabbedMenuClass, used for making a tabbed styled browser
  author: jack@inex.nl
  last update: 15/03/2004
  (c) 2004 Info Pinnacle BV
*/

function TabbedMenuClass(){
  
  // public interface
  this.Init       = Init; 
  this.SelectTab  = SelectTab;
  this.getSelectedTab = getSelectedTab;
  this.BlockTab = BlockTab;
  this.UnBlockTab = UnBlockTab;
  this.IsBlocked = IsBlocked;
  
  //private variables
  var theNrOfTabs;
  var theSelectedTab;
  var theMenuName;
  var theContentName;
  var theObjectName;
  var theTabStatusArr = new Array();
  
  //initiate object
  function Init(aMenuName, aContentName,aNrOfTabs, aObjectName){
    theNrOfTabs=aNrOfTabs;
    theMenuName=aMenuName;
    theContentName=aContentName;
    theObjectName=aObjectName;
    theTabStatusArr = new Array();
    for(var i=0;i<=aNrOfTabs;i++){theTabStatusArr[i]=0; }
  }
  
  function IsBlocked(aTabNr){
    if(theTabStatusArr[aTabNr]==0)return true;
    return false;
  }
  
  function getSelectedTab(){return theSelectedTab; }
    
  function BlockTab(aTabNr){
     document.getElementById(theMenuName+'_'+aTabNr+'_Div').className='cwc'+theMenuName+'-'+aTabNr+'-g';
     theTabStatusArr[aTabNr]=0;
  }
  function UnBlockTab(aTabNr){
    if(aTabNr==theSelectedTab){
      document.getElementById(theMenuName+'_'+aTabNr+'_Div').className='cwc'+theMenuName+'-'+aTabNr+'-a';
    }else{
      document.getElementById(theMenuName+'_'+aTabNr+'_Div').className='cwc'+theMenuName+'-'+aTabNr;
    }
    theTabStatusArr[aTabNr]=1;
  }
  
  //display the content for a tab, and update the status of the tabs
  function SelectTab(aTabNr){
    
    if(aTabNr==theSelectedTab)return true;
    if(theTabStatusArr[aTabNr]==1){
      theSelectedTab=aTabNr;
      theEventHandler.Raise(theObjectName,"MENUCHANGE",new String(aTabNr));
      for(var i=1;i<=theNrOfTabs;i++){
        if(i==theSelectedTab){
          try{
            document.getElementById(theMenuName+'_'+theSelectedTab+'_Div').className='cwc'+theMenuName+'-'+theSelectedTab+'-a';
            //status='cwc'+theMenuName+'-'+theSelectedTab+'-a';
            document.getElementById(theContentName+'_'+theSelectedTab+'_Div').className='cwc'+theContentName+'-'+theSelectedTab+'-a';
          }catch(E){}
        }else{
          try{
            var ghostTab=theTabStatusArr[i]==0?"-g":"";
            document.getElementById(theMenuName+'_'+i+'_Div').className='cwc'+theMenuName+'-'+i+ghostTab;
            document.getElementById(theContentName+'_'+i+'_Div').className='cwc'+theContentName+'-'+i;
          }catch(E){}
        }
      }
      return true;
    }else{
      return false;
    }    
  }
  
}