var admoveconfig=new object(); admoveconfig.isinitialized=false; admoveconfig.scrollx=0; admoveconfig.scrolly=0; admoveconfig.movewidth=0; admoveconfig.moveheight=0; admoveconfig.resize=function(){ var winsize=getpagesize(); admoveconfig.movewidth=winsize[2]; admoveconfig.moveheight=winsize[3]; admoveconfig.scroll(); } admoveconfig.scroll=function(){ var winscroll=getpagescroll(); admoveconfig.scrollx=winscroll[0]; admoveconfig.scrolly=winscroll[1]; } addevent(window,"resize",admoveconfig.resize); addevent(window,"scroll",admoveconfig.scroll); function admove(id){ if(!admoveconfig.isinitialized){ admoveconfig.resize(); admoveconfig.isinitialized=true; } var obj=document.getelementbyid(id); obj.style.position="absolute"; var w=admoveconfig.movewidth-obj.offsetwidth; var h=admoveconfig.moveheight-obj.offsetheight; var x = w*math.random(),y = h*math.random(); var rad=(math.random()+1)*math.pi/6; var kx=math.sin(rad),ky=math.cos(rad); var dirx = (math.random()<0.5?1:-1), diry = (math.random()<0.5?1:-1); var step = 1; var interval; this.setlocation=function(vx,vy){x=vx;y=vy;} this.setdirection=function(vx,vy){dirx=vx;diry=vy;} obj.custommethod=function(){ obj.style.left = (x + admoveconfig.scrollx) + "px"; obj.style.top = (y + admoveconfig.scrolly) + "px"; rad=(math.random()+1)*math.pi/6; w=admoveconfig.movewidth-obj.offsetwidth; h=admoveconfig.moveheight-obj.offsetheight; x = x + step*kx*dirx; if (x < 0){dirx = 1;x = 0;kx=math.sin(rad);ky=math.cos(rad);} if (x > w){dirx = -1;x = w;kx=math.sin(rad);ky=math.cos(rad);} y = y + step*ky*diry; if (y < 0){diry = 1;y = 0;kx=math.sin(rad);ky=math.cos(rad);} if (y > h){diry = -1;y = h;kx=math.sin(rad);ky=math.cos(rad);} } this.run=function(){ var delay = 10; interval=setinterval(obj.custommethod,delay); obj.onmouseover=function(){clearinterval(interval);} obj.onmouseout=function(){interval=setinterval(obj.custommethod, delay);} } }