/**
*/
function vitafocus_carousel_move(index) {

	var mover = index < 0
		? jQuery('#carousel li').get(0)
		: jQuery('#carousel li').get(
			jQuery('#carousel li').length - 1
			);
	
	if (index > 0) {
		jQuery(
			jQuery('#carousel li').get(0)
			).before(
				jQuery('#carousel li').get(
					jQuery('#carousel li').length - 1
					)
				);
		
		} else {
		jQuery(
			jQuery('#carousel li').get(
				jQuery('#carousel li').length - 1
				)
			).after(
				jQuery('#carousel li').get(0)
				);

		}
	}

/**
*/
function vitafocus_carousel_auto() {

	if ((arguments.length == 0) && !vitafocus_carousel_hover) {
		vitafocus_carousel_move(-1);
		}
	setTimeout(function() {
		vitafocus_carousel_auto();
		}, 3000);
	}

var vitafocus_carousel_hover = false;
var vitafocus_carousel_timeout = setTimeout('a=1;', 100);

/**
*/
jQuery(document).ready(
	function() {
		
		// set the handlers
		//
		jQuery('a.carousel-left').click(
			function() {
				vitafocus_carousel_move(1);
				}
			);
		jQuery('a.carousel-right').click(
			function() {
				vitafocus_carousel_move(-1);
				}
			);

		jQuery('#carousel li, a.carousel-left, a.carousel-right')
			.mouseover(
				function () {
					vitafocus_carousel_hover = true;

					clearTimeout(vitafocus_carousel_timeout);
					vitafocus_carousel_timeout = setTimeout(function() {
						vitafocus_carousel_hover = false;
						}, 10000);
					}
				)
			.mouseout(
				function () {
					vitafocus_carousel_hover = false;
					}
				);

		vitafocus_carousel_auto(1);
		}
	);