对联广告特效
/*对联广告
例子:(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 id="big' + this.name + '" style="display:;" >\
<a href="#" target="_blank" ><img src="' + this.bigImg + '" ></a>\
<div style="cursor:pointer" onclick="$(\'big' + this.name + '\').style.display=\'none\';$(\'small' + this.name + '\').style.display=\'\'" >关闭</div>\
</div>\
<div id="small' + this.name + '" style="display:none;cursor:pointer;" onclick="$(\'big' + this.name + '\').style.display=\'\';$(\'small' + this.name + '\').style.display=\'none\'" ><img src="' + this.smallImg + '" ></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";
}