var snow = function() {
  
  var snowsrc=null;
  var count=null;
  var doc_width;
  var doc_height;
  
  var dx = new Array();
  var xp = new Array();
  var yp = new Array();
  var am = new Array();
  var stx = new Array();
  var sty = new Array();
  

  var initSnow = function(count_snow,src_snow)
  {
    count = parseInt(count_snow);
    snowsrc = src_snow;
    tmp = getWindowSize();
    doc_width = tmp[0];
    doc_height = tmp[1];
    for (i=0; i<count; ++ i) 
    {  
      dx[i] = 0;                             // set coordinate variables
      xp[i] = Math.random()*(doc_width-50);  // set position variables x
      yp[i] = Math.random()*doc_height;      // set position variables x
      am[i] = Math.random()*20;              // set amplitude variables
      stx[i] = 0.02 + Math.random()/10;      // set step variables x
      sty[i] = 0.7 + Math.random();          // set step variables y
      document.write('<div id="dot'+ i +'" style="position: absolute; z-index: ' + i + '; visibility: visible; top: 15px; left: 15px;"><img src="' + snowsrc + '" border="0"><\/div>');
    }
  }
  
  var startSnow = function ()
  {
    if ((snowsrc != null) && (count!=null))
    {
      for (i = 0; i < count; ++ i) 
      {
        yp[i] += sty[i];
        if (yp[i] > doc_height-50) 
        {
          xp[i] = Math.random()*(doc_width-am[i]-30);
          yp[i] = 0;
          stx[i] = 0.02 + Math.random()/10;
          sty[i] = 0.7 + Math.random();
        }
        dx[i] += stx[i];
  
        byID("dot"+i).style.top=yp[i]+'px';
        byID("dot"+i).style.left=xp[i] + am[i]*Math.sin(dx[i]) + 'px';
  
      }
      setTimeout(startSnow,50);
    }
  }
  
	return {
	  init:function(cnt,src) { 
	    initSnow(cnt,src);
	  },
		start: function() {
		  startSnow();
		}
	};
  
  
} ();

//snow.init(10,'http://loe.lg.ua/include/javascript/snow/snow3.gif');
//snow.start();

