
// Browser Checker
function browserCheck(){
	this.ver=navigator.appVersion
	this.agent=navigator.userAgent
	this.dom=document.getElementById?1:0
	this.opera6=((this.agent.indexOf("Opera 6")>-1) && this.dom)?1:0;
	this.ie5=((this.ver.indexOf("MSIE 5")>-1) && this.dom && !this.opera6)?1:0;
	this.ie6r=((this.ver.indexOf("MSIE 6")>-1) && this.dom && (document.compatMode == "BackCompat"))?1:0;
	this.ie6s=((this.ver.indexOf("MSIE 6")>-1) && this.dom && (document.compatMode == "CSS1Compat"))?1:0;
	this.ie4=(document.all && !this.dom)?1:0;
	this.ie=(this.ie4||this.ie5||this.ie6r||this.ie6s)?1:0;
	this.mac=(this.agent.indexOf("Mac")>-1)?1:0;
	this.ns6=(this.dom && (parseInt(this.ver) >= 5)) ?1:0;
	this.ns4=(document.layers && !this.dom)?1:0;
	this.ns=(this.ns4||this.ns6)?1:0;
	this.bw5=(this.ie5||this.ie6r)?1:0;
	this.bw6=(this.ie6s||this.ns6||this.opera6)?1:0;
	this.bw=(this.ie6r||this.ie6s||this.ie5||this.ns6||this.opera6)?1:0;
	return this;
}

// Global Variables
var ENMarginTop, ENMarginBottom, ENTop;
var ENDivName, ENObject, ENCurrentY;

window.onload = function ENInit(id, mt, mb, tp)
{
	initRollovers() // rollover.js

	id = 'pagetop'; // DIVid
	mt = 205; // margin-top
	mb = 192; // margin-bottom
	tp = 88; // position-top
	bw=new browserCheck; 
	if (bw.bw) {
		ENDivName = bw.bw5 ? document.all(id) : bw.bw6 ? document.getElementById(id) : 0;
		ENObject = ENDivName.style;
		ENObject.position = 'absolute';
		ENMarginTop = mt ? mt : 0; 
		winheight = getWindowHeight(); 
		ENMarginTop = winheight - ENMarginTop; // [06.06.1]
		ENMarginBottom = mb ? mb : 0; 
		ENCurrentY = ENTop = tp ? tp : ENDivName.offsetTop;
		ENSmoothMove();
	}
}

function ENSmoothMove()
{
	var winh = bw.ie6s ? document.documentElement.clientHeight : (bw.ns6||bw.opera6) ? innerHeight : bw.bw5 ? document.body.clientHeight : 0 ;
	var yt = bw.ie6s ? document.documentElement.scrollTop : bw.bw5 ? document.body.scrollTop : (bw.ns6||bw.opera6) ? window.pageYOffset : 0;
	var divh = ENDivName.offsetHeight;

	if (winh >= ENMarginTop + divh + ENMarginBottom) {
		yt = Math.max(yt + ENMarginTop, ENTop);
	} else {

		
		var yt1 = Math.max(yt + ENMarginTop, ENTop);
		var f1 = (yt1 > ENCurrentY) ? 1 : 0;

		
		var yt2 = yt - (divh + ENMarginBottom - winh);
		yt2 = Math.max(yt2, ENTop);
		var f2 = (yt2 < ENCurrentY) ? 1 : 0;

		
		if (f1 && f2) yt = ENCurrentY;
		else yt = f2 ? Math.max(yt1, yt2) : Math.min(yt1, yt2);

	}

	if (yt != ENCurrentY) {
		
		var vy = (yt - ENCurrentY) * 0.5;
		if (Math.abs(vy) < 1) vy = (vy > 0) ? 1 : (vy < 0) ? -1 : 0;
		ENCurrentY += Math.round(vy);
		ENObject.top = ENCurrentY + 'px';
	}
	setTimeout('ENSmoothMove()', 10);
}

