function Scrolling(pFrom, pTo, step, curve) {
	this.pFrom = pFrom;
	this.pTo   = pTo;
	this.step  = 0;
	this.MAXSTEPS = step;
	this.CURVE = curve;
}
Scrolling.prototype.run = function() {
	++this.step;
	var x = this.pTo.x - Math.pow(this.CURVE, this.step) * (this.pTo.x - this.pFrom.x);
	var y = this.pTo.y - Math.pow(this.CURVE, this.step) * (this.pTo.y - this.pFrom.y);
	window.scrollTo(x, y);
	return this.step >= this.MAXSTEPS;
};

function beginScroll(step, curve) {
	var cpos = new CurPoint(); 
	var dpos = new CurPoint();
	dpos.y = 0;
	var scr = new Scrolling(cpos, dpos, step, curve);
	scr.iid = setInterval(function() { if (scr.run()) clearInterval(scr.iid); }, 10);
}

if (document.all) {
	if (document.compatMode == "CSS1Compat") {
		CurPoint = function () {
			this.x = document.documentElement.scrollLeft;
			this.y = document.documentElement.scrollTop;
		};
	} else {
		CurPoint = function () {
			this.x = document.body.scrollLeft;
			this.y = document.body.scrollTop;
		};
	}
} else if (window.pageXOffset !== undefined) {
	CurPoint = function () {
		this.x = window.pageXOffset;
		this.y = window.pageYOffset;
	};
} else {
	CurPoint = function () {
		this.x = window.scrollX;
		this.y = window.scrollY;
	};
}
