var schnee_leftx  = 10;
var schnee_width  = 900;

if(!window.JSFX)
	JSFX=new Object();

JSFX.layerNo=0; 
/**********************************************************************************/
JSFX.createLayer = function(htmlStr, parent)
{
	var elem = null;

 	if(document.layers) 
	{
		var xName="xLayer" + JSFX.layerNo++;
		elem=new Layer(2000);
 
		elem.document.open(); 
		elem.document.write(htmlStr); 
		elem.document.close(); 
		elem.moveTo(0,0);
		elem.innerHTML = htmlStr;
	}
	else 
	if(document.all) 
	{
		var xName = "xLayer" + JSFX.layerNo++; 
		var txt = '<DIV ID="' + xName + '"'
			+ ' STYLE="position:absolute;left:0;top:0; z-index:20">' 
			+ htmlStr 
			+ '</DIV>'; 

		document.body.insertAdjacentHTML("BeforeEnd",txt); 

		elem = document.all[xName]; 
	} 
	else 
	if (document.getElementById)
	{
		var xName="xLayer" + JSFX.layerNo++;
		var txt = ""
			+ "position:absolute;left:0px;top:0px; z-index:20";

		var newRange = document.createRange();

		elem = document.createElement("DIV");
		elem.setAttribute("style",txt);
		elem.setAttribute("id", xName);

		document.body.appendChild(elem);

		newRange.setStartBefore(elem);
		strFrag = newRange.createContextualFragment(htmlStr);	
		elem.appendChild(strFrag);
	}

	return elem;
}
/**********************************************************************************/
JSFX.Layer = function(newLayer, parent) 
{
	if(!newLayer)
		return;

	if(typeof newLayer == "string")
		this.elem = JSFX.createLayer(newLayer, parent);
	else
		this.elem=newLayer;

	if(document.layers)
	{
		this.images		= this.elem.document.images; 
		this.parent		= parent;
		this.style		= this.elem;
		if(parent != null)
			this.style.visibility = "inherit";
 	} 
	else 
	{
		this.images  = document.images; 
		this.parent	 = parent;
		this.style   = this.elem.style; 
	} 
	window[this.elem.id]=this;	//save a reference to this
} 
/**********************************************************************************/
/**********************************************************************************/
/*** moveTo (x,y) ***/
JSFX.Layer.prototype.moveTo = function(x,y)
{
	this.style.left = x; //+"px";
	this.style.top = y; //+"px";
}

if(!window.JSFX)
	JSFX=new Object();

if(!JSFX.Browser)
	JSFX.Browser = new Object();

if(navigator.appName.indexOf("Netscape") != -1)
{
	JSFX.Browser.getCanvasWidth	= function() {return innerWidth;}
	JSFX.Browser.getCanvasHeight	= function() {return innerHeight;}
	JSFX.Browser.getWindowWidth 	= function() {return outerWidth;}
	JSFX.Browser.getWindowHeight	= function() {return outerHeight;}
	JSFX.Browser.getScreenWidth 	= function() {return screen.width;}
	JSFX.Browser.getScreenHeight	= function() {return screen.height;}
	JSFX.Browser.getMinX		= function() {return(pageXOffset);}
	JSFX.Browser.getMinY		= function() {return(pageYOffset);}
	JSFX.Browser.getMaxX		= function() {return(pageXOffset+innerWidth);}
	JSFX.Browser.getMaxY		= function() {return(pageYOffset+innerHeight);}

}
else 	if(document.all) 	{
	JSFX.Browser.getCanvasWidth	= function() {return document.body.clientWidth;}
	JSFX.Browser.getCanvasHeight	= function() {return document.body.clientHeight;}
	JSFX.Browser.getWindowWidth 	= function() {return document.body.clientWidth;}
	JSFX.Browser.getWindowHeight	= function() {return document.body.clientHeight;}
	JSFX.Browser.getScreenWidth	= function() {return screen.width;}
	JSFX.Browser.getScreenHeight	= function() {return screen.height;}
	JSFX.Browser.getMinX		= function() {return(document.body.scrollLeft);}
	JSFX.Browser.getMinY		= function() {return(document.body.scrollTop);}
	JSFX.Browser.getMaxX		= function() {
		return(document.body.scrollLeft
			+document.body.clientWidth);
	}
	JSFX.Browser.getMaxY		= function() {
			return(document.body.scrollTop
				+document.body.clientHeight);
	}
} 
JSFX.LayerSchnee = function(theHtml)
{
	//Call the superclass constructor
	this.superC	= JSFX.Layer;
	this.superC(theHtml);

	this.x = Math.round(schnee_leftx + Math.random() * schnee_width);
	this.y = Math.round(-10 -Math.random()*20);
	this.dx = Math.round(Math.random() * Math.random() * 2 +0);
	this.dy = Math.round(Math.random() * 1 +1);
	this.ang = 0;
	this.angStep = .2;
	this.amp = 4;
	this.state = "FALL";

	this.moveTo(this.x,this.y);
}
JSFX.LayerSchnee.prototype = new JSFX.Layer;

JSFX.LayerSchnee.prototype.animate = function()
{
	if(this.state == "OFF")
		return;

	this.x += this.dx+1;
	this.y += this.dy;
	this.ang += this.angStep;

	this.moveTo(this.x + this.amp*Math.sin(this.ang), this.y);

	if( (this.x > schnee_leftx + schnee_width )
	 || (this.x < schnee_leftx)
	 || (this.y > JSFX.Browser.getMaxY()-20)
	  )
	{
		this.x = Math.round(schnee_leftx + Math.random() * schnee_width);
		this.y = Math.round(-10 -Math.random()*20);
		this.dx = Math.round(Math.random() * Math.random() * 3 +1 );
		this.dy = Math.round(Math.random() * 2 +1);
	}
}

/*** Class AnimSchnee extends Object ***/
JSFX.AnimSchnee = function(numSprites, theImage)
{
	this.id = "JSFX_AnimSchnee_"+JSFX.AnimSchnee.count++;
	this.sprites = new Array();
	for(i=0 ; i<numSprites; i++)
	{
		this.sprites[i]=new JSFX.LayerSchnee(theImage);
	}
	window[this.id]=this;
	this.animate();
}
JSFX.AnimSchnee.count = 0;

JSFX.AnimSchnee.prototype.animate = function()
{
	setTimeout("window."+this.id+".animate()",50);

	for(i=0 ; i<this.sprites.length ; i++)
		this.sprites[i].animate();

}
/*** END Class AnimSchnee ***/

Schnee = function(n, theImage)
{
// deaktiviert, wieder im Herbst / Winter aktivieren

//	objSchnee = new JSFX.AnimSchnee(n, "<font color=white><IMG SRC='http://xy-zimmer.de/img/"+theImage+"'></font>");
//	return objSchnee;

//	objSchnee = new JSFX.AnimSchnee(24, "<font color=white size=+1>.</font>");
//	return objSchnee;
}

