if(!window.Wabmo)
	Wabmo=new Object();
Wabmo.layerNo=0; 
Wabmo.createElem = function(htmlStr)
{	var elem = null;
 	if(document.layers) 
	{	elem=new Layer(2000); 
		elem.document.open(); 
		elem.document.write(htmlStr); 
		elem.document.close(); 
		elem.innerHTML = htmlStr;	}
	else 
	if(document.all) 
	{	var xName = "xLayer" + Wabmo.layerNo++; 
		var txt = "<DIV ID='" + xName 
			+ "' STYLE=\"position:absolute;" 
			+ "visibility:hidden\">" 
			+ htmlStr 
			+ "</DIV>"; 
			document.body.insertAdjacentHTML("BeforeEnd",txt); 
		elem = document.all[xName]; 	} 
	else 
	if (document.getElementById)
	{	var xName="xLayer" + Wabmo.layerNo++;
		var txt = ""
			+ "position:absolute;"
			+ "visibility:hidden";
		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;}
Wabmo.Layer = function(newLayer) 
{	if(!newLayer)
		return;
	if(typeof newLayer == "string")
		this.elem = Wabmo.createElem(newLayer);
	else
		this.elem=newLayer;
	if(document.layers)
	{	this.images=this.elem.document.images; 
		this.style = this.elem; 	} 
	else 
	{	this.images  = document.images; 
		this.style   = this.elem.style; 	} } 
var ns4 = (navigator.appName.indexOf("Netscape") != -1 && !document.getElementById);
Wabmo.Layer.prototype.moveTo = function(x,y)
{	this.style.left = x+"px";
	this.style.top = y+"px";}
if(ns4)
	Wabmo.Layer.prototype.moveTo = function(x,y) { this.elem.moveTo(x,y); }
Wabmo.Layer.prototype.show		= function() 	{ this.style.visibility = "visible"; } 
Wabmo.Layer.prototype.hide		= function() 	{ this.style.visibility = "hidden"; } 
if(ns4)
{	Wabmo.Layer.prototype.show		= function() 	{ this.style.visibility = "show"; }
	Wabmo.Layer.prototype.hide 		= function() 	{ this.style.visibility = "hide"; }
}
if(document.all)
{	Wabmo.Layer.prototype.setOpacity = function(pc)
	{	if(this.style.filter=="")
			this.style.filter="alpha(opacity=100);";
		this.elem.filters.alpha.opacity=pc;	}}
else
	Wabmo.Layer.prototype.setOpacity = function(pc) {return 0;}
Wabmo.Browser = new Object();
if(navigator.appName.indexOf("Netscape") != -1)
{	Wabmo.Browser.getCanvasWidth	= function() {return innerWidth;}
	Wabmo.Browser.getCanvasHeight	= function() {return innerHeight;}
	Wabmo.Browser.getMinX		= function() {return(pageXOffset);}
	Wabmo.Browser.getMinY		= function() {return(pageYOffset);}
	Wabmo.Browser.getMaxX		= function() {return(pageXOffset+innerWidth);}
	Wabmo.Browser.getMaxY		= function() {return(pageYOffset+innerHeight);}
}
else 	if(document.all)
{	Wabmo.Browser.getCanvasWidth	= function() {return document.body.clientWidth;}
	Wabmo.Browser.getCanvasHeight	= function() {return document.body.clientHeight;}
	Wabmo.Browser.getMinX		= function() {return(document.body.scrollLeft);}
	Wabmo.Browser.getMinY		= function() {return(document.body.scrollTop);}
	Wabmo.Browser.getMaxX		= function() {
		return(document.body.scrollLeft
			+document.body.clientWidth);	}
	Wabmo.Browser.getMaxY		= function() {
			return(document.body.scrollTop
				+document.body.clientHeight);	}} 
Wabmo.Halloween = new Object();
Wabmo.Halloween.Ghosts = new Array();
Wabmo.Halloween.start = function()
{	if(Wabmo.Halloween.theTimer == null)
	{	Wabmo.Halloween.theTimer = setTimeout("Wabmo.Halloween.animateAll()", 40);	}}
Wabmo.Halloween.animateAll = function()
{	Wabmo.Halloween.theTimer = setTimeout("Wabmo.Halloween.animateAll()", 40);
	var sp = Wabmo.Halloween.Ghosts;
	var i;
	for(i=0 ; i<sp.length ; i++)
	{	sp[i].animate();	}}
Wabmo.AddGhost = function(img)
{	var myGhost = null;
	var htmlStr = "<IMG SRC='"+img+"'>";
	myGhost = new Wabmo.Layer(htmlStr);
	myGhost.op = 0;
	myGhost.x = Math.random()*Wabmo.Browser.getMaxX();
	myGhost.y = Math.random()*Wabmo.Browser.getMaxY();
	myGhost.dx = 0;
	myGhost.dy = 0;
	myGhost.w = 30;
	myGhost.h = 30;
	myGhost.targetX = Math.random()*Wabmo.Browser.getMaxX();
	myGhost.targetY = Math.random()*Wabmo.Browser.getMaxY();
	myGhost.state = "off"
	myGhost.animate = Wabmo.animateGhosts;
	myGhost.hide();
	myGhost.setOpacity(this.op);
	myGhost.moveTo(myGhost.x,myGhost.y);
	Wabmo.Halloween.Ghosts[Wabmo.Halloween.Ghosts.length] = myGhost;
	Wabmo.Halloween.start();}
Wabmo.animateGhosts = function()
{	if(this.state == "off")
	{	if(Math.random() > .99)
		{
			this.state="up";
			this.show();		}	}
	else if(this.state == "on")
	{	if(Math.random() > .98)
			this.state="down";	}
	else if(this.state == "up")
	{	this.op += 2;
		this.setOpacity(this.op);
		if(this.op==100)
			this.state = "on";	}
	else if(this.state == "down")
	{	this.op -= 2;
		if(this.op==0)
		{	this.hide();
			this.state = "off";		}
		else
			this.setOpacity(this.op);	}
	m = this;
	var X = (this.targetX - m.x);
	var Y = (this.targetY - m.y);
	var len = Math.sqrt(X*X+Y*Y);
	if(len < 1) len = 1;
	var dx = 20 * (X/len);
	var dy = 20 * (Y/len);
	var ddx = (dx - this.dx)/10;
	var ddy = (dy - this.dy)/10;
	this.dx += ddx;
	this.dy += ddy;
	m.x += this.dx;
	m.y += this.dy;
	m.moveTo(m.x, m.y);
	if(Math.random() >.95 )
	{	this.targetX = Math.random()*(Wabmo.Browser.getCanvasWidth()-150);
		this.targetY = Math.random()*(Wabmo.Browser.getCanvasHeight()+Wabmo.Browser.getMinY()-150);	}}

