/*
start : the current left position of the object you want to move
change : the change to the start position, positive numbers move to the left, negative to the right
obj : the page element to be moved
dir : should be 'x' or empty for left and right moving, 'y' for up and down. 
*/

function autoScroll(start,change,obj,dir){//
	//alert('start='+start+' change='+change+' obj='+obj.id)
	//start = 0;
	change = -400;
	//obj = document.getElementById('playlist_content');
	dir = 'x';
	var then = new Date();
	var duration = Math.abs(change)*1.2;	
	//if(duration > 3000) duration = 3000;
	//alert('duration='+duration)
	duration = 1000;
	var rate = 20;
	var begin_val = start;
	var change_val = change;
	function ease(t,b,c,d){
		if ((t/=d/2) < 1) return c/2*t*t*t*t*t + b;
		return c/2*((t-=2)*t*t*t*t + 2) + b;
	}
	function ease_out(t,b,c,d){
		return c*((t=t/d-1)*t*t + 1) + b;
	}
	function easeframe(){
		//alert('easeframe');
		var now = new Date();
		var curtime = now - then;
		if(curtime <= duration){
			if(dir == 'x'){
				var x = ease_out(curtime,begin_val,change_val,duration);
				//obj.x = x;
				obj.style.left = x+'px';
				setTimeout(easeframe,rate);
			}
			else{// dir = 'y'
				var y = ease_out(curtime,begin_val,change_val,duration);
				//obj.y = y;
				obj.style.top = y+'px';
				setTimeout(easeframe,rate);
			}
		}
	}
	easeframe();
}

