var aktiv = 0;
var max_scroll = 150;

//Browser innere Fensterhöhe ermitteln
function getHeight() {
	var height = document.body.clientHeight;
	return height;
}

//Inhaltshöhe ermitteln
function getHH() {
	ih = getHeight() - 326;
	//Abstand Scrollbuttons setzen
	document.getElementById("scroll_space").style.height = ih - 60;
	//alert((ih-60));
	document.getElementById("content").style.height = ih;
	/*Scrollbuttons ausblenden, wenn nicht benötigt wird*/
	/*if (GetElementHeight(document.getElementById("main")) < ih) {
		document.getElementById("scroll_up_img").style.display = 'none';
		document.getElementById("scroll_down_img").style.display = 'none';
	}*/
		
			if (GetElementHeight(document.getElementById("main")) > (ih-60)) {
				
				document.getElementById("scroll_up_img").style.display = 'inline';
				document.getElementById("scroll_down_img").style.display = 'inline';
			} else {
				document.getElementById("scroll_up_img").style.display = 'none';
				document.getElementById("scroll_down_img").style.display = 'none';
			}
			//alert(GetElementHeight(document.getElementById("main")) +'xxx'+ ih);
			//document.getElementById("content_sub_menu").style.height = '1px';
		
	return true;
}

//Runterscrollen
function go_down(){
	var top = 0;
	top = document.getElementById("main").style.top;
	ih = getHeight() - 326; //Höhe vom Content Bereich
	mm = GetElementHeight(document.getElementById("main")); //Höhe vom Inhalt gesamt
	
	max_scroll = (mm - ih) + 40; //Scrollbare höhe
	document.getElementById("content").style.height = ih;
	top = parseInt(top);
	if (Math.abs(top) < max_scroll) top = top - 5;
	document.getElementById("main").style.top = top;
}

//Raufscrollen
function go_up(){
	var top = 0;
	getHH(); //Höhe von Contentfeld ermitteln und setzen
	top = document.getElementById("main").style.top;
	top = parseInt(top);
	if (top < 0) top = top + 5;
	document.getElementById("main").style.top = top;
}

function down(){
	aktiv = window.setInterval('go_down()',20);
	document.getElementById("scroll_down_img").src = '/gif/down_over.gif';
}

function up(){
	aktiv = window.setInterval('go_up()',20);
	document.getElementById("scroll_up_img").src = '/gif/up_over.gif';
}

function stop(){
	clearInterval(aktiv);
	document.getElementById("scroll_down_img").src = '/gif/down.gif';
	document.getElementById("scroll_up_img").src = '/gif/up.gif';
}

//Element Höhe ermitteln
function GetElementHeight (elm) {
	if (!elm) {
    	return 0;
	}
	if (document.layers) {
		if (!elm.height) {
			elm.height = elm.clip.height;
		}
		return elm.height;
	} else if (typeof(elm.style && elm.style.height) == 'number') {
		return elm.style.height;
	} else if (typeof(elm.style && elm.style.height) == 'string' && !isNaN(parseInt(elm.style.height))) {
		return parseInt(elm.style.height);
	} else if (elm.offsetHeight) {
		return elm.offsetHeight;
	} else if (typeof(elm.style && elm.style.pixelHeight) == 'number') {
		return elm.style.pixelHeight;
	} else if (elm.clientHeight) {
		return elm.clientHeight;
	}
	return 0;
}

//window.onresize = getHH;