try{ wmp.advert={}; }catch(e){ wmp={advert:{}}; } wmp.apply = function(o, c, defaults){ // no "this" reference for friendly out of scope calls if(defaults){ ext.apply(o, defaults); } if(o && c && typeof c == 'object'){ for(var p in c){ o[p] = c[p]; } } return o; }; /** var ad=new wmp.advert.fixedad({}); */ wmp.advert.fixedad=function(paras){ this.id='ad_'+parseint(math.random()*1000); this.type="fixedad"; this.width=0; this.height=0; this.content=''; this.renderto=null; var self=this; function build(){ wmp.apply(self,paras); box=document.createelement("div") with(box.style){ width=self.width+"px"; height=self.height+"px"; overflow="hidden"; } box.innerhtml=self.content; if(self.renderto==null || typeof(self.renderto)=='undefined'){ //self.renderto=document.body; document.writeln(box.outerhtml); return; }else if(typeof(self.renderto)=='string'){ self.renderto=document.getelementbyid(self.renderto); } self.renderto.appendchild(box); } this.load=function(){ build(); } } wmp.advert.popad=function(paras){ this.id='ad_'+parseint(math.random()*1000); this.type="popad"; this.width=100; this.height=100; this.xvalue=0; this.yvalue=0; this.title=""; this.content=''; var self=this; function build(){ wmp.apply(self,paras); var content=self.content; content=content.replace("\r","").replace("\n",""); var html =''; html+='' + self.title + ''; html+=''; html+='' + content + ''; var pupwin=window.open('','_blank','width='+self.width+',height='+self.height+',top='+self.top+',left='+self.left); pupwin.document.write(html); } this.load=function(){ build(); } } wmp.advert.floatad=function(paras){ //public this.id='ad_'+parseint(math.random()*1000); this.type="floatad"; this.width=100; this.height=100; this.xvalue=0; this.yvalue=0; this.content=""; this.closebutton=true; this.closebuttonhtml="关闭"; this.speed=6; //private var self=this; var timer=null; var contentdiv=document.createelement("div"); var rootdiv=document.createelement("div"); var xx=this.xvalue; var yy=this.yvalue; var vx=vy=0 var vmin=2; var vmax=5; var vx=vmin+vmax*math.random(); var vy=vmin+vmax*math.random(); var vr=2; var isinit=false; var ishide=false; var loopnum=0; function build(){ wmp.apply(self,paras); self.speed=parseint(500 / self.speed); if(self.closebutton==true || self.closebutton=='0'){ //var closebutton=document.createelement("span"); //closebutton.href="javascript:;"; var closebuttondiv=document.createelement("div"); closebuttondiv.setattribute("align","right"); with(closebuttondiv.style){ position="absolute"; //backgroundcolor="#ffffff"; backgroundcolor="rgba(255,255,255,0.7)"; cursor="pointer"; top="0px"; right="0px"; margin="1px"; padding="2px"; zindex="999"; fontsize="12px"; //filter= "alpha(style=0,opacity=60,finishopacity=80)"; } closebuttondiv.innerhtml=self.closebuttonhtml; closebuttondiv.onclick=function(){ self.hide(); } rootdiv.appendchild(closebuttondiv); } contentdiv.innerhtml = self.content; with(rootdiv.style){ position="absolute"; zindex="900"; display="none"; wordbreak="break-all"; width = self.width+"px"; height = self.height+"px"; left=self.xvalue; top=self.yvalue; filter= "alpha(style=0,opacity=100,finishopacity=100)"; } rootdiv.onmouseover=function(){ self.stop(); } rootdiv.onmouseout=function(){ self.start(); } rootdiv.appendchild(contentdiv); document.body.appendchild(rootdiv); isinit=true; xx=parseint(self.xvalue); yy=parseint(self.yvalue); } function movediv(){ var pagex=pagew=pagey=pageh=0; var isie=(document.all)?true:false; if(!isie){ pagex=window.pagexoffset; pagew=window.innerwidth; pagey=window.pageyoffset; pageh=window.innerheight; }else{ pagex=window.document.body.scrollleft; pagew=window.document.body.offsetwidth-8; pagey=window.document.body.scrolltop; pageh=window.document.body.offsetheight; if(pageh<=0)pageh=screen.availheight-100; } xx=xx+vx; yy=yy+vy; vx+=vr*(math.random()-0.5); vy+=vr*(math.random()-0.5); if(vx>(vmax+vmin)) vx=(vmax+vmin)*2-vx; if(vx<(-vmax-vmin)) vx=(-vmax-vmin)*2-vx; if(vy>(vmax+vmin)) vy=(vmax+vmin)*2-vy; if(vy<(-vmax-vmin)) vy=(-vmax-vmin)*2-vy; if(xx<=pagex){ xx=pagex; vx=vmin+vmax*math.random(); } if(xx>=pagex+pagew-self.width){ xx=pagex+pagew-self.width; vx=-vmin-vmax*math.random(); } if(yy<=pagey){ yy=pagey; vy=vmin+vmax*math.random(); } if(yy>=pagey+pageh-self.height){ yy=pagey+pageh-self.height; vy=-vmin-vmax*math.random(); } rootdiv.style.display="none"; if(!isie){ rootdiv.style.left = xx+'px'; rootdiv.style.top = yy+'px'; }else{ rootdiv.style.left = xx+'px'; rootdiv.style.top = yy+'px'; } /* console.log(loopnum++); console.log('xx='+xx); console.log('yy='+yy); console.log('vx='+vx); console.log('vy='+vy); console.log('y='+(pageh)); console.log('----------------------------'); */ rootdiv.style.display="block"; //if(loopnum>20)self.stop(); } this.hide=function(){ rootdiv.style.display="none"; ishide=true; } this.stop=function(){ //window.cleartimeout(timer); window.clearinterval(timer); timer=null; } this.start=function(){ if(ishide==false){ movediv(); timer=window.setinterval(movediv,self.speed); } //movediv(); } this.load=function(){ if(!isinit)build(); self.start(); } } wmp.advert.curtainad=function(paras){ this.id='ad_'+parseint(math.random()*1000); this.type="curtainad"; this.width=0; this.height=0; this.xposition='left'; this.yposition='top'; this.xvalue=0; this.yvalue=0; this.content=''; this.closebutton=true; this.closebuttonhtml="关闭"; var rootdiv=document.createelement("div"); var self=this; function build(){ wmp.apply(self,paras); var contentdiv=document.createelement("div"); if(self.closebutton==true || self.closebutton=='0'){ //var closebutton=document.createelement("span"); //closebutton.href="javascript:;"; var closebuttondiv=document.createelement("div"); closebuttondiv.setattribute("align","right"); with(closebuttondiv.style){ position="absolute"; backgroundcolor="#ffffff"; cursor="hand"; top="0px"; right="0px"; margin="1px"; padding="2px"; zindex="999"; fontsize="12px"; filter= "alpha(style=0,opacity=60,finishopacity=80)"; } closebuttondiv.innerhtml=self.closebuttonhtml; closebuttondiv.onclick=function(){ self.hide(); } rootdiv.appendchild(closebuttondiv); } contentdiv.innerhtml = self.content; with(rootdiv.style){ position="fixed"; zindex="900"; wordbreak="break-all"; width = self.width+"px"; height = self.height+"px"; overflow ='hidden'; filter= "alpha(style=0,opacity=100,finishopacity=100)"; } rootdiv.style[self.xposition]=self.xvalue+'px'; rootdiv.style[self.yposition]=self.yvalue+'px'; rootdiv.appendchild(contentdiv); document.body.appendchild(rootdiv); } this.hide=function(){ rootdiv.style.display="none"; ishide=true; } this.load=function(){ build(); } }