How to apply function to a chosen region only? I am using this template.php function:

function mytheme_menu_tree($variables) {
    return '&lt;ul class="page_nav" id="pages"&gt;' . $variables['tree'] . '&lt;/ul&gt;';
}


Now it applies to the menu no matter in which region it is. What if I want it to apply only if the menu is inside i.e. Top Menu region? I guess its something that needs to be added before return line?

Also I noticed another problem. It applies to all menus, i.e. if I have two menus, my return line applies to both menus, and 2nd menu is not even shown because id="" can be shown only once.

So I need that function to apply to the menu which is in Top menu region only.
You can use theme_menu_tree__MENU_NAME() to target a specific menu.