var menue_leave;
    var MID = 0;
    var pre_pid = 1;
    
    function switch_on(nb)
    {
        if( all_sm_urls[ nb-1 ] == "" )
            return;
            
        if( MID )
            document.getElementById( "menueItem" + MID ).style.backgroundImage = 'url(../' + baseURL + '/static/images/mm_back.gif)';
        MID = nb;
        hide_menue(1);
        document.getElementById("menueItem"+MID).style.backgroundImage = 'url(../' + baseURL + '/static/images/mm_back_act.gif)';
        show_layer();
    }

	function hoverSubMenue(nb){
		document.getElementById('subMenueIcon' + nb).style.backgroundColor = '#88C308';
	}
	
	function leaveSubMenue(nb){
		document.getElementById('subMenueIcon' + nb).style.backgroundColor = '';
	}
	
	function hoverSubSubMenue(nb){
		document.getElementById('subSubMenueIcon' + nb).style.backgroundColor = '#88C308';
	}
	
	function leaveSubSubMenue(nb){
		document.getElementById('subSubMenueIcon' + nb).style.backgroundColor = '';
	}

    function show_layer()
    {
        if(document.getElementById)
        {
            sm_titles = all_sm_titles[MID-1];
            sm_urls = all_sm_urls[MID-1];
			
            Layer_value = "<table onmouseover=\"hide_menue(1)\" onmouseout=\"hide_menue(0)\" cellpadding=\"0\" cellspacing=\"0\" border=\"0\" style=\"background-color:#385362; border-style:solid; border:2px;\" width=\"151\"><tr><td colspan=\"2\" width=\"134\" height=\"10\"></td></tr>";
           
            for(x = 0; x < sm_titles.length; x++)
            {
            	if(!(sm_titles[x] instanceof Array)){
            		Layer_value += "<tr><td id=\"subMenueIcon" + x + "\" width=\"7\" height=\"22\"></td><td width=\"127\" height=\"22\"><p style=\"margin-left:10px\"><a onmouseover=\"hoverSubMenue(" + x + ")\" onmouseout=\"leaveSubMenue(" + x + ")\" class=\"linkSubMenue\" href=\"" + sm_urls[x] + "\">" +  sm_titles[x] + "</a></p></td></tr>";
            	}
            	else{
            		Layer_value += "<tr><td id=\"subMenueIcon" + x + "\" width=\"7\" height=\"22\"></td><td width=\"127\" height=\"22\"><p class=\"textSubMenue\" style=\"margin-left:10px\">" +  sm_titles[x][0] + "</p></td></tr>";
            		
            		for(s = 1; s < sm_titles[x].length; s++){
            			Layer_value += "<tr><td id=\"subSubMenueIcon" + s + "\" width=\"7\" height=\"22\"></td><td width=\"127\" height=\"22\"><img style=\"margin-left:15px\" src=\"../" + baseURL + "/static/images/icn_arw.png\" width=\"7\" height=\"12\" alt=\"\"><a style=\"margin-left:5px\" onmouseover=\"hoverSubSubMenue(" + s + ")\" onmouseout=\"leaveSubSubMenue(" + s + ")\" class=\"linkSubMenue\" href=\"" + sm_urls[x][s-1] + "\">" +  sm_titles[x][s] + "</a></td></tr>";
            		}
            		//Sub Cat
            	}
            }

            Layer_value += "<tr><td colspan=\"2\" width=\"151\" height=\"10\"></td></tr></table>";
            
            var menueItemPos = getPositionOfObject(document.getElementById( "menueItem" + MID));
            
            if(MID < subMenueCount){
            	posX = menueItemPos.x;
            }
            else{
            	posX = menueItemPos.x - (151 - 99);
            }
            
            with( document.getElementById( "menueLayer" ) )
            {
                innerHTML = Layer_value;
                style.display = "block";
                style.width = 151;
                style.left = posX;
                style.top = menueItemPos.y + 24;
            }
        }
    }

    function hide_layer()
    {
        document.getElementById("menueItem"+MID).style.backgroundImage = 'url(../' + baseURL + '/static/images/mm_back.gif)';
        with(document.getElementById("menueLayer").style)
        {
            innerHTML = "";
            display = "none";
            width = 1;
            height = 1;
            x = 1;
            y = 1;
        }
    }

    function hide_menue( rsn )
    {
        if( !MID )
            return;

        if(rsn == 0)
        {
            menue_leave = window.setTimeout("hide_layer()",300);
        }

        if( rsn == 1 )
        {
            if( menue_leave )
                window.clearTimeout(menue_leave);
        }
    }
    
    function getPositionOfObject(obj){
     var tagname="", x=0, y=0;

while((typeof(obj) == "object") && (typeof(obj.tagName) != "undefined"))
	{
	y += obj.offsetTop;
	x += obj.offsetLeft;
	tagname = obj.tagName.toUpperCase();

	if (tagname == "BODY"){
  		obj = 0;
	}

	if(typeof(obj) == "object"){
		if(typeof(obj.offsetParent) == "object"){
    		obj = obj.offsetParent;
		}
	}
	}

     var position = new Object();
     position['x'] = x;
     position['y'] = y;

     return position;
}