
var MN_dc="|";
var MN_ct=0.75;
var MN_bz=50;
var MN_wd = 150;
var MN_xorg = 120;
var MN_ch = 16;
var MN_ss = "txt0";
var MN_bio = "imgs/menu_celloff.gif";
var MN_bil = "imgs/menu_cellon.gif";
var MN_tn = "imgs/transparent.gif";

var MN_nm = [];
var MN_mc = [];
var MN_y_off = [];
var MN_tid,MN_lv,MN_y_off;
IG_preload(MN_bil);

function MN_shw(ip_nm,ip_lv,ip_y_off){
	if (!loaded) return;
	clearTimeout(MN_tid);
	if (!ip_lv){
		MN_close();
		img_swap(ip_nm,"imgs/l_menu_"+ip_nm+"_on.gif");
	} else {
		if (window.display) display.menu_on();//above level=0
		MN_clr(ip_lv+1);	
		MN_y_off[ip_lv] = parseInt(ip_y_off);
		if (MN_nm[ip_lv]) MN_clr(ip_lv)
	} 
	MN_lv = (ip_lv) ? ip_lv : 0;
	MN_nm[MN_lv] = ip_nm;
	var x = MN_xorg + (MN_lv*MN_wd);
	var yo=0;
	for (var i=1;i<=MN_lv;i++){
		yo+=MN_y_off[i];
	}	
	var y = MN_mc[MN_nm[0]].y + (yo*MN_ch);
	MN_mc[ip_nm].lv = MN_lv;
	MN_mc[ip_nm].hi.left = x;
	MN_mc[ip_nm].co.left = x;
	MN_mc[ip_nm].ca.left = x;
	MN_mc[ip_nm].hi.top = y;
	MN_mc[ip_nm].co.top = y;
	MN_mc[ip_nm].ca.top = y;
	MN_mn_vis(ip_nm,"visible");
}

function MN_mn_vis(ip_nm,ip_st){
	MN_mc[ip_nm].hi.visibility=ip_st;
	MN_mc[ip_nm].co.visibility=ip_st;
	MN_mc[ip_nm].ca.visibility=ip_st;
	if (ip_st=="hidden") MN_mc[ip_nm].ov(false);
}

function MN_clr(ip_lv){
	st = (ip_lv) ? ip_lv : 0;
	for (i=st;i<=MN_lv;i++){
		MN_mn_vis(MN_nm[i],"hidden");
	}
}

function MN_out(){
	clearTimeout(MN_tid);
	MN_tid = setTimeout("MN_close();",MN_ct*1000);
}

function MN_close(){
	MN_clr();
	img_swap(MN_nm[0]);
	if (window.display) display.menu_off();
}

function MN_add(ip_nm, ip_tx, ip_cd , ip_y){
	o = MN_mc[ip_nm] = {};
	o.y = ip_y;
	o.t = ip_tx.split(MN_dc);
	o.c = ip_cd.split(MN_dc);
	o.nm = ip_nm
	o.hi = get_layer(o.nm+"hl",MN_bz,MN_write("hl",o)).style;
	o.co = get_layer(o.nm+"co",MN_bz+1,MN_write("co",o)).style;
	o.ca = get_layer(o.nm+"ce",MN_bz+2,MN_write("ce",o)).style;
	o.ov = function(rn){
		if (this.al) img_swap(this.al,MN_bio);
		img_swap(rn,MN_bil);
		this.al = rn;
	}
}

function MN_write(ip_type,o){
	var rn,ostr,hr;
	var str ="<table cellpadding='0' cellspacing='0' border='0' width='"+ MN_wd +"' height='" + (MN_ch*o.t.length) + "'>";

	for (j=0;j<o.t.length;j++){
		rn = "hl_"+o.nm+"_"+j;
		str += "<tr height="+ MN_ch+"'><td height="+ MN_ch+"' class="+MN_ss+" align='right'>";
		
		if (ip_type=="co"){
		str+="<span class='pd1'>"
			//str+= "&nbsp;&nbsp;</td>";
			//str+= "<td align='right'>";
			str+= o.t[j]+"&nbsp;</span></td>";
		}

		if (ip_type=="ce"){
			lk = o.c[j].substring(0,1)=="l";
			vl = o.c[j].substring(2,o.c[j].length);
			ostr = "clearTimeout(MN_tid);MN_mc['"+o.nm+"'].ov('"+rn+"');";
			ostr+= (lk) ? "MN_clr(MN_mc['"+o.nm+"'].lv+1);" : "MN_shw('"+vl+"',MN_mc['"+o.nm+"'].lv+1,'"+j+"');";
			hr= (lk) ? "document.location.href=\'" + vl + "\';" : "";
			str_cl = (lk) ? "" : "arrow";
			str+= "<a href=\"javascript:"+hr+"\" onmouseover=\""+ostr+"\" onmouseout='MN_out();'><img suppress='true' src='"+MN_tn+"' height='"+MN_ch+"' width='"+MN_wd+"' border='0' class='"+str_cl+"'></a>";
		}
		
		if (ip_type=="hl"){
			str+= "<img suppress='true' src='"+MN_bio+"' height="+MN_ch+" width="+MN_wd+" name='"+rn+"'>";
		}	
		str+= "</td></tr>";
	}
	str+="</table>";
	str+="<table></table>";
	return str;
}