new CarouselUtils();   // This is needed to declare the static variables
function CarouselUtils()
{
	//-----------------------------------------------------------------------------------------------------------
	// Static functions
	//-----------------------------------------------------------------------------------------------------------

	CarouselUtils.init = init;
	
	//-----------------------------------------------------------------------------------------------------------
	// Functions
	//-----------------------------------------------------------------------------------------------------------
	
	function init(contentDiv)
	{
		var selector = '.carousel';
		
		if (contentDiv != null)
		{
			selector = '#' + contentDiv.attr('id') + ' ' + selector;
		}
			
		$(selector).each(function(i)
		{
			$(this).hide('fast'); // This is hack for IE-7 to display all products together in carousel (Arvind Patel)
			initCarousel(this.id);
			$(this).show('fast'); // This is hack for IE-7 to display all products together in carousel (Arvind Patel)
		});
	}
	
	function initCarousel(id)
	{
		var id = '#' + id;
		var count = parseInt($(id + '_count').val());
		var autoSpeed = parseInt($(id + '_auto_speed').val());
		var scrollCount = parseInt($(id + '_scroll_count').val());
		
		if (count <= scrollCount)
		{
			autoSpeed = 0;
			scrollCount = 0;
		}
			
		$(id + ' .carousel_content').jCarouselLite(
		{
			btnNext: id + ' .carousel_right',
			btnPrev: id + ' .carousel_left',
			visible: count,
			speed: 500,
			scroll: scrollCount,
			auto: autoSpeed,
			mouseWheel : true,
			circular: true
		});
	}
}
