aCurrIndices = new Array(-1,-1,-1);

document.onselectstart = function() {return false};

function makeMenu() {
	for (var i = 0; i < aMenu.length; i++) {
		var vMenuObj0 = aMenu[i];
		var vStr = "<div id='MenuWrapper_"+i+"' class='MenuWrapper'>"
		vStr += "<a id='MenuLink_"+i+"' href='javascript:void(0)' onclick='showSubmenu("+i+")' onmouseover='menuMouseOver("+i+")' onmouseout='menuMouseOut("+i+")' >"+vMenuObj0.text+"</a>";
		vStr += "<div id='Submenu_"+i+"' class='Submenu'>";
		for (var j = 0; j < vMenuObj0.submenu.length; j++) {
			vStr += "<div id='MenuWrapper_"+i+"_"+j+"' class='"+((j != vMenuObj0.submenu.length-1) ? "SubmenuOption" : "SubmenuLastOption")+"'>";
			vStr += "<a id='MenuLink_"+i+"_"+j+"' href='javascript:void(0)' onmouseover='submenuMouseOver("+j+")' onmouseout='submenuMouseOut("+j+")' onclick='submenuClick("+j+")' >"+vMenuObj0.submenu[j].text+"</a>";
			var vMenuObj1 = vMenuObj0.submenu[j];
			if (vMenuObj1.submenu) {
				vStr += "<div id='Submenu_"+i+"_"+j+"' class='Submenu'>";
				for (var k = 0; k < vMenuObj1.submenu.length; k++) {
					vStr += "<div id='MenuWrapper_"+i+"_"+j+"_"+k+"' class='"+((k != vMenuObj1.submenu.length-1) ? "SubmenuOption" : "SubmenuLastOption")+"'>";
					vStr += "<a id='MenuLink_"+i+"_"+j+"_"+k+"' href='javascript:void(0)' onmouseover='subsubmenuMouseOver("+k+")' onmouseout='subsubmenuMouseOut("+k+")' onclick='subsubmenuClick("+k+")'>"+vMenuObj1.submenu[k].text+"</a>";
					vStr += "</div>";
				}
				vStr += "</div>";
			}
			vStr += "</div>";
		}
		vStr += "</div>";
		vStr += "</div>";
		document.write(vStr);
	}
}

function showSubmenu(vIndex) {
	if (aCurrIndices[2] > -1) {
		document.getElementById("MenuLink_"+aCurrIndices[0]+"_"+aCurrIndices[1]+"_"+aCurrIndices[2]).style.color = "#666666";
	}
	if (aCurrIndices[1] > -1) {
		document.getElementById("MenuLink_"+aCurrIndices[0]+"_"+aCurrIndices[1]).style.color = "#666666";
		if (aMenu[aCurrIndices[0]].submenu[aCurrIndices[1]].submenu) {
			document.getElementById("Submenu_"+aCurrIndices[0]+"_"+aCurrIndices[1]).style.visibility = "hidden";
			document.getElementById("MenuWrapper_"+aCurrIndices[0]+"_"+aCurrIndices[1]).style.background = "url(images/white.gif)";
		}
	}
	aCurrIndices[0] = vIndex;
	aCurrIndices[1] = -1;
	aCurrIndices[2] = -1;
	for (var i = 0; i < aMenu.length; i++) {
		var vStyle = document.getElementById("Submenu_"+i).style;
		var vDiv = document.getElementById("MenuWrapper_"+i);
		vStyle.top = (vDiv.offsetTop-(vIndex > 0 ? vDiv.offsetHeight+3 : 0))+"px";
		vStyle.left = vDiv.offsetLeft+vDiv.offsetWidth+"px";
		if (i == vIndex) {
			for (j = 0; j < aMenu[aCurrIndices[0]].submenu.length; j++) {
				document.getElementById("MenuWrapper_"+aCurrIndices[0]+"_"+j).style.width = aMenu[aCurrIndices[0]].submenuWidth+"px";
			}
			document.getElementById("MenuLink_"+i).style.color = "#000000";
			document.getElementById("MenuWrapper_"+i).style.background = "url(images/menu_rule.gif)";
			vStyle.visibility = "visible";
		}
		else {
			document.getElementById("MenuLink_"+i).style.color = "#666666";
			document.getElementById("MenuWrapper_"+i).style.background = "url(images/white.gif)";
			vStyle.visibility = "hidden";
		}
	}
	aMenu[vIndex].func();
}

function showSubsubmenu(vIndex) {
	aCurrIndices[1] = vIndex;
	aCurrIndices[2] = -1;
	for (var i = 0; i < aMenu[aCurrIndices[0]].submenu.length; i++) {
		var vStyle = document.getElementById("Submenu_"+aCurrIndices[0]+"_"+vIndex).style;
		var vDiv = document.getElementById("MenuWrapper_"+aCurrIndices[0]+"_"+vIndex);
		vStyle.top = (vDiv.offsetTop-(vIndex > 0 ? vDiv.offsetHeight+3 : 0))+"px";
		vStyle.left = (vDiv.offsetLeft+vDiv.offsetWidth)+"px";
			if (i == vIndex) {
			document.getElementById("MenuLink_"+aCurrIndices[0]+"_"+i).style.color = "#000000";
			document.getElementById("MenuWrapper_"+aCurrIndices[0]+"_"+i).style.background = "url(images/menu_rule.gif)";
			}
		else {
			document.getElementById("MenuLink_"+aCurrIndices[0]+"_"+i).style.color = "#666666";
			document.getElementById("MenuWrapper_"+aCurrIndices[0]+"_"+i).style.background = "url(images/white.gif)";
		}
		vStyle.visibility = "visible";
	}
}

function makeFirstOptionActive(vObj) {
	document.getElementById("MenuLink_"+aCurrIndices[0]+"_0").style.color = "#000000";
	aCurrIndices[1] = 0;
}

function loadPanoramaImage(vSrc) {
	document.getElementById("PanoramaImage").src = "images/"+vSrc;
}

function menuMouseOver(vIndex) {
	if (aCurrIndices[0] != vIndex) document.getElementById("MenuLink_"+vIndex).style.color = "#ff6600";
}

function menuMouseOut(vIndex) {
	document.getElementById("MenuLink_"+vIndex).style.color = (aCurrIndices[0] == vIndex) ? "#000000" : "#666666";
}

function submenuMouseOver(vSubindex) {
	if (aCurrIndices[1] != vSubindex) document.getElementById("MenuLink_"+aCurrIndices[0]+"_"+vSubindex).style.color = "#ff6600";
}

function submenuMouseOut(vSubindex) {
	document.getElementById("MenuLink_"+aCurrIndices[0]+"_"+vSubindex).style.color = (aCurrIndices[1] == vSubindex) ? "#000000" : "#666666";
}

function submenuClick(vSubindex) {
	if (aCurrIndices[2] > -1) {
		document.getElementById("MenuLink_"+aCurrIndices[0]+"_"+aCurrIndices[1]+"_"+aCurrIndices[2]).style.color = "#666666";
	}
	if (aCurrIndices[1] > -1 && aMenu[aCurrIndices[0]].submenu[aCurrIndices[1]].submenu) document.getElementById("Submenu_"+aCurrIndices[0]+"_"+aCurrIndices[1]).style.visibility = "hidden";
	var vSubmenuId = "MenuLink_"+aCurrIndices[0]+"_"+vSubindex;
	document.getElementById(vSubmenuId).style.color = "#000000";
	if (aCurrIndices[1] > -1) {
		document.getElementById("MenuLink_"+aCurrIndices[0]+"_"+aCurrIndices[1]).style.color = "#666666";
		document.getElementById("MenuWrapper_"+aCurrIndices[0]+"_"+aCurrIndices[1]).style.background = "url(images/white.gif)";
	}
	aCurrIndices[1] = vSubindex;
	aCurrIndices[2] = -1;
	aMenu[aCurrIndices[0]].submenu[vSubindex].func();
}

function subsubmenuMouseOver(vSubindex) {
	if (aCurrIndices[2] != vSubindex) document.getElementById("MenuLink_"+aCurrIndices[0]+"_"+aCurrIndices[1]+"_"+vSubindex).style.color = "#ff6600";
}

function subsubmenuMouseOut(vSubindex) {
	document.getElementById("MenuLink_"+aCurrIndices[0]+"_"+aCurrIndices[1]+"_"+vSubindex).style.color = (aCurrIndices[2] == vSubindex) ? "#000000" : "#666666";
}

function subsubmenuClick(vSubindex) {
	var vSubmenuId = "MenuLink_"+aCurrIndices[0]+"_"+aCurrIndices[1]+"_"+vSubindex;
	document.getElementById(vSubmenuId).style.color = "#000000";
	if (aCurrIndices[2] > -1) document.getElementById("MenuLink_"+aCurrIndices[0]+"_"+aCurrIndices[1]+"_"+aCurrIndices[2]).style.color = "#666666";
	aCurrIndices[2] = vSubindex;
	aMenu[aCurrIndices[0]].submenu[aCurrIndices[1]].submenu[aCurrIndices[2]].func();
}


function loadContent(vSrc, vWidth, vHeight, vTop, vLeft) {
	var vDiv = document.getElementById("ContentFrame");
	vDiv.style.visibility = "hidden";
	vDiv.src = vSrc;
	vDiv.style.top = vTop+"px";
	vDiv.style.left = vLeft+"px";
	vDiv.style.width = vWidth+"px";
	vDiv.style.height = vHeight+"px";
//	vDiv.style.border = "none";
	vDiv.style.visibility = "visible";
}

function loadFlashCard(vSrc) {
	document.getElementById("FlashCard").style.visibility = "visible";
	var vDiv = document.getElementById("FlashCardFrame");
	vDiv.style.visibility = "hidden";
	vDiv.src = vSrc;
	vDiv.style.visibility = "visible";
}

function closeFlashCard() {
	var vDiv = document.getElementById("FlashCardFrame");
	vDiv.style.visibility = "hidden";
	vDiv.src = vDiv.src;
	document.getElementById("FlashCard").style.visibility = "hidden";
	var vObj = document.getElementById("MenuLink_"+aCurrIndices[0]+"_"+aCurrIndices[1]);
	if (vObj) vObj.style.color = "#666666";
	if (aCurrIndices[0] != 3) aCurrIndices[1] = -1;
}

function init() {
	loadContent("company.html",460,290,189,268);
}
	
	