/*
 * functions to toggle the view of tabs/subtabs
 * .p. 
 */
/*
           //Note: Put the following function in the header of the html file containing the tabnavs
          //maximum number of tabs on the page, subtabs under each tab is  calculated automatically
          var MAXTABS = 5;
          
          document.observe("dom:loaded", function() {
                   //syntax: showSubTab(inTabNo,subTabNo); 
                   // This will automatically open the respective tab also
                    showSubTab(1,1);
            }); 


*/
         
         
         function closeTabs(tabscount){
             $R(1,tabscount).each(function(t){
                
                $('tab'+t+'data').hide().removeClassName('openTab');
                //remove the li-tab styling
                $('tab'+t).removeClassName('currentTab');
             });
          }

         function showTab(tabNo){
             //first close all the open tabs
             closeTabs(MAXTABS);
             
             $('tab'+tabNo+'data').show().addClassName('openTab');
             $('tab'+tabNo).addClassName('currentTab');
         }


         function showSubTab(inTabNo, SubTabNo){
             
             //first hide all the subtabs
             hideSubTabs(inTabNo);
             
             
             var stbs = $$('div#'+'tab'+inTabNo+'data .sub_tabs li').length;
             
             
             
             if (stbs>0) {
                 $('tab' + inTabNo + '_' + SubTabNo + 'data').show().addClassName('openSubTab');
                 $('tab' + inTabNo + '_' + SubTabNo).addClassName('currentSubTab');
             }
             
             //open up the tab for this subtab
             showTab(inTabNo);
         }

        function hideSubTabs(forTabNo){
                 //   $$('div#page p.summary img').each(Element.hide);
                 //   var st = $$('div#'+'tab'+tabNo+'data li');
            
                //find the number of subtabs in this tab
                var stbs = $$('div#'+'tab'+forTabNo+'data .sub_tabs li').length;
             
                if (stbs > 0) {
                    $R(1, stbs).each(function(stb){
                    
                        //hide the subtab div
                        $('tab' + forTabNo + '_' + stb + 'data').hide().removeClassName('openSubTab');
                        //remove the li-subtab styling
                        $('tab' + forTabNo + '_' + stb).removeClassName('currentSubTab');
                    });
                }
        }   

