$(document).ready(function(){
	function mycarousel_initCallback(carousel) {
    		jQuery('.jcarousel-control a').bind('click', function() {
	        carousel.scroll(jQuery.jcarousel.intval(jQuery(this).text()));
       	 return false;
    		});
	}

	function display_first(carousel, item, idx, state){
		jQuery('.jcarousel-control a').each(function(){
			if ($(this).html()==idx)
				$(this).css('color','red');
			else 
				$(this).css('color','#6D6D70');

		});

	}
	$("#car_top5").jcarousel({
		vertical: true,
		wrap: 'circular',
		scroll: 2,
		auto: 6, 
		visible: 2,
		buttonNextHTML: null,
        	buttonPrevHTML: null,
		itemFallbackDimension: 113
	});
	
	$("#car_banner").jcarousel({
		scroll: 1,
		buttonNextHTML: null,
        	buttonPrevHTML: null,
		wrap: 'last',
		initCallback: mycarousel_initCallback,
		itemFirstInCallback: display_first,
		auto: 6
		
	});
	
	$(".car_basic").jcarousel({
		scroll: 5
	});	
	
	if ($("#brandSelect").length === 1)
	{
		$("#brandSelect").change(function(){
			if (this.value.length > 2) 
			{
				var loc = document.location+"";
				if (loc.indexOf("brand") > 0)
				{
					var shifty = loc.split("&");
					shifty.pop();
					loc = shifty.join("&");
				}
				loc = loc + "&brand=" + this.value;
				document.location = loc;
			}
			
		});
	}
	
})



