window.offscreenBuffering=true; function getWindowWidth() { if (typeof(window.innerWidth) == 'number') return window.innerWidth; var d = document; var b = d.body ? d.body : d.documentElement; return b.clientWidth; } function getWindowHeight() { if (typeof(window.innerHeight) == 'number') return window.innerHeight; var d = document; var b = d.body ? d.body : d.documentElement; return b.clientHeight; } //alert(getWindowHeight()); function SkyScraper(id, inertia, k, yPad, yMin, yHeight) { this.inertia = inertia; this.k = k; this.yPad = yPad; this.yMin = yMin; this.yHeight = yHeight; 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 = 'SkyScraper_' + id eval(this.gRef+'=this') if (yPad < yMin) yPad = yMin; this.div.style.top = yPad + 'px'; //alert(getWindowHeight()); setInterval(this.gRef + '.checkScroll()', 100); } SkyScraper.prototype.getPageYOffset = function() { if (window.pageYOffset) { return window.pageYOffset; } if (document.body && document.body.scrollTop) { return document.body.scrollTop; } return 0; } SkyScraper.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); } } SkyScraper.prototype.checkScroll = function() { var y = this.getPageYOffset(); if (y != this.lastYOffset) { this.lastYOffset = y; this.scrolled = true; } else if (this.scrolled && this.yHeight < ( getWindowHeight() - 100 ) ) { this.scrolled = false; this.dest = y + this.yPad; if (this.dest < this.yMin) this.dest = this.yMin; this.slide(); } }