

	 /**********************************************************
     * You may use this code for free on any web page provided that 
     * these comment lines and the following credit remain in the code.
     * Floating Div from http://www.javascript-fx.com
     ********************************************************/
	 
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;

var container=d.getElementById?d.getElementById(containerId):d.all?d.all[containerId]:d.layers[containerId];
var topContainer=d.getElementById?d.getElementById(topContainerId):d.all?d.all[topContainerId]:d.layers[topContainerId];

var containerX = findLeftPos(container);
var containerY = findTopPos(container);

var topContainerX = findLeftPos(topContainer);
var topContainerY = findTopPos(topContainer);

var y1 = parseInt(topContainerY + topContainer.offsetHeight + 100);
var y2 = parseInt(container.offsetHeight + containerY);
var fdiv=d.getElementById?d.getElementById(floatingDivId):d.all?d.all[floatingDivId]:d.layers[floatingDivId];

function FloatDiv()
{
    if (fdiv) {
        if (fdiv.style.display != 'none') {
            if (y1 >= y2) {
                //Hide the floating div, as the page is not 'long' enough to require the floating link        
                fdiv.style.display = 'none';
            }
        }

        JSFX_FloatDiv(floatingDivId, floatingDivXoffset, floatingDivYoffset).floatIt();

    }
}

function JSFX_FloatDiv(id, sx, sy)
{
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	var px = document.layers ? "" : "px";	
	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
	el.cx = el.sx = sx;el.cy = el.sy = sy;	
	el.sP=function(x,y){this.style.left=x+px;this.style.top=y+px;};

	el.floatIt=function()
	{
		var pX, pY;
		pX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
		document.documentElement && document.documentElement.clientWidth ? 
		document.documentElement.clientWidth : document.body.clientWidth;
		pY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
		document.documentElement.scrollTop : document.body.scrollTop;
		if(this.sy<0) 
		pY += ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
		document.documentElement.clientHeight : document.body.clientHeight;
		this.cx += (pX + this.sx - this.cx)/8;this.cy += (pY + this.sy - this.cy)/8;
		
		//Modification of original script starts here:
		var height = ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
		document.documentElement.clientHeight : document.body.clientHeight;
		
		//Align the scrolling link to the bottom of the page
		this.cy = height - this.sy + pY;					
		
		//Contain the link within the specified bounded area
		if(this.cx!=(containerX + this.sx))
			this.cx=(containerX + this.sx);
			
		//Min Y-value
		if(this.cy < (topContainerY + topContainer.offsetHeight + this.sx))
		this.cy= (topContainerY + topContainer.offsetHeight + this.sx);
		
		//Max Y-value
		if(this.cy>container.offsetHeight)
		this.cy=container.offsetHeight;
		
		//Reposition the Floating Div:
		this.sP(this.cx, this.cy);		
	}
	return el;
}

//Hookup the javascript events
FloatDiv();
window.onresize=FloatDiv;
window.onscroll=FloatDiv;

//Helper Functions
function findLeftPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return curleft;
}

function findTopPos(obj) {
	var curleft = curtop = 0;
	if (obj.offsetParent) {
		curleft = obj.offsetLeft
		curtop = obj.offsetTop
		while (obj = obj.offsetParent) {
			curleft += obj.offsetLeft
			curtop += obj.offsetTop
		}
	}
	return curtop;
}
