// Triggers scrolling from right to left on carousel (used on timer to trigger auto scroll)
jQuery.noConflict();


jQuery(function(jQuery){

	// Home page carousel
	var carousel_arr = [];
	
	// Temporary containers for form data in carousel
	var form_data = [];
	var new_item;
	
	var msie = jQuery.browser.msie;
	
	// Initialization 
	function carouselInitCallback(carousel){
		jQuery.each(jQuery('#carousel ul').children(),function(){
			carousel_arr.push(jQuery(this).html());
		});
		jQuery('.jcarousel-next,.jcarousel-prev').insertAfter('#carousel-wrap');
	//	var auto_carousel = setInterval("scrollCarousel()", 11000);
		jQuery('#carousel, .jcarousel-next, .jcarousel-prev').mouseover(function(e){
			e.stopPropagation();
			
			carousel.options.animation = 1000;
			carousel.options.easing = 'easeOutCubic';
			//clearInterval(auto_carousel);
			carousel.startAuto(0);
			
			
			
		});
	}
	
	// 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]);
		// Apply PNG Fix for IE6
		jQuery('#carousel .desc-wrap, #carousel .lbl').ifixpng();
	}
	
	// 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

	jQuery('#carousel ul').jcarousel({
		scroll:1,
		wrap: 'circular',
		initCallback: carouselInitCallback,
		itemVisibleInCallback: {onBeforeAnimation: carouselInCallback},
	itemVisibleOutCallback: {onAfterAnimation: carouselOutCallback},
		easing:'easeInOutCubic',
		animation:1500,
		auto: 9
	});
	
	// If good ole IE, apply some PNG fixes and allow for hover state on previous and next buttons
		
	
	

	
});



	

