/**
  * Handles tabbed content
  *
  * @author Nils Heuermann <nils.heuermann@absofort.de>
  */

var curTab ;
var tabInitialized = false ;

tabInit = function () {
	if (tabInitialized) {
		return ;
	}
	tabInitialized = true ;
	var tabs = document.getElementById('tabbed').getElementsByTagName('div') ;
	for (var i = 0; i < tabs.length; i++) {
		if (tabs[i].id.indexOf('tab') != 0) {
			continue ;
		}
		var id = tabs[i].id ;
		id = id.substr(3) ;
		tabs[i].onclick = function() {
			showTab(this) ;
		}
		
		if (!curTab) {
			showTab(tabs[i]) ;
		}
		else {
			document.getElementById('content'+id).style.display = 'none' ;
		}
	}
}

showTab = function(elem) {
	var id = elem.id ;
	id = id.substr(3) ;
	if (curTab && id != curTab) {
		document.getElementById('content'+curTab).style.display = 'none' ;
		document.getElementById('tab'+curTab).className = 'taboff' ;
	}
	document.getElementById('content'+id).style.display = '' ;
	document.getElementById('tab'+id).className = 'tabon' ;
	curTab = id ;
}
