var tms = new Array();
var menus = new Array("menu_empresa", "menu_produtos");

var ie = document.all && navigator.appName.indexOf("Microsoft") > -1 ? true : false;

function topo_DoFSCommand(command, args) {
	switch(command){
		case "showMenuItem":
			showMenuItem(args);
		break;
		case "hideMenuItem":
			hideMenuItem(args);
		break;
	}
}

if (ie && navigator.userAgent.indexOf("Windows 3.1") == -1) {
	document.write('<SCRIPT LANGUAGE=VBScript\> \n');
	document.write('on error resume next \n');
	document.write('Sub topo_FSCommand(ByVal command, ByVal args)\n');
	document.write('  call topo_DoFSCommand(command, args)\n');
	document.write('end sub\n');
	document.write('</SCRIPT\> \n');
}

function showMenuItem(i, o){
	if(i > -1 && i != "undefined"){
		var item = menus[i];
	} else {
		var item = false;
	}
	for(j=0; j<menus.length; j++){
		if(menus[j] != item) document.getElementById(menus[j]).style.visibility = "hidden";
	}
	if(item){
		var obj = document.getElementById(item);
		//
		forceShow(i, true);
		if(obj.style.visibility != "visible"){
			obj.style.visibility = "visible";
		}
		if(o){
			o.i = i;
			o.onmouseout = function(){
				hideMenuItem(this.i, 1400);
			}
		} else {
			hideMenuItem(i, 1400);
		}
	}
}

function showCascade(obj){
	var o = document.getElementById(obj);
	o.loop = setInterval("show('" + obj + "');", 90);
}

function forceShow(i, noshow){
	var item = menus[i];
	if(typeof tms[item] != "undefined"){
		if(!noshow) document.getElementById(item).style.visibility = "visible";
		clearTimeout(tms[item]);
		delete tms[item];
	}
}

function hideMenuItem(i, s){
	if(s == "undefined") var s = 500;
	if(i < menus.length){
		var item = menus[i], hideAction = "document.getElementById('" + item + "').style.visibility = 'hidden';";
		tms[item] = setTimeout(hideAction, s);
	}

}
