var stocktabIds=new Object(); function expandcontent(tablink) { var lid = tablink.parentNode.parentNode.id; // UL id var llist = document.getElementById(lid).getElementsByTagName("dd"); // LI list of DL for (var i = 0; i < llist.length; i++) { llist[i].className = "" // Hide all tabs if (typeof stocktabIds[lid][i] != "undefined") { // Check tab content referenced exists document.getElementById(stocktabIds[lid][i]).style.display="none"; // Hide all tab contents } } tablink.parentNode.className = "selected"; // Highlight this tab document.getElementById(tablink.getAttribute("rel")).style.display = "block"; // Display corresponding tab contents } function savestocktabIds(lid, relattribute) {// save ids of tab content divs if (typeof stocktabIds[lid]=="undefined") //if this array doesn't exist yet stocktabIds[lid]=new Array(); stocktabIds[lid][stocktabIds[lid].length]=relattribute; } function initializetabcontent() { for (var i = 0; i < arguments.length; i++) { // for each DL ids var lobj = document.getElementById(arguments[i]); var llist=lobj.getElementsByTagName("dd"); // Array of the LI elements within DL var current_tab = 0; for (var x = 0; x < llist.length; x++) { // Loop through each LI element if ( llist[x].getElementsByTagName("a")[0] ) { var listlink=llist[x].getElementsByTagName("a")[0]; if (listlink.getAttribute("rel")) { if (typeof stocktabIds[arguments[i]] == "undefined") stocktabIds[arguments[i]] = new Array(); stocktabIds[arguments[i]][stocktabIds[arguments[i]].length] = listlink.getAttribute("rel"); listlink.onclick = function() { expandcontent(this); return false; } if (llist[x].className == "selected") { // Show default tab expandcontent(listlink); current_tab = x + 1; } } } } // for each LI element if (current_tab == 0) expandcontent(llist[0].getElementsByTagName("a")[0]); // Just auto load first tab instead } // for each DL element }