SnowClass= function(picture){
     this.snowsrc=picture || "snow.gif";//img fiocco
  	 this.no = 10;//numero di fiocchi
  	 this.hidesnowtime = 0;//vita di un fiocco
  	 this.snowdistance = "windowheight";//("windowheight" or "pageheight")

  	 // coordinate and position variables
  	 this.dx = new Array();
  	 this.xp = new Array();
  	 this.yp = new Array();
  	 // amplitude and step variables
  	 this.am = new Array();
  	 this.stx = new Array();
  	 this.sty = new Array();

  	 var i, width = 800, height = 600; 
  
  	 width = document.body.clientWidth;
  	 height = document.body.clientHeight;

  	 for (i = 0; i < this.no; ++ i) {  
		 this.dx[i] = 0;                        // set coordinate variables
    	 this.xp[i] = Math.random()*(width-50);  // set position variables
    	 this.yp[i] = Math.random()*height;
    	 this.am[i] = Math.random()*20;         // set amplitude variables
    	 this.stx[i] = 0.02 + Math.random()/10; // set step variables
    	 this.sty[i] = 0.7 + Math.random();     // set step variables
		 document.write("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src='"+this.snowsrc+"' border=\"0\"><\/div>");
  	 }
  }
SnowClass.prototype ={
    anim:function(){
	    width = document.body.clientWidth-10;
	 	height=document.body.clientHeight;

     	for (i = 0; i < this.no; ++ i) {  // iterate for every dot
     		this.yp[i] += this.sty[i];
      	 	if (this.yp[i] > height-50) {
         	   this.xp[i] = Math.random()*(width-this.am[i]-30);
         	   this.yp[i] = 0;
        	   this.stx[i] = 0.02 + Math.random()/10;
       		   this.sty[i] = 0.7 + Math.random();
      	    }
      	 	this.dx[i] += this.stx[i];
      	 	$("dot"+i).style.top=this.yp[i]+"px";
      	 	$("dot"+i).style.left=this.xp[i] + this.am[i]*Math.sin(this.dx[i])+"px";  
    	}
		//obj=this.anim();
        //setTimeout(obj, 10);
		//snowtimer=setTimeout("snowAnim()", 10);
   },
   hide:function(timer){
		if (timer) clearTimeout(timer)
		for (i=0; i<no; i++) $("dot"+i).style.visibility="hidden";
   }
}

//var snow = new SnowClass();
//setInterval("snow.anim()",10);
