function flake(key, image) {
	
	// Variables
	this.key = key
	this.image = image
	this.xPos = 0;
	this.yPos = 0
	this.xMod = 0
	this.xAmp = 0
	this.yGrav = 0
	this.mod = 0
	this.layerName = ("flake"+key+"flake")
	
	this.show=show
	this.animate=animate
	this.reset=reset
	
	// Constructor
	this.reset()
	this.show()
		
	// Methods
	function show() {
		
		if (MS || DOM) {
			document.write("<div id='" + this.layerName + "' style='POSITION: absolute; Z-INDEX: " + this.key + "; VISIBILITY: visible; TOP: " + this.yPos + "px; LEFT: " + this.xPos + "px;'><img src='" + this.image + "' border='0'></div>");
		} else {
			document.write("<layer name='"+ this.layerName +"' left='" + this.xPos + "' top='" + this.yPos + "' visibility='show'><img src='" + this.image + "' border='0'></layer>");
		}
		
	}

	function animate(xSpeed, ySpeed) {
		this.mod += this.xMod;
		this.xPos += xSpeed;
		this.yPos += (this.yGrav+ySpeed);
		
		//+window.document.body.scrollTop
		//+window.pageYOffset
				
		if (MS) {
			document.all[this.layerName].style.pixelLeft = this.xPos + this.xAmp*Math.sin(this.mod);
			document.all[this.layerName].style.pixelTop = this.yPos;
			
		} else if (DOM) {
			document.getElementById(this.layerName).style.left = this.xPos + this.xAmp*Math.sin(this.mod);
			document.getElementById(this.layerName).style.top = this.yPos;

		} else {
			document.layers[this.layerName].left = this.xPos + this.xAmp*Math.sin(this.mod);
			document.layers[this.layerName].top = this.yPos;
		}
				
	}

	function reset() {

		if (MS) {
			doc_width = document.body.clientWidth;
			doc_height = document.body.clientHeight;
			this.xPos = ((doc_width)/2)-Math.random() * (doc_width-50)
			this.yPos = (0-Math.random() * (doc_height-50)) //+ window.document.body.scrollTop
		} else if (DOM) {
			doc_width = self.innerWidth;
			doc_height = self.innerHeight;
			this.xPos = ((doc_width)/2)-Math.random() * (doc_width-50)
			this.yPos = (0-Math.random() * (doc_height-50)) //+ window.pageYOffset
		} else {
			doc_width = self.innerWidth;
			doc_height = self.innerHeight;
			this.xPos = Math.random() * (doc_width-50)
			this.yPos = (Math.random() * (doc_height-50)) //+ window.pageYOffset
		}
		
		this.xMod = 0.02 + Math.random()/10;
		this.xAmp = Math.random()*20;
		this.yGrav = 0.7 + Math.random()
	}
			
}

function snow(number, xWind, ySpeed, imageArray) {
	
	// Variables
	this.number = number
	this.xSpeed = 0
	this.ySpeed = ySpeed
	
	this.xWind = xWind
	this.mod = 0
	this.xMod = 0.1
	this.xAmp = this.xWind
	
	this.imageArray = imageArray.split(",")
	
	this.flakeArray = new Array()

	this.show=show
	this.animate=animate	
	
	// Constructor
	this.show()
	this.animate()
	
		
	// Methods
	function show() {
		for(var i = 0; i < this.number; i++) {
			var j = Math.round(Math.random()*(this.imageArray.length-1))
			this.flakeArray[i] = new flake(i, this.imageArray[j]);		
		}
	}
	
	function animate() {
		
		if (MS) {
			doc_width = document.body.clientWidth;
			doc_height = document.body.clientHeight;
			doc_scrollY = window.document.body.scrollTop;		
		} else {
			doc_width = self.innerWidth;
			doc_height = self.innerHeight;
			doc_scrollY = window.pageYOffset;
		}
		
		this.mod += this.xMod;
		this.xSpeed = this.xAmp*Math.sin(this.mod)
		//self.status=this.xSpeed
		if (this.xSpeed < 0) {
			this.xSpeed = 1
			this.xAmp = Math.random()*this.xWind
		}
				
		for(var i = 0; i < this.number; i++) {
			this.flakeArray[i].animate(this.xSpeed, this.ySpeed);
			if (this.flakeArray[i].xPos > doc_width-40) this.flakeArray[i].reset();
			if (this.flakeArray[i].yPos > doc_height-25+doc_scrollY) this.flakeArray[i].reset();
		}
		setTimeout("snow.animate()", 20);
	}
}

var DHTML = 0, DOM = 0, MS = 0, NS = 0, OP = 0;

if (window.opera) {
     OP = 1;
 }
 if(document.getElementById) {
   DHTML = 1;
   DOM = 1;
 }
 if(document.all && !OP) {
   DHTML = 1;
   MS = 1;
 }
if(document.layers && !OP) {
   DHTML = 1;
   NS = 1;
 }
