function slider(id) {
	$.ajax({
	  url: 'ajax/imagem.php?id=' + id,
	  success: function(data) {
		$('#slider-wrap').html(data);
		
		var direction = false;
		if ($('#slider').children().length > 1)
			direction = true;
			
		if (id == 1) {
	        $('#slider').nivoSlider({
	            effect: 'fade',
	            directionNav: direction,
	            directionNavHide: true,
	            controlNav: !direction,
				randomStart: true,
	        });
		} else {
	        $('#slider').nivoSlider({
	            effect: 'fade',
	            directionNav: direction,
	            directionNavHide: false,
	            controlNav: direction,
				pauseTime: 9999999,
	        });
		}
	  }
	});
}

$(window).load(function() {
	$("a[rel=fancyvideo]").fancybox({
	    overlayShow: true,
	    frameWidth:640,
	    frameHeight:360,
	});
	
	$(window).hashchange(function() {
		var hash = 1;
		if (location.hash != '')
			var hash = location.hash.substring(2);
		
		slider(hash);
	});

	$('#menu > li > a').click(function() {
		if ($(this).attr('class') != 'active') {
			$('#menu li ul').slideUp();
			$(this).next().slideToggle();
			$('#menu li a').removeClass('active');
			$(this).addClass('active');
		}
	});
	
	$(window).trigger('hashchange');
});
