
/* T R E E  D R A W I N G  M E T H O D S */

function getTreeColorFromDepth (depth)
{
	switch (depth)
	{
		case 0: return color2;
		default: return color1;
	}
}


function tree_drawItem (idx, depth, name, url, group, selected_state)
{
	var item;
	var size = depth * 6;
	
	document.write (" \
	<DIV id='tree" + idx + "' style='filter: alpha (opacity=80);position: absolute; z-index: " + (100 - depth) + "'> \
	<TABLE height='20' width='174' cellpadding='0' cellspacing='0' border='0'> \
	<TR height='19' bgcolor='" + getTreeColorFromDepth (depth) + "'> \
	<TD width='" + size + "'><IMG src='"+img_blank+"' width='" + size + "' height='1'></TD> ");
	
	if (group)
	{
		document.write ("<TD width='14'><IMG id='img"+idx+"' src='"+img_closed+"' border='0'></TD>");
	}
	else
	{
		document.write ("<TD width='14'><IMG src='"+img_leaf+"'></TD>");
	}
	
	document.write (" \
	<TD width='"+(174-14-size)+"' class='menutop'>" + name + "</TD> \
	</TR> \
	</TABLE></DIV> \
	");

	item = document.getElementById ("tree" + idx);

	item.xsize = 174;
	item.ysize = 20;
	
	return item;
}



/*  M E N U  D R A W I N G   M E T H O D S  */


function drawMenuRoot (idx, data)
{
	var item;
	
	var hasUrl = (data[idx][0].length >= 2);
	var color = false;
	try
	{
		color = data[idx][0][2];
	}
	catch(e){}
	
	document.write (" \
	<DIV id='menu" + idx + "' style='position: absolute; z-index: 300'> \
	<TABLE cellspacing='0' cellpadding='0' border='0' height='14'> \
	<TR> \
	");
	
	document.write (" \
	<TD id='menu_" + idx + "' bgcolor='"+color2+"' class='menutop' align='center'>&nbsp;&nbsp;<b>" + data[idx][0][0] + "</b>&nbsp;&nbsp;</TD> \
	<TD width='1' height='14'><IMG src='/chorege/img/nav/sep.gif' height='14' width='1'></TD> \
	</TR> \
	</TABLE> \
	</DIV> \
	");

	item = document.getElementById ("menu" + idx);
	
	if (hasUrl)
	{
		item.url = data[idx][0][1];
		item.onclick = menu_click;
	}
	item2 = document.getElementById ("menu_" + idx);
	
	if( color )
	{
		if( menu_color )
		item2.bgColor = "#e5e5e5";
		item2.style.color ="#436998"
	}
	else
	{
		item2.onmouseover = menu_setActive;
		item2.onmouseout = menu_setInactive;	
	}
	return item;
}


function drawMenuContent (idx, data)
{
	var content;
	
	document.write (" \
	<DIV id='menu" + idx + "_content' style='position: absolute; z-index: 300'> \
	<TABLE cellspacing='0' cellpadding='0' border='0' bgcolor='#2c96ae' height='14' style='filter:alpha(opacity=80);-moz-opacity:.80;opacity:.80;'> \
	");
	
	for (var i = 1; i < data[idx].length; i++)
	{
		document.write (" \
		<TR height='18'> \
		<TD width='1' bgcolor='#FFFFFF'><IMG src=" + img_blank + " width='1' height='14'></TD> \
		<TD id='menu"+idx+"_"+i+"' class='menutopn2'>&nbsp;&nbsp;" + data[idx][i][0] + "&nbsp;&nbsp;</TD> \
		<TD width='1' bgcolor='#FFFFFF'><IMG src=" + img_blank + " width='1' height='14'></TD> \
		</TR> \
		");

		var td = document.getElementById ("menu"+idx+"_"+i);
		
		td.url = data[idx][i][1];
		td.onmouseover = menu_setActive2;
		td.onmouseout = menu_setInactive2;
		td.onclick = menu_click;
		
	}
	
	document.write (" \
	<TR><TD colspan='3' height='1' bgcolor='#FFFFFF'><IMG src=" + img_blank + " width='100%' height='1'></TD></TR> \
	</TABLE> \
	</DIV> \
	");
	
	content = document.getElementById ("menu" + idx + "_content");
	
	return content;
}

function MM_jumpMenu(targ,selObj,restore,header){ //v3.0
  if(!header || selObj.selectedIndex > 0) eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_jumpMenuGo(selName,targ,restore,header){ //v3.0
  var selObj = MM_findObj(selName); if (selObj) MM_jumpMenu(targ,selObj,restore,header);
}

