﻿function makeArray(elname){
	switch (elname){
	case "tab":
		var x=document.getElementById("tablist").getElementsByTagName("li");
		break;
	case "textdiv":
		var x=document.getElementById("addinfo").getElementsByTagName("div");
		break;
	}
	var elarray = new Array();
	for (i = 0; i < x.length; i++)
	{
		elarray[i] = x[i].id;
	}
	return elarray;
}

function tabHighlight(id){
//	tabs = makeArray("tab");
	for (x in tabs)
	{
		document.getElementById(tabs[x]).style.backgroundColor="#999999";
		document.getElementById(tabs[x]).style.color="#ffffff";
	}
	document.getElementById(id).style.backgroundColor="#cccccc";
	document.getElementById(id).style.color="#000000";
}

function showtext(id){
//	textbox = makeArray("textdiv");
	for (y in tabs)
	{
		document.getElementById(textbox[y]).style.display="none";
	}
	document.getElementById(id).style.display="block";
}

function ShowText(section){
	tabHighlight("tab-" + section);
	showtext("text-" + section);
}

function open_home(){
	window.top.location="http://www.wurth.co.uk"
}

window.onload = function(){
	tabs = makeArray("tab");
	textbox = makeArray("textdiv");
	tabHighlight("tab-overview");
	showtext("text-overview");

	el = document.getElementsByTagName("a");
	for (var i=0; i<el.length; i++){
		if (el[i].rel=="ext") {
			el[i].onclick = function () {
				return !window.open(this.href);
			}
		}
	}
}