/***
*	Browser detection Objekt
*/
var client = new Browser();


/***
*	bestimmt Browser und OS
*/
function Browser() {
	this.opera		=	false;
	this.mie		=	false;
	this.net6		=	false;
	this.net4		=	false;
	this.mozilla	=	false;
	this.icab		=	false;
	this.version	=	0;
	this.win		=	false;
	this.mac		=	false;
	
	// Browser und die Version bestimmen
	if (navigator.userAgent.indexOf("iCab") != -1) {
		this.icab = true;
		this.version = navigator.userAgent.substr(navigator.userAgent.indexOf("iCab") +5 ,3);
	} else if (navigator.userAgent.indexOf("Opera") != -1) {
		this.opera = true;
		this.version = navigator.userAgent.substr(navigator.userAgent.indexOf("Opera") +6 ,3);
	} else if (navigator.appName.indexOf("Netscape") != -1) {
		if (navigator.userAgent.indexOf("Gecko") != -1) {
			if (navigator.userAgent.indexOf("Netscape6") != -1) {
				this.net6 = true;
				this.version = navigator.userAgent.substr(navigator.userAgent.indexOf("Netscape6") +10 ,3);
			} else {
				this.mozilla = true;
				this.version = navigator.userAgent.substr(navigator.userAgent.indexOf("rv:") +3 ,5);
			}
		} else {
			this.net4 = true;
			this.version = navigator.appVersion.substr(0,3);
		}
	} else if (navigator.userAgent.indexOf("MSIE") != -1) {
		this.mie = true;
		this.version = navigator.userAgent.substr(navigator.userAgent.indexOf("MSIE") +5 ,3);
	} 
	
	// Bestimmt OS
	if (navigator.platform.indexOf("Mac") != -1) {
		this.mac = true;
	} else if (navigator.platform.indexOf("Win") != -1) {
		this.win = true;
	}
}


/***
*	Image-Wechsler Objekt
*/
function imageSwapObj(imgNameStr, srcPathPrefixStr) {

	// Settings
	this.srcPathPrefix = srcPathPrefixStr;
	this.srcPathSuffix = ".gif";
	this.overStr = "_2";
	this.outStr = "_1";
	this.imgNameSuffix = "Img";

	// Bild Name
	this.imgName = imgNameStr + this.imgNameSuffix;

	// Over Bild
	this.overImg = new Image();
	this.overImg.src = this.srcPathPrefix + imgNameStr + this.overStr + this.srcPathSuffix;
	
	// Out Bild
	this.outImg = new Image();
	this.outImg.src = this.srcPathPrefix + imgNameStr + this.outStr + this.srcPathSuffix;
	
	// Over FX
	this.over = function() {
		window.document.images[this.imgName].src = this.overImg.src;
	}
	
	// Out FX
	this.out = function() {
		window.document.images[this.imgName].src = this.outImg.src;
	}
}


/***
*	Layout Hoehe Objekt
*/
function layoutHightObj(layoutSpaceStr) {

	this.layoutSpace = layoutSpaceStr;

	// Hoehe des sichtbaren Beriechs des Browser Fensters
	if (client.mie) {
		this.tdHight = document.body.clientHeight;
	} else {
		this.tdHight = window.innerHeight;
	}
	
	this.spacer = function() {
		str = '<img id="layoutSpacer" src="bilder/spacer.gif" width="1" height="' + (this.tdHight - this.layoutSpace) + '">';
		return str;
	}
	
}


/***
*	laedte Seite neu
*/
function resetLayout() {
	location.reload();
}


/***
*	Layout Hoehe Objekt
*/
function layoutHightHalbObj(layoutSpaceStr) {

	this.layoutSpace = layoutSpaceStr;

	// Hoehe des sichtbaren Beriechs des Browser Fensters
	if (client.mie) {
		this.tdHight = document.body.clientHeight;
	} else {
		this.tdHight = window.innerHeight;
	}
	
	this.spacer = function() {
		str = '<img id="layoutSpacer" src="bilder/spacer.gif" width="1" height="' + ((this.tdHight - this.layoutSpace) / 2) + '">';
		return str;
	}
	
}


/***
*	Oeffnet Browser Fenster mit PicViewer
*/
function openPicViewer(imgID,typ) {

	var URL = 'picviewer.php?imgPath=' + imgID;
	
	if (document.layers) {
		picViewer = window.open(URL,'PicViewer','height=450,width=450,locationbar=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,top=' + (screen.height-420)/2 + ',left=' + (screen.width-420)/2 + ',status=yes');
	} else {
		picViewer = window.open(URL,'PicViewer','height=450,width=450,locationbar=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,top=' + (screen.height-420)/2 + ',left=' + (screen.width-420)/2 + ',status=yes');
	}

}


/***
*	Oeffnet Browser Fenster
*/
function openWin(URL,name,width,height) {

	if (client.mie) {
		topPos = (document.body.clientHeight - height) / 2;
	} else {
		topPos = (window.innerHeight - height) / 2;
	}
	
	if (client.mie) {
		leftPos = (document.body.clientWidth - width) / 2;
	} else {
		leftPos = (window.innerWidth - width) / 2;
	}

    if (document.layers) {
		window.open(URL,name,'height=' + height + ',width=' + width + ',locationbar=no,menubar=no,toolbar=no,scrollbars=no,resizable=no,top=' + topPos  + ',left=' + leftPos + ',status=yes');
	} else {
		window.open(URL,name,'height=' + height + ',width=' + width + ',locationbar=no,menubar=no,toolbar=no,scrollbars=no,resizable=no,top=' + topPos  + ',left=' + leftPos + ',status=yes');
	}
}


/***
*	CSS Netscape 4 Windows Fix
*/
function initCSSFile(urlsuffix) {
	if ((client.net4) && (client.win)) {
		str = urlsuffix + 'css/netscape4win.css';
	} else if ((client.net4) && (client.mac)) {
		str = urlsuffix + 'css/netscape4mac.css';
	}else {
		str = urlsuffix + 'css/default.css';
	}
	document.write('<link rel="stylesheet" href="' + str + '" type="text/css">\n');
}
