/* the tabmenu script provides the functionality for the tabs shown on the articleDetail-Page,
 * each menuItem corresponds to the tabItem in position, e.g. the first <li> is adressed to the 
 * first <div> in <div id="tabContent">, etc.
 * 
 * written by Florian Kraft 
 */
function tabMenu() {
	
	/* if there's no bidHistory, fix the width of the tabContent */
	
	bidHistory = document.getElementById("bidHistoryInfo");
	
	if (bidHistory) {
		document.getElementById("tabContent").style.width = "650px";
	} else {
		document.getElementById("tabContent").style.width = "860px";
	}
	
	/* read in all menuItems and tabItems */
	menuItems = document.getElementById("addInfoTabs");
	menu = menuItems.getElementsByTagName("li");
	
	tabItems = document.getElementById("tabContent");
	tabs = tabItems.getElementsByTagName("div");
	
	/* assign internal ids for identification */
	for (i = 0; i < menu.length; i++) {
		/* add custom attributes, for "id", assigning an index */
		menu[i].setAttribute("id", "productTab" + i);
		menu[i].setAttribute("onmouseover", "activate(this)");
		tabs[i].setAttribute("class", "productTab");
		tabs[i].setAttribute("id", "productInfoTab" + i);
		/* set all to invisible, except the first */
		if (i != 0) {
			tabs[i].style.display = "none";
		} 
		/* set the first menuItem active*/
		menu[0].setAttribute("class", "active");
	}
	
}

/* activate a tab */
function activate(object) {
	/* set the menu item active */
	object.setAttribute("class", "active");
	j = object.getAttribute("id").substring(10);
	tabs[j].style.display = "block";
	
	/* set all other tabs an menu items inactive */
	for (i = 0; i < tabs.length; i++) {
		if (i != j) {
			menu[i].removeAttribute("class", "active");
			tabs[i].style.display = "none";
		}
	}
}


