	/////////////////////////////////////////////////////////
	//// Snowcode by MarkW
	/////////////////////////////////////////////////////////
	var sf = new Array();
	var mypage;
	var numberofflakes;
	var dumpedflakes;
	var mytick;
	var e;
	var e2;
	var x;
	var y;
	var height;
	var width;
	var background;
	var fallspeed;
	var wind;
	var winddefault;
	var obj2;
	var floorthreshold;
	var floorthresholdmax;
	var floorheight;
	var direction;
	var fallspeedmodifier;
	var canvaswidth;

	function flake(x,y,width,height,background,fallspeed,id,direction)
	{
		this.x						= x;
		this.y						= y;
		this.width					= width;
		this.height					= height;
		this.background				= background;
		this.fallspeed				= fallspeed;
		this.direction				= direction;
		var myid					= 'flake' + id;
		this.obj					= document.getElementById(myid);
		this.obj.style.background	= background;
		this.obj.style.top			= y;
		this.obj.style.left			= x;
		this.obj.style.width		= width + 'px';
		this.obj.style.height		= height + 'px';
		this.obj.style.position		= 'absolute';
		this.obj.style.display		= 'block';
	}

	function initialisesnowflakes(innumflakes,infloorheight,flakewidth,flakeheight,incanvaswidth)
	{
		numberofflakes = innumflakes;
		dumpedflakes = 0;
		fallspeedmodifier = 0;

		canvaswidth = incanvaswidth;

		floorheight = infloorheight;
		floorthresholdmax = 500; // Amount to drop before floor rises
		floorthreshold = floorthresholdmax;

		winddefault = 4;
		wind = winddefault; // Higher the strong the variance
		mypage = document.getElementById('wrapper');
		for (a=0;a<numberofflakes;a++)
		{
			e = document.createElement('div');
			e.setAttribute('id','flake' + a);
			mypage.appendChild(e);

			x = Math.floor(Math.random()*incanvaswidth);
			y = Math.floor(Math.random()*infloorheight);
			direction = Math.floor(Math.random()*4);
			width = flakewidth;
			height = flakeheight;
			background = "transparent url(images/spr_flake.gif) 0 0 no-repeat";
			fallspeed = (Math.floor(Math.random()*6)) + 1;

			sf[a] = new flake(x,y,width,height,background,fallspeed,a,direction);

		}

		mytick = setTimeout('tick()',0);
	}

	function tick()
	{
		clearTimeout(mytick);
		for (a=0;a<numberofflakes;a++)
		{
			sf[a].obj.style.background = background;
			switch (sf[a].direction)
			{
				case 1:
					sf[a].x += Math.floor(Math.random()*wind);
					break;
				case 2:
					sf[a].x -= Math.floor(Math.random()*wind);
					break;
			}
			if (sf[a].x < 0)
			{
				sf[a].x = canvaswidth;
			}
			if (sf[a].x > canvaswidth)
			{
				sf[a].x = 0;
			}
			if (sf[a].y < 0)
			{
				 sf[a].y = canvaswidth - 20;
			}
			sf[a].y += (sf[a].fallspeed + fallspeedmodifier);
			if (sf[a].y > floorheight)
			{
				// Dump a snowflake on the ground
				/*floorthreshold--;
				if (floorthreshold < 1)
				{
					floorthreshold = floorthresholdmax;
					floorheight--;
					if (floorheight < 480)
					{
						floorheight = 480;
					}
				}
				dumpedflakes ++;
				var ss = 'dumpedflake' + dumpedflakes;
				e2 = document.createElement('div');
				e2.setAttribute('id',ss);
				mypage.appendChild(e2);
				obj2 = document.getElementById(ss);
				obj2.style.display = 'block';
				obj2.style.position = 'absolute';
				obj2.style.width = '8px';
				obj2.style.height = '8px';
				obj2.style.top = sf[a].y + 'px';
				obj2.style.left = sf[a].x + 'px';
				obj2.style.background = 'transparent url(/images/spr_flake.gif) 0 0 no-repeat';
				*/
				sf[a].y = 0;
			}
			sf[a].obj.style.top		= sf[a].y + 'px';
			sf[a].obj.style.left	= sf[a].x + 'px';
		}
		mytick = setTimeout('tick()',50);
	}

