var nn=document.layers?true:false;
var n6=document.getElementById?true:false;
var ie=document.all?true:false;
if ((ie) && (n6)) n6 = false;

var sichtbar = "visible";
var unsichtbar = "hidden";

var fJS = false;
var vn = navigator.appVersion.substring(0,1);

var BrowserName = null;
var BuggyBrowsers = "ie4,IE6,ie5,ie5.5"; // Fehler bei der Darstellung der Overlay png
aryBuggyBrowsers = new Array();
aryBuggyBrowsers = BuggyBrowsers.split(",");
browser = getBrowser();

/****************************************
***	Funktion: GetXmlHttpObject
*** Fuer die Benutzung von AJAX
****************************************/

var xmlHttp;
var xmlHttp = null;

function GetXmlHttpObject() {
	var xmlHttp = null;
	try {
		// Firefox, Opera 8.0+, Safari
		xmlHttp=new XMLHttpRequest();
		if (xmlHttp.overrideMimeType) {
			xmlHttp.overrideMimeType('text/xml;charset=iso-8859-1');
		}
	}
	catch (e) {
		// Internet Explorer
		try {
			xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
		}
		catch (e) {
			xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	return xmlHttp;
}

/****************************************
***	Methode: indexOf
*** Erweiterung der Methode indexOf bei Arrays
****************************************/

if(!Array.indexOf) {
	Array.prototype.indexOf = function(el) {
    	for(var i = 0; i < this.length; i++) if(el == this[i]) return i;
	}
}

/****************************************
***	Funktion: ShowOverlay
*** Zeigt den Overlay an, je nach Browser werden die Selectboxen ausgeblendet
****************************************/

var ausblendCount = 0;
var aryAusgeblendeteSelLists = new Array();
function ShowOverlay ( anaus ) {
	if ( anaus ) {
		if ( document.getElementById("overlayBG").style.display != "block" )
		{
			getWahreHoehe();
			if ( aryBuggyBrowsers.indexOf(BrowserName) > -1 ) {
				ausblendCount = 0;
				aryAusgeblendeteSelLists = new Array();
				var selListen = document.getElementById('container').getElementsByTagName('select');
				for (var i=0; i<selListen.length; i++) {
					if ( selListen[i].style.display == "none" )
					{
						aryAusgeblendeteSelLists[ausblendCount] = selListen[i];
						ausblendCount++;
					}
					selListen[i].style.display = "none";
				}
				document.getElementById("overlayBG").style.filter = "Alpha(opacity=60, finishopacity=60, style=0)";
			}
	
			document.getElementById("overlayBG").style.height = wahreHoehe + "px";
			document.getElementById("overlayBG").style.display = "block";
		}
	}
	else {
		if ( aryBuggyBrowsers.indexOf(BrowserName) > -1 ) {
			var selListen = document.getElementById('container').document.getElementsByTagName('select');
			for (var i=0; i<selListen.length; i++) {
				check = 1;
				for ( var x=0; x<aryAusgeblendeteSelLists.length; x++ )
				{
					if ( aryAusgeblendeteSelLists[x] == selListen[i] )
					{
						check = 0;
					}
				}
				if ( check == 1 )
				{
					selListen[i].style.display = "inline";
				}
			}
		}

		document.getElementById("overlayBG").style.display = "none";
		document.getElementById("overlayBG").style.height = "100%";
	}
	return true;
}

/****************************************
***	Funktion: getBrowser
*** Identifikation des Browsers
****************************************/

function getBrowser () {
	if (document.ids) {
		BrowserName = "nc4";
	}
	else if ( document.all && !document.getElementById ) {
		BrowserName = "ie4";
	}
	else if ( window.opera && !document.createElement ) {
		BrowserName = "op5";
	}
	else if( window.opera && window.getComputedStyle ) {
		if(document.createRange) {
			BrowserName = "op8";
		}
		else if(window.navigate) {
			BrowserName = "op7.5";
		}
		else {
			BrowserName = "op7.2";
		}
	}
	else if ( window.opera && document.compatMode ) {
		BrowserName = "op7";
	}
	else if ( window.opera && document.releaseEvents ) {
		BrowserName = "op6";
	}
	else if( document.contains && !window.opera ) {
		BrowserName = "kq3";
	}
	else if(window.pkcs11&&window.XML) {
		BrowserName = "f15";
	}
	else if( window.getSelection && window.atob ) {
		BrowserName = "nn7";
	}
	else if( window.getSelection && !document.compatMode ) {
		BrowserName = "nn6";
	}
	else if( window.clipboardData && document.compatMode ) {
		BrowserName = window.XMLHttpRequest? "IE7" : "IE6";
	}
	else if( window.clipboardData ) {
		BrowserName = "ie5";
		if( !document.createDocumentFragment ) {
			BrowserName += ".5";
		}
     	if( document.doctype && !window.print ) {
			BrowserName += "m";
		}
	}
	else if( document.getElementById && !document.all ) {
		BrowserName = "op4";
	}
	else if( document.images && !document.all ) {
		BrowserName = "nn3";
	}
	else if(document.clientWidth&&!window.RegExp) {
		BrowserName = "kq2";
	}
	return BrowserName;
}

/****************************************
*** Scripte für Ladeanimation
****************************************/

var tmpDivLadeAni = "";

function ladeAnimation ( anaus )
{
	tmpDivLadeAni = document.getElementById("ladeani");
	if ( anaus )
	{
		tmpDivLadeAni.style.top = 100+document.body.scrollTop + "px";
		tmpDivLadeAni.style.display = "block";
	}
	else
	{
		tmpDivLadeAni.style.display = "none";
	}
}

/****************************************
***	Funktion: getWahreHoehe
*** Tatsächliche verfügbare Browserfensterhöhe
****************************************/

var wahreHoehe;
function getWahreHoehe ()
{
	if (window.innerHeight && window.scrollMaxY)
	{
         wahreHoehe = window.innerHeight + window.scrollMaxY;
	}
	else if (document.body.scrollHeight > document.body.offsetHeight) {
		wahreHoehe = document.body.scrollHeight;         
	}
	else {
		wahreHoehe = document.body.offsetHeight;         
	}
}

/****************************************
*** Scripte für Bildvergrößerung
****************************************/

var aktivBild = 0;
var tmpDivBildAnzeige = "";
var tmpDivBildNavi = "";
var tmpDivDiashow = "";
var tmpDivBildContainer = "";
var tmpDivBildText = "";
var goDiashow = null;
var tmpCheck = true;

function zoomBild ( id )
{
	aktivBild = id;
	tmpDivBildNavi = document.getElementById("bildnavi");
	tmpDivDiashow = document.getElementById("diashow");
	
	if ( aktivBild < 0 ) aktivBild = zoomFiles.length-1;
	if ( aktivBild > zoomFiles.length-1 ) aktivBild = 0;
	
	var tmpFile = zoomFiles[aktivBild];
	var tmpText = zoomText[aktivBild];
	
	if ( ( zoomFiles.length > 1 ) && ( tmpDivBildNavi ) )
	{
		if ( zoomFiles.length < 5 )
		{
			tmpDivDiashow.style.display = "none";
		}
		tmpDivBildNavi.style.display = "block";
	}
	
	anzeigeBild ( tmpFile, tmpText );
}

function anzeigeBild ( tmpFile, tmpText )
{
	ShowOverlay( true );
	
	if ( zoomFiles.length > 1 && tmpCheck )
	{
		for(i=0;i<zoomFiles.length;i++)
		{
			if ( tmpFile == zoomFiles[i] )
			{
				tmpCheck = false;
				zoomBild ( i );
			}
		}
	}
	
	tmpDivLadeAni = document.getElementById("ladeani");
	tmpDivLadeAni.style.top = 150+document.body.scrollTop + "px";
	tmpDivLadeAni.style.display = "block";
	
	bild = new Image ();
	bild.src = tmpFile;
	
	bild.onload = function() { anzeigeBildDiv ( tmpFile, tmpText ); };
	if ( bild.complete )
	{
		anzeigeBildDiv ( tmpFile, tmpText );
	}
}

function anzeigeBildDiv ( tmpFile, tmpText )
{
	document.images["bildxl"].alt = tmpText;
	document.images["bildxl"].height = bild.height;
	document.images["bildxl"].width = bild.width;
	
	tmpDivBildContainer = document.getElementById("bildcontainer");
	tmpDivBildAnzeige = document.getElementById("bildanzeige");
	tmpDivBildText = document.getElementById("bildtext");
	tmpDivBildContainer.style.width = bild.width;
	tmpDivBildContainer.style.backgroundImage = "url(" + tmpFile + ")";
	tmpDivBildText.innerHTML = tmpText;
	tmpDivBildAnzeige.style.top = 50+document.body.scrollTop + "px";
	tmpDivBildAnzeige.style.display = "block";
	tmpDivLadeAni.style.display = "none";
}

function diashow ()
{
	if ( goDiashow == null )
	{
		diashowStartStop.innerHTML = "stoppen"
	}
	zoomBild( aktivBild );
	aktivBild += 1;
	goDiashow = setTimeout( "diashow()", 3000 );
}

function diashowStop ()
{
	if ( goDiashow != null ) 
	{
		window.clearTimeout( goDiashow );
		diashowStartStop.innerHTML = "starten"
		goDiashow = null;
	}
}

function bildanzeigeSchliessen ()
{
	diashowStop ();
	tmpDivBildAnzeige.style.display = "none";
	if ( tmpDivBildNavi )
	{
		tmpDivBildNavi.style.display = "none";
		tmpDivDiashow.style.display = "block";
	}
	tmpCheck = true;
	ShowOverlay ( false );
}

/****************************************
***	Funktion: openPopUp
*** PopUps
****************************************/
var tmpDivPopUp = "";
var tmpDivPopUpInhalt = "";
function openPopUp ( seite, breite )
{
	//alert( seite );
	tmpDivPopUp = document.getElementById("popup");
	tmpDivPopUpInhalt = document.getElementById("popup_content");
	tmpDivPopUp.style.top = 70+document.body.scrollTop + "px";
	if ( breite )
	{
		tmpDivPopUp.style.width = breite + "px";
		tmpDivPopUp.style.maxWidth = breite-20 + "px";
		tmpDivPopUp.style.marginLeft = breite/-2 + "px";
	}
	else
	{
		tmpDivPopUp.style.width = "600px";
		tmpDivPopUp.style.maxWidth = "580px";
		tmpDivPopUp.style.marginLeft = "-300px";
	}
	
	if ( ShowOverlay( true ) )
	{
		ladeAnimation( true );
	}
	tmpDivPopUpInhalt.src = seite;
}

function showPopUp ()
{
	if ( ShowOverlay( true ) )
	{
		ladeAnimation( false );
		tmpDivPopUp.style.display = "block";
	}
	
	var tmp = document.getElementById("popup_content").contentWindow.document.body;
	if (tmp.scrollHeight > tmp.offsetHeight) {
		var hoehe = tmp.scrollHeight + 10;         
	}
	else {
		var hoehe = tmp.offsetHeight + 10;         
	}
	
	tmpDivPopUpInhalt.height = hoehe;
	tmpDivPopUp.style.height = (hoehe+51) + "px";
}

function closePopUp ()
{
	ShowOverlay( false );
	
	tmpDivPopUp.style.display = "none";
	tmpDivPopUp.style.height = "";
	tmpDivPopUpInhalt.src = "";
	tmpDivPopUpInhalt.height = 1;
}

/****************************************
*** sonstige Scripte
****************************************/

function ieFake(fake) 
{
	if ((document.all) && (fake)) fake.blur();
}

var tmpTxt;
function statAnzeige(txt) 
{
	tmpTxt = txt;
	setTimeout("window.status = tmpTxt;",0);
	return true;
}

function divEin ( div ) 
{
	var tmpDiv = document.getElementById(div);
	if ( tmpDiv )
	{
		tmpDiv.style.display = "block";
	}
}

function divAus ( div ) 
{
	var tmpDiv = document.getElementById(div);
	if ( tmpDiv )
	{
		tmpDiv.style.display = "none";
	}
}

function drucken() 
{
	if (window.print) self.print();
	if(document.all && navigator.appVersion.substring(22,23)==4) {
		self.focus();
	    var OLECMDID_PRINT = 6;
	    var OLECMDEXECOPT_DONTPROMPTUSER = 2;
	    var OLECMDEXECOPT_PROMPTUSER = 1;
	    var WebBrowser = '<OBJECT ID="WebBrowser1" WIDTH="0" HEIGHT="0" CLASSID="CLSID:8856F961-340A-11D0-A96B-00C04FD705A2"></OBJECT>';
	    document.body.insertAdjacentHTML('beforeEnd',WebBrowser);
	    WebBrowser1.ExecWB(OLECMDID_PRINT,OLECMDEXECOPT_DONTPROMPTUSER);
	    WebBrowser1.outerHTML = '';
	}
}

function checkStichwortSuche() 
{
	var iCheck = true;
	for(i=0;i<document.stichwortsuche.stichwort.value.length;i++) 
	{
		if (document.stichwortsuche.stichwort.value.substr(i,1) != ' ') 
		{
			iCheck = false;
			i = document.stichwortsuche.stichwort.value.length;
		}
	}
	if ((document.stichwortsuche.stichwort.value == '') || (iCheck)) 
	{
		alert("Bitte geben Sie ein Stichwort ein,\nnachdem gesucht werden soll.");
		return false;
	}
	return;
}

function loginCheck() 
{
	iCheck = true;
	var tmp1 = eval("document.mitglieder_login.loginname");
	var tmp2 = eval("document.mitglieder_login.loginpasswort");
	//alert(tmp1);
	for( i=0;i<tmp1.value.length;i++ )
	{
		if ( tmp1.value.substr(i,1) != ' ' )
		{
			iCheck = false;
			i = tmp1.value.length;
		}
	}
	for( i=0;i<tmp2.value.length;i++ )
	{
		if ( tmp2.value.substr(i,1) != ' ' )
		{
			iCheck = false;
			i = tmp2.value.length;
		}
	}
	if (( tmp1.value == '' ) || ( tmp2.value == '' ) || ( iCheck ))
	{
		alert("Bitte geben sie Ihren Benutzernamen und das zugehörige Passwort an!");
		return false;
	}
}
