
// Funktion zum Wechsel zwischen den verschiedenen Texten:
function Anzeige( strNaviDiv, Nummer ) {
	if ( strNaviDiv == "Bildbrowser_Navi" ) {
		var RegExpHover = /_hover\.gif/;
		var RegExpNormal = /\.gif/;
		var RegExpBackground = /(255.*){3}/;
		var Container = document.getElementById( "flashcontent1" );
		var AlleBilder = Container.getElementsByTagName( "div" );
		var Inhalt = document.getElementById( "Bildbrowser_Pic" + Nummer );
		var AlleInhalte = new Array();
		for ( x=0; x <= AlleBilder.length - 1; x++ ) {
			if ( AlleBilder[x].className == "BildbrowserPics" ) {
				AlleInhalte.push(AlleBilder[x]);
			}
		}
	} else {
		//alert(Nummer);
		var Container = document.getElementById( "Beschreibung_Inhalte" );
		var AlleInhalte = Container.getElementsByTagName( "div" );
		
		var strNummer = Nummer + 1;
		var Inhalt = document.getElementById( strNaviDiv + "Text" + strNummer );
		//alert(strNaviDiv + "Text" + strNummer);
	}
	for ( y=0; y <= AlleInhalte.length - 1; y++ ) {
		AlleInhalte[y].style.display = "none";
		//WertTesten( AlleInhalte[y].getAttribute("id") + " wurde ausgeblendet." );
	}
	// "Inhalt" soll erst angezeigt werden, wenn Flash fertig geladen wurde
	//FlashGeladen = false;
	fnFlashGeladen();
	if ( FlashGeladen == true && blSeiteGeladen == true ) {
		var NaviDiv = document.getElementById( strNaviDiv );
		var AlleATags = NaviDiv.getElementsByTagName( "a" );
		
		for ( y=0; y < AlleATags.length; y++ ) {
			if ( AlleATags[y].className != "ModellKonfig" ) {
				AlleATags[y].style.background = "transparent";
				AlleATags[y].style.borderBottom = "1px solid #303030";
			}
			if ( strNaviDiv == "Bildbrowser_Navi" ) {
				AlleATags[y].firstChild.setAttribute("src", AlleATags[y].firstChild.getAttribute("src").replace( RegExpHover, ".gif" ) );
			}
		}
		AlleATags[Nummer].style.background = "white";
		AlleATags[Nummer].style.borderBottom = "1px solid white";
		if ( strNaviDiv == "Bildbrowser_Navi" ) {
			Bildbrowser_BildWechsel( Inhalt ); /*  */
			AlleATags[Nummer].firstChild.setAttribute("src", AlleATags[Nummer].firstChild.getAttribute("src").replace( RegExpNormal, "_hover.gif" ) );
		} else {
			if ( Inhalt != null ) {
				Inhalt.style.display = "block";
				neuAufbau();
			}
		}
		AlleATags[Nummer].blur();
	} else {
		setTimeout( function callAnzeige() { Anzeige( strNaviDiv, Nummer ); }, 500 );
	}
}
function fnFlashGeladen() {
	FlashGeladen = false;
	if ( swfobject.getFlashPlayerVersion().major >= 8 ) {
		//var SinnPPFlash = swfobject.getObjectById("SinnPP");
		var SinnPPFlash = document.getElementById("SinnPP");
		if ( SinnPPFlash != null ) {
			try {
				var FlashPercentLoaded = SinnPPFlash.PercentLoaded();
				if ( !isNaN(FlashPercentLoaded) ) {
					if ( FlashPercentLoaded == 100 ) {
						throw true;
					}
				}
				throw false;
			} catch (FehlerVar) {
				if ( FehlerVar === true ) {
					FlashGeladen = true;
				}
			}
		}
	} else {
		FlashGeladen = true;
	}
}
function fnPause(millis) {
	var date = new Date();
	var curDate = null;
	
	do { curDate = new Date(); }
	while ( curDate-date < millis );
}
function Rollover( objElement, boolHover ) {
	var AlleATags = objElement.parentNode.getElementsByTagName("a");
	var imgBild = objElement.firstChild;
	var strBildSource = imgBild.getAttribute("src");
	var RegExpHover = /_hover\.gif/;
	var RegExpNormal = /\.gif/;
	var RegExpBackground = /(255.*){3}/;
	
	/*
	for ( x=0; x < AlleATags.length; x++ ) {
		if ( AlleATags[x] != objElement && RegExpHover.test(AlleATags[x].firstChild.getAttribute("src")) ) {
			AlleATags[x].firstChild.setAttribute("src", AlleATags[x].firstChild.getAttribute("src").replace( RegExpHover, ".gif" ) );
		}
	}
	*/
	
	if ( !RegExpHover.test(strBildSource) ) {
		if ( boolHover ) {
			imgBild.setAttribute("src", strBildSource.replace( RegExpNormal, "_hover.gif" ) );
		}
	} else {
		if ( !document.all ) {
			var Hintergrund = window.getComputedStyle(objElement, "").getPropertyValue("background-color");
		} else {
			var Hintergrund = objElement.currentStyle.backgroundColor;
		}
		if ( !boolHover && !RegExpBackground.test(Hintergrund) ) {
			imgBild.setAttribute("src", strBildSource.replace( RegExpHover, ".gif" ) );
		}
	}
}

function Bildbrowser_BildWechsel( BrowserPic ) {
	if ( Einblendung != null ) {
		clearInterval(Einblendung);
		Einblendung = null;
	}
	var Bilder = document.getElementById( "flashcontent1" ).getElementsByTagName("div");
	
	for ( y=0; y < Bilder.length; y++ ) {
		if ( Bilder[y].className == "BildbrowserPics" ) {
			Bilder[y].style.display = "none";
			Bilder[y].firstChild.style.display = "none";
		}
	}
	if ( !document.all ) {
		BrowserPic.style.opacity = "0.0";
	} else {
		BrowserPic.filters[0].opacity = 0;
	}
	BrowserPic.style.display = "block";
	BrowserPic.parentNode.style.display = "block";
	strPlay = "einmal";
	Einblendung = setInterval( function callFunc() { Einblenden(null, BrowserPic, "asd"); }, intIntervall );
}

var ZoomInOut = null;
var intIntervallZoom = 15;
var intZoomSchritte = 50;

function Bildbrowser_Zoom() {
	var Breite1 = 300;
	var Breite2 = 375;
	var intZoomSchrittWeite = Math.floor((Breite2 - Breite1) / intZoomSchritte);
	if ( ZoomInOut != null ) {
		clearInterval(ZoomInOut);
		ZoomInOut = null;
	}
	var Bilder = document.getElementById( "flashcontent1" ).getElementsByTagName("div");
	for ( y=0; y < Bilder.length; y++ ) {
		if ( Bilder[y].className == "BildbrowserPics" && Bilder[y].style.display == "block" ) {
			var AktuellesBild = Bilder[y];
		}
	}
	var NeuesBild = document.getElementById(AktuellesBild.firstChild.getAttribute("id") + "_XL");
	
	NeuesBild.style.width = Breite1 + "px";
	ZoomInOut = setInterval( function callFunc() { Bildbrowser_ZoomIn(NeuesBild, Breite2, intZoomSchrittWeite); }, intIntervallZoom );
	
}

function Bildbrowser_ZoomIn( Bild, Breite2, intSchrittWeite ) {
	
	var BildBreite = parseInt(Bild.style.width);
	if ( BildBreite + intSchrittWeite <= Breite2 ) {
		Bild.style.width = BildBreite + intSchrittWeite + "px";
	} else {
		clearInterval(ZoomInOut);
		ZoomInOut = null;
		Bild.style.width = Breite2 + "px";
	}
}

function MSIE6_erkennen() {
	var Ausdruck = /MSIE 6/;
	var test1 = Ausdruck.test( navigator.userAgent );
	return test1;
}

function Firefox_erkennen() {
	var Ausdruck = /Gecko/;
	var test1 = Ausdruck.test( navigator.userAgent );
	return test1;
}

function Versenden(Formular) {
	if ( document.forms[Formular].txtSuche.value != "" ) {
//		document.forms[Formular].submit();
	} else {
		alert("Bitte geben Sie einen Suchbegriff in das Textfeld ein.");
	}
}

function Speichern(Adresse) { location.href = Adresse; }

function MerklisteSchreiben(ModellNr) {
	var Merkliste = '';
	var k = document.cookie.split('; ');
	for (i = 0;i < k.length; ++i) {
		var hallo = k[i].split('=');
		if (hallo[0].search("Merkliste")) {
			Merkliste = Merkliste + hallo[0] + ':' + hallo[1] + '-';
			if (hallo[0]=="Modell") { var ModellNr = hallo[1]; }
		} else {
			// Cookie für die Sprache berücksichtigen ???
		}
    }
	//alert(Merkliste);
	document.cookie = "Merkliste_"+ModellNr+"=" + Merkliste;
}

function MerklisteLesen(Ort) {
	var Merkliste = '';
	var k = document.cookie.split('; ');
	for (i = 0;i < k.length; ++i){
		var hallo = k[i].split('=');
		if (!hallo[0].search("/Merkliste/")) {
			//var ModellNr = hallo[0].split('_');
			Merkliste = Merkliste + hallo[0] + ',';
		}
    }
	//alert(Merkliste);
	if ( Ort == "Merkliste" ) {
	/* alert(strHauptOrdner);
	alert(strHauptDatei); */
		location.href = strHauptOrdner + strHauptDatei + "?Merkliste=" + Merkliste;
	} else {
		location.href = strHauptOrdner + strHauptDatei + "?Seite=27&Merkliste=" + Merkliste;
	}
}

function MerklisteLeer() {
	var Liste = document.cookie.split('; ');
	var Merkliste = document.getElementById("MerklisteLink");
	var Bestellen = document.getElementById("BestellenLink");
	var Ausdruck = /strLang/;
	
	for ( x=0; x < Liste.length; x++ ) {
		if ( Liste[x] != "" && !Ausdruck.test(Liste[x]) ) {
			var Leer = "Inhalt";
		}
	}
	/*
	for ( x=0; x < Liste.length; x++ ) {
		if ( Liste[x] != "" ) {
			var Leer = "Inhalt";
		}
	}
	*/
	try {
		if ( Leer == "Inhalt" ) {
			Merkliste.style.color = "#ec3223";
			Bestellen.style.display = "inline";
		} else {
			Merkliste.style.color = "white";
			Bestellen.style.display = "none";
		}
		throw "richtig";
	} catch (e) { }
}

function MerklisteLoeschen(ModellNr,Merkliste,Ort) {
	//document.cookie = ModellNr+"=jjjjjj;  expires=Thu, 01-Jan-70 00:00:01 GMT";
	
	// Cookie für die Sprache berücksichtigen ???
	
	document.cookie = ModellNr+"=jjjjjj;  expires=Thu, 01-Jan-90 00:00:01 GMT";
	MerklisteLeer();
	MerklisteLesen(Ort);
	
}

function Bestellen() {
	var Merkliste = "";
	var k = document.cookie.split('; ');
	for (i = 0;i < k.length; ++i) {
		if (k[i].search("Merkliste")) {
			var hallo = k[i].split('=');
			Merkliste = Merkliste + hallo[0] + ',';
		}
    }
	location.href = strHauptOrdner + strHauptDatei + "?Seite=27&Merkliste=" + Merkliste;
}

function fnZahlungsArt( objSelectElement ) {
	var strTypA = "Vorkasse";
	var strTypB = "Kreditkartenzahlung"
	var objTypA = document.getElementById(strTypA);
	var objTypB = document.getElementById(strTypB);
	var objFormular = document.Bestellung;
	
	if ( objSelectElement.value == strTypA ) {
		//alert( objSelectElement.value );
		objTypB.style.display = "none";
		/* objFormular.Kreditkarte.selectedIndex = 0;
		objFormular.Kartenummer.value = "";
		objFormular.KarteDatum.value = "";
		objFormular.Pruefziffer.value = ""; */
		objTypA.style.display = "block";
	} else {
		if ( objSelectElement.value == strTypB ) {
			/*alert( objSelectElement.value ); */
			objTypA.style.display = "none";
			/*
			objFormular.Kontoinhaber.value = "";
			objFormular.Bank.value = "";
			objFormular.Kontonummer.value = "";
			objFormular.BLZ.value = ""; */
			objTypB.style.display = "block";
		} else {
			objTypA.style.display = "none";
			objTypB.style.display = "none";
			/* objFormular.Kreditkarte.selectedIndex = 0;
			objFormular.Kartenummer.value = "";
			objFormular.KarteDatum.value = "";
			objFormular.Pruefziffer.value = ""; */
			/*
			objFormular.Kontoinhaber.value = "";
			objFormular.Bank.value = "";
			objFormular.Kontonummer.value = "";
			objFormular.BLZ.value = ""; */
		}
	}
}

function FensterOeffnen (Adresse) {
  MeinFenster = window.open(Adresse, "Zweitfenster", "width=800,height=600,left=100,top=200");
  MeinFenster.focus();
}

function DepotAdressen( StartContainer, ZielContainer ) {
	if ( StartContainer != null ) {
		var Depotadressen = StartContainer.getElementsByTagName("div");
		var Anzahl = Depotadressen.length;
		
		for( x=0; x < Anzahl; x++) {
			if ( Depotadressen[x].className == "Stadt" ) {
				var Adresse = Depotadressen[x].cloneNode(true);
				ZielContainer.appendChild(Adresse);
			}
		}
		for( x=Anzahl-1; x >= 0; x--) {
			if ( Depotadressen[x].className == "Stadt" ) {
				StartContainer.removeChild(Depotadressen[x]);
			}
		}
	}
}
function Depot_anzeigen( Nr, StadtLink ) {
	var DIV_Elemente = document.getElementsByTagName("div");
	var StadtID = "Stadt" + Nr;
	var Stadt = document.getElementById( StadtID );
	if ( Stadt != null ) {
		var Depots = Stadt.getElementsByTagName( "p" );
	} else {
		var Depots = new Array();
	}
	for ( x=0; x < DIV_Elemente.length; x++ ) {
		if ( DIV_Elemente[x].className == "Stadt" ) {
			DIV_Elemente[x].style.display = "none";
		}
	}
	if ( Stadt != null ) {
		Stadt.style.display = "block";
	}
	for ( y=0; y < Depots.length; y++ ) {
		Depots[y].style.display = "block";
	}
	if ( Firefox_erkennen() && StadtLink !== false ) {
		StadtLink.blur();
	}
}
// Nur für Testzwecke:
function WertTesten( Wert ) {
	var body1 = document.getElementsByTagName("body")[0];
	var TestDIV = document.getElementById( "TestAusgabe" );
	var TextNodeNeu = document.createTextNode( "::" + Wert + "::" );
	if ( TestDIV ) {
		var TextNode = TestDIV.firstChild;
		TestDIV.removeChild(TextNode);
	} else {
		var TestDIV = document.createElement("div");
		TestDIV.setAttribute("id", "TestAusgabe");
		TestDIV.style.position = "absolute";
		TestDIV.style.right = "5px";
		TestDIV.style.bottom = "5px";
		TestDIV.style.color = "#000000";
		TestDIV.style.fontSize = "10px";
		TestDIV.style.backgroundColor = "white";
		body1.appendChild( TestDIV );
	}
	TestDIV.appendChild( TextNodeNeu );
}
function ZweiSpaltenFloat() {
	if ( document.getElementById("MitteHaupt") ) {
		var objDIVs = document.getElementById("MitteHaupt").getElementsByTagName("div");
		var objFachbegriffe = new Array();
		var objLinks;
		var objRechts;
		
		for ( x=0; x < objDIVs.length; x++ ) {
			if ( objDIVs[x].className == "Fachbegriff" ) {
				/* objDIVs[x].style.marginBottom = "0px";
				objDIVs[x].style.marginTop = "0px"; */
				objFachbegriffe.push(objDIVs[x]);
			}
		}
		if ( objFachbegriffe.length > 1 ) {
			objFachbegriffe[0].style.styleFloat = "left";
			objFachbegriffe[0].style.cssFloat = "left";
			objLinks = objFachbegriffe[0];
			objFachbegriffe[1].style.styleFloat = "right";
			objFachbegriffe[1].style.cssFloat = "right";
			objRechts = objFachbegriffe[1];
			
			for ( y=2; y < objFachbegriffe.length; y++ ) {
				if ( (objLinks.offsetTop + objLinks.offsetHeight) <= (objRechts.offsetTop + objRechts.offsetHeight) ) {
					objFachbegriffe[y].style.styleFloat = "left";
					objFachbegriffe[y].style.cssFloat = "left";
					objLinks = objFachbegriffe[y];
				} else {
					objFachbegriffe[y].style.styleFloat = "right";
					objFachbegriffe[y].style.cssFloat = "right";
					objRechts = objFachbegriffe[y];
				}
			}
		}
	}
}
