// --------------------------------------------------
//		(c) SingularIT 2002
// --------------------------------------------------
/*
function browserObject() {
function testScroll() {
function CheckScrollTop(prop,temp,newValue) {
function CheckScrollLeft(prop,temp,newValue) {
function layerMoveBy( ID, x, y) {
function layerMoveTo( ID, x, y) {
function layerResizeBy( ID, w, h) {
function layerResizeTo( ID, w, h) {
function layerGetX( ID ) {
function layerGetY( ID ) {
function layerGetWidth( ID ) {
function layerGetHeight( ID ) {
function layerGetRight( ID ) {
function layerGetBottom( ID ) {
function layerGetContentWidth( ID ) {
function layerGetVisible( ID ) {
function layerGetZ( ID ) {
function layerSetZ( ID, z ) {
function layerShow( ID ) {
function layerHide( ID ) {
function layerInside( ID, x, y) {
function initResizeBug() {
function nsResizeBug() {
function initBrowserComp() {
function preloadImages() {
function swapImage(imgSrc,imgID,layerID,layerMother,layerGrandmother) {
function layerCreate( ID, x, y, z, str) {
function layerHTMLWrite( ID, str) {
function layerSetClip( ID, x, y, w, h) {
*/
// constructs a browser information object
//--------------------------------
function browserObject() {
//--------------------------------
	var the_nav = navigator;
	var the_ver = the_nav.appVersion; 
	var the_ua	= the_nav.userAgent.toLowerCase();

	this.DOM	= (document.getElementById && document.createElement);

	this.navigator	= navigator;
	this.appVersion = the_nav.appVersion; 
	this.userAgent	= the_nav.userAgent.toLowerCase();
	
	this.ie		= (the_ua.indexOf('msie') != -1);
	this.ie4	= (document.all && !document.getElementById);
	this.ie4up	= (document.all) ? true : false;
	this.ie5	= (the_ua.indexOf('msie 5.0') != -1)
	this.ie55	= (the_ua.indexOf('msie 5.5') != -1)
	this.ie6	= (the_ua.indexOf('msie 6.0') != -1)

	this.ns		= (the_nav.appName.indexOf('Netscape') != -1);
	this.ns4	= (this.ns && the_ver.indexOf("4.") != -1);
	this.ns6	= (this.ns && document.getElementById);
	this.ns60 = (this.ns6 && navigator.userAgent.indexOf('6.0')!=-1);
	this.ns61 = (this.ns6 && navigator.userAgent.indexOf('6.1')!=-1);

	this.moz	= (the_ua.indexOf("mozilla")!=-1 && the_ua.indexOf("gecko")!=-1 && the_ua.indexOf("netscape6")==-1);
	this.opera	= (the_ua.indexOf('opera') != -1);
	if(this.opera && typeof this.DOM == 'function') this.DOM = true;
	if(this.opera && this.DOM) this.ns6 = true;

	this.mac	= (the_nav.platform.toLowerCase().indexOf('mac') != -1);
	this.xwin	= (the_ver.indexOf("X11")>0);
	this.win32	= (the_nav.platform.toLowerCase().indexOf('win32') != -1);

	this.compatible = ((this.DOM || this.ie4up || this.ns4) && !this.opera);
	this.width = null; //to be set later after document is loaded;
	this.height = null; //to be set later after document is loaded;
	return this;
}
var browser = new browserObject();
//--------------------------------
function initBrowserComp() { // initiate properties after loading
//--------------------------------
// custom for Museumgasten: browser.compatible check removed. Now in index.html
	if (browser.ie) {
		browser.width = document.body.clientWidth;
		browser.height = document.body.clientHeight;
		Array.prototype.push = ArrayPush;
		Array.prototype.pop = ArrayPop;
	}
	else if (browser.ns4) {
		browser.width = window.innerWidth;//-20;
		browser.height = window.innerHeight;//-20;
		initResizeBug(); // init resize bug in NS
	}
	else if (browser.ns6) {
		browser.width = window.innerWidth;
		browser.height = window.innerHeight;
	}
	else if(browser.opera) {
			browser.width = window.innerWidth;
			browser.height = window.innerHeight;
	}
	return (true);
}

var FREELAYERS = new Array();

//--------------------------------
// LAYER REFERENCE CREATOR
//--------------------------------
function layerGetRef( ID ) {
//--------------------------------
	if (browser.ns6) return document.getElementById(ID);
	else if (browser.ns4) return document.layers[ID];
	else return document.all[ID];
}
//--------------------------------
function layerMoveTo( ID, x, y) {
//--------------------------------
	var thisID = layerGetRef(ID);
	if (browser.ns4) thisID.moveTo(x, y);
	else {
		thisID.style.left = x;
		thisID.style.top = y;
	}
}
//--------------------------------
function layerResizeTo( ID, w, h) {
//--------------------------------
	var thisID = layerGetRef(ID);
	if (browser.ns4) {
		thisID.resizeTo(w,h);
		thisID.document.width = w;
		thisID.document.height = h;
	}
	else {
		thisID.style.width = w+"px";
		thisID.style.height = h+"px";
	}
}
//--------------------------------
function layerShow( ID ) {
//--------------------------------
	var thisID = layerGetRef(ID);
	if (browser.ns4) thisID.visibility = "show";
	else thisID.style.visibility = "visible";
}
//--------------------------------
function layerHide( ID ) {
//--------------------------------
	var thisID = layerGetRef(ID);
	if (browser.ns4) thisID.visibility = "hide";
	else thisID.style.visibility = "hidden";
}
//--------------------------------
// LAYER PROPERTIES
//--------------------------------
function layerGetX( ID ) {
//--------------------------------
	var thisID = layerGetRef(ID);
	if(browser.ns4) return thisID.left;
	else return parseInt(thisID.style.left);
}
//--------------------------------
function layerGetY( ID ) {
//--------------------------------
	var thisID = layerGetRef(ID);
	if(browser.ns4) return thisID.top;
	else return parseInt(thisID.style.top);
}
//--------------------------------
function layerGetWidth( ID ) {
//--------------------------------
	var thisID = layerGetRef(ID);
	if (browser.ns4) return(thisID.document.width);
	else if (browser.ns6) {
		var the_width = 0;
		if(isNaN(parseInt(thisID.style.width)) || (parseInt(thisID.style.width)==0)) {
			the_width = (parseInt(document.defaultView.getComputedStyle(thisID,null).getPropertyValue('width')));
		}
		else the_width = (parseInt(thisID.style.width));
		if(the_width == 0) {
			var tw = thisID.style.width;
			thisID.style.width = "auto";
			the_width = thisID.offsetWidth;
			thisID.style.width = tw;
		}
		return the_width;
	}
	else return(thisID.offsetWidth);
}
//--------------------------------
function layerGetHeight( ID ) {
//--------------------------------
	var thisID = layerGetRef(ID);
	if (browser.ns4) return(thisID.document.height);
	else if (browser.ns6) {
		var the_height = 0;
		if(isNaN(parseInt(thisID.style.height)) || (parseInt(thisID.style.height)==0)) {
			the_height = (parseInt(document.defaultView.getComputedStyle(thisID,null).getPropertyValue('height')));
		}
		else the_height = (parseInt(thisID.style.height));
		if(the_height == 0) {
			var th = thisID.style.height;
			thisID.style.height = "auto";
			the_height = thisID.offsetHeight;
			thisID.style.height = th;
		}
		return the_height;
	}
	else return(thisID.offsetHeight);
}
//--------------------------------
function layerGetRight( ID ) {
//--------------------------------
	return (layerGetWidth(ID) + layerGetX(ID));
}
//--------------------------------
function layerGetBottom( ID ) {
//--------------------------------
	return (layerGetHeight(ID) + layerGetY(ID));
}
//--------------------------------
// NS4 RESIZE BUG FIX
//--------------------------------
function initResizeBug() {
//--------------------------------
	document.orPageWidth = innerWidth;
	document.orPageHeight = innerHeight;
	onresize = nsResizeBug;
}
//--------------------------------
function nsResizeBug() {
//--------------------------------
	if (innerWidth != document.orPageWidth || innerHeight != document.orPageHeight) location.reload();
}
//--------------------------------
// ARRAY METHODS FOR IE
//--------------------------------
function ArrayPush(the_element) {
//--------------------------------
	this[this.length] = the_element;
}
//--------------------------------
function ArrayPop(the_element) {
//--------------------------------
	var the_value = this[this.length-1];
	this.length--;
	return(the_value);
}
//--------------------------------
// IMAGE PRELOAD AND SWAP
//--------------------------------
var PRLIMG = new Array();
//--------------------------------
function preloadImages() {
//--------------------------------------------------
	for(var i=0; i<PRLNAMES.length; i++) {
		PRLIMG[i] = new Image();
		PRLIMG[i].src = 'gfx/'+PRLNAMES[i];
	}
}
//--------------------------------
function swapImage(imgSRC,imgID) {
//--------------------------------
	if (browser.ns4 && swapImage.arguments.length > 2) {
		var thisDocument = '';
		for (var i=(swapImage.arguments.length-1) ; i>=2 ; i--) {
			thisDocument += 'document.layers["'+swapImage.arguments[i]+'"].';
		}
		thisDocument += 'document.images["'+imgID+'"].src="'+imgSRC+'"';
		eval(thisDocument);
	}
	else document.images[imgID].src = imgSRC;
}
