//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 (ie && win) {	pluginlist = detectIE("Adobe.SVGCtl","SVG Viewer") + detectIE("SWCtl.SWCtl.1","Shockwave Director") + detectIE("ShockwaveFlash.ShockwaveFlash.1","Shockwave Flash") + detectIE("rmocx.RealPlayer G2 Control.1","RealPlayer") + detectIE("QuickTimeCheckObject.QuickTimeCheck.1","QuickTime") + detectIE("MediaPlayer.MediaPlayer.1","Windows Media Player") + detectIE("PDF.PdfCtrl.5","Acrobat Reader"); }
if (ns || !win) {	nse = ""; for (var i=0;i<navigator.mimeTypes.length;i++) nse += navigator.mimeTypes[i].type.toLowerCase(); pluginlist = detectNS("image/svg-xml","SVG Viewer") + detectNS("application/x-director","Shockwave Director") + detectNS("application/x-shockwave-flash","Shockwave Flash") + detectNS("audio/x-pn-realaudio-plugin","RealPlayer") + detectNS("video/quicktime","QuickTime") + detectNS("application/x-mplayer2","Windows Media Player") + detectNS("application/pdf","Acrobat Reader"); }
function detectIE(ClassID,name) { result = false; document.write('<SCRIPT LANGUAGE=VBScript>\n on error resume next \n result = IsObject(CreateObject("' + ClassID + '"))</SCRIPT>\n'); if (result) return name+','; else return ''; }
function detectNS(ClassID,name) { n = ""; if (nse.indexOf(ClassID) != -1) if (navigator.mimeTypes[ClassID].enabledPlugin != null) n = name+","; return n; }
pluginlist += navigator.javaEnabled() ? "Java," : "";
if (pluginlist.length > 0) pluginlist = pluginlist.substring(0,pluginlist.length-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 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 != 1) || (item.className != "mi")) continue;
			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) {
	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");
		var 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) {

			menu.style.top =  (getAbsTop(obj) + 42) + "px";
			menu.style.left = getAbsLeft(obj) + "px";
			menu.style.display = "block";
			menu.style.visibility = "visible";

		}
	}
}
   
function highlight(obj) {
	clearTimeout(tID);
	obj = document.getElementById(obj);
	var PElement = document.getElementById(obj.parentNode.id);
	for (var i=0;i<PElement.childNodes.length;i++) {
		var elm = PElement.childNodes[i];
		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 (cmd.toLowerCase().indexOf("javascript:") != 0){
		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;
		}	
	}
	else{
		eval(cmd.substr(11));
	};
}

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];
		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";
		var 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) continue;
					if (tElm.className == "io") tElm.className = "mi";
				}
				HideMenu(childMenu);
				childMenu.style.visibility = "hidden";
				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;
	HideMenu(PMenu);
	var menu = document.getElementById(obj.getAttribute("menu"));
	if (menu) {
		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";			
			}
			else if (!!document.all && !!document.createElement && !!document.appendChild && !!is_ie4up && !!mb) {
				var ienavfix = document.createElement("iframe");
				ienavfix.id = menu.id + "fix";
				ienavfix.style.position = "absolute";
				ienavfix.style.zIndex = "1";
				ienavfix.style.display = "block";
				ienavfix.style.top = menu.style.top;
				ienavfix.style.left = menu.style.left;
				ienavfix.style.width = menu.offsetWidth + "px";
				ienavfix.style.height = menu.offsetHeight + "px";
				mb.appendChild(ienavfix);
			}		
		}
	}
}

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+"\")");
		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")) continue;
				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+"\")");
			}	
    }
  }
}  	

//Menu Code Ends

window.onload = InitMenu;
