/******************************************
* Snow Effect Script- By Altan d.o.o. (http://www.altan.hr/snow/index.html)
* Visit Dynamic Drive DHTML code library (http://www.dynamicdrive.com/) for full source code
* Last updated Nov 9th, 05' by DD. This notice must stay intact for use
******************************************/
  
  // Configure below to change number of snow to render
  var no = 8;
  // Configure whether snow should disappear after x seconds (0=never):
  var hidesnowtime = 0;
  // Configure how much snow should drop down before fading ("windowheight" or "pageheight")
  var snowdistance = "pageheight";

///////////Stop Config//////////////////////////////////

$(function(){  
  var dx, xp, yp;    // coordinate and position variables
  var am, stx, sty;  // amplitude and step variables
  var i, doc_width = 800, doc_height = 600; 
  
  doc_width  = $(document).width();
  doc_height = $(document).height();
  
  dx  = new Array();
  xp  = new Array();
  yp  = new Array();
  am  = new Array();
  stx = new Array();
  sty = new Array();
  var useImages = ['bal1.png', 'bal2.png', 'bal3.png'];
  
  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()*20;         // set amplitude variables
    stx[i] = 0.02 + Math.random()/10; // set step variables
    sty[i] =  0.7 + Math.random();     // set step variables
    var newEl = $("<div></div>")
		.attr('id', "dot"+i)
		.css('position', 'absolute')
		.css('z-index',  i)
		.css('visibility', 'visible')
		.css('top',      '15px')
		.css('left',     '15px')
		.html("<img src='images/"+useImages[i%3]+"' border='0' />");
	
	$("body").append(newEl);
  }
  
  function snowIE_NS6(){  // IE and NS6 main animation function
	doc_width  = $(document).width();
	doc_height = $(document).height();
	
	if(!doc_width || !doc_height)
		return;
	
    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] = 0.02 + Math.random()/10;
        sty[i] = 0.7 + Math.random();
      }
      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";  
    }
  }

  function hidesnow(){
	if (window.snowtimer)
		clearInterval(snowtimer);
	for (i=0; i<no; i++)
		document.getElementById("dot"+i).style.visibility="hidden";
  }
  
  snowtimer = setInterval(snowIE_NS6, 10);
});

