var SM_timeout;
var SM_currentMenu = "_NO_MENU_SHOWN_";
var SM_overSub = false;

function showSubMenu(id, leftOffset) {
	clearTimeout(SM_timeout);
	if (SM_currentMenu != "_NO_MENU_SHOWN_") {
		closeSubMenu(SM_currentMenu);
	}
	SM_currentMenu = id;
	var submenuObj = document.getElementById("sub-"+id);
	submenuObj.style.display = "block";
	submenuObj.style.left = leftOffset+"px";
	submenuObj.subId = id;
	submenuObj.onmouseout = function() {
		SM_overSub = false;
		clearTimeout(SM_timeout);		
		hideSubMenu(this.subId, "js");
	}
	submenuObj.onmouseover = function() {
		SM_overSub = true;
		clearTimeout(SM_timeout);
	}
	try { showFlashTab(id); }
	catch(err) {
		showNormalTab(id);
	}
}



function hideSubMenu(id, source) {
	if (source == "js" || !SM_overSub) {
		SM_timeout = setTimeout('closeSubMenu("'+id+'")',200);
	}
}



function closeSubMenu(id) {
	var SM_currentMenu = "_NO_MENU_SHOWN_";
	var submenuObj = document.getElementById("sub-"+id);
	submenuObj.style.display = "none";
	submenuObj.onmouseout = null;
	submenuObj.onmouseover = null;
	try { hideFlashTab(id); }
	catch(err) {
		hideNormalTab(id);
	}
}

function hideFlashTab(id) {
	//LC_changeObj.innerHTML += "HFT ";
	swfobject.getObjectById("flash_menu").hideFlashTab(id);
}

function showFlashTab(id) {
	//LC_changeObj.innerHTML += "SFT ";
	swfobject.getObjectById("flash_menu").showFlashTab(id);
}

function initializeAlternativeMenu() {
	var menuList = document.getElementById("JS_alternative_menu");
	var counter = 0;
	for (var i=0; i<menuList.childNodes.length; i++) {
		if (menuList.childNodes[i].tagName == "LI") {
			menuList.childNodes[i].counter = counter;
			menuList.childNodes[i].onmouseover = function() {
				showSubMenu(this.counter, this.offsetLeft);
			}
			menuList.childNodes[i].onmouseout = function() {
				hideSubMenu(this.counter, "js");
			}
			counter++;
		}
	}
}

function hideNormalTab(id) {
	var menuList = document.getElementById("JS_alternative_menu");
	for (var i=0; i<menuList.childNodes.length; i++) {
		if (menuList.childNodes[i].tagName == "LI") {
			if (menuList.childNodes[i].counter == id) {
				menuList.childNodes[i].className = "";
			}
		}
	}
}

function showNormalTab(id) {
	var menuList = document.getElementById("JS_alternative_menu");
	for (var i=0; i<menuList.childNodes.length; i++) {
		if (menuList.childNodes[i].tagName == "LI") {
			if (menuList.childNodes[i].counter == id) {
				menuList.childNodes[i].className = "active";
			}
		}
	}
}