/*
Based on:
Snow Effect Script
Submitted by Altan d.o.o. (snow@altan.hr, http://www.altan.hr/snow/index.html)
For full source code to this script, visit http://dynamicdrive.com
*/

  var s="images/snowflake.gif"              // snowflake image
  var no = 15;                              // snowflakes to render
  var dim = 20;                             // image size
  var dx, xp, yp;                           // coordinate and position variables
  var am, stx, sty;                         // amplitude and step variables
  var i, doc_width = 800, doc_height = 600;

  if (navigator.appName == "Netscape") {
    doc_width = self.innerWidth - 200;
    doc_height = self.innerHeight;
  }
  else if (navigator.appName == "Microsoft Internet Explorer") {
    doc_width = document.documentElement.scrollWidth - 400;
    doc_height = document.documentElement.scrollHeight;
  }

  dx = new Array();
  xp = new Array();
  yp = new Array();
  am = new Array();
  stx = new Array();
  sty = new Array();

  for (i = 0; i < no; ++ i) {
    dx[i] = 0;                              // set coordinate variables
    xp[i] = Math.random()*(doc_width-50);   // set position variables
    yp[i] = Math.random()*doc_height;
    am[i] = Math.random()*10;               // set amplitude variables
    stx[i] = 0.02 + Math.random()/10;       // set step variables - speed of wiggle left to right
    sty[i] = 0.99 + Math.random();            // set step variables - speed of descent
    document.write("<div id=\"dot"+ i +"\" style=\"position: absolute; top: 0px; left: 0px;\"><img src='" + s + "' width=" + dim + " border=\"0\"></div>");
  }

  function fall() {                       // main animation function
    for (i = 0; i < no; ++ i) {             // iterate for every dot

      yp[i] += sty[i];

      if (yp[i] > doc_height-50) {
        xp[i] = Math.random()*(doc_width-am[i]-30);
        yp[i] = 0;
        stx[i] = .02 + Math.random()/50;
        sty[i] = .08 + Math.random();

        if (navigator.appName == "Netscape") {
          doc_width = window.innerWidth;
          doc_height = window.innerHeight;
        }
        else if (navigator.appName == "Microsoft Internet Explorer") {
          doc_width = document.body.clientWidth;
          doc_height = document.body.clientHeight;
        }
      }

      dx[i] += stx[i];

      document.getElementById("dot"+i).style.top = yp[i] + 'px';
      document.getElementById("dot"+i).style.left = xp[i] + am[i]*Math.sin(dx[i]) + 'px';
    }
    setTimeout("fall()", 10);
  }

  fall();
