// JavaScript Document
var no = 20;
var speed = 40;
var snowflake = "/images/snow.gif"; 

var dx, xp, yp; 
var am, stx, sty; 
var i;
var doc_width = 800;
var doc_height = 250; 

dx = new Array(); 
xp = new Array(); 
yp = new Array(); 
am = new Array(); 
stx = new Array(); 
sty = new Array(); 

function snow() { 
	for (i = 0; i < no; ++ 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]; 
		$("#dot" + i).css({
			"top" : yp[i] + "px",
			"left" : xp[i] + am[i]*Math.sin(dx[i]) + "px"
		}); 
	}
	window.setTimeout(snow, speed); 
} 

$(document).ready(function() {
	doc_width = $(document.body).width();
	doc_height = 250; 
	for (i = 0; i < no; ++ i) { 
		dx[i] = 0; 
		xp[i] = Math.random()*(doc_width-50); 
		yp[i] = Math.random()*doc_height; 
		am[i] = Math.random()*20; 
		stx[i] = 0.02 + Math.random()/10; 
		sty[i] = 0.7 + Math.random(); 
		$(document.body).append("<div id=\"dot"+ i +"\" style=\"POSITION: absolute; Z-INDEX: "+ i +"; VISIBILITY: visible; TOP: 15px; LEFT: 15px;\"><img src=\"" + snowflake + "\" border=\"0\"></div>")
	} 
	snow(); 
});
