// JavaScript Document
var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;

function JSFX_FloatDiv(id, sx, sy)
{
	/*
	 * this needs to be set for each page
	 */
	var topDistance = 160
	
	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){
		var displayedHeight = document.documentElement.clientHeight			// net displayed height of page
		var elHeight = (ns)? this.clientHeight	: this.scrollHeight			// net height of the element
		var pageHeight = document.body.clientHeight;						// total height of complete page
		//				y + "     :     " + displayedHeight + 	"     :     " + elHeight + "     :     " + topDistance 
		//window.status = y + "     :     " +	this.scrollHeight		+	"     :     " + elHeight + "     :     " + topDistance 

		
		this.style.left=x+px;
		if(y > topDistance){
			
			verticalHeightToCheck = elHeight + y;
			//verticalHeightToCheck = ns ? (y + elHeight) : (y - elHeight);
			//window.status = verticalHeightToCheck + "     :     " + pageHeight

			if(pageHeight > verticalHeightToCheck){
				y = y - topDistance
				this.style.top = y+px;
			}else{
				/*
				//window.status = this.style.top;
				elementCurrentY = this.style.top
				elementCurrentY = parseInt(elementCurrentY.substr(0,elementCurrentY.length-2)) - 5
				window.status = this.style.bottom
				*/
				//y = y - topDistance
				/*
				*/
				elementCurrentY = pageHeight - elHeight - topDistance
				this.style.top = elementCurrentY+px;
			}
		}else{
			this.style.top = "0"+px;
		}
		test = y+px
		//window.status = "top " + " : " + this.style.top //+ " : "  + test
		//window.status = document.body.clientHeight
	};

	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;
		
		//window.status = pY + " : " + this.sy + " : " + this.cy + " : " + document.body.clientHeight;
		//pY -= document.documentElement.scrollTop	//test

		var scr_w = document.body.clientWidth;						// net displayed width of page
		var scr_h = document.body.clientHeight;						// total height of complete page
		var displayedHeight = document.documentElement.clientHeight	// net displayed height of page
		var elHeight = this.clientHeight							// net height of the element
		if(pY>120){
			//this.cy = 0;
		}else{
			//this.cy = -this.cy;
		}

		if(scr_w < 800){
			this.cx = 0;
		}else{
			//this.cx = (scr_w -800)/2 ;
		}
		//window.status = scr_h//for height
		//window.status = this.cy;
		//window.status = "elHeight " + " : " + elHeight
		//this.style.bottom
		this.sP(this.cx, this.cy);
		setTimeout(this.id + "_obj.floatIt()", 20);
	}
	return el;
}

/*
 * Notes 
 * sP is the element
 */