<?php

/* Menus */
add_theme_support('nav-menus');

register_nav_menus( array(
	'primary' => 'Main Menu',
));

/* Generate Menu */
function site_menu($name='',$x=1) {
	if($name) {
		$menu = wp_nav_menu('container_class=menu&echo=0&menu='.$name.'&depth='.$x);
	} else {
		$menu = wp_nav_menu('container_class=menu&echo=0&depth='.$x);
	}
	
	/* Remove the wrapper and the poorly used title element */
	$menu = str_replace('<div class="menu">','',$menu);
	$menu = str_replace('<ul>','',$menu);
	$menu = str_replace('</ul></div>','',$menu);
	$menu = preg_replace('/<ul id=\"(.*?)\" class=\"(.*?)\">/','',$menu);
	$menu = preg_replace('/title=\"(.*?)\"/','',$menu);
	echo $menu;
}
?>