$(document).ready(function(){

	//console.log('ready');

	$('#slider .imgs')
		.after('<div id="sliderControls">')
		.cycle({
			fx:     'fade',
			speed:  1000,
			timeout: 5000,
			pager:  '#sliderControls'
	});


    jQuery('#carouselReplace').jcarousel({
		scroll: 1,
		animation: 500,
		auto: 4,
		wrap: 'last',
		initCallback: carouselInit
    });

	$('#carousel a').hover(
		function(){
			$(this).children(".infoblock").animate({top: '50'}, {queue:false, duration:200, easing:'linear'});
		},
		function(){
			$(this).children(".infoblock").animate({top: '115'}, {queue:false, duration:500, easing:'swing'});
		}
	);

});

function carouselInit(carousel){
    // Disable autoscrolling if the user clicks the prev or next button.
    carousel.buttonNext.bind('click', function() {
        carousel.startAuto(0);
    });

    carousel.buttonPrev.bind('click', function() {
        carousel.startAuto(0);
    });

    // Pause autoscrolling if the user moves with the cursor over the clip.
    carousel.clip.hover(function() {
        carousel.stopAuto();
    }, function() {
        carousel.startAuto();
    });

};
