jQuery(function($) {
	
	$("#navigation li").hover(function() {
		$("ul:eq(0)", this).stop(true,true).fadeIn().css({
			left: ( $(this).width() - $("ul:eq(0)", this).outerWidth() )/2 + parseInt( $(this).css("padding-left") )
		});
	},function() {
		$("ul:eq(0)", this).stop(true,true).fadeOut();
	});
	
	$('#navigation > ul > li > a').each(function() {
		$(this).html($(this).html().replace(/([\S]*)(\s|$)/, '<strong>$1</strong> '));
	});
	
	$(".field").focus(function(){
		if($(this).val()==$(this).attr("title")) $(this).val("");
	}).blur(function(){
		if($(this).val()=="") $(this).val($(this).attr("title"));
	});
	
	$("#search-toggle").click(function() {
		$("#search").toggle();
		$(this).toggleClass("search-toggled");
		return false;
	});
	
	// $("#side-nav ul li.facebook > a, #side-nav ul li.twitter > a").click(function(e) {
	// 	if( $(e.target).is("a:eq(0)") )
	// 	{
	// 		$(this).parent().toggleClass('active');
	// 		return false;
	// 	}
	// 	else
	// 	return false;
	// });
	
	$(window).load(function() {
		$("#navigation").css({
			width: $("#navigation ul:eq(0)").outerWidth()
		});
	});
	
	$('#bottom-nav .menu > li').each(function() {
		var width = $(this).find('> a').first().outerWidth(true);
		$(this).find('li').each(function() {
			if ($(this).outerWidth(true) > width) {
				width = $(this).outerWidth(true);
			}
		});
		
		$(this).width(width);
	});
});
