/* JavaScript Library */

var ns4 = (document.layers)?1:0;
var dom = (document.getElementById && !document.all);
var ie4 = (document.all)?1:0;
var opr = navigator.userAgent.indexOf("Opera");
var moz = navigator.appName=="Netscape" && navigator.appCodeName=="Mozilla" && !document.all;
var mac = navigator.userAgent.indexOf("Mac")!= -1;

window.status = "REITZ-Modellbau Schloßberg"; // writes Javascript default message in browser status bar

// calculate the height of a layer
function getDivsHeight() {
	var iDivsHeight = 0;
	for(var i=0; i < arguments.length; i++) {
		if (document.getElementById(arguments[i]))
			iDivsHeight += document.getElementById(arguments[i]).offsetHeight;
	}
	return iDivsHeight;
}

// set the height of the back main layer in order to move the footer
function setDivContentMinHeight() {
	var oDivcontent, iWinInnerHeight, tmpHeight;
	var mozCorrection = moz ? -1 : 0;
	oDivcontent = document.getElementById(arguments[0]); //assumes first passed object as name for the content area layer
	oStopperDiv = document.getElementById(arguments[1]); // retrieve stopper div object
	
	iWinInnerHeight = document.body.clientHeight; // store window height of the inner browser area temporarily

	if (arguments.length == 4) {
		tmpHeight = getDivsHeight(arguments[2], arguments[3]);
	}
	else if (arguments.length == 3) {
		tmpHeight = getDivsHeight(arguments[2]);
	} // calculate the height of the page elements except the content area; using the getDivsHeight function
	
	if(oStopperDiv) {
		if (iWinInnerHeight > (tmpHeight + oStopperDiv.offsetTop + oStopperDiv.offsetHeight)) {
			oDivcontent.style.height = iWinInnerHeight - tmpHeight + mozCorrection;
		} else {
			oDivcontent.style.height = oStopperDiv.offsetTop + oStopperDiv.offsetHeight + mozCorrection;
		}
	}
		//if there is more space on the page than the header and footer height, than the main layer is set to a new height
}

// Wrapper function to apply the changes to the footer / main layers if DOM browser detected
// loadEvent triggers a bugfix for MSIE 5.0 and footer bar placement, "true" is for function calls in onLoad events,
// "false" is default and for onResize events

function init(loadEvent) {
	if (!ns4) {
		setDivContentMinHeight('main', 'stopper', 'header', 'footer');
		footero=document.getElementById('footer');
		if (footero)
			footero.style.visibility='visible';
	}
	if (loadEvent && ie4 && !ns4 && ((navigator.appVersion.indexOf("MSIE 5.0")!= -1) || (mac))) {
		window.resizeBy(1,1);
		window.resizeBy(-1,-1);
	}
}

// popup window opener service function for standard content pages
function showPopUp(zielFrame, parameter) {
        var newWindow = window.open("about:blank", zielFrame, parameter);
        newWindow.focus();    
}


