cm_style_menu='';
cm_style_hdr='';
cm_style_item='font-family:Tahoma, Verdana; font-size:11px; color:#fff; font-weight:bold; height:21px; background-color:#252525; border-style:solid; border-color:#484848; border-width:0px 1px 1px 1px; padding:0px 9px 0px 9px; text-transform:uppercase;';
cm_style_link='font-family:Tahoma, Verdana; font-size:11px; color:#FFF; text-decoration:none;';
cm_link_over='this.offsetParent.style.backgroundColor=\'#FFFFFF\';';
cm_link_out='this.offsetParent.style.backgroundColor=\'#000000\';';

cm_shiftx=0;
cm_shifty=0;

cm_list=Array();
cm_timer=null;
cm_inited=false;

function cm_init() {
	var i;
	var d='';
	for(i=0; i<cm.length; i++) {
		d+='<div id="cm'+i+'" style="z-index:3;position:absolute;left:0px;top:0px;visibility:hidden;" onMouseOver="cm_over();" onMouseOut="cm_out();">';
		d+=cm_menustart();
		var j;
		for(j=0; j<cm[i].length; j++)
			d+=cm_menuitem(cm[i][j],i);
		d+=cm_menuend();
		d+='</div>';
	}
	document.getElementById('cm').innerHTML=d;
	cm_inited=true;
}

function cm_menu(id,t) {
	if(!cm_inited)
		return;
	cm_hideall();
	var e=document.getElementById('cm'+id).style;
	var x=0;
	var y=-3;
	var tmp=t;
	while(tmp!=null) {
		x+=tmp.offsetLeft;
		y+=tmp.offsetTop;
		tmp=tmp.offsetParent;
	}
	e.left=x-1;
	e.top=y+t.offsetHeight+4;
	e.visibility='visible';
	cm_list=Array();
	cm_list[0]=id;
}

function cm_hidesub(m) {
	var i;
	for(i=0; i<cm_list.length; i++)
		if(cm_list[i]==m) {
			var j=i;
			for(i++; i<cm_list.length; i++)
				document.getElementById('cm'+cm_list[i]).style.visibility='hidden';
			cm_list=cm_list.slice(0,j+1);
			break;
		}
}

function cm_submenu(id,t,m) {
	var i;
	for(i=0; i<cm_list.length; i++)
		if(cm_list[i]==m) {
			var j=i;
			for(i++; i<cm_list.length; i++)
				document.getElementById('cm'+cm_list[i]).style.visibility='hidden';
			cm_list=cm_list.slice(0,j+1);
			break;
		}
	var e1=document.getElementById('cm'+id);
	var e2=document.getElementById('cm'+m);
	if(t.offsetLeft+t.offsetWidth+e2.offsetLeft+cm_shiftx+e1.offsetWidth<document.body.clientWidth)
		e1.style.left=t.offsetLeft+t.offsetWidth+e2.offsetLeft+cm_shiftx-1;
	else
		e1.style.left=t.offsetLeft+e2.offsetLeft-e1.offsetWidth-cm_shiftx;
	e1.style.top=t.offsetTop+e2.offsetTop+cm_shifty;
	e1.style.visibility='visible';
	cm_list[cm_list.length]=id;
}

function cm_over() {
	if(cm_timer!=null)
		clearTimeout(cm_timer);
	cm_timer=null;
}

function cm_out() {
	if(cm_timer!=null)
		clearTimeout(cm_timer);
	cm_timer=setTimeout('cm_hideall();',400);
}

function cm_hideall() {
	if(!cm_inited)
		return;
	if(cm_timer!=null)
		clearTimeout(cm_timer);
	cm_timer=null;
	var i;
	for(i=0; i<cm.length; i++)
		document.getElementById('cm'+i).style.visibility='hidden';
	cm_list=Array();
}

function cm_menustart() {
	return '<table cellspacing=0 cellpadding=0 border=0 style="'+cm_style_menu+'">';
}

function cm_menuend() {
	return '</table>';
}

function cm_menuitem(t,m) {
	if(t.length>1) {
		var s='<tr><td width=63 style="'+cm_style_item+'"';
		if(t.length>2)
			s+=' onmouseover="cm_submenu('+t[2]+',this,'+m+');this.style.backgroundColor=\'#EE7D03\';this.style.cursor=\'pointer\';window.status=\''+t[0]+'\';return true;" onmouseout="this.style.backgroundColor=\'#252525\';window.status=\'\';return true;"';
		else
			s+=' onMouseover="cm_hidesub('+m+');this.style.backgroundColor=\'#EE7D03\';this.style.cursor=\'pointer\';window.status=\''+t[0]+'\';return true;" onmouseout="this.style.backgroundColor=\'#252525\';window.status=\'\';return true;"';
		if(t[1].length>0)
		{
			s+=' onClick="location.href=\''+t[1]+'\';"';
		}
		s+='><nobr>';
		s+=''+t[0];
		if(t.length>2)
			s+='&nbsp;<span style="font-size:13px; color:#494949;">&raquo;</span></td></tr>';
		else
			s+='</nobr></td></tr>';
		return s;
	}
	return '<tr><td style="'+cm_style_hdr+'">'+t[0]+'</td></tr>';
}
