function generateLeftNav(selectedLink, lvl2Links, lvl2URLs, lvl3Links, lvl3URLs, menuBorderColor, menuId)
{

	var aLvl2Links = lvl2Links.split("~");
	var aLvl2URLs = lvl2URLs.split("~");
	var aLvl3Links = lvl3Links.split("~");
	var aLvl3URLs = lvl3URLs.split("~");
	var sHtml;
	var iLeftNavHeight;

	if (document.getElementById("leftNavTbl") != null)
		document.getElementById("leftNavTbl").style.background = "#f8e4c5";
	else
		document.getElementById("uctlLeftNav_leftNavTbl").style.background = "#f8e4c5";


	sHtml = "<table style='width:100%' cellspacing='0' cellpadding='0'>";
	
	for (i=0;i<aLvl2Links.length;i++)
	{
		if (aLvl2URLs[i] != "")
		{
		if (i==0)
		{
			sHtml = sHtml + "<tr class='level1-menu-item'><td width='4px'></td><td width='11px'></td><td align='left' valign='middle' style='height:32px' colspan='2'>";	
			sHtml = sHtml + "<a href='";
			sHtml = sHtml + aLvl2URLs[i];
			sHtml = sHtml + "' class='menu-selected-text'>";
			sHtml = sHtml + aLvl2Links[i];
			if (selectedLink == "")
			{		
				sHtml = sHtml + "</a></td><td width='6px'></td><td width='4px' class='menu-hide-item-border'></td></tr>";
			}
			else
			{
				sHtml = sHtml + "</a></td><td width='6px'></td><td width='4px' style='background:" + menuBorderColor + "'></td></tr>";				
			}
			iLeftNavHeight = 32;
		}
		else
		{
			if (selectedLink == aLvl2Links[i])
			{
				sHtml = sHtml + "<tr><td colspan='6' style='height:4px;background:" + menuBorderColor + "'></td></tr>";
				iLeftNavHeight = iLeftNavHeight + 4;
				sHtml = sHtml + "<tr style='background:#ffffff'><td width='4px' style='background:" + menuBorderColor + "'></td><td></td><td align='left' valign='middle' style='height:20px' colspan='2'>";
				sHtml = sHtml + "<a href='";
				sHtml = sHtml + aLvl2URLs[i];
				sHtml = sHtml + "' class='menu-text'>";
				sHtml = sHtml + aLvl2Links[i];
				sHtml = sHtml + "</a></td><td width='6px'></td><td width='4px'></td></tr>";
				iLeftNavHeight = iLeftNavHeight + 20;
				if (aLvl3Links.length>1)
				{
					for (j=1;j<aLvl3Links.length;j++)
					{
					if (aLvl3Links[j] !="")
					{
						sHtml = sHtml + "<tr class='' style='background:#ffffff'><td style='background:" + menuBorderColor + "'></td><td></td><td width='10px'></td><td align='left' valign='middle' style='height:20px'>";
						sHtml = sHtml + "<a href='";
						sHtml = sHtml + aLvl3URLs[j];
						sHtml = sHtml + "' class='menu-text'>";
						sHtml = sHtml + aLvl3Links[j];
						sHtml = sHtml + "</a></td><td></td><td width='4px'></td></tr>";				
						iLeftNavHeight = iLeftNavHeight + 20;
					}
					}
				}				
				sHtml = sHtml + "<tr><td colspan='6' style='height:4px;background:" + menuBorderColor + "'></td></tr>";				
				iLeftNavHeight = iLeftNavHeight + 4;
			}
			else
			{
				sHtml = sHtml + "<tr class=''><td width='4px'></td><td></td><td align='left' valign='middle' style='height:30px' colspan='2'>";
				sHtml = sHtml + "<a href='";
				sHtml = sHtml + aLvl2URLs[i];
				sHtml = sHtml + "' class='menu-text'>";
				sHtml = sHtml + aLvl2Links[i];
				if (selectedLink == "")
				{						
					sHtml = sHtml + "</a></td><td width='6px'></td><td width='4px' class='menu-hide-border'></td></tr>";
				}
				else
				{
					sHtml = sHtml + "</a></td><td width='6px'></td><td width='4px' style='background:" + menuBorderColor + "'></td></tr>";
				}
				iLeftNavHeight = iLeftNavHeight + 30;
			}
		}
		}
	}
	 
	sHtml = sHtml + "</table>";
	
	if (document.getElementById("hdnLeftNavHeight") != null)
	{
		document.getElementById("hdnLeftNavHeight").value = iLeftNavHeight.toString();
	}
	
	if (document.getElementById("leftNav") != null)
		document.getElementById("leftNav").innerHTML = sHtml;
	else
		document.getElementById("uctlLeftNav_leftNav").innerHTML = sHtml;	
		
	if (selectedLink=="" && lvl3Links=="" && lvl3URLs=="")
	{
		document.getElementById("border1").style.background = menuBorderColor;
		document.getElementById("border2").style.background = menuBorderColor;	
		if (document.getElementById("leftNavBorder") != null)
			document.getElementById("leftNavBorder").style.background = "#f8e4c5";
		else
			document.getElementById("uctlLeftNav_leftNavBorder").style.background = "#f8e4c5";
	}
	else
	{	    
		document.getElementById("border1").style.background = "#f8e4c5";
		document.getElementById("border2").style.background = menuBorderColor;	
		if (document.getElementById("leftNavBorder") != null)
			document.getElementById("leftNavBorder").style.background = menuBorderColor;
		else
			document.getElementById("uctlLeftNav_leftNavBorder").style.background = menuBorderColor;
	}	
	
	if (document.getElementById("hdnCurrMenuItem").value != "")
	{		
		var prevMenuId = document.getElementById("hdnCurrMenuItem").value;
		document.getElementById(prevMenuId.replace("default","highlight")).style.visibility = "hidden";
		document.getElementById(prevMenuId.replace("default","highlight")).style.display = "none";
		document.getElementById(prevMenuId).style.visibility = "visible";
		document.getElementById(prevMenuId).style.display = "inline";	
		
		document.getElementById(prevMenuId.replace("default","baseBorder")).style.visibility = "visible";
		document.getElementById(prevMenuId.replace("default","baseBorder")).style.display = "inline";
		document.getElementById(prevMenuId.replace("default","baseBorder")).style.background = menuBorderColor;
		document.getElementById(prevMenuId.replace("default","surrBorder")).style.visibility = "hidden";
		document.getElementById(prevMenuId.replace("default","surrBorder")).style.display = "none";	
	}
	
	if (menuId!="" && menuId!=null)
	{
		document.getElementById(menuId.replace("default","highlight")).style.background = menuBorderColor;
		document.getElementById(menuId.replace("default","highlight")).style.visibility = "visible";
		document.getElementById(menuId.replace("default","highlight")).style.display = "inline";
		document.getElementById(menuId).style.visibility = "hidden";
		document.getElementById(menuId).style.display = "none";
		document.getElementById(menuId.replace("default","baseBorder")).style.visibility = "hidden";
		document.getElementById(menuId.replace("default","baseBorder")).style.display = "none";
		document.getElementById(menuId.replace("default","surrBorder")).style.visibility = "visible";
		document.getElementById(menuId.replace("default","surrBorder")).style.display = "inline";
		document.getElementById(menuId.replace("default","surrBorder")).style.background = menuBorderColor;
		document.getElementById("hdnCurrMenuItem").value = menuId;
		
		for(i=0;i<100;i++)
		{
			if (document.getElementById("baseBorder" + i) == null) 
				break;
			else
			{
				if (menuId.replace("default","baseBorder") != ("baseBorder" + i))
				{
					document.getElementById("baseBorder" + i).style.visibility = "visible";
					document.getElementById("baseBorder" + i).style.display = "inline";
					document.getElementById("baseBorder" + i).style.background = menuBorderColor;
				}
			}
		}	
		
		for(i=0;i<100;i++)
		{
			if (document.getElementById("linkText" + i) == null) 
				break;
			else
			{
				if (menuId.replace("default","linkText") != ("linkText" + i))
				{
					document.getElementById("linkText" + i).className = "main-menu-text";
				}
				else
				{
					document.getElementById("linkText" + i).className = "menu-selected-text";
				}
			}
		}			
		
	}
	
	setMidBorder(menuBorderColor);
	
	var iPageHeight;
	var totalLeftNavHeight;
	if (document.getElementById("hdnInitPageHeight") != null)
	{
		if (document.getElementById("hdnInitPageHeight").value != "")
		{
			iPageHeight = parseInt(document.getElementById("hdnInitPageHeight").value); 
			alert(iPageHeight);
			alert(iLeftNavHeight);
			if ((iPageHeight - 90 - 60) > iLeftNavHeight)
			{
				totalLeftNavHeight = iPageHeight - 90 - iLeftNavHeight - 60;
			}
			else
			{
				totalLeftNavHeight = 0;
			}
			if (document.getElementById("leftNavContainer") != null)
			{
				document.getElementById("leftNavContainer").style.height = totalLeftNavHeight + "px";
			}
			alert(totalLeftNavHeight);
		}
	}
}

function setMidBorder(menuBorderColor)
{
	document.getElementById("midBorder1").style.background = menuBorderColor;
	document.getElementById("midBorder3").style.background = menuBorderColor;
	for(i=0;i<100;i++)
	{
		if (document.getElementById("midBorder2" + i) == null) 
			break;
		else
			document.getElementById("midBorder2" + i).style.background = menuBorderColor;
	}	
}
