$(function(){
	$('#nav>li>ul').hide();
	$('#nav>li>a.tl_nav').removeAttr("href");
	//$('#nav>li>a.tl_nav').attr('href','#'); 
	$('#nav>li').click(function()
	{   
	    var val = document.getElementById("ctl00_ucLeft_hdnMenu").value;
	    //alert(val);
		// check that the menu is not currently animated
		//alert("top - "+$('#nav ul:animated').size());
		if ($('#nav ul:animated').size() == 0)
		{
			// create a reference to the active element (this)
			// so we don't have to keep creating a jQuery objects
			$heading = $(this);
			// create a reference to visible sibling elements
			// so we don't have to keep creating a jQuery object
			$expandedSiblings = $heading.siblings().find('ul:visible');
			
			if ($expandedSiblings.size() > 0)
			{   //alert($expandedSiblings.size());
				$expandedSiblings.slideUp(500, function(){$heading.find('ul').slideDown(500);});
				//$heading.find('ul').slideUp(500);
			}
			else
			{
			    //alert("Value =" +val);
			    if(document.getElementById("ctl00_ucLeft_hdnMenu").value==0)
			    {
				    $heading.find('ul').slideDown(500);
				    //alert("Down");
				    //alert($expandedSiblings.size());
				    document.getElementById("ctl00_ucLeft_hdnMenu").value = 1;
				}
				else
				{
				    //$expandedSiblings.slideUp(500, function(){$heading.find('ul').slideDown(500);});
				    $heading.find('ul').slideUp(500);
				    document.getElementById("ctl00_ucLeft_hdnMenu").value = 0 ;
				    //alert("Up");
				}
			}
		}
	});
});