pieces=11;
width=940;
gwidth=pieces*width;  
//newPos=(pieces-1)*width; 
newPos=0;
b=0;
z=0;
g=9; // tempo

function info() {
	var test = window.getComputedStyle(document.getElementById("dx"),"").getPropertyValue("width"); 
	alert('weite: ' + test);
}
function right() {
	var rightPos = newPos*-1;
	var slidingDiv= document.getElementById("dx");	
		if (parseInt(slidingDiv.style.left) < rightPos )
	{ 
	z++; if(z>width/g*0.3) b+=.6;
	slidingDiv.style.left = parseInt(slidingDiv.style.left) + (g+b) + "px";
	setTimeout(right, 1);
	} else { slidingDiv.style.left=rightPos + "px"; }
}
function left() {	
	var leftPos = newPos*-1;
	var slidingDiv= document.getElementById("dx");
		//document.getElementById('v').value= slidingDiv.style.left;
		if (parseInt(slidingDiv.style.left) > leftPos)
	{ 
	z++; if(z>width/g*0.3) b+=.6;
	slidingDiv.style.left = parseInt(slidingDiv.style.left) - (g+b) + "px";
	setTimeout(left, 1);	
	} else { slidingDiv.style.left=leftPos + "px"; }
}
function setpos(d) {   
   z=0;b=0;
   if(d=='r') newPos-=width; else newPos+=width;
   if(newPos<0)  newPos=0;
   if(newPos>gwidth-width)  newPos=gwidth-width;   
   //alert("Pos: " + newPos);
}
function setposi(d) {   
   var test =document.getElementById("dx").style.left; 
   var d=d*1;
   var act = test.replace(/px/g, "")*-1;
   //alert('actpos: ' + act + ' ->neuPos: ' + d);
   z=0;b=0;
  if(d=='r') newPos-=width; else newPos+=width;
  if(newPos<0)  newPos=0;
   if(newPos>gwidth-width)  newPos=gwidth-width;
  //alert("Pos: " + newPos);
   newPos=d;
   if(act<=d) left(); else right();
}
