// each tab should have the same id as the a tag with the following vaiable on the end
var tabmodifier = "-tab";
//Set tab to intially be selected when page loads:
//[which tab (1=first tab), ID of tab content to display]:
var initialtab=[0];
//Turn menu into single level image tabs (completely hides 2nd level)?
var turntosingle=0; //0 for no (default), 1 for yes
//Set CSS to hide the tabs - sets items with a class of 'tabcontent' to display: none
var hidetabs=1; //0 for no (default), 1 for yes
var previoustab="";

function expandcontent(cid, aobject){
	if (document.getElementById){
		if(aobject){
			highlighttab(aobject);
		}
		if (turntosingle==0){
			if (previoustab!=""){
				document.getElementById(previoustab).style.display="none";
				document.getElementById(cid).style.display="block";
				previoustab=cid;
			}else{
				document.getElementById(cid).style.display="block";
				previoustab=cid;
			}
		}
	}
}

function highlighttab(aobject){
	if (typeof tabobjlinks=="undefined"){
		collecttablinks();
	}
	for (i=0; i<tabobjlinks.length; i++) {
		tabobjlinks[i].className="";
	}
	aobject.className="current";
}

function collecttablinks(){
	var tabobj=document.getElementById("tabs");
	tabobjlinks=tabobj.getElementsByTagName("A");
}

function do_onload(){
	var currenttab=null;
	var count = 0;
	var tabspresent = document.getElementById('tabs');
	if(tabspresent){
		
		var content = document.getElementById("tabcontainer");
		var cdiv = content.getElementsByTagName("div");
		var tabs = new Array();
		for(i=0; i<cdiv.length; i++){
			if(cdiv[i].className == "tabcontent"){
				tabs[count] = cdiv[i];
				tabs[count].style.display = "none";
				count++;
			}
		}
		
		collecttablinks();
		for (i=0; i<tabobjlinks.length; i++) {
			tabobjlinks[i].onmouseover = function(){				
				expandcontent(this.id+tabmodifier, this);				
			}
			tabobjlinks[i].onclick = function(){
				if(this.rel) {
					window.location =  this.rel;
				}
				return false;			
			}
			if(tabobjlinks[i].className == "current"){
				initialtab=[i];
				currenttab=i;
			}
		}
		if(currenttab != null){
			expandcontent(tabs[initialtab].id);
		}else{
			expandcontent(tabs[initialtab].id, tabobjlinks[initialtab]);
		}
	}
}

if (window.addEventListener)
window.addEventListener("load", do_onload, false)
else if (window.attachEvent)
window.attachEvent("onload", do_onload)
else if (document.getElementById)
window.onload=do_onload