// Triggers scrolling from right to left on carousel (used on timer to trigger auto scroll)
  function scrollCarousel(){
  	$('.jcarousel-next').trigger('click');
  }
  
  jQuery(function($){
  
  	// Home page carousel
  	var carousel_arr = [];
  	
  	// Temporary containers for form data in carousel
  	var form_data = [];
  	var new_item;
  	
  	var msie = $.browser.msie;
  	
  	// Initialization 
  	function carouselInitCallback(carousel){
  		$.each($('#carousel').children(),function(){
  			carousel_arr.push($(this).html());
  		});
  		$('.jcarousel-next,.jcarousel-prev').insertAfter('#carousel-wrap');
  		var auto_carousel = setInterval("scrollCarousel()", 9000);
  		$('#carousel, .jcarousel-next, .jcarousel-prev').mouseover(function(e){
  			e.stopPropagation();
  			
  			carousel.options.animation = 1000;
  			carousel.options.easing = 'fadeOut';
  			clearInterval(auto_carousel);
  			carousel.startAuto(0);
  			
  			// Adds mouseover function for body, to resume auto carousel motion
  			// Added 2009-03-25
  			$('body').mouseover(function(){
  				carousel.options.animation = 1500;
  				carousel.options.easing = 'fadeIn';
  				$('.jcarousel-next').trigger('click');
  				auto_carousel = setInterval("scrollCarousel()", 9000);
  				$(this).unbind('mouseover');
  			});
  			
  		});
  	}
  	
  	// Fired before carousel moved, appends new item to carousel to give illusion of infininate list
  	function carouselInCallback(carousel, item, i, state, evt){
  		var idx = carousel.index(i, carousel_arr.length);
  		new_item = carousel.add(i,carousel_arr[idx - 1]);
  	}
  	
  	// Fired after carousel move, removes item from end of carousel (same one which was appended beforehand)
  	function carouselOutCallback(carousel, item, i, state, evt){
  		carousel.remove(i);
  	}
  	
  	// Invoke home page carousel
  	$('ul#carousel').jcarousel({
  		scroll:1,
  		auto: 3,
  		wrap: 'circular',
  		initCallback: carouselInitCallback,
  		itemVisibleInCallback: {onBeforeAnimation: carouselInCallback},
  		itemVisibleOutCallback: {onAfterAnimation: carouselOutCallback},
  		easing:'easeInOutCubic',
  		animation:1500
  	});
  });
