$(document).ready(function() {
	$("#header ul li").hover(function(){
		$("ul", this).fadeIn(250);
	}, function(){
		$("ul", this).fadeOut(250);
	});
	
    var total = $('#slider img').length;
    var rand = Math.floor(Math.random()*total);	
    $('#slider').nivoSlider({
		effect: 'fold',
		animSpeed:500,
		pauseTime:7500,
        startSlide:rand,
		slices:6,
		directionNav:false,
		directionNavHide:false,
		controlNav:false,
		controlNavThumbs:false,
		keyboardNav:true,
		pauseOnHover:true,
		captionOpacity:0.85,
		afterLoad: function(){
			$(".nivo-caption").animate({right:"0"}, {easing:"easeOutBack", duration: 500})
		},
		beforeChange: function(){
			$(".nivo-caption").animate({right:"-420"}, {easing:"easeInBack", duration: 500})
		},
		afterChange: function(){
			$(".nivo-caption").animate({right:"0"}, {easing:"easeOutBack", duration: 500})
		}
	});
	
	$("#sidebar ul ul").hide();
	$("#sidebar ul li.active ul").show();
	$("#sidebar > ul > li:has(ul) > a").click(function(){
		$("#sidebar ul ul:visible").slideUp(300);
		$(this).parent().children("ul:hidden").slideDown(300);
		return false;
	});
});
