var Menu = {
	init: function()
	{
		$('#menu > a').click(Menu.click);
		var sPath = window.location.pathname;
		if(sPath.lastIndexOf('.htm') != -1)
			var sPage = sPath.substring(sPath.lastIndexOf('/') + 1, sPath.lastIndexOf('.'));
		doc = document.location.toString();
		if (doc.match('#'))
			Menu.select($("."+doc.split('#')[1]).parent(), false);
	},
	click: function(e)
	{return Menu.select(this);},
	select: function(element, fade)
	{
		if(!fade)
			fade = true;
		element = $(element);
		element.blur();
		underline_newpos = element.offset().left - element.parent().offset().left;
		$("#underline").animate({left: underline_newpos, width: element.width()});
		request = $.ajax({url: element.attr('href') + "?ajax", async: false});
		if (request.readyState == 4 && request.status == 200) {
			$("#content_wrap").fadeOut("fast", function(){
				$("#content_wrap").html(request.responseText);
				$("#content_wrap").fadeIn("slow");
			})
		}
		
		document.location = "#" + element.attr('title');
		return false;
	}

}
$(function(){Menu.init();});


