var anchors;
var j = 0;

function show_menu(obj){

    id = obj.getAttribute("id");
    
    var el = document.getElementById('B' + obj.id);
    
    
    
    if (el.style.display == "none") {
        obj.style.backgroundImage = "url(http://" + location.host + "/images/default/open.gif)";
        el.style.display = "block";
    }
    else {
        obj.style.backgroundImage = "url(http://" + location.host + "/images/default/close.gif)";
        el.style.display = "none";
    }
    
    
    
}

function open_menu(id){
	

	
  i = 0;
    while (document.getElementById(id).parentNode.id) {
		anchor=document.getElementById(id).parentNode;
		anchor.style.display="block";
		id = anchor.id;
		document.getElementById(id.substr(1)).style.backgroundImage = "url(http://" + location.host + "/images/default/open.gif)";
        i++;
        if (i > 10) 
            return false;
    }
    
}

function init(){


    if (!document.getElementsByTagName) 
        return;
    anchors = document.getElementsByTagName('div');
    
    for (i = 0; i < anchors.length; i++) {
    
        var anchor = anchors[i]
        
        
        if (menu_type = anchor.getAttribute("menu_type")) {
        
            if (menu_type == 400) 
                anchor.style.display = "none";
            
            if (menu_type == 1) {
                anchor.style.backgroundImage = "url(http://" + location.host + "/images/default/close.gif)";
                anchor.onclick = function(){
                    show_menu(this);
                    return false;
                }
            }
        }
    }
	
    if(menu_id) open_menu(menu_id);
}




