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";

zoomFiles = new Array();

if(window.navigator.systemLanguage && !window.navigator.language) {
	function hoverIE() {
    	if (document.getElementById("Navigation")) {
			var LI = document.getElementById("Navigation").firstChild;
			do {
				if (sucheUL(LI.firstChild)) {
					LI.onmouseover=einblenden; LI.onmouseout=ausblenden;
				}
				LI = LI.nextSibling;
			}
			while(LI);
		}
	}

	function sucheUL(UL) {
		do {
			if(UL) UL = UL.nextSibling;
			if(UL && UL.nodeName == "UL") return UL;
		}
		while(UL);
		return false;
	}

	function sucheA(A) {
/*		do {
			if(A) A = A.nextSibling;
			if(A && A.nodeName == "A") return A;
		}
		while(A);
		return false;
*/
		return A.getElementsByTagName("A")[0];
	}
	
	var BGOrgi = "";
	var ColorOrgi = "#000000";
	var FWOrgi = "normal";
	function einblenden() {
		var UL = sucheUL(this.firstChild);
		var A = sucheA(this);
		UL.style.display = "block";
		BGOrgi = this.style.backgroundColor;
		ColorOrgi = A.style.color;
		FWOrgi = A.style.fontWeight;
		this.style.backgroundColor = "#EAEEEF";
		A.style.color = "#004885";
		A.style.fontWeight = "bold";
/*		alert(A);*/
	}
	
	function ausblenden() {
		sucheUL(this.firstChild).style.display = "none";
		this.style.backgroundColor = BGOrgi;
		sucheA(this).style.color = ColorOrgi;
		sucheA(this).style.fontWeight = FWOrgi;
	}
	window.onload=hoverIE;
}

/****************************************
***	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;
}

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();

/****************************************
***	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;
}

/****************************************
*** 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: 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;
}

/****************************************
***	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 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: openPopUp
*** PopUps
****************************************/
var tmpDivPopUp = "";
var tmpDivPopUpInhalt = "";
var tmpPopUpBreite = 620;
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";
		tmpPopUpBreite = breite;
	}
	else
	{
		tmpDivPopUp.style.width = "620px";
		tmpDivPopUp.style.maxWidth = "600px";
		tmpDivPopUp.style.marginLeft = "-310px";
	}
	
	if ( ShowOverlay( true ) )
	{
		ladeAnimation( true );
	}

	tmpDivPopUpInhalt.src = seite;
}

function showPopUp ()
{
	if ( ShowOverlay( true ) )
	{
		ladeAnimation( false );
		tmpDivPopUp.style.display = "block";
	}
	
	tmpDivPopUpInhaltRahmen = parent.frames["popup_frame"].document.getElementById("popup_content_rahmen");
	if ( tmpPopUpBreite )
	{
		tmpDivPopUpInhaltRahmen.style.width = tmpPopUpBreite-20 + "px";
	}
	else
	{
		tmpDivPopUpInhaltRahmen.style.width = "600px";
	}
	
	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+70) + "px";
}

function closePopUp ()
{
	ShowOverlay( false );
	
	tmpDivPopUp.style.display = "none";
	tmpDivPopUp.style.height = "";
	tmpDivPopUpInhalt.src = "";
	tmpDivPopUpInhalt.height = 1;
}

function ieFake ( fake )
{
	if ( ( fake ) && ( fake.blur) )
	{
		fake.blur();
	}
}

var tmpTxt;
function statAnzeige ( mtxt ) 
{
	tmpTxt = txt;
	setTimeout("window.status = tmpTxt;",0);
	return true;
}

var wi = null;
function info ( datei, x, y, scbar ) 
{
	tmpScroll = "yes";
	if (scbar == 0) tmpScroll = "no";
	if (!x) var tmpX = 520;
	else var tmpX = x+20;
	if (!y) var tmpY = 350;
	else var tmpY = y+30;
	if (wi != null) if (!wi.closed) wi.close();
	wi = window.open(datei,'Infofenster','left=' + ((screen.availWidth/2)-tmpX/2) + ',top=' + ((screen.availHeight/2)-tmpY/2) + ',marginwidth=0 marginheight=0,leftmargin=0,topmargin=0,scrollbars=' + tmpScroll + ',status=no,width=' + tmpX + ',height=' + tmpY + ',resizable=no');
	if (wi.opener==null) wi.opener=self;
	return;
}

function feldGr ( feld, inhalt, max ) 
{
	who = feld;
	if (inhalt >= max) 
	{
		alert('Achtung, maximale Feldgröße erreicht!');
		who.value = who.value.substr(0,max-1);
	}
}

function popup_drucken ()
{
	/* IE */
	if ( document.frames )
	{
		document.frames.popup_frame.focus();
		document.frames.popup_frame.drucken();
	}
	/*  FF */
	else
	{
		popup_frame.drucken();
	}
}

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;
	var tmpFeld = document.suche.stichwort;
	var tmpAction = document.suche.action;
	for( i=0; i < tmpFeld.value.length; i++)
	{
		if ( tmpFeld.value.substr(i,1) != ' ' )
		{
			iCheck = false;
			i = tmpFeld.value.length;
		}
	}
	if ( ( tmpFeld.value == '' ) || ( iCheck ) )
	{
		alert( "Bitte geben Sie ein Stichwort ein,\nnach dem gesucht werden soll." );
		return false;
	}
	tmpAction = tmpAction.replace(/#suchwort#/g, tmpFeld.value);
	document.suche.action = tmpAction;
	return;
}

function loginCheck() 
{
	iCheck = true;
	var tmp1 = eval("document.loginform.loginname");
	var tmp2 = eval("document.loginform.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 Kundenkennung und das zugehörige Passwort an!");
		return false;
	}
}

function inhaltCheck ( field, txt, url ) 
{
	iCheck = true;

	for(i=0;i<field.value.length;i++) 
	{
		if (field.value.substr(i,1) != ' ') 
		{
			iCheck = false;
			i = field.value.length;
		}
	}
	if (iCheck) 
	{
		alert(txt);
		//return false;
	}
	else 
	{
		document.location.href = url;
	}
}

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";
	}
}