MediaWiki:Tabs.js

/*	Simple but flexible javascript tabs Author: Abdullah A. Abduldayem Contact: http://www.zeldawiki.org/User:Abdullah See http://www.zeldawiki.org/MediaWiki_talk:Tabs.js for examples and documentation

function ShowTab(id,num,total) { document.getElementById('_'+id+num).style.display='block'; if (document.getElementById(id+num).className != 'tab-article tabselected') document.getElementById(id+num).className+=' tabselected';

for(var i=0;i<=total;i++) {		if(i!=num) {			document.getElementById('_'+id+i).style.display='none' document.getElementById(id+i).className = document.getElementById(id+i).className.replace(/\b tabselected\b/,'') }	} }

function tabstart { tabcontainer = getElementsByClassName(document, '*', 'tabcontainer'); tabcontents = getElementsByClassName(document, '*', 'tabcontents');

for(var x=0; x<=tabcontainer.length -1; x++) { tabcontainer[x].id = "tab-" + x + "-"; tabs = getElementsByClassName(tabcontainer[x], '*', 'tab-article'); contents = tabcontents[x].childNodes;

var is_ie = ((clientPC.indexOf('msie') != -1) && (clientPC.indexOf('opera') == -1)); if(is_ie){ for(var y=0; y<=tabs.length -1; y++) { tabs[y].setAttribute('id', tabcontainer[x].id + y); tabs[y].setAttribute('onclick', "ShowTab('" + tabcontainer[x].id + "'," + y + "," + (tabs.length -1) + ");"); contents[y].setAttribute('id', '_' + tabcontainer[x].id + y); if (!contents[y].style.display) {contents[y].setAttribute('style', "display:none;");} }		}		else{ for(var y=0; y<=tabs.length -1; y++) { tabs[y].setAttribute('id', tabcontainer[x].id + y); tabs[y].setAttribute('onclick', "ShowTab('" + tabcontainer[x].id + "'," + y + "," + (tabs.length -1) + ");"); contents[y*2 +1].setAttribute('id', '_' + tabcontainer[x].id + y); if (!contents[y*2 +1].style.display) {contents[y*2 +1].setAttribute('style', "display:none;");} }		}

} } addOnloadHook(tabstart);