$(document).ready(function() {

		function innerSlider_initCallback(carousel) {
		    jQuery('.jcarousel-control a').bind('click', function() {
		        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
		        return false;
		    });
		};
		
		// Highlight current number
		function highlight(carousel, objectli,liindex,listate){
			var activeIndex = liindex;
			if( jQuery(objectli).is('.reverse'))						// Reverse number colors if slide is colored
				$('.jcarousel-control').addClass('reverse');
			else
				$('.jcarousel-control').removeClass('reverse');
			if( liindex > carousel.size() )
			{
				activeIndex = liindex % carousel.size();
				if( activeIndex == 0)
					activeIndex = carousel.size();
			}
		    jQuery('.jcarousel-control a:nth-child('+ activeIndex +')').attr("class","selected");
		};
		// Remove highlight from previous number
		function removehighlight(carousel, objectli,liindex,listate){
			var activeIndex = liindex;
			if( liindex > carousel.size() )
			{
				activeIndex = liindex % carousel.size();
				if( activeIndex == 0)
					activeIndex = carousel.size();
			}
		    jQuery('.jcarousel-control a:nth-child('+ activeIndex +')').removeAttr("class","selected");
		};

	
		// Set up homepage brands slider
		$('.innerSlider').jcarousel({
		// Configuration goes here
			visible: 1,
			scroll: 1,
			wrap: 'last',
			auto: 9,
			initCallback: innerSlider_initCallback,
			itemVisibleInCallback:  highlight,
			itemVisibleOutCallback: removehighlight,
			buttonNextHTML: null,
	        buttonPrevHTML: null
		});
		
});

