cm_style_menu='';
cm_style_hdr='';
cm_style_item='font-family:Tahoma, Verdana; font-size:11px; color:#EBEBEB; font-weight:bold; height:21px; background:#252525; border-style:solid; border-bottom-color:#646464; border-width:0px 0px 1px 0px; padding:2px 10px; text-transform:uppercase;';

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;display:none;" 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 tmpo=$(t).offset();
	e.left=tmpo.left - 11 +'px';
	e.top=tmpo.top + 22 + 'px';
	$('#cm'+id).show();
	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.display='none';
			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.display='none';
			cm_list=cm_list.slice(0,j+1);
			break;
		}
	var e1=document.getElementById('cm'+id);
	var e1_offset=$(e1).offset();
	var t_offset=$(t).offset();

	e1.style.left=t_offset.left + $(t).width() + 'px';
	e1.style.top=t_offset.top+'px';

	$('#cm'+id).show();
	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++)
		$('#cm'+i).fadeOut();
	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=\'#B80000\';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=\'#B80000\';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>';
}

