var ulWidth;
var lock;
var left;
var scrollStarted = false;
var x = 1;
var counter = 0;

function moveOne(){
if(!lock){
	lock = true;
	counter = counter - x;

	oneLength = ((ulWidth)/3);
	
	startpos = -oneLength;

	distance = $(".home-scroller-wrapper ul li").width()+6;

	leftVal = $(".home-scroller-wrapper ul").css('left');
	leftVal = parseFloat((""+leftVal).replace(/px/,""));


	$(".home-scroller-wrapper ul").animate({left:leftVal+(distance * x)},600,'swing', 
		function(){
			lock = false;
			if(counter==items||counter==-items){
				$(".home-scroller-wrapper ul").css({left:startpos})
				counter=0;}
		});
	}
}


$(document).ready(function(){

	$(".home-scroller-left").show();
	$(".home-scroller-right").show();

	$(".home-scroller-wrapper").width(509);

	items = $(".home-scroller-wrapper ul li").size();

	$(".home-scroller-wrapper").css({overflow:'hidden'});

	repeat1 = $(".home-scroller-wrapper ul").html();

	repeat1 = repeat1+repeat1;

	$(".home-scroller-wrapper ul").append(repeat1);
	ulWidth= items * 3 * ($(".home-scroller-wrapper ul li").width()+6);

	$(".home-scroller-wrapper ul").css({width:ulWidth,position:'relative',left:-(ulWidth/3)});

	$(".home-scroller-left a").click(function(){x=1; moveOne();});
	$(".home-scroller-right a").click(function(){x=-1; moveOne();});

});

var ulWidth2;
var lock;
var left;
var scrollStarted = false;
var xh = 1;
var counter2 = 0;

function moveOneHasznalt(){
if(!lock){
	lock = true;
	counter2 = counter2 - xh;

	oneLength = ((ulWidth2)/3);
	
	startpos = -oneLength;

	distance = $(".hasznalt-scroller-wrapper ul li").width()+6;

	leftVal = $(".hasznalt-scroller-wrapper ul").css('left');
	leftVal = parseFloat((""+leftVal).replace(/px/,""));


	$(".hasznalt-scroller-wrapper ul").animate({left:leftVal+(distance * xh)},600,'swing', 
		function(){
			lock = false;
			if(counter2==items2||counter2==-items2){
				$(".hasznalt-scroller-wrapper ul").css({left:startpos})
				counter2=0;}
		});
	}
}


$(document).ready(function(){

	$(".hasznalt-scroller-left").show();
	$(".hasznalt-scroller-right").show();

	$(".hasznalt-scroller-wrapper").width(509);

	items2 = $(".hasznalt-scroller-wrapper ul li").size();

	$(".hasznalt-scroller-wrapper").css({overflow:'hidden'});

	repeat2 = $(".hasznalt-scroller-wrapper ul").html();

	repeat2 = repeat2+repeat2;

	$(".hasznalt-scroller-wrapper ul").append(repeat2);
	ulWidth2= items2 * 3 * ($(".hasznalt-scroller-wrapper ul li").width()+6);

	$(".hasznalt-scroller-wrapper ul").css({width:ulWidth2,position:'relative',left:-(ulWidth2/3)});

	$(".hasznalt-scroller-left a").click(function(){xh=1; moveOneHasznalt();});
	$(".hasznalt-scroller-right a").click(function(){xh=-1; moveOneHasznalt();});

});
