function Cscreendata(){
}
Cscreendata.prototype.go=function(){ 
	this.body= document.getElementsByTagName("body")[0];
	this.nav=document.getElementById('nav');
	this.site=document.getElementById('site');
	this.main=document.getElementById('main');
	this.content=document.getElementById('content');
	this.bottom=document.getElementById('bottom');
	this.top=document.getElementById('top');
	var BrowserName = navigator.appName;
	if(BrowserName == "Microsoft Internet Explorer") this.IE=true; else  this.IE= false;
	this.aktiv = window.setInterval("screendata.scrolltest()", 2000);
	this.scrolltest();
}

Cscreendata.prototype.scrolltest=function(){ 

	var t=0;
	if(this.IE){
		t=document.documentElement.scrollTop
	}else{
		t=window.pageYOffset;
	}
	t+=10;
//	this.nav.style.top=t+'px';
	var mh=this.main.offsetHeight; //grösse fenster
	var nh=this.nav.offsetHeight;
	var ch=this.content.offsetHeight;
	var th=this.top.offsetHeight;
	
	var vk=  th-t;
	if(vk<0) vk=0;
	
	
//	this.nav.innerHTML= vk;
	
	if(nh>mh-vk){
	/**	
		this.nav.innerHTML=
		"ScrollTop "+t+"<br>"
		;
		*/
		t=0;
//		vk;
	}
	

	var uh=this.bottom.offsetTop-(t+nh);
	if(uh<0) t+=uh;
	
	
	if(t<th) t=th+10;
	this.nav.style.top=t+'px';

//	alert(this.nav.offsetHeight);
	var sl = this.site.offsetLeft;
	if(this.autohor){
		var left= (this.main.offsetWidth -this.site.offsetWidth)/2;
		if(left<0)left=0;
		this.site.style.left=left+"px";
	}else if(sl<0){
		this.site.style.left="0px";
		this.site.style.marginLeft="0px";
		this.autohor=true;
	}

}

screendata=new Cscreendata();
function screendata_go(){
	screendata.go();
}

window.addEventListener?window.addEventListener('load',screendata_go,false):window.attachEvent('onload',screendata_go);

