var h=0;
var subMenu;
var p;

function initPage()
{
	var n = document.getElementById("left-nav");
	if (n)
	{
		var lis = n.getElementsByTagName("li");
		for (var i = 0; i < lis.length; i++)
		{
			if (lis[i].getElementsByTagName("ul").length)
			{
				if (lis[i].parentNode.id == "left-nav")
				{
					var a = lis[i].getElementsByTagName("a").item(0);
					if (a)
					{
						a.onclick = function ()
						{
							p = this.parentNode;
							subMenu = p.getElementsByTagName("ul").item(0);
							if (p.className.indexOf("active") != -1)
							{
								
								p.className = p.className.replace("active", "");
								hidemenu();
								
								for (var i = 0; i < lis.length; i++)
									{
													
										if (lis[i]!=p)
										{
										lis[i].className = "";
										if (lis[i].parentNode.id == "left-nav")
											lis[i].style.height = "40px";
										}
									}
							}
							else
							{
								p.className = " active";
								
								for (var i = 0; i < lis.length; i++)
									{
										if (lis[i]!=p)
										lis[i].className = "narrow";
										if (lis[i].parentNode.id == "left-nav")
											lis[i].style.height = "30px";
										
									}
								//alert ("show!!!");
								showmenu();
				
								
							}
							return false;
						}
					}
				}
			}
		}
	}
}

if (window.addEventListener)
	window.addEventListener("load", initPage, false);
else if (window.attachEvent)
	window.attachEvent("onload", initPage);
	
//================sliding functions==================//


function showmenu(subMenu)
{
h=0
intShow=setInterval("show()",3);
}
function hidemenu(element)
{
		p.style.height="40px";
		subMenu.style.height="0px";
}
function show()
{
	if (h<80)
	{
	h=h+5;
	subMenu.style.height=h+'px'
	p.style.height=h+'px'
	}
	else
	{
		p.style.height="105px";
		subMenu.style.height="80px";
		clearInterval(intShow);
	}
}
function hide()
{
	if (h>0)
	{
	h=h-5;
	subMenu.style.height=h+"px";
	p.style.height=h+"px";
	alert("hey!!!");
	}
	else
	{
		p.style.height="40px";
		subMenu.style.height="0px";
		clearInterval(intHide);
	}
}

	
	
