/***
*	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;
	}
}

/***
*	Rand weg bei Links Funktion
*/
function blurLink(obj) {
	if ((client.mie) || (client.net6) || (client.mozilla)) {
		obj.blur();
	}
}


/***
*	Image-Wechsler Objekt
*/
function imageSwapObj(imgNameStr, outSrc, overSrc, clickSrc, imgGrp) {

	// Bild Name
	this.imgName = imgNameStr;

	// Bild Objekt
	this.object = window.document.images[this.imgName];
	
	// Over Bild
	this.overImg = new Image();
	this.overImg.src = overSrc;
		
	// Out Bild
	this.outImg = new Image();
	this.outImg.src = outSrc;

	// Click Bild
	if (clickSrc != '') {
		this.clickImg = new Image();
		this.clickImg.src = clickSrc;
	}
	
	// Click Bild
	this.isClicked = false;
	
	// Image Gruppe
	this.imgGrp = imgGrp;
	
	// Bild Gruppen
	if (imgGrp != '') {
		this.grpObjs = imgGrp.imgObjs;
	}
	
	// Over FX
	this.over = function() {
		if (this.isClicked == false) {
			this.object.src = this.overImg.src;
		}
	}
	
	// Out FX
	this.out = function() {
		if (this.isClicked == false) {
			this.object.src = this.outImg.src;
		}
	}
	
	// Click FX
	this.click = function() {
		if (clickSrc != '') {
			if (this.isClicked == false) {
				this.object.src = this.clickImg.src;
				this.isClicked = true;
			} else {
				this.object.src = this.overImg.src;
				this.isClicked = false;
			}
			if(this.imgGrp != '') {
				for (i = 0; i < this.grpObjs.length; i++) {
					nameStr = eval(this.grpObjs[i] + ".imgName")
					if (nameStr != this.imgName) {
						eval(this.grpObjs[i] + ".isClicked = false");
						eval(this.grpObjs[i] + ".out();");
					}
				}

			}
		}
	}
}

/***
*	Image-Wechsler Gruppe
*/
function imageSwapGrp(grpObjs) {

	if (grpObjs.indexOf(",")>-1) {
		this.imgObjs = grpObjs.split(",");
	} else {
		this.imgObjs = new Array(grpObjs);
	}
}

/***
*	Mulit Bild welchsel
*/
function imageSwapMulti(imgNameStr,outImg,images) {

	if (images.indexOf(",")>-1) {
		this.imgSrc = images.split(",");
	} else {
		this.imgSrc = new Array(images);
	}
	
	for(i = 0; i < this.imgSrc.length; i++) {
		eval("this.overImg_" + i + " = new imageSwapObj('" + imgNameStr + "' , '" + outImg + "' , '" +  this.imgSrc[i] + "' , '', '')");
	}
	
	// Over FX
	this.over = function(id) {
		eval("this.overImg_" + id + ".over();");
	}
	
	// Out FX
	this.out = function(id) {
		eval("this.overImg_" + id + ".out();");
	}
}


/***
*	ToolTips FX
*/
function toptooltips(imgNameStr,outImg,images) {

	this.swapImg = imgNameStr;

	if (images.indexOf(",")>-1) {
		this.imgSrc = images.split(",");
	} else {
		this.imgSrc = new Array(images);
	}
	
	for(i = 0; i < this.imgSrc.length; i++) {
		eval("this.overImg_" + i + " = new imageSwapObj('" + this.swapImg + "' , '" + outImg + "' , '" +  this.imgSrc[i] + "' , '', '')");
	}
	
	// Over FX
	this.over = function(id,toolImg) {
		if (document.images[toolImg].src.indexOf("_3") == -1) {
			eval("this.overImg_" + id + ".over();");
		}
	}
	
	// Out FX
	this.out = function(id) {
		eval("this.overImg_" + id + ".out();");
	}
	
	// Out FX
	this.click = function(id) {
		if (document.images[this.swapImg].src.indexOf("_2") == -1) {
			eval("this.overImg_" + id + ".over();");
		} else if (document.images[this.swapImg].src.indexOf("_2") > -1) {
			eval("this.overImg_" + id + ".out();");
		}
		
	}
}

/***
*	Fenster
*/
function initWin(name, url ,width, height, scroll, resizable, status, center) {
	
	// Name
	this.name = name;
	
	// Seite
	this.url = url;
	
	// Breite
	this.width = width;
	
	// Hoehe
	this.height = height;
	
	// Oben
	this.top = (center == 1) ? (screen.height-this.height)/2 : 0;
	
	// Links
	this.left = (center == 1) ? (screen.width-this.width)/2 : 0;
	
	// Scrollbars
	this.scroll = scroll;
	
	// Veraenderbar
	this.resizable = resizable;
	
	// Status
	this.status = status;
	
	// Zentrieren
	this.center = center;
	
	// oeffnen
	this.open = function() {
		this.win = window.open(this.url,this.name,'height=' + this.height + ',width=' + this.width + ',locationbar=no,menubar=no,toolbar=no,scrollbars=' + this.scroll + ',resizable=' + this.resizable + ',top=' + this.top + ',left=' + this.left + ',status=' + this.status);	
	}
}


/***
*	Oeffnet Browser Fenster mit PicViewer
*/
function openPicViewer(imgPath, typ, theme, lang) {

	var URL = '/picviewer.php?imgPath=' + imgPath + "&typ=" + typ + "&theme=" + theme + "&lang=" + lang;

		if (document.layers) {
			picViewer = window.open(URL,'PicViewer','height=420,width=420,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=420,width=420,locationbar=no,menubar=no,toolbar=no,scrollbars=no,resizable=yes,top=' + (screen.height-420)/2 + ',left=' + (screen.width-420)/2 + 'status=yes');
		}

}



/***
*	Gloassar Fenster
*/
function openGlossar(thema, theme, lang) {

	URL = '/glossar.php?theme=' + theme + '&keyword=' + thema + '&lang=' + lang;
	glossarWin = window.open(URL,'Gloassar','height=350,width=200,locationbar=no,menubar=no,toolbar=no,scrollbars=no,resizable=no,top=' + (screen.height-350)/2 + ',left=' + (screen.width-200)/2 + ',status=yes');

}


/***
*	Print View
*/
function printSite(URL) {
	
	printWin = window.open(URL,'PrintFunction','height=' + (screen.height - 300) + ',width=600,locationbar=no,menubar=no,toolbar=yes,scrollbars=yes,resizable=no,top=50,left=' + (screen.width-600)/2 + ',status=yes');
	
}


/***
*	Window oeffnenaus Flash
*/
function openFlaWin(URL, hoehe, breite) {
	window.open(URL,'FlashWin','height=' + hoehe + ',width=' + breite + ',locationbar=no,menubar=no,toolbar=no,scrollbars=no,resizable=no,top=' + (screen.height-hoehe)/2 + ',left=' + (screen.width-breite)/2 + ',status=no');
}