/*
Floating Menu script-  Roy Whittle (http://www.javascript-fx.com/)
Script featured on/available at http://www.dynamicdrive.com/
This notice must stay intact for use
*/


function TJsfx(Name, Id)
{
	this.Name = Name;
	this.Id = Id;
	this._Body = null;
	this._Layers = document.layers;				
	this._Ns = (navigator.appName.indexOf("Netscape") != -1);
	this.Component = null;		
	this._X = 0;
	this._Y = 0;
	this._Initialized = false;				
	this._Initialize = TJsfx_Initialize;
	this._Move = TJsfx_Move;		
	this.Active = false;
	this.XOffset = 5;
	this.YOffset = 5;
	this.Anchor = -1;
	this.Delay = 10;
	this.Width = 100;
	this.InitializePosition = TJsfxInitializePosition;
	this.Show = TJsfxShow;
	this.Hide = TJsfxHide;
	this.CreateHtml = TJsfxCreateHtml;
	this.FreeHtml = TJsfxFreeHtml;
}

function TJsfx_Initialize()
{
	this._Body = (document.compatMode!="BackCompat")? document.documentElement : document.body;
	this.Component = document.getElementById ? document.getElementById(this.Id) : (document.all ? document.all[this.Id] : this._Layers[this.Id]);			
	if (this._Layers)
		this.Component.style = this.Component;		
}

function TJsfxInitializePosition()
{
	if (this.Anchor < 0)
	{
		this._X = this.XOffset;
		this._Y = this.YOffset;
	}
	else
	{
		switch (this.Anchor)
		{
			case 0: this._X = this.XOffset;
							this._Y = this.YOffset;
							break;
			case 1: this._X = (this._Ns ? window.innerWidth : this._Body.scrollLeft + this._Body.clientWidth) - this.XOffset - this.Width;		
							this._Y = this.YOffset;
							break;
			case 2: this._X = this.XOffset;
							this._Y = (this._Ns ? window.pageYOffset + window.innerHeight : this._Body.scrollTop + this._Body.clientHeight) - this.YOffset - this.Component.clientHeight;
							break;
			case 3: this._X = (this._Ns ? window.innerWidth : this._Body.scrollLeft + this._Body.clientWidth) - this.XOffset - this.Width;		
							this._Y = (this._Ns ? window.pageYOffset + window.innerHeight : this._Body.scrollTop + this._Body.clientHeight) - this.YOffset - this.Component.clientHeight;
							 break;
		}
	}
}	

function TJsfx_Move()
{
	var Delta = 1;
	var TopY = this._Ns ? window.pageYOffset : this._Body.scrollTop;
	if (this.Anchor < 0)
		this._X = this.XOffset;
	else
	{
		if (this.Anchor % 2 != 0)
			this._X = (this._Ns ? window.innerWidth : this._Body.scrollLeft + this._Body.clientWidth) - this.XOffset - this.Width;
			
		if (this.Anchor > 1)
		{
			Delta = -1;
			var TopY = (this._Ns ? window.pageYOffset + window.innerHeight : this._Body.scrollTop + this._Body.clientHeight) - this.Component.clientHeight;
		}
	}
	this._Y += (TopY + (Delta * this.YOffset) - this._Y) / 8;
	this.Component.style.left = this._X + "px";
	this.Component.style.top = this._Y + "px";
	if (this.Active)
		setTimeout(this.Name + "._Move()", this.Delay);	
}

function TJsfxShow()
{
	if (!this._Initialized)
	{
		this._Initialize();
		this._Initialized = true;
	}
	this.InitializePosition();
	this.Active = true;
	this._Move();
	this.Component.style.visibility = this._Layers ? "show" : "visible";
}

function TJsfxHide()
{
	this.Active = false;
	this.Component.style.visibility = this._Layers ? "hide" : "hidden";		
}		

function TJsfxCreateHtml()
{
	if (!this._Layers)
		document.write('<div id="' + this.Id + '" style="position:absolute;visibility:hidden;z-index:100;">');	
	document.write('<layer id="' + this.Id + '">');	
}

function TJsfxFreeHtml()
{
	document.write("</layer>");
	if (!this._Layers)
		document.write("</div>");	
}