// JavaScript Document


var target = 0;

function moveto(){

	var currenttop = 0;
	var difference = 0;
	var incquant = 0;
	
	currenttop = document.getElementById('trolly').style.top.substring(0,document.getElementById('trolly').style.top.length -2);
	if (!currenttop){
		//alert('No current height value');
		currenttop = 0;
	}
	
	if (currenttop != target){
		
		difference = target - currenttop;
		
		if (difference > 0){
			incquant = Math.ceil(difference/10);
		}
		else{
			incquant = Math.floor(difference/10);
		}
		
		var newtop = parseInt(currenttop) + parseInt(incquant);

		//alert('Current Top = '+ currenttop +'\nDifference = '+difference+'\n Incquant = '+incquant+'\n New Top = '+newtop);
		
		if (difference < 0){
			if (newtop < target){
				newtop = target;
			}
		}
		
		if (difference > 0){
			if (newtop > target){
				newtop = target;
			}
		}
		
		document.getElementById('trolly').style.top = newtop + 'px';
		setTimeout(moveto,20);
	}
}	
