/*对联广告
  例子:(new CoupletAD()).ini("Images/u517.png", "Images/u521.png", "left", "left");
*/
var CoupletAD = function() { }
CoupletAD.prototype.ini = function(bigImg, smallImg, position, name) {
    this.bigImg = bigImg;
    this.smallImg = smallImg;
    this.position = position;
    this.name = name;
    this.timer = null;
    this.create();
}
CoupletAD.prototype.create = function() {
    var self = this;
    var oDiv = document.createElement('div');
    oDiv.id = this.name;
    oDiv.style.cssText = "position:absolute;top:300px;" + this.position + ":10px;";
    document.body.appendChild(oDiv);

    var str = '<div ></div>';

    oDiv.innerHTML = str;

    if (this.timer == null) {
        this.timer = setInterval(function() {
            self.move();
        }, 500)
    }

}
CoupletAD.prototype.move = function() {
    $(this.name).style.top = document.documentElement.clientHeight / 2 + document.documentElement.scrollTop - 200 / 2 + "px";
}

相关文章: