BiteTabs = { // Loads a tab. loadTab: function(tabgroup, selected_tab) { // Get all tab ids which are part of this tab group. var tabsInGroup = $$("div[id^='"+tabgroup+"']"); // Set all to the unhighlighted class except for the clicked one, and // hide all the divs except the selected one. for (i = 0; i < tabsInGroup.length; i++) { // The div itself. if(tabsInGroup[i].id == tabgroup+'_'+selected_tab) { $(tabsInGroup[i].id).style.display = "block"; } // The tab itself. else if(tabsInGroup[i].id == tabgroup+'_'+selected_tab+'_tab') { $(tabsInGroup[i].id).className = 'bite_tabon'; } // Is this another (unselected) tab? else if(tabsInGroup[i].id.substring(tabsInGroup[i].id.length - 3, tabsInGroup[i].id.length) == 'tab') { $(tabsInGroup[i].id).className = 'bite_taboff'; } // This is one of the other (unselected) divs. else { $(tabsInGroup[i].id).style.display = "none"; } } // Callback to update the $_SESSION variable. new Ajax.Request('/home/_update_saved_tab.php?tabgroup='+tabgroup+'&selected_tab='+selected_tab); } };