
/* 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 isPresentInPathTree(name)
{
	for(var i = 0; i < path_tree_data.length;i++)
	{
		if(path_tree_data[i][1]==name)
		{
			return false;
		}
	}
	return true;
}

compteur = 0;
function tree_drawItem (idx, depth, name, url, group, selected_state)
{
	var item;
	var size = depth * 10;
	document.write (" \
	<DIV id='tree" + idx + "' style='position: absolute; z-index: " + (100 - depth) + "'> \
	<TABLE height='15' width='160' cellpadding='0' cellspacing='0' border='0'> ");
	if (compteur == 0)
	{
		document.write (" \
	<TR><TD></TD> \
	<TD colspan='2' bgColor='#999999'><IMG src='"+img_blank+"' width='10' height='1'></TD></TR>");
	compteur = 1;
	}
	
	document.write (" \
	<TR height='15' class='menugauche1'> \
	<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
	{
		if( isPresentInPathTree(name) )
		{
			document.write ("<TD width='14'><IMG src='"+img_leaf+"'></TD>");
		}
		else
		{
			document.write ("<TD width='14'><IMG src='"+img_closedSelected+"'></TD>");
		}
	}
	
	if( isPresentInPathTree(name) )
	{
		document.write (" \
		<TD id='treename" + name + "' width='"+(160-14-size)+"' class='menugauche1'>" + name + "</TD> \
		</TR>");
	}
	else
	{
		document.write (" \
		<TD id='treename" + name + "' width='"+(160-14-size)+"' class='menugauche1Selected'>" + name + "</TD> \
		</TR>");
	}
	
	
	document.write (" \
	<TR><TD></TD> \
	<TD colspan='2' bgColor='#999999'><IMG src='"+img_blank+"' width='10' height='1'></TD></TR>");
	
	document.write (" \
	</TABLE></DIV> \
	");
	item = document.getElementById ("tree" + idx);

	item.xsize = 160;
	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);
	
	document.write (" \
	<DIV id='menu" + idx + "' style='position: absolute; z-index: 300'> \
	<TABLE cellspacing='0' cellpadding='0' border='0' height='18'> \
	<TR> \
	");
	if (idx == 0)
	{
	//alert();
	document.write (" \
	<TD width='1' height='20'><IMG src='/poenv/img/trait_nav.gif' border='0' width='1'></TD> \
	");
	}
	
	document.write (" \
	<TD id='menutd" + idx + "' bgcolor='"+color2+"' class='menutop' align='center'><IMG src='/poenv/img/00.gif' width='5' height='1' align='middle'><b>" + data[idx][0][0] + "</b><IMG src='/poenv/img/00.gif' width='5' height='1'></TD> \
	<TD width='1' align='center' height='20'><IMG src='/poenv/img/trait_nav.gif' border='0' width='1'></TD> \
	</TR> \
	</TABLE> \
	</DIV> \
	");

	item = document.getElementById ("menu" + idx);
	
	var td = document.getElementById ("menutd"+idx);
	
	if (hasUrl)
	{
		item.onclick = menu_click;
		item.url = data[idx][0][1];
		
		
	}
	td.onmouseover = menu_setActive;
	td.onmouseout = menu_setInactive;
	
	return item;
	var compt = 1;
}


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='"+color2+"' height='18'> \
	");
	
	for (var i = 1; i < data[idx].length; i++)
	{
		document.write (" \
		<TR height='18'> \
		<TD width='1' bgcolor='"+color1+"'><IMG src=" + img_blank + " width='1' height='18'></TD> \
		<TD id='menu"+idx+"_"+i+"' class='menutop'>&nbsp;&nbsp;" + data[idx][i][0] + "&nbsp;&nbsp;</TD> \
		<TD width='1' bgcolor='"+color1+"'><IMG src=" + img_blank + " width='1' height='18'></TD> \
		</TR> \
		");

		var td = document.getElementById ("menu"+idx+"_"+i);
		
		td.url = data[idx][i][1];
		td.onmouseover = menu_setActive;
		td.onmouseout = menu_setInactive;
		td.onclick = menu_click;
		
	}
	
	document.write (" \
	<TR><TD colspan='3' height='1' bgcolor='"+color1+"'><IMG src=" + img_blank + " width='100%' height='1'></TD></TR> \
	</TABLE> \
	</DIV> \
	");
	
	content = document.getElementById ("menu" + idx + "_content");
	
	return content;
}

