$().ready(function() {
	// firefox no likey title tooltips
	$("#navigation a").attr('title', '');
	$("#navigation .wrapper li:first").addClass('first');
	$("#navigation .wrapper li:last").addClass('last');
	var olWidth = $("#navigation .wrapper").width();
	$("#navigation .wrapper").css({'marginLeft' : -(olWidth / 2)});
	$("ul.sf-menu").superfish({
	    animation:{opacity:'show'},
    	speed:'fast',
    	autoArrows:false,
	    dropShadows:false,
	    delay:400
	}).find('ul').bgIframe({opacity:false}); 
	$("#navigation ul.sf-menu > li").hover(
		function() {
			if (!$(this).hasClass('active')) {
				$(this).addClass('active');
			}
		}, function() {
			$(this).removeClass('active');
		}
	);
	$("#masthead .wrapper a").css({'text-indent' : '-9999px'});
	$("#shelf #shelfTab a").click(function() {
		var shelfState = $(this).parent().attr('class');
		if (shelfState == 'closed') {
			if ($.browser.name == 'msie') {
				if ($.browser.version < 7) {
					$("#masthead p").hide();
					$("#shelf").css({'background-position' : '0px 0px'});
				}
			};	
			$('#shelf').css({
				'z-index' : '9999'
			}).animate({
				'top' : '0px'
			}, 500);
			$("#shelfTab").removeClass('closed').addClass('open');
		} else {
			$('#shelf').animate({
				'top' : '-401px'
			}, 500, function() {
				$(this).css({
					'z-index' : '1'
				});
				if ($.browser.name == 'msie') {
					if ($.browser.version < 7) {
						$("#shelf").css({'background-position' : '0px -9999px'});
						$("#masthead p").show();
					}
				};	
			});
			$("#shelfTab").removeClass('open').addClass('closed');
		}
		return false;
	});
	$("#page .recent li").hover(
		function() {
			$(this).addClass('over');
		},
		function() {
			$(this).removeClass('over');
		}
	);
	$(".recent .categories").each(function() {
		var $kids = $(this).find('a .category');
		var length = $kids.length;
		if (length > 1) {
			$(this).find('a .category:first').parent().remove();
			$(this).find('a:last').prepend('<span class="icon"></span>');
		}
	});
});
