home *** CD-ROM | disk | FTP | other *** search
/ com!online 2002 May / comcd0502.iso / homepage / special / javascript / 08_01 / javascripts / imgblossomani / imgblossomani.js < prev   
Encoding:
JavaScript  |  2001-03-27  |  4.4 KB  |  162 lines

  1. // CREDITS:
  2. // FlowerPower: put springtime on your website
  3. // by Urs Dudli and Peter Gehrig 
  4. // Copyright (c) 2001 Peter Gehrig and Urs Dudli. All rights reserved.
  5. // Permission given to use the script provided that this notice remains as is.
  6. // Additional scripts can be found at http://www.24fun.com.
  7. // info@24fun.com
  8. // 3/27/2001
  9.  
  10. // IMPORTANT: 
  11. // If you add this script to a script-library or a script-archive 
  12. // you have to insert a highly visible link to http://www.24fun.com right into the 
  13. // webpage where the script will be displayed.
  14.  
  15. // CONFIGURATION:
  16. // Go to http://www.24fun.com, open category 'image' and 
  17. // download the ZIP-file of this script containing
  18. // 6 images and the script-file with step-by-step instructions for easy configuration.
  19.  
  20. // do not edit the variables below
  21. var frame=new Array()
  22. frame[0]=new Image()
  23. frame[0].src="frame1.gif"
  24. frame[1]=new Image()
  25. frame[1].src="frame2.gif"
  26. frame[2]=new Image()
  27. frame[2].src="frame3.gif"
  28. frame[3]=new Image()
  29. frame[3].src="frame4.gif"
  30. frame[4]=new Image()
  31. frame[4].src="frame5.gif"
  32. frame[5]=new Image()
  33. frame[5].src="frame6.gif"
  34.  
  35. var i_nownumberofframes=0
  36. var i_maxnumberofframes=5
  37. var i_numberofblossoms=0
  38.  
  39. var marginleft=0
  40. var margintop=0
  41. var marginbottom
  42. var marginright
  43.  
  44. var timer
  45. var thisblossom
  46.  
  47. showblossomstime=showblossomstime*1000
  48.  
  49. function positionblossoms() {
  50.     if (document.all) {   
  51.         marginbottom=document.body.clientHeight-40
  52.         marginright=document.body.clientWidth-40    
  53.         for (i=0;i<=numberofblossoms;i++) {     
  54.             var randx=Math.floor(marginright*Math.random())
  55.             var randy=Math.floor(marginbottom*Math.random())
  56.             thisblossom=eval("document.all.blossom"+i+".style")
  57.             thisblossom.posLeft=randx
  58.             thisblossom.posTop=randy
  59.             thisblossom.visibility="visible"
  60.         }
  61.         thisblossom=eval("blossom0")
  62.         openblossoms()
  63.     }
  64.     if (document.layers) {   
  65.         marginbottom=window.innerHeight-40
  66.         marginright=window.innerWidth-40       
  67.         for (i=0;i<=numberofblossoms;i++) {     
  68.             var randx=Math.floor(marginright*Math.random())
  69.             var randy=Math.floor(marginbottom*Math.random())
  70.             thisblossom=eval("document.blossom"+i)
  71.             thisblossom.left=randx
  72.             thisblossom.top=randy
  73.             thisblossom.visibility="visible"
  74.         }
  75.         thisblossom=eval("document.blossom0.document")
  76.         openblossoms()
  77.     }
  78. }
  79.  
  80. function openblossoms() {
  81.     if (document.all) {
  82.         clearTimeout(timer)
  83.         if (i_nownumberofframes<=i_maxnumberofframes) {
  84.             thisblossom.innerHTML="<img src='"+frame[i_nownumberofframes].src+"'>"
  85.             i_nownumberofframes++
  86.             timer=setTimeout("openblossoms()",openblossomspeed)
  87.         }
  88.         else  {
  89.             clearTimeout(timer)
  90.             i_nownumberofframes=0
  91.             switchtonextblossom()
  92.         }
  93.     }
  94.     if (document.layers) {   
  95.         if (i_nownumberofframes<=i_maxnumberofframes) {
  96.             thisblossom.write("<img src='"+frame[i_nownumberofframes].src+"'>")
  97.             thisblossom.close()
  98.             i_nownumberofframes++
  99.             timer=setTimeout("openblossoms()",openblossomspeed)
  100.         }
  101.         else  {
  102.             clearTimeout(timer)
  103.             i_nownumberofframes=0
  104.             switchtonextblossom()
  105.         }
  106.     }
  107. }
  108.  
  109. function switchtonextblossom() {
  110.     if (document.all) {
  111.         i_numberofblossoms++
  112.         if (i_numberofblossoms<=numberofblossoms) {
  113.             thisblossom=eval("blossom"+i_numberofblossoms)
  114.             openblossoms()
  115.         }
  116.         else {
  117.             setTimeout("hideblossoms()",showblossomstime)
  118.         }
  119.     }
  120.     if (document.layers) {
  121.         i_numberofblossoms++
  122.         if (i_numberofblossoms<=numberofblossoms) {
  123.             thisblossom=eval("document.blossom"+i_numberofblossoms+".document")
  124.             openblossoms()
  125.         }
  126.         else {
  127.             setTimeout("hideblossoms()",showblossomstime)
  128.         }
  129.     }
  130. }
  131.  
  132. function hideblossoms() {
  133.     if (document.all) {
  134.         for (i=0;i<=numberofblossoms;i++) {     
  135.             thisblossom=eval("document.all.blossom"+i+".style")
  136.             thisblossom.visibility="hidden"
  137.         }
  138.     }
  139.     if (document.layers) {
  140.         for (i=0;i<=numberofblossoms;i++) {     
  141.             thisblossom=eval("document.blossom"+i)
  142.             thisblossom.visibility="hidden"
  143.         }
  144.     }
  145. }
  146.  
  147. if (document.all) {
  148.     for (i=0;i<=numberofblossoms;i++) {
  149.         document.write("<div id='blossom"+i+"' style='position:absolute;top:0px;left:0px;visibility:hidden;'><img name='blossomimg"+i+"' src='frame1.gif'></div>")
  150.         document.clear()
  151.     }
  152. }
  153.  
  154. if (document.layers) {
  155.     for (i=0;i<=numberofblossoms;i++) {
  156.         document.write("<layer name='blossom"+i+"' visibility=hide><img name='blossomimg"+i+"' src='frame1.gif'></layer>")
  157.     }
  158. }
  159.  
  160. window.onresize=positionblossoms
  161. window.onload=positionblossoms
  162.