
var timer = ""
var ActiveMenu = "";
var ActiveSubMenu = "";
var SelectedMenu = "";

function highlight1() {
	if (event.srcElement.id.indexOf("ivitem") == 0) {
		event.srcElement.style.background='#fffdec';
		event.srcElement.style.cursor='hand';
	}
}

function rein(Item,Col) {
	Item.style.cursor="hand";
	Item.style.backgroundColor=Col;
}

function raus(Item,Col) {
	Item.style.cursor="default";
	Item.style.backgroundColor=Col;
}

function undohighlight() {
	var el = event.srcElement;
	if (el.tagName=="A") {
		el = el.parentNode;
	}
	if (el.id.indexOf("ivitem") == 0) {
		el.style.cursor='default';
		el.style.background='#fff7cc';
	}
}


function showActiveMenu() {
//alert('showActiveMenu: '+ActiveMenu);
	SelectedMenu = ActiveMenu;
	hideAllMenus();
	if (ActiveMenu != "") {
		var am = getmenu(ActiveMenu);
		if(am != null) {
		am.style.visibility = "visible";
		am.style.background = "#fff7cc";
		var amchilds = am.childNodes;
		for (i=1; i < amchilds.length; i++) {
			if (amchilds[i].tagName=="div" && amchilds[i].id.indexOf("ivitem") ==0) {
			amchilds[i].onmouseout= undohighlight;
			amchilds[i].onmouseenter= highlight1;
			}
			}
		}
	
	}
	if (ActiveSubMenu != "") {
		showsubmenu(ActiveSubMenu, ActiveMenu);
		var sm = getmenu(ActiveSubMenu);
		sm.style.background = "#fffdec";
	}
	clearTimeout(timer);
}

function getmenu(tabid) {
	//alert("ivmenu"+tabid);
	return document.getElementById("ivmenu" + tabid);
	//return document.all["ivmenu"+tabid];
}

function getElement(elementid) {
	return document.getElementById(elementid);
}

function resettimer() {
	clearTimeout(timer);
	timer=setTimeout("showActiveMenu();", 1500);
}
function resetquicktimer() {
	clearTimeout(timer);
	timer=setTimeout("showActiveMenu();", 200);
}

function showsubmenu(tabid, tabparentid) {
   	hideAllNotCurrentMenus();
   	 
	var submenu = getmenu(tabid);
	if (submenu != null) {
	   
		var parentmenu = getmenu(tabparentid);
		submenu.style.position = "absolute";
		submenu.style.top = "85px";
		submenu.style.left = parentmenu.offsetLeft + 140 + "px";
		//window.staus = parentmenu.offsetLeft;
		if (tabid==ActiveSubMenu) {
		//	var smbar = getElement("ivbar"+tabid);
		//	smbar.style.background = "#ffd400";
		}
		submenu.style.visibility = "visible";
	}
	resettimer();
}

function showmenu(tabid) {
	SelectedMenu = tabid;	
 	hideAllMenus();
	var menu = getmenu(tabid);
	if(menu != null) {
	  menu.style.visibility = "visible";
	}
	clearTimeout(timer);
	//resettimer();
}

function hideAllMenus() {
	var divs = document.getElementsByTagName("div");
	for(i = 0; i < divs.length; i++){
		var obj = divs[i];
   		if (obj.tagName == "DIV" && obj.id.indexOf("ivmenu") != -1) {
			obj.style.visibility="hidden";
		}
	}
}

function hideAllNotCurrentMenus() {
	var divs = document.getElementsByTagName("DIV");
	for(i = 0; i < divs.length; i++){
		var obj = divs[i];
   		if (obj.tagName == "DIV" && obj.id.indexOf("ivmenu") != -1) {
			var selid = "ivmenu" + SelectedMenu;
			if (obj.id != selid) {
				obj.style.visibility="hidden";
			}
		}
	}
}

resetquicktimer() ;
