jQuery(function($) {

	function mycarousel_initCallback(carousel) {
		$('.slider-controls a.next').click(function() {
			carousel.next();
			return false;
		});
		$('.slider-controls a.prev').click(function() {
			carousel.prev();
			return false;
		});
		$(".slider-navigation a").click(function(){
	    	var x = parseInt($(this).text());
	    	carousel.scroll(x);
	    	return false;
	    });
	};
	function mycarousel_itemVisibleInCallback(carousel, li, pos, state) {
		$(".slider-navigation a").removeClass('active');
		$(".slider-navigation a").eq(pos-1).addClass('active');
	};

		
	if ($('#slider').length && $('#slider li').length > 1) {
		$('#slider > ul').jcarousel({
			scroll: 1,
			wrap: 'both',
			animation: 350,
			easing: 'easeInOutExpo',
			initCallback: mycarousel_initCallback,
			itemVisibleInCallback: mycarousel_itemVisibleInCallback
	    });
	};
	
	$(window).load(function() {
		var h = $('#slider').height();
		$('#slider .page').each(function() {
			if (h < $(this).height()) {
				h = $(this).height();
			}
		});
		
		$('#slider, #slider .jcarousel-list, #slider .jcarousel-list > li, #slider li .page').height(h);

	});
	
	$('.photo-gallery a.fancybox').fancybox();
});

