
// code by www.widelldesign.com // credit if copy

var id					= 'Slide'
var sectionWidth 		= 800;
var animationSteps 		= 40;
var currentPosition		= 0;
var currentGoal			= 0;
var currentStep			= 0;


function slideImage(newNumber) {
	currentGoal = (newNumber-1)*sectionWidth;
	currentStep = 0;
	animate( currentStep, currentPosition, currentGoal);
}

function animate(step, start, goal) {
	// ignores multiple runs! no start if "goal" or "step" are not what global vars expects.
	if ((goal == currentGoal)&&(step==currentStep)) {
		if (step == animationSteps) {
			currentPosition = goal;
		}
		else {
			var percent = step/animationSteps;
			var soft = 1-(1-percent)*(1-percent);
			currentPosition = Math.floor(soft* (goal-start)+start);
		}
		document.getElementById(id).style.left='-'+currentPosition+'px';
		currentStep = step+1; 
		if (currentPosition != currentGoal) setTimeout("animate ("+(step+1)+", "+start+", "+goal+")", 0);
	}
}

