/* copyright 2002-2006 S. Brandhoff - info@g68.de - www.g68.de */

var arrAlleMarken = alleMarken.split (',');


// make_id (aus aw_fb) auswerten und MenŸ "Marke" vorbelegen
function initJumpers(dieMarke) {
	
	if (document.aktuell) {
		document.aktuell.aktModell.selectedIndex = 0;
	}
	
	if (dieMarke > 0) {
		for (i=0; i < document.bestand.marke.length; i++) {
			if (document.bestand.marke.options[i].value == dieMarke)
				document.bestand.marke.options[i].selected = true;
		}
		markenWahl(true);
	}
	else if (document.bestand.marke.options[document.bestand.marke.selectedIndex].value > 0) {
		markenWahl(true);
	}
}




// DropmenŸ "Aktuell" aufbauen
function initDirektWahl() {
	
	document.write('<select name="aktModell" onChange="hopserAktuell(aspDasLayout);">');
	document.write('<option value="0" selected="selected">Artikel w&auml;hlen...<\/option>');
//	document.write('<option value="aw_genf_06">Bilder vom Genfer Autosalon 2006<\/option>');

	arrAktuelleAutos = aktuelleAutos.split(';');

	for (i = 0; i < arrAktuelleAutos.length; i++) {
		auto = arrAktuelleAutos[i];
	
		markeTemp = (arrModels[auto.split(',')[0]]).split(';')[0];
		pfad = markeTemp.split(',')[0];
		marke = markeTemp.split(',')[1];
	
		typTemp = (arrModels[auto.split(',')[0]]).split(';')[auto.split(',')[1]];
		datei = typTemp.split(',')[0];
		typ = typTemp.split(',')[1];
		typ = typ.split('[')[0];


		document.writeln('<option value=' + pfad + ',' + datei + '>' + marke + ' ' + typ + '<\/option>');


		
		/* ########### Ausnahme-Regeln fuer Marke/Modell (individuell & allgemein) ############
		
		if (marke == "Mazda") {
			document.writeln('<option value=' + pfad + ',' + datei + '>' + typ + '<\/option>');
		}
		else {
			document.writeln('<option value=' + pfad + ',' + datei + '>' + marke + ' ' + typ + '<\/option>');
		}
		*/
	}
	document.write('<\/select>');
}



// DropmenŸ "Modell" leer aufbauen, wird durch Funktion "markenWahl()" befŸllt
function initModell() {
	document.writeln('<select name="modell" onChange="hopserBestand(aspDasLayout);">');
	document.writeln('<option value="0" selected>Modell w&auml;hlen...<\/option>');
	document.writeln('<\/select>');
}


// Marken-MenŸ bauen #############################################
function initMarken() {
	document.writeln('<select name="marke" onChange="markenWahl(true);">');
	document.writeln('<option value="0" selected>Marke w&auml;hlen...<\/option>');
		

	
	for (i = 0; i < arrAlleMarken.length; i++) {
		if (aspDasLayout == 1) {
			arrAlleMarkenMitKey[arrAlleMarken[i]] = arrAlleMarkenText[i];
		}

		markeTemp = (arrModels[arrAlleMarken[i]]).split(';')[0];
		pfad = markeTemp.split(',')[0];
		marke = markeTemp.split(',')[1];
		document.writeln('<option value='+pfad+'>'+marke+'<\/option>');
	}
	document.writeln('<\/select>');
}



// schreibt nach Wahl der Marke das DropmenŸ "Modell"
function markenWahl() {
	var arrModelList, objModellWahl;
	
	if (document.bestand.modell == null) {
		return;
	}
	
	objModellWahl = document.bestand.modell;
	objModellWahl.selectedIndex = 0;
	objModellWahl.options.length = 1;

	if (document.bestand.marke.selectedIndex >= 1) {
		arrModelList = (arrModels[document.bestand.marke.value]).split(';');
		for (i = 1; i < arrModelList.length; i++) {
			objModellWahl.options.length = i+1;
			objModellWahl.options[i].value = (arrModelList[i]).split(',')[0];
			objModellWahl.options[i].text = (arrModelList[i]).split(',')[1];
        }
	}
}



// von "Aktuell" zum Fahrbericht
function hopserAktuell(aspDasLayout) {
	var gehLesen = "";
	
	with (document.aktuell) {
		gehLesen = aktModell.value;

		if (gehLesen == 0) {
			return false;
		}
		else if (gehLesen == "aw_genf_06") {
			if (window.name == "allianzautowelt") {
				SandboxPopUp ('/allianz/content/ger/galerie_genf_06/index.asp','galerie_extra','sidebar=no,status=yes,scrollbars=yes,width=838,height=505,');
			}
			else {
				document.location.href = "/allianz/content/ger/galerie_genf_06/index.asp";
			}
		}

		else if (gehLesen == "aw_ami_06") {
			if (window.name == "allianzautowelt") {
				SandboxPopUp ('/allianz/content/ger/galerie_ami_06/index.asp','galerie_extra','sidebar=no,status=yes,scrollbars=yes,width=838,height=505,');
			}
			else {
				document.location.href = "/allianz/content/ger/galerie_ami_06/index.asp";
			}
		}

/* 		else if (gehLesen == "genf") { */
/* 			if (window.name == "allianzautowelt") { */
/* 				SandboxPopUp ('/allianz/content/ger/galerie_genf/index.asp','galerie_extra','sidebar=no,status=yes,scrollbars=yes,width=680,height=462,left=146,top=116'); */
/* 			} */
/* 			else { */
/* 				document.location.href = "/allianz/content/ger/galerie_genf/index.asp"; */
/* 			} */
/* 		} */

		else {
		//alert (gehLesen);
			if (aspDasLayout == 1) {
				var pfadTemp = gehLesen.split (',');
				document.location.href = "/magazin/fahrberichte/" + arrAlleMarkenMitKey[pfadTemp[0]] + "/" + pfadTemp[1] + "/index.asp";
			}
			else {
				document.location.href = "?aw_fb=" + aspDasLayout + ",2," + gehLesen + ",0";
			}
		}
	return true;
	}
}



// von "Modell" zum Fahrbericht
function hopserBestand(aspDasLayout) {
	var pfadMarke = "", pfadModell = "", gehLesen = "";
	with (document.bestand) {
		pfadMarke = marke.value;
		pfadModell = modell.value;
		
		if ((pfadMarke == 0) || (pfadModell == 0)) {
			alert('Bitte erst Marke und dann Modell waehlen!');
			return false;
		}
		else {
			if (aspDasLayout == 1) {
				document.location.href = "/magazin/fahrberichte/" + arrAlleMarkenMitKey[pfadMarke] + "/" + pfadModell + "/index.asp";
			}
			else {
				document.location.href = "?aw_fb=" + aspDasLayout + ",2," + pfadMarke + "," + pfadModell + ",0";
			}
		}
	return true;
	}
}


function SandboxPopUp(theURL,winName,features) {
	window.open(theURL,winName,features);
}



// End of File
