// 
// 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
//	 
// Adapted by zhangxun2001@hotmail.com 
// 2006/08/16 adjust dcw
// 2005/11 add floatBar()
// 2005/01 
// 

var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
var floatbar_Switch = true;

floatBar(); // must put before set rcol style

var rcol = d.getElementById("rightcol");
var col2 = d.getElementById("pagecell1");

rcol.style.height = col2.scrollHeight;
rcol.style.width = "178px";
	
/* screen.width > 1024 ? "17%" : screen.width > 900 ? "179px" : "23.3%"; */
	
function floatBar()
{
	var pnv = JSFX_FloatDiv("pageNav", 580 ,55); // old 580 useful ?
	if (pnv != null) 
		pnv.floatIt();
}


function floatbarOpen() {
	floatbar_Switch = true;
}

function floatbarClose() {
	floatbar_Switch = false;
}
	
function JSFX_FloatDiv(id, sx, sy)
{
	var val = sy; // temp holder
	var el = d.getElementById ? d.getElementById(id) : d.all ? d.all[id] : d.layers[id];
	var px = d.layers ? "" : "px"; // pixel
    var dcw = d.body.clientWidth ;
	
	if (el == null) return null;
	
	window[id + "_obj"] = el;
	if (d.layers) el.style = el;
	
    dcw -= dcw < 800 ? 36 : dcw < 1000 ? 44 : 50; // 800 ~ 1000 -> 44
	// old: dcw < 800 ? 36 : dcw < 1000 ? 46 : 50;
	el.cx = el.sx = dcw - el.clientWidth ? dcw - el.clientWidth : 0; // adjust start pos	
	el.cy = el.sy = sy; // start pos
	
	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 : 
			d.documentElement && d.documentElement.clientWidth ? 
			d.documentElement.clientWidth : d.body.clientWidth;
		pY = ns ? pageYOffset : d.documentElement && d.documentElement.scrollTop ? 
			d.documentElement.scrollTop : d.body.scrollTop;
		
		if (this.sy < 0) 
			pY += ns ? innerHeight : d.documentElement && d.documentElement.clientHeight ? 
				d.documentElement.clientHeight : d.body.clientHeight;
				
		this.cx += (pX + this.sx - this.cx)/8;
		
	    val += (pY + this.sy - val)/8;
		if (val > 300) // ?
	      this.cy += (pY + this.sy - this.cy)/8 - 27; // ?
 		else
		   this.cy = this.sy ;
		     		   
		this.sP(this.cx, this.cy);
		
		if (!floatbar_Switch) return;
		setTimeout(this.id + "_obj.floatIt()", 30);
	}
	
	return el;
} 
	