var tuttiprod={
	moving:false,
	direction:'next',
	held:false,
	animate:function(){
		if(tuttiprod.held) return false;
		if(tuttiprod.direction=='next'){
			$('.termek_csuszka a.next').click();
		}else{
			$('.termek_csuszka a.prev').click();
		}
	}
};
$(function(){
	$('.termek_csuszka a.prev').addClass('disabled');
	$('.termek_csuszka a.prev').bind('click',function(){
		if(tuttiprod.moving) return false;
		tuttiprod.moving=true;
		tuttiprod.direction='prev';
		var $csuszka=$('.termek_csuszka .csuszka');
		var currLeft=parseInt($csuszka.css('left'));
		currLeft=currLeft?currLeft:0;
		if(currLeft<0){
			if(currLeft==-110){$(this).addClass('disabled');tuttiprod.direction='next';}
			$csuszka.animate({left:'+=110'},800,function(){tuttiprod.moving=false;});
		}else{
			tuttiprod.moving=false;
		}
		$('.termek_csuszka a.next').removeClass('disabled');
		return false;
	});
	$('.termek_csuszka a.next').bind('click',function(){
		if(tuttiprod.moving) return false;
		tuttiprod.moving=true;
		tuttiprod.direction='next';
		var $nextImg;
		var len=$('.termek_csuszka .ablak img').length;
		var $csuszka=$('.termek_csuszka .csuszka');
		var currLeft=parseInt($csuszka.css('left'));
		currLeft=currLeft?currLeft:0;
		if(currLeft>(-110*(len-1))){
			if(currLeft==(-110*(len-2))){$(this).addClass('disabled');tuttiprod.direction='prev';}
			$nextImg=$csuszka.find('img[rel]:eq(0)');
			$nextImg.attr('src',$nextImg.attr('rel'));
			$nextImg.removeAttr('rel');
			$csuszka.animate({left:'-=110'},800,function(){tuttiprod.moving=false;});
		}else{
			tuttiprod.moving=false;
		}
		$('.termek_csuszka a.prev').removeClass('disabled');
		return false;
	});
	$('.termek_csuszka .csuszka').width($('.termek_csuszka .ablak img').length*160);
	$('.termek_csuszka').bind('mouseover',function(){tuttiprod.held=true});
	$('.termek_csuszka').bind('mouseout',function(){tuttiprod.held=false});
	if(!ishome){
		setInterval('tuttiprod.animate();',3000);
	}
});