function switch_menu(parentGoalId, childGoalId) {
    if(parentGoalId == 0 || childGoalId == 0) return;
    var element = document.getElementById("menu_item" + parentGoalId);
    if("expanded" == element.className) {
        clearAllMenus(parentGoalId, childGoalId);
        return;
    } 
    clearAllMenus(parentGoalId, childGoalId);
    element.className = "expanded";
    document.getElementById("menu_anchor" + childGoalId).className = "selected-goal";
    document.getElementById("sub_menu_item" + parentGoalId).style.display = "";
}


function clearAllMenus(parentGoalId, childGoalId) {
    var submenus = document.getElementsByName("sub_menu_item");
    for(var i = 0; i < submenus.length; ++i) {
        submenus[i].style.display = "none";
    }
    
    var menus = document.getElementsByName("menu_item");
    for(var i = 0; i < menus.length; ++i) {
        menus[i].className = "";
    }

    var goalList = document.getElementsByName("menu_anchor");
    for(var i = 0; i < goalList.length; ++i) {
        goalList[i].className = "";
    }
}
