jQuery.fn.snow = function(options){
	var owner = jQuery(this);
	var options = jQuery.extend({
		'image_dir': '/js/images/',
		'buffer': 40,
		'objects': [{
			'image': "snowflake1.png",
			'width': 20, 'height': 21,
			'left': 88, 'top': 10,
			'amlitude': 20, 'rate': 0.001, 'phase': 1
		},
		{
			'image': "snowflake2.png",
			'width': 24, 'height': 24,
			'left': 162, 'top': 30,
			'amlitude': 30, 'rate': 0.001, 'phase': 2
		},
		{
			'image': "snowflake3.png",
			'width': 27, 'height': 27,
			'left': 24, 'top': 41,
			'amlitude': 20, 'rate': 0.001, 'phase': 3
		},
		{
			'image': "snowflake4.png",
			'width': 41, 'height': 40,
			'left': 92, 'top': 59,
			'amlitude': 30, 'rate': 0.001, 'phase': 4
		},
		{
			'image': "snowflake5.png",
			'width': 33, 'height': 34,
			'left': 209, 'top': 43,
			'amlitude': 20, 'rate': 0.001, 'phase': 5
		},
		{
			'image': "snowflake1.png",
			'width': 20, 'height': 21,
			'left': 188, 'top': -20,
			'amlitude': 30, 'rate': 0.002, 'phase': 6
		},
		{
			'image': "snowflake5.png",
			'width': 33, 'height': 34,
			'left': 9, 'top': -43,
			'amlitude': 20, 'rate': 0.001, 'phase': 5
		}
		
	]}, options);

	owner.css({'position': 'relative', 'overflow': 'hidden'});
	for(var snowflake in options.objects){
		owner.append("<div class='snowflake' style='"+
			"position: absolute; "+
			"background-image: url("+ options.image_dir + options.objects[snowflake].image +"); "+
			"width: "+options.objects[snowflake].width+"px; "+
			"height: "+options.objects[snowflake].height+"px; "+
			"left: "+options.objects[snowflake].left+"px; "+
			"top: "+options.objects[snowflake].top+"px;"+
			"'></div>"
		);
	}

	setInterval(function (){
		var top = 0;
		var left = 0;
		var dateObj = new Date();
		var sec = dateObj.getTime();
		var height = parseInt(owner.css("height"));
		var children = owner.children(".snowflake");
		children.each(function(index){
			var child = children.eq(index);
			top = parseInt(child.css("top"));
			left = options.objects[index].left;
			if(top > height){
				top = -options.buffer;
			}
			child.css({
				"top": top + 1,
				"left": left + Math.sin(options.objects[index].rate * sec + options.objects[index].phase) * options.objects[index].amlitude
			});
		});
	}, 40);
}
