/*
CMS Menu v1.0
(C)2003 Aptus s.c.
*/

//background-image:URL(/i/bg1.gif); background-repeat:repeat-x; background-position:top; background-color:RGB(183,6,40);

cm_menubg='RGB(183,6,40)'
cm_style_menu='background-color:#96001D;';
cm_style_hdr='';
cm_style_item_start='';
cm_style_item='background-color:'+cm_menubg+'; font-family:Tahoma,Verdana,Arial; font-size:11px; color:RGB(252,247,249); padding:2px 10px 2px 2px; background-image:URL(/i/bg1.gif); background-repeat:repeat-x; background-position:top;';
cm_style_item2='background-color:'+cm_menubg+'; font-family:Tahoma,Verdana,Arial; font-size:11px; color:RGB(252,247,249); padding:2px 20px 2px 2px; background-image:URL(/i/bg1.gif); background-repeat:repeat-x; background-position:top;';
cm_style_link='font-family:Tahoma,Verdana,Arial; font-size:11px; color:#FFFFFF; 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()
{
	width=Array(66,47,55,51,119,80,59,71);
	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(width[i]);
		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=0;
	var tmp=t;
	while(tmp!=null) {
		x+=tmp.offsetLeft;
		y+=tmp.offsetTop;
		tmp=tmp.offsetParent;
	}
	e.left=x+t.offsetWidth;
	e.top=y-2;
	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+14;
	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();',500);
}

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(width)
{
	return '<table width="'+width+'" cellspacing=0 cellpadding=0 border=0 style="'+cm_style_menu+'"';
}

function cm_menuend()
{
	var s='<tr><td width='+width+' bgcolor="#96001D"><img src="i/b.gif" width=1 height=1></td></tr>';
    s+='<tr><td width='+width+' bgcolor="#B70628"><img src="i/b.gif" width=1 height=1></td></tr>';
	s+='</table>';
	return s;
}

function cm_menuitem(t,m)
{
	if(t.length>1) {
		var s='<tr><td width="100%" bgcolor="#96001D" colspan=2><img src="i/b.gif" width=1 height=1></td></tr>';
		s+='<tr><td width="100%" bgcolor="#B70628" colspan=2><img src="i/b.gif" width=1 height=1></td></tr>';
		s+='<td nowrap';
		if(t.length>2)
			s+=' style="'+cm_style_item2+'" onmouseover="cm_submenu('+t[2]+',this,'+m+'); this.style.color=\'#E9A710\'; this.style.cursor=\'pointer\'; window.status=\''+t[0]+'\'; return true;" onmouseout="this.style.color=\'#FCF7F9\'; window.status=\'\'; return true;"';
		else
			s+=' style="'+cm_style_item+'" onMouseover="cm_hidesub('+m+'); this.style.color=\'#E9A710\'; this.style.cursor=\'pointer\';window.status=\''+t[0]+'\';return true;" onmouseout="this.style.color=\'#FCF7F9\'; window.status=\'\'; return true;"';
		if(t[1].length>0)
		{
			s+=' onClick="location.href=\''+t[1]+'\';"';
		}
		s+='>';
		s+='&nbsp;'+t[0];
		s+='</td>';

		if(t.length>2)
			s+='<td width=15 bgcolor=\'#96001D\'><img src=\'/i/sc2.gif\' width=15 height=17></td>';
		else
			s+='<td width=15 bgcolor=\'#96001D\'><img src=\'/i/sc1.gif\' width=15 height=17></td>';

		s+='</tr>';
		return s;
	}
	return '<tr><td style="'+cm_style_hdr+'">'+t[0]+'</td></tr>';
}
