
var speed_content = 5; // Scroll speed für content
var time_content = 25; // rep.-time für content

var speed_popUp = 84; // Scroll speed für popUp
var time_popUp = 25; // rep.-time für popUp

// Browser detection
var dom = document.getElementById ? true:false;
var nn4 = document.layers ? true:false;
var ie4 = document.all ? true:false;

var contentT; // Content layer Y;
var contentH; // Content height
var contentClipH; // Content clip height
var popT; // pop layer Y;
var popH; // pop height
var PopClipH; // pop clip height

var timer = setTimeout("",0);
var scrollContentTrue = false;
var scrollPopUpTrue = false;

var ScrH = 0;
var ScrW = 0;
var ScrHoff;
var ScrWoff;


function up(){
	clearTimeout(timer);
	// Resetting variables
	clickUp = false;
	clickDown = false;
	clickDrag = false;
	clickAbove = false;
	clickBelow = false;
	return true;
}

// Reads content layer top
function getT(){
	if(ie4)
		contentT = document.all.content.style.pixelTop;
	else if(nn4)
		contentT = document.contentClip.document.content.top;
	else if(dom)
		contentT = parseInt(document.getElementById("content").style.top);
}

function getPopT(){
	if(ie4)
		popT = document.all.pop_up.style.pixelTop;
	else if(nn4)
		popT = document.contentClip.document.pop_up.top;
	else if(dom)
		popT = parseInt(document.getElementById("pop_up").style.top);
}
// Moves the layer
function moveTo(){
	if(ie4){
		document.all.content.style.top = contentT;
		}
	else if(nn4){
		document.contentClip.document.content.top = contentT;
			}
	else if(dom){
		document.getElementById("content").style.top = contentT + "px";
	}
}

function stepTo(){
	if(ie4){
		document.all.pop_up.style.top = popT;
		}
	else if(nn4){
		document.contentClip.document.pop_up.top = popT;
			}
	else if(dom){
		document.getElementById("pop_up").style.top = popT + "px";
	}
}

// Scrolls up
function scrollUp(){
	getT();
	if (contentT < 0)
	{
		if(scrollContentTrue == true)
		{
			contentT = contentT + speed_content;
			moveTo();
			timer = setTimeout("scrollUp()",25);
		}
	}
}

// Scrolls down
function scrollDown()
{
	getT();
 	if (contentT > (contentClipH-contentH))
	{
		if(scrollContentTrue == true)
		{
			contentT = contentT - speed_content;
			moveTo();
			timer = setTimeout("scrollDown()",25);
		}
	}
}


// Step up
function stepUp(){
	getPopT("pop_up");
	if (popT < 0)
	{
		if(scrollPopUpTrue == true)
		{
			popT = popT + speed_popUp;
			stepTo();
			timer = setTimeout("stepUp();",500);
		}
	}
}

// Step down
function stepDown()
{
	getPopT("pop_up");
 	if (popT > (PopClipH-popH))
	{
		if(scrollPopUpTrue == true)
		{
			popT = popT - speed_popUp;
			stepTo();
			timer = setTimeout("stepDown()", 500);
		}
	}
}

function mouseOff()
{
	scrollContentTrue = false;
}

function mouseDown()
{
	scrollContentTrue = true;
	scrollDown();
}


function mouseUp()
{
	scrollContentTrue = true;
	scrollUp();
}

function mousePopOff()
{
	scrollPopUpTrue = false;
}

function mousePopUp()
{
	scrollPopUpTrue = true;
	stepUp();
}

function mousePopDown()
{
	scrollPopUpTrue = true;
	stepDown();
}

// reloads page to position the layers againh
function reloadPage(){
	location.reload();
}
function test(){window.alert("test");}


// Preload
function eventLoader(){
		
	if(ie4){
		// Height of content layer and clip layer
		contentH = parseInt(document.all.content.scrollHeight);
		contentClipH = parseInt(document.all.contentClip.style.height);
		popH = parseInt(document.all.pop_up.scrollHeight);
		PopClipH = parseInt(document.all.PopUpClip.style.height);
		//offset();
	}
	else if(nn4){
		contentH = document.contentClip.document.content.clip.bottom;
		contentClipH = document.contentClip.clip.bottom;
		popH = document.PopUpClip.document.pop_up.clip.bottom;
		PopClipH = document.PopUpClip.clip.bottom;
	}
	else if(dom){
		contentH = parseInt(document.getElementById("content").offsetHeight);
		contentClipH = parseInt(document.getElementById("contentClip").offsetHeight);
		document.getElementById("content").style.top = 0 + "px";
		popH = parseInt(document.getElementById("pop_up").offsetHeight);
		PopClipH = parseInt(document.getElementById("PopUpClip").offsetHeight);
		document.getElementById("pop_up").style.top = 0 + "px";
		//20050215
		//offset();
		
	}
//}
	
	// Initializes event capturing
	if(nn4){
		document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
		window.onresize = reloadPage;
	}
	
	if(dom){
		//document.attachEvent('onresize', reloadPage);
	}
	
	if (contentH <= contentClipH)
	{
		scrollerOff();
	}
	if (popH <= PopClipH)
	{
		popscrollerOff();
	}
	
}	



function offset()
{
	if(ie4){
		
		if( document.body.offsetHeight > 624)
		{
			ScrHoff = (document.body.offsetHeight - 624) / 2; 
		}else{ScrHoff = 0;}
		
		if( document.body.offsetWidth > 906)
		{
			ScrWoff = (document.body.offsetWidth - 906) / 2;
		}else{ScrWoff = 0;}
		//alert("ie height:" +  document.body.scrollHeight + "ScrH :" + ScrHoff +"  doc bod W:" + document.body.offsetWidth + "Pixel");
		document.all.Layer_root.style.top = ScrHoff + "px";
		document.all.Layer_root.style.left = ScrWoff + "px";
	}
	if(dom && !ie4){
		if( window.innerHeight > 624)
		{
			ScrHoff = (window.innerHeight-624)/2; 
		}else{ScrHoff = 0;}
		
		if( window.innerWidth > 906)
		{
			ScrWoff = (parseInt(window.innerWidth)-906)/2;
		}else{ScrWoff = 0;}
		//alert("domoben :" + ScrH +"woff :" + ScrWoff + "li :" + ScrWoff + "Pixel");
		document.getElementById("Layer_root").style.top = ScrHoff + "px";
		document.getElementById("Layer_root").style.left =  ScrWoff + "px";
	}
	
}

function newwin0()
{
	var winw = 900;
	var winh = 605;
	var w = screen.availWidth;
	var h = screen.availHeight;
	var xset = (w - winw) / 2;
	var yset = ((h - winh) / 2)-35;
	window.open("./startseite.html", "erstes",  "width="+winw+", height="+winh+", top="+yset+", left="+xset+", 			screenX=0, screenY=0, menubar, location=yes");
}


function newwin(anfang)
{
	var scheck = navigator.userAgent;
	var re = /.*Mac.*/;
	var lo = re.test(scheck);
	var a = (navigator.plugins.length)-1;
	/*for (i=0; i<=a; i++) {
		alert(navigator.plugins[i].name);
		}*/

	if (lo == true)
	{
		window.open(anfang, "", "width=900, height=620, top=20, left=20, screenX=20, screenY=20, 						scrolling=0, menubar");
	}
	else
	{
		window.open(anfang, "", "width=900, height=620, top=20, left=20, screenX=20 ,screenY=20 ,scrolling=0, 					menubar");
	}
}

function htmlver(anfang)
{
	window.self.close();
	window.open(anfang, "", "width=900,height=620,top=20,left=20,screenX=20,screenY=20,scrolling=0,menubar");
}

function newwinhtml(anfang)
{
	window.open(anfang, "html", "width=900,height=620,top=20,left=20,screenX=20,screenY=20,scrolling=0,menubar");
}

function popup(url,titel,w,h)
{
	params = 'dependent=yes,width=' + w + ',height=' + h ;
	window.open(url,titel,params);
}

function flip(image_id,image,text_id,text_color) {
	 if (document.getElementById(text_id)){
	document.getElementById(text_id).style.color = text_color;}
	if(document.getElementById(image_id)){
	document.getElementById(image_id).src=image;}
 }

function scrollerOff()
{
	document.getElementById('up').style.zIndex=0;
	document.getElementById('down').style.zIndex=0;
}

function popscrollerOff()
{
	document.getElementById('step_up').style.zIndex=0;
	document.getElementById('step_down').style.zIndex=0;
}

 function over(){}

 function sichtbar(){
	//alert("fkt sichtbar()");
	if(ie4){
	//alert("fkt sichtbar() ie4");
		document.all.Layer_root.style.visibility = "visible";
		
		
	}
	else if(nn4){
	//alert("fkt sichtbar() nn4");
		document.Layer_root.style.visibility = "visible";
	}
	else if(dom){//alert("fkt sichtbar() dom" + document.getElementById("Layer_root").style.visibility);
		document.getElementById("Layer_root").style.visibility = "visible";
		//document.getElementById("PopUpClip").style.visibility = "visible";
		//alert("fkt sichtbar() dom" + document.getElementById("Layer_root").style.visibility);
	}
}

