ecms_float_fullscreen.js 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. brOK=navigator.javaEnabled()?true:false;
  2. //ns4=(document.layers)?true:false;
  3. //ie4=(document.all)?true:false;
  4. var vmin=2; var vmax=5; var vr=2; var timer1;
  5. function Chip(chipname,width,height){
  6. this.named=chipname;
  7. this.vx=vmin+vmax*Math.random();
  8. this.vy=vmin+vmax*Math.random();
  9. this.w=width; this.h=height;
  10. this.xx=0;
  11. this.yy=0;
  12. this.timer1=null;
  13. }
  14. function movechip(chipname) {
  15. if(brOK){
  16. eval("chip="+chipname);
  17. if(ns4){
  18. pageX=window.pageXOffset;
  19. pageW=window.innerWidth;
  20. pageY=window.pageYOffset;
  21. pageH=window.innerHeight;
  22. }
  23. else{
  24. pageX=window.document.body.scrollLeft;
  25. pageW=window.document.body.offsetWidth-8;
  26. pageY=window.document.body.scrollTop;
  27. pageH=window.document.body.offsetHeight;
  28. }
  29. chip.xx=chip.xx+chip.vx;chip.yy=chip.yy+chip.vy;
  30. chip.vx+=vr*(Math.random()-0.5);
  31. chip.vy+=vr*(Math.random()-0.5);
  32. if(chip.vx>(vmax+vmin)) chip.vx=(vmax+vmin)*2-chip.vx;
  33. if(chip.vx<(-vmax-vmin)) chip.vx=(-vmax-vmin)*2-chip.vx;
  34. if(chip.vy>(vmax+vmin)) chip.vy=(vmax+vmin)*2-chip.vy;
  35. if(chip.vy<(-vmax-vmin)) chip.vy=(-vmax-vmin)*2-chip.vy;
  36. if(chip.xx<=pageX){
  37. chip.xx=pageX;chip.vx=vmin+vmax*Math.random();
  38. }
  39. if(chip.xx>=pageX+pageW-chip.w){
  40. chip.xx=pageX+pageW-chip.w;
  41. chip.vx=-vmin-vmax*Math.random();
  42. }
  43. if(chip.yy<=pageY){
  44. chip.yy=pageY;
  45. chip.vy=vmin+vmax*Math.random();
  46. }
  47. if(chip.yy>=pageY+pageH-chip.h){
  48. chip.yy=pageY+pageH-chip.h;
  49. chip.vy=-vmin-vmax*Math.random();
  50. }
  51. if(ns4){
  52. eval('document.'+chip.named+'.top ='+chip.yy);
  53. eval('document.'+chip.named+'.left='+chip.xx);
  54. }
  55. else{
  56. eval('document.all.'+chip.named+'.style.pixelLeft='+chip.xx);
  57. eval('document.all.'+chip.named+'.style.pixelTop ='+chip.yy);
  58. }
  59. chip.timer1=setTimeout("movechip('"+chip.named+"')",100);
  60. }
  61. }
  62. function stopme(chipname){
  63. if(brOK){
  64. eval("chip="+chipname);
  65. if(chip.timer1!=null){
  66. clearTimeout(chip.timer1)
  67. }
  68. }
  69. }
  70. var DGbanner2;
  71. function DGbanner2() {
  72. DGbanner2=new Chip("DGbanner2",60,80);
  73. if(brOK){
  74. movechip("DGbanner2");
  75. }
  76. }
  77. window.onload=DGbanner2;