window.offscreenBuffering=true;

function ElasticFloat(id, inertia, k, yPad, yMin) {

	this.inertia = inertia;
	this.k = k;
	this.yPad = yPad;
	this.yMin = yMin;
	
	this.div = document.getElementById ? 
		document.getElementById(id) : document.all[id];

	this.yPos = 0;
	this.dy = 0;
	
	this.dest = 0;
	this.lastYOffset = 0;
	this.scrolled = false;

    // global reference to this object
    this.gRef = 'ElasticFloat_' + id
    eval(this.gRef+'=this')
    
    if (yPad < yMin) yPad = yMin;
    this.div.style.top = yPad + 'px';
    
    setInterval(this.gRef + '.checkScroll()', 250);
}

ElasticFloat.prototype.getPageYOffset = function() {
	if (window.pageYOffset) {
		return window.pageYOffset;
	}
	if (document.body && document.body.scrollTop) {
		return document.body.scrollTop;
	}
	return 0;
}

ElasticFloat.prototype.slide = function() {
    var y = this.dest - this.yPos;
	this.dy = this.dy * this.inertia + y * this.k;
    this.yPos += this.dy; 
    this.div.style.top = Math.round(this.yPos) + 'px';
    if (Math.round(this.dy) != 0) {
    	setTimeout(this.gRef + '.slide()', 100);
    }
}

ElasticFloat.prototype.checkScroll = function() {
	var y = this.getPageYOffset();
	if (y != this.lastYOffset) {
		this.lastYOffset = y;
		this.scrolled = true;
	}
	else if (this.scrolled) {
		this.scrolled = false;
		this.dest = y + this.yPad;
		if (this.dest < this.yMin) this.dest = this.yMin;
		this.slide();
	}
}
                                                                                                                                        