var car1Stopped = false;
var car1CurrentIndex = 1;
var car1Delay = 6000;

$(document).ready(function(){
	$('#baner').hover(function(){
		car1Stopped = true;
	},function(){
		car1Stopped = false;
	});
	
	$('#baner_yellow_link a').click(function(e){
		e.preventDefault();
		car1CurrentIndex = $(this).attr('rel');
		if(!$(this).hasClass('active'))
		{
			$('#baner_yellow_link a').removeClass('active');
			$('.baner_desc').removeClass('active');
			var itemid = $(this).attr('rel');
			$(this).addClass('active');
			$('#baner_desc'+itemid).addClass('active');
			$('.banner_content').stop(true, true).hide();
			$('#banner_content'+itemid).stop(true, true).fadeIn();
		}
	});
		
	var chooseMe = null;
	var mytimeout = null;
	$('.baner_desc').hover(function(){
		car1CurrentIndex = $(this).attr('rel');
		chooseMe = car1CurrentIndex;
		if(!$(this).hasClass('active')) {
			mytimeout = setTimeout(function(){
				if(car1CurrentIndex==chooseMe) {
					$('#banner_link'+car1CurrentIndex).trigger('click');
				}
			},300);
		}
	},function(){
		chooseMe = null;
		if(mytimeout){
			clearTimeout(mytimeout);
		}
	});
	
	car1Step = function(index){
		if(!car1Stopped) {
			if(car1CurrentIndex<3) {
				car1CurrentIndex++;
			} else {
				car1CurrentIndex = 1;
			}
			$('#banner_link'+car1CurrentIndex).trigger('click');
		}
		setTimeout(car1Step, car1Delay, car1CurrentIndex);
	};
	setTimeout(car1Step, car1Delay, car1CurrentIndex);

});
