if(detectBrowser.modernBrowser()){ // Tabs class. Usage: var dd = new TabFactory(); var TabFactory = Class.create(); TabFactory.prototype = { initialize:function(){ this.tabs = $$('.tabs').map(function(el){ return new Tabs(el); }); } }; var Tabs = Class.create(); Tabs.prototype = { initialize:function(tabContainer){ tabContainer = $(tabContainer); var classNames = $A(tabContainer.classNames()); // Some elements look bizarre during initial load until javascript gets to them. // For those elements, we apply a class called "prejs" so that once the code is // running it can remove that CSS class. This way, a "pre-rendered" state can be // seen by the user while the Javascript is still loading, and unsettled layout // can be avoided. if(tabContainer.className.indexOf("prejs_")>-1){ for(var j=0;j -1){ tabContainer.removeClassName(classNames[j]); } } } // 1. Seek out list items in container this.tabButtons = tabContainer.immediateDescendants().select(function(childNode){ return (childNode.nodeName.toLowerCase()=="li"); }).map(function(currentTab,i){ currentTab.removeClassName((i==0)?"tab_inactive":"tab_active"); currentTab.addClassName((i==0)?"tab_active":"tab_inactive"); Event.observe(currentTab,'click',function(ev){ ev.stop(); for(var j=0;j-1){ for(var j=0;j-1){ item.removeClassName(classNames[j]); } } } // set up initial visual state for each tab's contents item.removeClassName((i==0)?"tab_content_inactive":"tab_content_active"); item.addClassName((i==0)?"tab_content_active":"tab_content_inactive"); }); } }; document.observe("contentloaded",function(){ var dd = new TabFactory(); }); }