var HLCarouselle_lock=0;
var HLCarouselle_current=0;

function HLCarouselleMoveLeft()
{
if(!HLCarouselle_lock)
HLCarouselleSetNewActive(-1);
return false;
}

function HLCarouselleMoveTo(target)
{
if(!HLCarouselle_lock){
var cdiv=HLCarouselle_current;
if (cdiv==5) 
{
	cdiv=0;
	current=0;
}
var len = cdiv-target;
if(len != 0)
	{
	HLCarouselleSetOnPlace(cdiv);
	HLCarouselle_current = target;
	var direction = len/Math.abs(len)*-1;
	HLCarouselleMoveFrame(direction,0,Math.abs(len));
	}
}
return false;
}

function HLCarouselleMoveRight()
{
if(!HLCarouselle_lock)
HLCarouselleSetNewActive(1);
return false;
}


function HLCarouselleSetNewActive(direction)
{
HLCarouselle_lock=1;
var cdiv=HLCarouselle_current;
var ndiv = cdiv+direction;
if (ndiv==6)
	{ cdiv=0;	ndiv=1;	}
if (ndiv==-1)
	{ cdiv=5;	ndiv=4;	}
HLCarouselle_current = ndiv;
HLCarouselleSetOnPlace(cdiv);
HLCarouselleMoveFrame(direction,0,1);
}

function HLCarouselleSetOnPlace(id)
{
x = id*460*-1;
var lenta = document.getElementById('lenta');
lenta.style['left']=x+"px";
}

function HLCarouselleMoveFrame(direction,cstep,num)
{
var lenta = document.getElementById('lenta');
fps=20;
step=25;
part=460/fps;
if(cstep < fps*num)
	{
	l = parseInt(lenta.style['left']);
	lenta.style['left']=(part*direction*-1+l)+"px";
	setTimeout('HLCarouselleMoveFrame('+direction+','+(cstep+1)+','+num+')', step);
	}
else{
HLCarouselle_lock=0;
HLCarouselleSetDot();
}
}

function HLCarouselleSetDot()
{
    localCurrent = HLCarouselle_current+1;
    if (localCurrent==6)
	localCurrent=1;
for(i=1;i<=5;i++)
    {

    var ball=document.getElementById('ball_'+i);
        ball.className = 'ball';
    if (i==localCurrent)
	ball.className = 'ball active';
    }

}