// Floater Script
/* Browser Detection Script */
browserVars = new browserVarsObj();
if(!browserVars.type.getById) document.captureEvents(Event.MOUSEMOVE)
document.onmousemove = new Function('e', 'browserVars.updateMouse(e)');

function browserDetect()
{
	this.getById = document.getElementById?true:false;
	this.layers = document.layers?true:false;
	this.ns4 = ((this.layers) && (!this.getById));
	this.ns6 = ((navigator.userAgent.indexOf('Netscape6') != -1) && (this.getById));
	this.moz = ((navigator.appName.indexOf('Netscape') != -1) && (this.getById) && (!this.ns6));
	this.ie  = ((!this.layers) && (this.getById) && (!(this.ns6 || this.moz)));
	this.opera = window.opera?true:false;
}


function browserVarsObj()
{
	this.updateMouse = browserVarsObjUpdateMouse;
	this.updateVars = browserVarsObjUpdateVars;
	
	this.mouseX = 0;
	this.mouseY = 0;
	
	this.type = new browserDetect();
	this.width = 0;
	this.height = 0
	this.screenWidth = screen.width;
	this.screenHeight = screen.height;
	this.scrollWidth = 0;
	this.scrollHeight = 0;
	this.scrollLeft = 0;
	this.scrollTop = 0;
	this.updateVars();
}

function browserVarsObjUpdateMouse(e)
{
	if(!this.type.ie)
	{
		this.mouseX = e.pageX;
		this.mouseY = e.pageY;
	}
	else
	{
		this.mouseX = window.event.clientX + this.scrollLeft;
		this.mouseY = window.event.clientY + this.scrollTop;
	}
}

function browserVarsObjUpdateVars()
{
	if(!this.type.getById)
	{
		this.width = window.innerWidth;
		this.height = window.innerHeight;
		this.scrollWidth = document.width;
		this.scrollHeight = document.height;
		this.scrollLeft = window.pageXOffset;
		this.scrollTop = window.pageYOffset;
		if(this.width < this.scrollWidth) this.width -= 16
		if(this.height < this.scrollHeight) this.height -= 16
	}
	else
	{
		if((!(this.type.ns6 || this.type.moz)) && (document.body))
		{
			this.width = document.body.offsetWidth;
			this.height = document.body.offsetHeight;
			this.scrollWidth = document.body.scrollWidth;
			this.scrollHeight = document.body.scrollHeight;
			this.scrollLeft = document.body.scrollLeft;
			this.scrollTop = document.body.scrollTop;
		}
		
		if((this.type.ns6 || this.type.moz) && (document.body))
		{
			this.width = window.innerWidth;
			this.height = window.innerHeight;
			this.scrollWidth = document.body.scrollWidth;
			this.scrollHeight = document.body.scrollHeight;
			this.scrollLeft = window.pageXOffset;
			this.scrollTop = window.pageYOffset;
		}
	}
}

// foater detection
function initFloaters()
{
	if(!document.getElementById) return;
	allFloaters = new Array();

	floater1 = new floater('floater1Div', 5, -1, -1, 30, 30);
}



function floater(div, position, width, height, hMargin, vMargin)
{
	this.div = document.getElementById(div);
	this.div.style.visibility = 'visible';
	if(width == -1) width = this.div.offsetWidth;
	if(height == -1) height = this.div.offsetHeight;
	this.position = position;
	this.width = width;
	this.height = height;
	this.hMargin = hMargin;
	this.vMargin = vMargin;

	this.doFloat = doFloat;
	this.idNo = allFloaters.length;
	allFloaters[allFloaters.length] = this;
	this.floatTimer = setInterval("allFloaters[" + this.idNo + "].doFloat()", 50);
}



function doFloat()
{
	browserVars.updateVars();

	var w = browserVars.width - this.width;
	var h = browserVars.height - this.height;
	var xPos = 0;
	var yPos = 0;
	
	if(this.position == 1){ xPos = this.hMargin; yPos = this.vMargin; }
	if(this.position == 2){ xPos = w/2; yPos = this.vMargin; }
	if(this.position == 3){ xPos = w - this.hMargin; yPos = this.vMargin; }
	if(this.position == 4){ xPos = w - this.hMargin; yPos = h/2; }
	if(this.position == 5){ xPos = w - this.hMargin; yPos = h - this.vMargin; }
	if(this.position == 6){ xPos = w/2; yPos = h - this.vMargin; }
	if(this.position == 7){ xPos = this.hMargin; yPos = h - this.vMargin; }
	if(this.position == 8){ xPos = this.hMargin; yPos = h/2; }
	if(this.position == 9){ xPos = w/2; yPos = h/2; }

	if(isNaN(xPos) || isNaN(yPos)) return;

	this.div.style.left = browserVars.scrollLeft + xPos;
	this.div.style.top = browserVars.scrollTop + yPos;
}

