function objectad() {
/* define variables*/
this.adid = 0;
this.adtype = 0;
this.adname = "";
this.imgurl = "";
this.imgwidth = 0;
this.imgheight = 0;
this.flashwmode = 0;
this.linkurl = "";
this.linktarget = 0;
this.linkalt = "";
this.priority = 0;
this.countview = 0;
this.countclick = 0;
this.installdir = "";
this.addir = "";
this.overduedate = "";
}
function floatzonead(_id) {
/* define constants */
this.vmin = 2;
this.vmax = 5;
this.vr = 2;
/* define common variables*/
this.id = _id;
this.zoneid = 0;
this.zonename = "";
this.zonewidth = 0;
this.zoneheight = 0;
this.showtype = 1;
this.divname = "";
this.div = null;
/* define unique variables*/
this.localitytype= 1;
this.floattype = 1;
this.left = 0;
this.top = 0;
this.delay = 50;
this.showclosead = false;
this.closefontcolor = "#ffffff";
this.width = 1;
this.height = 1;
this.vx = this.vmin+this.vmax*math.random();
this.vy = this.vmin+this.vmax*math.random();
this.timer = null;
this.step = 1;
this.xin = true;
this.yin = true;
/* define objects */
this.allad = new array();
this.showad = null;
/* define functions */
this.addad = floatzonead_addad;
this.getshowad = floatzonead_getshowad;
this.show = floatzonead_show;
this.float = floatzonead_float;
this.pause = floatzonead_pause;
this.resume = floatzonead_resume;
this.getright = floatzonead_getright;
this.gettail = floatzonead_gettail;
}
function floatzonead_addad(_ad) {
var date = new date();
var getdate = date.getfullyear() + "/" + (date.getmonth() + 1) + "/" + date.getdate();
var today = new date(getdate);
var overduedate = new date(_ad.overduedate);
if(today <= overduedate) {
this.allad[this.allad.length] = _ad;
}
}
function floatzonead_getshowad() {
if (this.showtype > 1) {
this.showad = this.allad[0];
return;
}
var num = this.allad.length;
var sum = 0;
for (var i = 0; i < num; i++) {
sum = sum + this.allad[i].priority;
}
if (sum <= 0) {return ;}
var rndnum = math.random() * sum;
i = 0;
j = 0;
while (true) {
j = j + this.allad[i].priority;
if (j >= rndnum) {break;}
i++;
}
this.showad = this.allad[i];
}
function floatzonead_show() {
if (!this.allad) {
return;
} else {
this.getshowad();
}
if (this.showad == null) return false;
this.divname = "floatzonead_div" + this.zoneid;
if (!this.showad.imgwidth) this.showad.imgwidth = this.zonewidth;
if (!this.showad.imgheight) this.showad.imgheight = this.zoneheight;
if (this.showad.addir=="") this.showad.addir = "ad";
if (this.localitytype==2) {
this.top = this.gettail();
} else if (this.localitytype==3) {
this.left = this.getright();
} else if (this.localitytype==4) {
this.left = this.getright();
this.top = this.gettail();
}
document.write("
" + ad_content(this.showad) + "");
document.write("
关闭
");
document.write("
");
if (this.showad.countview) {
document.write ("");
}
this.width = (this.showad.imgwidth)?this.showad.imgwidth:this.zonewidth;
this.height = (this.showad.imgheight)?this.showad.imgheight:this.zoneheight;
this.div = document.getelementbyid(this.divname);
this.float();
}
function floatzonead_getright(){
if (window.innerwidth) {
return window.innerwidth-16 - this.left - this.zonewidth;
} else {
return document.documentelement.clientwidth - this.left - this.zonewidth;
}
}
function floatzonead_gettail(){
if (window.innerwidth) {
return window.innerheight - this.top - this.zoneheight;
} else {
return document.documentelement.clientheight - this.top - this.zoneheight;
}
}
function floatzonead_float() {
if(document.all) {
pagex=window.document.documentelement.scrollleft;
pagew=window.document.documentelement.offsetwidth-22;
pagey=window.document.documentelement.scrolltop;
pageh=window.document.documentelement.offsetheight-4;
}
else {
pagex=window.pagexoffset;
pagew=window.innerwidth-22;
pagey=window.pageyoffset;
pageh=window.innerheight-4;
}
if (this.floattype==1) {
this.left=this.left+this.vx;
this.top=this.top+this.vy;
this.vx+=this.vr*(math.random()-0.5);
this.vy+=this.vr*(math.random()-0.5);
if(this.vx>(this.vmax+this.vmin))this.vx=(this.vmax+this.vmin)*2-this.vx;
if(this.vx<(-this.vmax-this.vmin))this.vx=(-this.vmax-this.vmin)*2-this.vx;
if(this.vy>(this.vmax+this.vmin))this.vy=(this.vmax+this.vmin)*2-this.vy;
if(this.vy<(-this.vmax-this.vmin))this.vy=(-this.vmax-this.vmin)*2-this.vy;
if(this.left<=pagex){this.left=pagex;this.vx=this.vmin+this.vmax*math.random();}
if(this.left>=pagex+pagew-this.width){this.left=pagex+pagew-this.width;this.vx=-this.vmin-this.vmax*math.random();}
if(this.top<=pagey){this.top=pagey;this.vy=this.vmin+this.vmax*math.random();}
if(this.top>=pagey+pageh-this.height){this.top=pagey+pageh-this.height;this.vy=-this.vmin-this.vmax*math.random();}
this.delay=80;
} else if (this.floattype==2) {
this.left+=this.step*(this.xin?1:-1);
this.top+=this.step*(this.yin?1:-1);
if(this.left<=pagex){this.xin=true;this.left<=pagex;}
if(this.left>=pagex+pagew-this.width){this.xin=false;this.left=pagex+pagew-this.width;}
if(this.top<=pagey){this.yin=true;this.top=pagey;}
if(this.top>=pagey+pageh-this.height){this.yin=false;this.top=pagey+pageh-this.height;}
this.delay=15;
} else if (this.floattype==3) {
this.top+=this.step*(this.yin?1:-1);
if(this.top<=pagey){this.yin=true;this.top=pagey;}
if(this.top>=pagey+pageh-this.height){this.yin=false;this.top=pagey+pageh-this.height;}
this.delay=15;
} else if (this.floattype==4) {
this.left+=this.step*(this.xin?1:-1);
if(this.left<=pagex){this.xin=true;this.left<=pagex;}
if(this.left>=pagex+pagew-this.width){this.xin=false;this.left=pagex+pagew-this.width;}
this.delay=15;
}
this.div.style.left=this.left + "px";
this.div.style.top =this.top + "px";
this.div.timer=settimeout(this.id+".float()",this.delay);
}
function floatzonead_pause() {
if(this.div.timer!=null){cleartimeout(this.div.timer);}
}
function floatzonead_resume() {
this.float();
}
function ad_closedl(d){
document.getelementbyid(d).style.visibility = "hidden";
}
function ad_content(o) {
var str = "";
if (o.adtype == 1 || o.adtype == 2) {
imgurl = o.imgurl .tolowercase();
if (o.installdir.indexof("http://") != - 1) imgurl = o.installdir.substr(0, o.installdir.length - 1) + imgurl;
if (imgurl.indexof(".swf") != - 1) {
str = "";
} else if (imgurl.indexof(".gif") != - 1 || imgurl.indexof(".jpg") != - 1 || imgurl.indexof(".jpeg") != - 1 || imgurl.indexof(".bmp") != - 1 || imgurl.indexof(".png") != - 1) {
if (o.linkurl) {
if (o.countclick) o.linkurl = o.installdir + o.addir + "/adcount.aspx?action=click&adid=" + o.adid
str += "";
}
str += "";
if (o.linkurl) str += "";
}
} else if (o.adtype == 3 || o.adtype == 4) {
str = o.adintro;
} else if (o.adtype == 5) {
str = "";
}
return str;
}
var zonead_1=new floatzonead("zonead_1");
var objad = new objectad();
objad.adid= 2;
objad.adtype= 2;
objad.adname= "";
objad.imgurl= "/imgs/xm-2019yd.jpg";
objad.imgwidth = 200;
objad.imgheight= 100;
objad.flashwmode = 0;
objad.adintro ="";
objad.linkurl = "/item/7947.aspx";
objad.linktarget= 1;
objad.linkalt= "";
objad.priority= 1;
objad.countview= false;
objad.countclick= false;
objad.overduedate= "2027/12/12";
objad.installdir= "/";
objad.addir= "iaa";
zonead_1.addad(objad);
zonead_1.zoneid=1;
zonead_1.zonewidth=200;
zonead_1.zoneheight=100;
zonead_1.showtype=1;
zonead_1.floattype= 2;
zonead_1.left= 100;
zonead_1.top= 100;
zonead_1.showclosead=false;
zonead_1.closefontcolor="#ffffff";
zonead_1.localitytype = 1;
zonead_1.show();