
// Snow Effect Javascript<br>
// copyright 19th November 2004, 20th July 2006 by Stephen Chapman<br>
// permission to use this Javascript on your web page is granted<br>
// provided that all of the code in this script (including these<br>
// comments) is used without any alteration<br>
// you can change the number of snow flakes if you like
<p>var num_flakes = 10;<br>
  var snowflakes = new Array(&quot;snowflake.gif&quot;,&quot;snowflake1.gif&quot;);</p>
<p>// DOM test<br>
  var aDOM = 0, ieDOM = 0, nsDOM = 0; var stdDOM = document.getElementById;<br>
  if (stdDOM) aDOM = 1; else {ieDOM = document.all; if (ieDOM) aDOM = 1; else 
  {<br>
  var nsDOM = ((navigator.appName.indexOf('Netscape') != -1)<br>
  &amp;&amp; (parseInt(navigator.appVersion) ==4)); if (nsDOM) aDOM = 1;}}<br>
  function findDOM(objectId, wS) {<br>
  if (stdDOM) return wS ? document.getElementById(objectId).style:<br>
  document.getElementById(objectId);<br>
  if (ieDOM) return wS ? document.all[objectId].style: document.all[objectId];<br>
  if (nsDOM) return document.layers[objectId];<br>
  }</p>
<p>// window size tests<br>
  function findLivePageWidth() {return window.innerWidth != null? window.innerWidth 
  : document.documentElement &amp;&amp; document.documentElement.clientWidth ? 
  document.documentElement.clientWidth : document.body != null ? document.body.clientWidth 
  :700;}function findLivePageHeight() {return window.innerHeight != null? window.innerHeight 
  : document.documentElement &amp;&amp; document.documentElement.clientHeight 
  ? document.documentElement.clientHeight : document.body != null? document.body.clientHeight 
  :500;}<br>
  function posX() {return typeof window.pageXOffset != 'undefined' ? window.pageXOffset:document.documentElement.scrollLeft? 
  document.documentElement.scrollLeft:document.body.scrollLeft? document.body.scrollLeft:0;}<br>
  function posY() {return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement.scrollTop? 
  document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;}</p>
<p>// make it snow<br>
  var speed = 50;var movw = new Array();var movh = new Array();var move = new 
  Array();var stepw = new Array();var steph = new Array();var posw = new Array();var 
  posh = new Array();var dir = new Array();var winWidth;var winHeight;<br>
  function startSnow() {winWidth = findLivePageWidth()-75;winHeight = findLivePageHeight()-50;<br>
  for (var i = 0; i &lt; num_flakes; i++){move[i] = 0;movh[i] = 12+ Math.random()*2;movw[i] 
  = 11+ Math.random()*4;posw[i] = Math.random()*(winWidth-35)+12;posh[i] = Math.random()*winHeight; 
  stepw[i] = 0.02 + Math.random()/10;steph[i] = 0.7 + Math.random();dir[i] = (Math.random()&gt;0.5)?1:-1;document.write('&lt;div 
  id=&quot;snow'+ i +'&quot; style=&quot;position: absolute; z-index: '+ i +'; 
  visibility:hidden; &quot;&gt;&lt;img src=&quot;'+snowflakes[Math.floor(Math.random()*snowflakes.length)]+ 
  '&quot; border=&quot;0&quot;&gt;&lt;/div&gt;');}setTimeout(&quot;moreSnow()&quot;, 
  speed);}<br>
  function moreSnow() {for (var i = 0; i &lt; num_flakes; i++) {if (posh[i] &gt; 
  winHeight-50) {posw[i] = 10+ Math.random()*(winWidth-movw[i]-30);posh[i] = 0;dir[i]=(Math.random()&lt;0.5)?1:-1;stepw[i] 
  = 0.02 + Math.random()/9;steph[i] = 1.3 + Math.random();} move[i] += stepw[i] 
  *dir[i]; if (Math.abs(move[i]) &gt; 3) {dir[i]=-dir[i]; posh[i]+=Math.abs(movh[i]*move[i]);posw[i]+=movw[i]*move[i]; 
  move[i]=0;} objstyle = findDOM('snow'+i,1); objstyle.left = (posX()+posw[i] 
  + movw[i]*move[i])+'px'; objstyle.top = (posY()+posh[i] + movh[i]*(Math.abs(Math.cos(move[i])+move[i])))+'px';objstyle.visibility 
  = 'visible';} setTimeout(&quot;moreSnow()&quot;, speed);}<br>
</p>
</body>
</html>

