6 * Moxiecode DHTML Tabs script.
9 * @copyright Copyright © 2004-2006, Moxiecode Systems AB, All rights reserved.
13 this.settings = new Array();
16 MCTabs.prototype.init = function(settings) {
17 this.settings = settings;
20 MCTabs.prototype.getParam = function(name, default_value) {
23 value = (typeof(this.settings[name]) == "undefined") ? default_value : this.settings[name];
26 if (value == "true" || value == "false")
27 return (value == "true");
32 MCTabs.prototype.displayTab = function(tab_id, panel_id) {
33 var panelElm = document.getElementById(panel_id);
34 var panelContainerElm = panelElm ? panelElm.parentNode : null;
35 var tabElm = document.getElementById(tab_id);
36 var tabContainerElm = tabElm ? tabElm.parentNode : null;
37 var selectionClass = this.getParam('selection_class', 'current');
39 if (tabElm && tabContainerElm) {
40 var nodes = tabContainerElm.childNodes;
42 // Hide all other tabs
43 for (var i=0; i<nodes.length; i++) {
44 if (nodes[i].nodeName == "LI")
45 nodes[i].className = '';
49 tabElm.className = 'current';
52 if (panelElm && panelContainerElm) {
53 var nodes = panelContainerElm.childNodes;
55 // Hide all other panels
56 for (var i=0; i<nodes.length; i++) {
57 if (nodes[i].nodeName == "DIV")
58 nodes[i].className = 'panel';
61 // Show selected panel
62 panelElm.className = 'current';
66 MCTabs.prototype.getAnchor = function() {
67 var pos, url = document.location.href;
69 if ((pos = url.lastIndexOf('#')) != -1)
70 return url.substring(pos + 1);
76 var mcTabs = new MCTabs();