jQuery(function(){


	jQuery('.arrow.lefts').click(function(){

		t = clearInterval(t);
		slideLeft();
			
	})

	jQuery('.arrow.rights').click(function(){

		t = clearInterval(t);
		slideRight();

	})


	initSlide();

	var t = setInterval("slideRight()",6000);



});





	function initSlide()
	{


		var logo_container = jQuery('.reviews-block .logo-block');
		var descr_container = jQuery('.reviews-block .text-popup .inner');

		var logo_width = jQuery('div',logo_container).first().width()+50;
		var descr_width = jQuery('div',descr_container).first().width()+50;

		jQuery('div', logo_container).each(function(){
			jQuery(this).addClass('logo')
		})
		
		jQuery('div', descr_container).each(function(){
			jQuery(this).addClass('descr')
		})


		jQuery('div.inner').css('height',jQuery('div.descr').first().height()+'px');
		
		jQuery('div.logo').first().addClass('current');
		jQuery('div.logo').first().siblings().css('left',logo_width+'px');	

		jQuery('div.descr').first().addClass('current');
		jQuery('div.descr').first().siblings().css('left',descr_width+'px');	

		

	}

	function slideLeft()
	{

		var logo_container = jQuery('.reviews-block .logo-block');
		var descr_container = jQuery('.reviews-block .text-popup .inner');

		var logo_width = jQuery('div',logo_container).first().width()+50;
		var descr_width = jQuery('div',descr_container).first().width()+50;

		var prev_logo = jQuery('div.logo.current').prev();
		var prev_descr = jQuery('div.descr.current').prev();

		jQuery('div.logo.current').animate({left:logo_width+'px'});
		jQuery('div.descr.current').animate({left:descr_width+'px'});
		
		
		if(prev_logo.length == 0)
		{
			prev_logo = jQuery('div.logo').last();
		}

		if(prev_descr.length == 0)
		{
			prev_descr = jQuery('div.descr').last();
		}

		jQuery('div.inner').animate({height:prev_descr.height()+'px'});


		prev_logo.css('left','-'+logo_width+'px');
		prev_descr.css('left','-'+descr_width+'px');


		jQuery('div.logo.current, div.descr.current').removeClass('current');
		prev_logo.addClass('current');
		prev_descr.addClass('current');

		jQuery('div.logo.current, div.descr.current').animate({
			left: '0'
		}, 1000);

		

	}


	function slideRight()
	{


		var logo_container = jQuery('.reviews-block .logo-block');
		var descr_container = jQuery('.reviews-block .text-popup .inner');

		var logo_width = jQuery('div',logo_container).first().width()+50;
		var descr_width = jQuery('div',descr_container).first().width()+50;

		var next_logo = jQuery('div.logo.current').next();
		var next_descr = jQuery('div.descr.current').next();

		jQuery('div.logo.current').animate({left:'-'+logo_width+'px'});
		jQuery('div.descr.current').animate({left:'-'+descr_width+'px'});


		
		if(next_logo.length == 0)
		{
			next_logo = jQuery('div.logo').first();
		}
			

		if(next_descr.length == 0)
		{
			next_descr = jQuery('div.descr').first();
		}

		jQuery('div.inner').animate({height:next_descr.height()+'px'});


		next_logo.css('left',logo_width+'px');
		next_descr.css('left',descr_width+'px');


		jQuery('div.logo.current, div.descr.current').removeClass('current');
		next_logo.addClass('current');
		next_descr.addClass('current');

		jQuery('div.logo.current, div.descr.current').animate({
			left: '0'
		}, 1000);	




	}
