jQuery(document).ready(function() {
			
	/* Build our Carousels if they exist on the page */
	jQuery('#pcarousel').jcarousel({
		auto: 9,	// auto move between slides every X seconds
		wrap: 'both',	// wrapping, leave alone for now
		visible: 1,	// how many slides are visible at a time
		scroll: 1,	// unsure
		start: 1,	// which carousel slide to start with
		initCallback: mycarousel_initCallback
	});
	
	// Setup the pausing / resuming when hovering over a carousel item
	var resumeTime = 9000;
	function mycarousel_initCallback(carousel) {
		// Disable autoscrolling if the user clicks the prev or next button.
		carousel.buttonNext.bind('click', function() {
		   var auto = carousel.options.auto;
			//carousel.startAuto(0);
			setTimeout(function(){
				if(!carousel.auto){
					carousel.startAuto(auto)
				}
			}, resumeTime);
		});
		
		carousel.buttonPrev.bind('click', function() {
			var auto = carousel.options.auto;
			carousel.startAuto(0);
			setTimeout(function(){
				if(!carousel.auto){
					carousel.startAuto(auto)
				}
			}, resumeTime);
		});

		// Pause autoscrolling if the user moves with the cursor over the clip.
		carousel.clip.hover(function() {
			carousel.auto = carousel.auto || carousel.options.auto;
			carousel.startAuto(0);
		}, function() {
			carousel.startAuto(carousel.auto);
		});
	};	
	

});
