 // intNumTabs : number of tabs in the control
 // intCurrentTab : currently selected tab
 var intNumTabs;
 var intCurrentTab= 0; 
 function onClickTab()
 {
     // check if it's the TD element event (the TR will bubble down to TD)
     if ("TD" == event.srcElement.tagName) 
         {
            // check if it's not the same tab that was already selected
            if (event.srcElement.cellIndex != intCurrentTab) 
                 {
                    setTab(event.srcElement.cellIndex)
                 }
         }
 }
 
 function setTab(newTab)
 {
   // call the onLeave event of the currently selected tab
	 onLeaveDiv(intCurrentTab);
 
     var tblTabControl = document.all.tblTabControl
 
     // assign the new tab to the current tab variable
     intCurrentTab = newTab;
 
     // Loop through each tab to change the appearance (class)
     for (var i = 0; i <= intNumTabs; i++)
         {
            switch (i)
                {
                // tab to the left
                case (newTab - 1):
                    tblTabControl.rows(0).cells(i).className = "clsTabSelLeft"
                    tblTabControl.rows(1).cells(i).className = "clsTabContent"
                    break;
 
                // tab to the right
                case (newTab + 1):
                    if (i != intNumTabs)
                        {
                          tblTabControl.rows(0).cells(i).className = "clsTabSelRight";
                          tblTabControl.rows(1).cells(i).className = "clsTabContent"
                        }
                    break;
 
                // tab itself
                case (newTab):
                    tblTabControl.rows(0).cells(i).className = "clsTabSel";
                    tblTabControl.rows(1).cells(i).className = "clsTabContentSel";
                    break;
 
                // all other tabs
                default:
                    if (i != intNumTabs)
                      {
                       tblTabControl.rows(0).cells(i).className = "clsTab";
                       tblTabControl.rows(1).cells(i).className = "clsTabContent";
                      }
                    break;
                 }
         }
 
   // call the onEnter of the newly selected tab
	onEnterDiv(newTab);
 }
 
 function onEnterDiv(i)
 {
     document.getElementById("divTabContent" + i).style.display = "block";
 }
 
 function onLeaveDiv(i)
 {
     document.getElementById("divTabContent" + i).style.display = "none";
 }
