var ns = (navigator.appName.indexOf("Netscape") != -1);
var d = document;
var px = document.layers ? "" : "px";

var lastsection = "";
var sectiontitle = "";

function getPixelsFromTop(obj){
	var objFromTop = obj.offsetTop;
	while(obj.offsetParent!=null) {
		objParent = obj.offsetParent;
		objFromTop += objParent.offsetTop;
		obj = objParent;
	}
	return objFromTop;
}

function JSFX_FloatDiv(id,endid,topMargin) {
	
	document.getElementById(id).style.position = 'absolute';
	var el=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	var elEnd=d.getElementById?d.getElementById(endid):d.all?d.all[endid]:d.layers[endid];
	
	el.style.display = "block";

	window[id + "_obj"] = el;
	if(d.layers)el.style=el;
	el.cx = el.sx = 0;
	el.cy = el.sy = 0;
	
	el.sP=function(x,y) {
		this.style.left=x+px;
		this.style.top=y+px;
	};

	el.flt=function() {
		var scrollX, scrollY, pageX, pageY;
		var imageY = 120;
		var imageOffsetX = 65;
		var pageWidth = 955;
		scrollX = (this.sx >= 0) ? 0 : ns ? innerWidth : 
			document.documentElement && document.documentElement.clientWidth ? 
			document.documentElement.clientWidth : document.body.clientWidth;
		scrollY = ns ? pageYOffset : document.documentElement && document.documentElement.scrollTop ? 
			document.documentElement.scrollTop : document.body.scrollTop;
		pageX = ns ? innerWidth : document.documentElement && document.documentElement.clientWidth ? 
			document.documentElement.clientWidth : document.body.clientWidth;
		pageY = ns ? innerHeight : document.documentElement && document.documentElement.clientHeight ? 
			document.documentElement.clientHeight : document.body.clientHeight;
			
		
		var offsetX = (pageX-pageWidth)/2;
		if( offsetX < 0 ) offsetX = 0; 
			
		var bottomMargin = getPixelsFromTop(elEnd)-(imageY+4);
		
		this.cx += scrollX + offsetX + imageOffsetX - this.cx;
		this.cy += (scrollY + pageY - imageY - this.cy)/8;
		
		if(this.cy<topMargin) this.cy=topMargin;
		if( this.cy>bottomMargin) this.cy=bottomMargin;
		
		this.sP(this.cx, this.cy);
		setTimeout(this.id + "_obj.flt()", 20);
	}

	return el;

}

function openprintable(pagename) 
{
	var url = pagename+".php?action=print";
	var style = "width=750,height=600,menubar=no,status=no,titlebar=no,toolbar=yes,scrollbars=yes";
	window.open(url,"printable",style);
}

function emailthispage(pagename,pagetitle) 
{
	var url = "emailthispage.php?url="+pagename+"&page="+pagetitle;
	var style = "width=375,height=500,menubar=no,status=no,titlebar=no,toolbar=no,scrollbars=yes";
	window.open(url,"emailthispage",style);
}

function highlightsection(id)
{
	if( lastsection.length ) {
		var elOld=d.getElementById?d.getElementById(lastsection):d.all?d.all[lastsection]:d.layers[lastsection];
		if( elOld ) elOld.innerHTML = sectiontitle;
	}
	
	var elNew=d.getElementById?d.getElementById(id):d.all?d.all[id]:d.layers[id];
	if( elNew ) {
		sectiontitle = elNew.innerHTML;
		elNew.innerHTML = "<font color=\"#000000\">"+sectiontitle+"</font>";
	}
	
	lastsection = id;
}

