function VerticalTabControl(name) { this.tabs = new Array(); this.activeTab = 0; // Outer Container this.container = document.createElement('div'); this.container.className = "vertical_tab_container"; // Clearing div, this helps the container div fit into the flow properly this.clearDiv = document.createElement('div'); this.clearDiv.style.clear = "both"; // Finger Column this.fingerColumn = document.createElement('div'); this.fingerColumn.className = "vertical_tab_finger_column"; // Insert into DOM tree after location of calling script this.scripts = document.getElementsByTagName('script'); this.lastScript = this.scripts[this.scripts.length - 1]; this.container.appendChild(this.fingerColumn); this.container.appendChild(this.clearDiv); this.lastScript.parentNode.insertBefore(this.container,this.lastScript.nextSibling); }; VerticalTabControl.prototype.activate = function(index) { //Deactivate this.tabs[this.activeTab].finger.className = "vertical_tab_finger"; this.tabs[this.activeTab].content.style.display="none"; this.tabs[this.activeTab].finger.onClick = null; //Activate this.tabs[index].finger.className = "vertical_tab_finger_active"; this.tabs[index].content.style.display="inline"; var vtControl = this; this.tabs[index].onclick = function(){ vtControl.activate(l) }; this.activeTab = index; }; VerticalTabControl.prototype.addTab = function(finger_html, content_html) { var l = this.tabs.length; this.tabs[l] = new Tab(); // Feel dirty using innerHTML but I too lazy to create, append table & form elements this.tabs[l].finger.innerHTML = finger_html; this.tabs[l].content.innerHTML = content_html; // Event handler for fingers, see http://www.brockman.se/writing/method-references.html.utf8 var vtControl = this; this.tabs[l].finger.onclick = function(){ vtControl.activate(l) }; this.fingerColumn.appendChild(this.tabs[l].finger); this.container.insertBefore(this.tabs[l].content, this.clearDiv); //this.container.appendChild(this.tabs[l].content); }; Tab = function() { // Tab type - has finger and content elements this.finger = document.createElement('div'); this.finger.className = "vertical_tab_finger"; this.content = document.createElement('div'); this.content.className = "vertical_tab_content"; }