//Menu Code STARTS
var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_ie = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie4up = (is_ie && (is_major >= 4));
var ie  = (agt.indexOf("msie") != -1);
var ns  = (navigator.appName.indexOf("Netscape") != -1);
var win = ((agt.indexOf("win")!=-1) || (agt.indexOf("32bit")!=-1));
var mac = (agt.indexOf("mac")!=-1);
if (!basehref) {var basehref = ""};

var tID = null;
var mb = null;

function resetTimer() {
	if (!!tID) clearTimeout(tID);
	tID = setTimeout("executeTimer()",1000);
}

function executeTimer() {
	HideMenu();
}

function getAbsLeft(elm) {
	if (!elm && this) elm = this;
	var nLeftPos = elm.offsetLeft;
	var pElm = elm.offsetParent;
	while (pElm) {
		nLeftPos += pElm.offsetLeft;
		pElm = pElm.offsetParent;
	}
	return nLeftPos;
}

function getAbsTop(elm) {
	if (!elm && this) elm = this;
	var nTopPos = elm.offsetTop;
	var pElm = elm.offsetParent;
	while (pElm) {
		nTopPos += pElm.offsetTop;
		pElm = pElm.offsetParent;
	}
	return nTopPos;
}

function hideObjectTags(){
	var classid = "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";
	var objs = document.getElementsByTagName("object");
	for (var i=0; i<objs.length; i++)if (objs[i].getAttribute("classid") == classid)objs[i].style.visibility = "hidden";
};

function showObjectTags(){
	var classid = "clsid:02BF25D5-8C17-4B23-BC80-D3488ABDDC6B";
	var objs = document.getElementsByTagName("object");
	for (var i=0; i<objs.length; i++)if (objs[i].getAttribute("classid") == classid)objs[i].style.visibility = "visible";
};

function FindSubMenu(subMenu) {
	var item = null;
	var menu = document.getElementById(subMenu);
	if (menu) {
		menu.onmouseout = resetTimer;
		menu.style.visibility = "hidden";
		for (var i=0;i<menu.childNodes.length;i++) {
			item = menu.childNodes[i];
			if (item.nodeType == 3 && item.className == "mi"){
				if (item.getAttribute("menu")) FindSubMenu(item.getAttribute("menu"));
				if (item.getAttribute("cmd"))  item.onclick = new Function("Do(\""+item.id+"\")");
				item.onmouseover = new Function("highlight(\""+item.id+"\")");
			};
		}
	}
}

function ShowMenu(obj) {
	var menu = null;
	clearTimeout(tID);
	HideMenu(mb);
	if (obj != null && obj.length) {
		obj = document.getElementById(obj);
		if (obj == null) return;
		if (obj.getAttribute("cmd")) window.status = obj.getAttribute("cmd");
		if (obj.getAttribute("menu"))menu = document.getElementById(obj.getAttribute("menu"));
		var bar = document.getElementById(obj.id);
		if (bar.getAttribute("cmd")) {
			if (bar.getAttribute("cmd").substr(0,1) == "/") {
				if (basehref == "") {
					window.status = window.location.protocol + "//" + window.location.host + bar.getAttribute("cmd");
				}
				else {
					window.status = basehref + bar.getAttribute("cmd");
				}	
			}	
			else {
				window.status = bar.getAttribute("cmd");
			}
		}
		else {
			window.status = "";
		}
		switch (bar.className){
			case "b":
				bar.className = "bo";
				break;
			case "bh":
				bar.className = "bho";
				break;
			case "bhs":
				bar.className = "bhso";
				break;
		}
		if (menu) {
			hideObjectTags();
			menu.style.top =  (getAbsTop(obj) + 29) + "px";
			menu.style.left = getAbsLeft(obj) + "px";
			menu.style.display = "block";
			menu.style.visibility = "visible";
			if (!!document.all) {
				var ienavfix = document.getElementById(menu.id + "fix");
				if (!!ienavfix) {
					ienavfix.style.display = "block";			
				}
			}
		}
	}
}
   
function highlight(obj) {
	clearTimeout(tID);
	obj = document.getElementById(obj);
	if (obj.className == "mi"){
		var PElement = document.getElementById(obj.parentNode.id);
		for (var i=0;i<PElement.childNodes.length;i++) {
			var elm = PElement.childNodes[i];
			if (elm.className == "io")elm.className = "mi";
		}
		obj.className="io";
		if (obj.getAttribute("cmd")) {
			if (obj.getAttribute("cmd").substr(0,1) == "/") {
				if (basehref == "") {
					window.status = window.location.protocol + "//" + window.location.host + obj.getAttribute("cmd");
				}
				else {
					window.status = basehref + obj.getAttribute("cmd");
				}	
			}
			else {
				window.status = obj.getAttribute("cmd");
			}
		}	
		else {
			window.status = "";
		}
		ShowSubMenu(obj);
	};
}

function Do(obj) {
	var cmd = document.getElementById(obj).getAttribute("cmd");
	var target = document.getElementById(obj).getAttribute("target");
   if (basehref == "") {
		if (target == "_blank")var win = window.open(cmd,"");
      else window.location = cmd;
	}
	else {
		if (target == "_blank")var win = window.open(basehref + cmd,"");
      else window.location = basehref + cmd;
	}	
}

function HideMenu(obj) {
	if (!mb) return;
	if (!obj) obj = mb;
	if (obj.tagName != "DIV") obj = mb;
	for (var i=0;i<obj.childNodes.length;i++) {
		var child = obj.childNodes[i];
		var childMenu = null;
		if (child.nodeType != 1) continue;
		if (child.className == "bo") document.getElementById(child.id).className = "b";
		if (child.className == "bho") document.getElementById(child.id).className = "bh";
		if (child.className == "bhso") document.getElementById(child.id).className = "bhs";
		if (child.getAttribute("menu"))childMenu = document.getElementById(child.getAttribute("menu"));
		if (childMenu) {
			if (childMenu.hasChildNodes()) {
				for (var j=0;j<childMenu.childNodes.length;j++) {
					var tElm = childMenu.childNodes[j];
					if (tElm.nodeType == 1 && tElm.className == "io")tElm.className = "mi";
				}
				HideMenu(childMenu);
				childMenu.style.visibility = "hidden";
				showObjectTags();
				if (!!document.all && !!document.createElement && !!document.appendChild && !!is_ie4up) {
					var ienavfix = document.getElementById(childMenu.id + "fix");
					if (!!ienavfix) {ienavfix.style.display = "none";}
				}	
				window.status = "";
			}
		}
	}
}

function ShowSubMenu(obj) {
	var PMenu = obj.parentNode;
	var menu = null;
	HideMenu(PMenu);
	if (obj.getAttribute("menu"))menu = document.getElementById(obj.getAttribute("menu"));
	if (menu) {
		hideObjectTags();
		menu.style.top = (obj.offsetTop + PMenu.offsetTop + 0) + "px";
		menu.style.left = (PMenu.offsetLeft + obj.offsetWidth + 3) + "px";
		menu.style.display = "block";
		menu.style.visibility = "visible";
		if (!!document.all) {
			var ienavfix = document.getElementById(menu.id + "fix");
			if (!!ienavfix) {
				ienavfix.style.display = "block";			
			}
		}
	}
}

function InitMenu() {
	if (!document.getElementById && !document.childNodes) return;
	mb = document.getElementById("mb");
	document.body.onclick = HideMenu;
	var bar,menu,item,menuItem = null;
	for (var i=0;i<mb.childNodes.length;i++) {
		bar = mb.childNodes[i];
		if ((bar.nodeType != 1) || !((bar.className == "b") || (bar.className == "bh") || (bar.className == "bhs"))) continue;
		bar.onmouseout = resetTimer;
		bar.onmouseover = new Function("ShowMenu(\""+bar.id+"\")");
		if (bar.getAttribute("cmd")) bar.onclick = new Function("Do(\""+bar.id+"\")");
		if (bar.getAttribute("menu"))menu = document.getElementById(bar.getAttribute("menu"));
		if (menu) {
			menu.onmouseout = resetTimer;
			menu.style.visibility = "hidden";
			for (var j=0;j<menu.childNodes.length;j++) {
				item = menu.childNodes[j];
				if ((item.nodeType == 1) && (item.className == "mi")){
					menuItem = document.getElementById(item.id);
					if (menuItem.getAttribute("menu")) FindSubMenu(menuItem.getAttribute("menu"));
					if (menuItem.getAttribute("cmd")) menuItem.onclick = new Function("Do(\""+menuItem.id+"\")");
					menuItem.onmouseover = new Function("highlight(\""+item.id+"\")");
				};
			}	
    }
  }
}  	
if (window.addEventListener)window.addEventListener("load",InitMenu,false);
if (window.attachEvent)window.attachEvent("onload",InitMenu);
