// unique scrolling viewport for at least IE,NS >= 4, th 2001-05-11
// updated 2002-07-02 bki
// modified for civ 2004-01-08 mb

function BrowserCheck()
{
	var browser = navigator.appName;
	var os = navigator.appVersion;
	if (browser == "Netscape") this.browser = "ns"
	else if (browser == "Microsoft Internet Explorer") this.browser = "ie";
	else this.browser = browser;

	if (os.indexOf("Win") != -1) this.os = "win"
	if (os.indexOf("Mac") != -1) this.os = "mac"
	else this.os = os;

	this.version = parseInt(navigator.appVersion)
	this.win = (this.os=="win")
	this.ns = (this.browser== "ns" && this.version<5)
	this.gk = (this.browser== "ns" && this.version>=5)
	this.ie = (this.browser== "ie" && this.version>=4)
}

is = new BrowserCheck();

var containerHeight = 300
var contentHeight = 0

var speed = (this.win)? 8:2

var time = 0
var pxsuffix = ""


function init() {

		if (is.ns) { //document.layers
		   
    		    content = document.containerDiv.document.contentDiv
            	content.xpos = content.left
				content.ypos = content.top
				contentHeight = content.document.height
	
				if (contentHeight > containerHeight) {
					document.layers['ContentUp'].visibility = "show"
					document.layers['ContentDown'].visibility = "show"
				}

        }
        if (is.ie) { //document.all

                content = contentDiv.style
                content.xpos = parseInt(content.pixelLeft)
                content.ypos = parseInt(content.pixelTop)
				contentHeight = document.all.contentStopper.offsetTop

				//parseInt, weil (lt. DOM2) in IE5pc und NS6 px angefuehrt wird
				if (is.mac) x_modifier = 1;
				else x_modifier = 2;
				
				ContentUp.style.left = parseInt(ContentUp.style.left) + x_modifier + "px"
				ContentDown.style.left = parseInt(ContentDown.style.left) + x_modifier + "px"
				ContentUp.style.top = parseInt(ContentUp.style.top) + 5 + "px"
				ContentDown.style.top = parseInt(ContentDown.style.top) + 5 + "px"
				if (contentHeight > containerHeight) {
					ContentUp.style.visibility = "visible"
					ContentDown.style.visibility = "visible"
				}

        }
        if (is.gk) { //document.getElementById

			pxsuffix="px"

			content = document.getElementById('contentDiv').style
            content.xpos = parseInt(content.left) || 0
            content.ypos = parseInt(content.top) || 0
			contentHeight = parseInt(getStyle('contentDiv','height'))

			if (contentHeight > containerHeight) {
				document.getElementById('ContentUp').style.visibility = "visible"
				document.getElementById('ContentDown').style.visibility = "visible"
			}

		}
		//self.focus()
}

function getStyle(el,styleProp){	
	var x = document.getElementById(el);	
	if (document.defaultView) var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
	else if (x.currentStyle) var y = eval('x.currentStyle.' + styleProp);
	return y;
}


function move(obj,x,y) {
    obj.xpos = parseInt(obj.xpos) + parseInt(x);
    obj.ypos = parseInt(obj.ypos) + parseInt(y);
    obj.left = obj.xpos + pxsuffix;
    obj.top = obj.ypos + pxsuffix;
}

function DoContentUp() {
	if (content.ypos < 0)	{
		move(content,0,speed);
		time = setTimeout('DoContentUp()',10);
	}
}

function DoContentDown() {
	if ((contentHeight-containerHeight+content.ypos) > 0)	{
		move(content,0,-speed);
		time = setTimeout('DoContentDown()',10);
	}
}

function top() {
   content.ypos = 0;
   content.top = 0 + pxsuffix;
}

function DoStop() {
	if (time) clearTimeout(time);
}

function reload() {
	if (is.ns) window.location.href = window.location.href;
}

