function easeInOut(minValue,maxValue,totalSteps,actualStep,powr) { 
//Generic Animation Step Value Generator By www.hesido.com 
    var delta = maxValue - minValue;
    var stepp = minValue+(Math.pow(((1 / totalSteps) * actualStep), powr) * delta); 
    return Math.ceil(stepp)
}
    
function doMove(elem,startPosx,endPosx,steps,intervals,powr) { 
    if (elem.leftChangeInt)
	window.clearInterval(elem.leftChangeInt);
	var actStep = 0;
    elem.leftChangeInt = window.setInterval(
	function() { 
	  elem.style.currentLeft = easeInOut(startPosx,endPosx,steps,actStep,powr);
	  elem.style.left = elem.style.currentLeft + "px"; 
	  actStep++;
	  if (actStep > steps) {
	  	window.clearInterval(elem.leftChangeInt);
	  }
	} 
	,intervals)
}

function doMoveV(elem2,startPosy,endPosy,steps,intervals,powr) { 
    if (elem2.topChangeInt)
	window.clearInterval(elem2.topChangeInt);
	var actStep = 0;
    elem2.topChangeInt = window.setInterval(
	function() { 
	  elem2.style.currentTop = easeInOut(startPosy,endPosy,steps,actStep,powr);
	  elem2.style.top = elem2.style.currentTop + "px"; 
	  actStep++;
	  if (actStep > steps) {
	  	window.clearInterval(elem2.topChangeInt);
	  }
	} 
	,intervals)
}

function moveRight(div_to_move) {
	var endPosx = 50;
	divObject = document.getElementById(div_to_move);
	startPosx = parseInt(divObject.style.left);
    doMove(divObject,startPosx,endPosx,40,1,0.5);
}
	
function moveLeft() {
	var endPosx = -850;
	divObject = document.getElementById("bar1");
	startPosx = parseInt(divObject.style.left);
    doMove(divObject,startPosx,endPosx,40,1,2);
}

function moveUp(div_to_move) {
	var endPosy = 0;
	divObject = document.getElementById(div_to_move);
	startPosy = parseInt(divObject.style.top);
    doMoveV(divObject,startPosy,endPosy,40,1,.5);
}

function moveDown() {
	var endPosy = 500;
	divObject = document.getElementById("bar2");
	startPosy = parseInt(divObject.style.top);
    doMoveV(divObject,startPosy,endPosy,40,1,2);
}
