var scroll = {
	timeout: 1000,

	toElem : function (e) {
		this.start(this.getElementY(e));
	}, 

	toID : function (id) {
		this.toElem(document.getElementById(id));
	}, 

	toTop : function () {
		this.start(0);
	}, 

	start : function (pos) {
		this.stop();
		this.from= window.scrollY || document.documentElement.scrollTop || document.body.scrollTop;
		this.to=pos;
		this.at=this.from;
		this.t0=(new Date()).getTime();
		var me=this;
		this.intrvl=setInterval( function() {me.step();},15);
	},

	stop : function () {
		if (this.intrvl) clearInterval(this.intrvl);
		this.intrvl=null;
	},

	step : function() {
		if (this.inStep) return;
		this.inStep=true;
		var time  = (new Date()).getTime(); 
		if (time-this.t0 >= this.timeout) {
			this.at=this.to;
			this.stop();
		}	else {
			var p = (time - this.t0) / (this.timeout);
			this.at = Math.sin(p * (Math.PI/2)) * (this.to-this.from) + this.from;
		}
 		window.scrollTo(0,this.at);
		this.inStep=false;
	},

	getElementY : function(e) {
		var y=0;
		while (e) {
			y += parseInt(e.offsetTop);
			e = e.offsetParent;
		} 
		return y;
	}

}