
/* 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 getTreeDrawItemColorFromDepth (depth)
{
	switch (depth)
	{
		case 0: return color_nav2;
		default: return color_nav1;
	}
}

function replaceStr (theStr)
{
	while (theStr.indexOf("&nbsp;") != -1)
	{
		theStr = theStr.replace('&nbsp;',' ');
	}
	return theStr;
}

function cptRow (theStr,sel)
{ 
	nbRow = 1;

	while (theStr.indexOf("&nbsp;") != -1)
	{
		theStr = theStr.replace('&nbsp;',' ');
	}
	if (theStr.length > 36)
	{
		if (sel)
		{
			nbRow = Math.round((theStr.length+18)/36);
		}
		else
		{
			nbRow = Math.round((theStr.length+10)/36);
		}
	}
	return nbRow ;
}

function tree_drawItem (idx, depth, name, url, group, selected_state, isselected)
{
	var item;
	var size = depth * 6;
	var nbrow = cptRow (name,isselected);

	if (isselected)
	{
		document.write (" \
		<DIV id='tree" + idx + "' style='position: absolute; z-index: " + (100 - depth) + "; \
		border-top : 1px solid #6AC618; \
		border-bottom: 1px solid #6AC618; \
		border-right: 1px solid #6AC618; \
		'> \
		<TABLE class='tabnav' height='"+18*nbrow +"' width='198' cellpadding='0' cellspacing='0' border='0'> \
		<TR height='"+19*nbrow +"'> ");
		if (depth >0 )
		{
			document.write ("<TD width='14'>	<IMG src='"+img_blank+"' width='" + size + "' height='1'></TD>");
		}
		document.write ("<TD width='14'><IMG id='img"+idx+"' src='"+img_leaf+"' border='0'>&nbsp;</TD>");
		document.write (" \
		<TD width='198' border='0'><a href='#' class='menunav2'>" + replaceStr (name) + "</a></TD> \
		</TR> \
		</TABLE></DIV> \
		");
	} 
	else
	{
		document.write (" \
		<DIV id='tree" + idx + "' style='position: absolute; z-index: " + (100 - depth) + "; border-left: 1px solid #6AC618; border-top : 0px; '> \
		<TABLE class='tabnav'  width='198' cellpadding='0' cellspacing='0' border='0'> \
		<TR height='"+20*nbrow +"'> ");
		if (group)
		{
			document.write ("<TD width='20'>&nbsp;<IMG id='img"+idx+"' src='"+img_closed+"' border='0'>&nbsp;</TD>");
		}
		if (depth >0 )
		{
			document.write ("<TD width='28'><IMG src='"+img_blank+"' width='" + size + "' height='1'>&nbsp;</TD>");
		}
		
		document.write (" \
		<TD class='tabnavnom' width='198' border='0'><a href='#' class='menunav'>" + replaceStr (name) + "</a></TD> \
		</TR> \
		</TABLE></DIV> \
		");
	}

	item = document.getElementById ("tree" + idx);

	item.xsize = 198;
	item.ysize = 20*nbrow ;
	
	return item;
}






/*
function tree_drawItem (idx, depth, name, url, group, selected_state)
{
	var item;
	var size = depth * 6;
	
	document.write (" \
	<DIV id='tree" + idx + "' style='position: absolute; z-index: " + (100 - depth) + "'> \
	<TABLE height='20' width='198' cellpadding='0' cellspacing='0' border='1'> \
	<TR height='19' bgcolor='" + getTreeDrawItemColorFromDepth (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='"+(198-14-size)+"' class='menutop'>" + name + "</TD> \
	</TR> \
	</TABLE></DIV> \
	");

	item = document.getElementById ("tree" + idx);

	item.xsize = 198;
	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='17'> \
	<TR> \
	");
	
	document.write (" \
	<TD id='menu_" + idx + "' bgcolor='"+color4+"' class='menutop' align='center'>&nbsp;&nbsp;<b>" + data[idx][0][0] + "</b>&nbsp;&nbsp;</TD> \
	<TD width='1' height='17' bgcolor='#FFFFFF'><IMG src='" + img_blank + "' height='17' 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 = menu_color2 (true);
		item2.style.borderLeft = "1px solid #DDDDE7";
		item2.style.borderTop = "1px solid #DDDDE7";
		item2.style.borderRight = "1px solid #DDDDE7";
		item2.style.borderBottom = "1px solid #ffffff";
		item2.style.color = color2;
	}
	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='"+color2+"' height='17'> \
	");
	
	for (var i = 1; i < data[idx].length; i++)
	{
		document.write (" \
		<TR height='17'> \
		<TD width='1' bgcolor='#ffffff'><IMG src=" + img_blank + " width='1' height='17'></TD> \
		<TD id='menu"+idx+"_"+i+"' class='menutop'>&nbsp;&nbsp;" + data[idx][i][0] + "&nbsp;&nbsp;</TD> \
		<TD width='1' bgcolor='#ffffff'><IMG src=" + img_blank + " width='1' height='17'></TD> \
		</TR> \
		");

		var td = document.getElementById ("menu"+idx+"_"+i);
		
		td.url = data[idx][i][1];
		td.onmouseover = ssmenu_setActive;
		td.onmouseout = ssmenu_setInactive;
		td.onclick = menu_click;
		
	}
	
	document.write (" \
	<TR>\
	<TD width='1' bgcolor='#ffffff'><IMG src=" + img_blank + " width='1' height='1'></TD> \
	<TD height='1' bgcolor='"+color1+"'><IMG src=" + img_blank + " width='100%' height='1'></TD> \
	<TD width='1' bgcolor='#ffffff'><IMG src=" + img_blank + " width='1' height='1'></TD> \
	</TR> \
	</TABLE> \
	</DIV> \
	");
	
	content = document.getElementById ("menu" + idx + "_content");
	
	return content;
}

