var navSelected = null; function selectTabNav (event, forceElement) { // pass an event or html object. overlay tab will be placed on top // and inherit the object's contents. var e = (event)?event:window.event; var srcElement = (forceElement)?forceElement:getSrcElement(e); //Position overlay to indicate selection setTabOverlay(srcElement); //Take whatever action clicking the tab is supposed to initiate selectTabNavContent(srcElement.id); } /* Stub function to be overwritten locally with whatever you want the tab flip to do. This function commented out to avoid the order of including Javascript files becoming critical. function selectTabNavContent(id){ ... } */ //Position overlay on top of tab to indicate that it is selected function setTabOverlay(srcElement) { if (srcElement.id && /img/.test(srcElement.id)){ srcElement = document.getElementById(srcElement.id.replace("img","")); } var pos = getAbsolutePos(srcElement); if (!navSelected){ var screen = document.getElementById("screen"); if (screen){ navSelected = screen.appendChild(document.createElement("DIV")); } else { navSelected = document.body.appendChild(document.createElement("DIV")); } navSelected.id = "tabNavSelected"; } with (navSelected){ style.left = (pos.x - 2) + "px"; style.top = (pos.y - 8) + "px"; style.height = (parseInt(srcElement.offsetHeight) + 7) + "px"; innerHTML = srcElement.innerHTML; //Set an attribute to indicate the currently selected tab the overlay is for navSelected.setAttribute("selectedtab", srcElement.id) } }