var submenuoffset=0; //Offset of submenus from main menu. Default is -2 pixels.
var mainMenuWidth=192;
var subMenuWidth=192;

function createcssmenu()
{
	var rootID="verticalmenu";
	var objRoot=$(rootID);
	var arrChild=objRoot.immediateDescendants();
	for(i=0; i<arrChild.length;i++)
	{
		nodes=arrChild[i].immediateDescendants();
		if(nodes.length>1)
		{
			processImmediateDescendants(1,nodes[0],nodes[1]);
		}
	}
}
function processImmediateDescendants(depth,aObj, node)
{
	
	var spanref=document.createElement("span");
	spanref.className="arrowdiv";
	spanref.innerHTML="&nbsp;&nbsp;";
	aObj.appendChild(spanref);

	if(depth==1)
	{
		left=mainMenuWidth + submenuoffset;
	}
	else
	{
		left=subMenuWidth + submenuoffset;
		
	}

	node.style.zIndex =node.style.zIndex + depth + 1;
	node.style.left=left+"px";
	//node.style.width=subMenuWidth+"px";
	
	node.parentNode.onmouseover=function()
	{
		this.getElementsByTagName("ul")[0].style.display="block";
	}
	node.parentNode.onmouseout=function()
	{
		this.getElementsByTagName("ul")[0].style.display="none";
	}
	
	depth=depth + 1;
	var arrNode=node.immediateDescendants();
	for(j=0; j<arrNode.length;j++)
	{
		cNodes=arrNode[j].immediateDescendants();
		if(cNodes.length>1)
		{		
			processImmediateDescendants(depth,cNodes[0],cNodes[1]);
		}
		
	}
	
}
if (window.addEventListener)
window.addEventListener("load", createcssmenu, false)
else if (window.attachEvent)
window.attachEvent("onload", createcssmenu)