// (c) Seb Gibbs 2003-2005

 var i
 var xp, yp, dx;   // coordinate and position variables
 var am, stx, sty;  // amplitude and step variables
 var doc_width = 1250, doc_height = 600;
 var wx = 0, swx = 0;

 var snowsrc="/images/snow.gif"
 var no = 22;

 var ns4up = (document.layers) ? 1 : 0;
 var ie4up = (document.all) ? 1 : 0;
 var ns6up = (document.getElementById&&!document.all) ? 1 : 0;

 if (ns4up||ns6up) {
   doc_width = self.innerWidth-32;
   doc_height = self.innerHeight-18 }
 else if (ie4up) {
   doc_width = document.body.clientWidth-32;
   doc_height = document.body.scrollHeight-18;
   if (doc_height<9) {doc_height=document.body.clientHeight-18}
 }

// no = no + (doc_height + doc_width)/180

	dots = new Array();
	xp = new Array();
	yp = new Array();
	dx = new Array();
	am = new Array();
	stx = new Array();
	sty = new Array();

 for (i = 0; i < no; ++i)
 { dx[i] = 0;
   xp[i] = Math.random()*doc_width;
   yp[i] = Math.random()*doc_height;
   am[i] = (i/no*20 + Math.random());
   stx[i] = 0.02 + (Math.random() /5);
   sty[i] = 0.5 + ((Math.random()*2+i/no) *2);
   if (ns4up) {
     document.write("<layer name=\"dot"+ i +"\" left=\"15\" top=\"15\" visibility=\"show\"><img src='"+snowsrc+"' border=\"0\"><\/layer>")
     dots[i] = document.layers["dot"+i] }
   else if (ie4up||ns6up) {
       document.write("<img id=\"dot"+ i +"\" style=\"POSITION:absolute;Z-INDEX:"+ i +";WIDTH:"+ ((i/no*8)+2) +"px\" src='"+snowsrc+"' border=\"0\">")
       if (ns6up) {dots[i] = document.getElementById("dot"+i).style}
       else
         if (ie4up) {dots[i] = document.all["dot"+i].style} } }


 function snow()
 { swx += (Math.random()-.5) - (swx/20)
   for (i = 0; i < no; ++i)
   { yp[i] += sty[i];
     xp[i] += wx*(i+9);
     dx[i] += .1;
     if (yp[i] > doc_height) {yp[i] = 0}
     if (xp[i] < 1) {xp[i] = doc_width}
     if (xp[i] > doc_width) {xp[i] = 0}
     dots[i].top = yp[i];
     dots[i].left = (xp[i]+am[i]*Math.sin(i+dx[i]))
     }
   wx += (swx*.01) - (wx/5);
   setTimeout("snow()",50)
   }

//   am[i]*Math.sin(dx[i]);
//   dx[i] += stx[i];


snow()
