var t; //timer
// frames per  second
var fps=18;
var acceleration=25;
var speedlimit=40;
// arrow snaps to these points, first is parked
var snapto = new Array (40,40,65,90,115,140,165,190) 

var  disabled=false;

// Move element d to point snapto[p]
function moveit(div,p){
//alert(p);
		d=document.getElementById(div);
		// starting position
		start=parseInt(d.style.top.replace(/px/,""));
		// destination position
		destination=snapto[p];
		moveit_step(div,start,destination,0);
}
// iterative steps for animation
function moveit_step(div,start,destination,position){
	if(!disabled&&start!=destination){
	clearTimeout(t);
	d=document.getElementById(div);
	distance=Math.abs(destination-start);
	progress=position / distance;

	x=2*(position/distance)-(1);
	jump=-acceleration*distance*.01*Math.pow(x,2)+(acceleration*distance*0.01)+0.25;
	//   check speed
	if(jump>speedlimit) jump=speedlimit;
	
	position +=jump;
	// convert to css position
	if(start<destination){
		new_position=(start+position);
	}else{
		new_position=(start-position);
	}
	//check bounds, is this  needed?
	if(destination>start&&new_position>destination){
		new_position=destination;
	}
	if(destination<start&&new_position<destination){
	  new_position=destination;
	 }
	d.style.top=new_position+"px";
	// continue
	if((destination>start&&new_position<destination)
	||(destination<start&&new_position>destination)){
		t=setTimeout("moveit_step('"+div+"',"+start+","+destination+","+position+")",1000/fps);
	}
	
	}else{
	
	clearTimeout(t);
	}
}



