/************************************************************************************************************************
											HJS Lieferprogramm
*************************************************************************************************************************
	Copyright 2008, i-factory GmbH, Iserlohn
	Florian Zeppenfeld, zeppenfeld@i-fac.de
	Alle Rechte vorbehalten.
************************************************************************************************************************/
if ( contextClient != "demo" )
{
	var useAJAX = true;
}
else
{
	var useAJAX = false;
}
var useHistory = false;
var waitTime = 50;
var strProduktTitle = "HJS Lieferprogramm";

if ( contextClient != "dk" )
{
	var AnzahlLayer = 4;
	lay = new Array(AnzahlLayer);
	layerTitel = new Array(AnzahlLayer);
	lay[0] = "auswahl";
	lay[1] = "schuesselnr";
	lay[2] = "werkstatt";
	lay[3] = "startseite";
	layerTitel[0] = "Fahrzeugidentifizierung über die Auswahl"
	layerTitel[1] = "Fahrzeugidentifizierung über die Schlüsselnummer"
	layerTitel[2] = "Werkstattfinder"
	layerTitel[3] = "Startseite"
}
else
{
	var AnzahlLayer = 2;
	lay = new Array(AnzahlLayer);
	layerTitel = new Array(AnzahlLayer);
	lay[0] = "auswahl";
	lay[1] = "startseite";
	layerTitel[0] = "Fahrzeugidentifizierung über die Auswahl"
	layerTitel[1] = "Startseite"
}
/************************************************************************************************************************
												HJS Lieferprogramm
************************************************************************************************************************/

var BrowserName = null;
var curr_layer = 0;
var curr_hersteller = 0;
var curr_modell = 0;
var curr_typ = 0;
var curr_typ2 = 0;
var curr_hsn = 0;
var curr_tsn = 0;
var curr_plzort = 0;

function SeitenNavi () {
	tmpTitel = strProduktTitle + " - " + layerTitel[curr_layer];
	tmpHash = "lay=" + lay[curr_layer];
	if ( lay[curr_layer] == "auswahl" ) {
		if ( curr_hersteller > 0 ) {
			tmpTitel = tmpTitel + " - " + document.fahrzeugsuche.hersteller[document.fahrzeugsuche.hersteller.selectedIndex].text;
			tmpHash = tmpHash + "&hersteller=" + curr_hersteller;
		}
		if ( curr_modell > 0 ) {
			tmpTitel = tmpTitel + " - " + document.fahrzeugsuche.modell[document.fahrzeugsuche.modell.selectedIndex].text;
			tmpHash = tmpHash + "&modell=" + curr_modell;
		}
		if ( curr_typ > 0 ) {
			tmpTitel = tmpTitel + " - " + document.fahrzeugsuche.fahrzeugtypen[document.fahrzeugsuche.fahrzeugtypen.selectedIndex].text;
			tmpHash = tmpHash + "&fahrzeugtypen=" + curr_typ;
		}
	}
	if ( lay[curr_layer] == "schuesselnr" ) {
		if ( curr_hsn != 0 && curr_tsn != 0 ) {
			tmpTitel = tmpTitel + " - Suche: " + curr_hsn + "/" + curr_tsn;
			tmpHash = tmpHash + "&hsn=" + curr_hsn;
			tmpHash = tmpHash + "&tsn=" + curr_tsn;			
		}
	}
	if ( lay[curr_layer] == "werkstatt" ) {
		if ( curr_plzort != 0 ) {
			tmpTitel = tmpTitel + " - Suche: " + curr_plzort;
			tmpHash = tmpHash + "&plzort=" + curr_plzort;
		}
	}
	
	document.title = tmpTitel;
	if ( useHistory  && !ladevorgang ) {
		isLinkForward = true;
		document.location = "#" + tmpHash;
	}
}

/****************************************
***	Funktion: Init
*** Entschluesselt den URL_Hash und oeffnet einen Layer mit SucheDisplay
****************************************/

var Vars = new Array;
function Init () {
	if ( useHistory ) {
		dhtmlHistory.initialize();
		dhtmlHistory.addListener(yourListener);
	}
	getWahreHoehe();	
	browser = getBrowser();
	aryBuggyBrowsers = new Array();
	aryBuggyBrowsers = BuggyBrowsers.split(",");
		
	var anchors = document.getElementsByTagName('a');

	for (var i=0; i<anchors.length; i++){
		var anchor = anchors[i];
		
		if (anchor.addEventListener) {
			anchor.addEventListener("click", function(evt) { 
				ieFake(evt.originalTarget);
	   		}, false);
			anchor.addEventListener("mouseover", function(evt) { 
			window.defaultStatus = "";
			window.status = evt.srcElement.title;
			return true;
	   		}, false);
		}
		else if (anchor.attachEvent) {
  			anchor.attachEvent("onclick", function(evt) { 
				ieFake(evt.srcElement);
	   		});
  			anchor.attachEvent("onmouseover", function(evt) { 
			window.defaultStatus = "";
			window.status = evt.srcElement.title;
			return true;
	   		});
		}
	}
}

function ieFake(fake) {
	if ((document.all) && (fake)) fake.blur();
}

function ShowKraftstoffWahl () {
	ShowOverlay(true);
	document.getElementById("kraftstoffwahl").style.display = "block";
}

function setKraftstoff(id, noexec)
{
	KraftstoffSelected = id;
	for ( i = 1; i<=2; i++ )
	{
		if ( i == id )
		{
			document.getElementById("krafts" + i).checked = true;
			document.getElementById("cb_" + i).src = "gif/checkbox_on.gif";
			document.getElementById("lblfor_cb" + i).className = "cbAktiv";
		}
		else
		{
			document.getElementById("krafts" + i).checked = false;
			document.getElementById("cb_" + i).src = "gif/checkbox_off.gif";
			document.getElementById("lblfor_cb" + i).className = "cbNonAktiv";
		}
	}
	if ( useAJAX && !noexec )
	{
		getHersteller(document.fahrzeugsuche);
	}
}

function setKraftstoff2(id)
{
	KraftstoffSelected = id;
	for ( i = 3; i<=4; i++ )
	{
		if ( (i-2) == id )
		{
			document.getElementById("krafts" + i).checked = true;
			document.getElementById("cb_" + i).src = "gif/checkbox_on.gif";
			document.getElementById("lblfor_cb" + i).className = "cbAktiv";
			document.getElementById("krafts" + (i+2)).checked = true;
			document.getElementById("cb_" + (i+2)).src = "gif/checkbox_on.gif";
			document.getElementById("lblfor_cb" + (i+2)).className = "cbAktiv";
		}
		else
		{
			document.getElementById("krafts" + i).checked = false;
			document.getElementById("cb_" + i).src = "gif/checkbox_off.gif";
			document.getElementById("lblfor_cb" + i).className = "cbNonAktiv";
			document.getElementById("krafts" + (i+2)).checked = false;
			document.getElementById("cb_" + (i+2)).src = "gif/checkbox_off.gif";
			document.getElementById("lblfor_cb" + (i+2)).className = "cbNonAktiv";
		}
	}
}

function setKraftstoff3(id)
{
	KraftstoffSelected = id;
	for ( i = 5; i<=6; i++ )
	{
		if ( (i-4) == id )
		{
			document.getElementById("krafts" + i).checked = true;
			document.getElementById("cb_" + i).src = "gif/checkbox_on.gif";
			document.getElementById("lblfor_cb" + i).className = "cbAktiv";
			document.getElementById("krafts" + (i-2)).checked = true;
			document.getElementById("cb_" + (i-2)).src = "gif/checkbox_on.gif";
			document.getElementById("lblfor_cb" + (i-2)).className = "cbAktiv";
		}
		else
		{
			document.getElementById("krafts" + i).checked = false;
			document.getElementById("cb_" + i).src = "gif/checkbox_off.gif";
			document.getElementById("lblfor_cb" + i).className = "cbNonAktiv";
			document.getElementById("krafts" + (i-2)).checked = false;
			document.getElementById("cb_" + (i-2)).src = "gif/checkbox_off.gif";
			document.getElementById("lblfor_cb" + (i-2)).className = "cbNonAktiv";
		}
	}
}

function getIndexByValue( form, value ) {
	for ( i = 0; i <= form.length; i++ ) {
		if ( form[i].value == value ) {
			return i;
		}
	}
}

ladevorgang = false;
function InitVars () {
	ladevorgang = true;
	initVars = window.location.hash;
	initVars = initVars.substr(1);
	Variablen = initVars.split("&");
	for (var i = 0; i <= Variablen.length-1; i++) {
		tmp = Variablen[i].split("=");
		Vars[tmp[0]] = tmp[1];
	}
	if ( Vars["lay"] != undefined ) {
		SucheDisplay(Vars["lay"]);
	}
	else {
		SucheDisplay(lay[0]);
	}
	if ( lay[curr_layer] == "auswahl" ) {
		if ( Vars["hersteller"] != undefined ) {
			index = getIndexByValue(document.fahrzeugsuche.hersteller,Vars["hersteller"]);
			document.fahrzeugsuche.hersteller.selectedIndex = index;
			getModelle(document.fahrzeugsuche);
		}
		else {
			curr_hersteller = 0;
		}
		
		if ( Vars["modell"] != undefined ) {
			Sleep(50);
			index = getIndexByValue(document.fahrzeugsuche.modell,Vars["modell"]);
			document.fahrzeugsuche.modell.selectedIndex = index;
			getModelleTypen(document.fahrzeugsuche);
		}
		else {
			curr_modell = 0;
		}
		
		if ( Vars["fahrzeugtypen"] != undefined ) {
			Sleep(50);
			index = getIndexByValue(document.fahrzeugsuche.fahrzeugtypen,Vars["fahrzeugtypen"]);
			document.fahrzeugsuche.fahrzeugtypen.selectedIndex = index;
			getProdukte(document.fahrzeugsuche);
		}
		else {
			curr_typ = 0;
		}
	}
	ladevorgang = false;
}

/****************************************
***	Funktion: ShowLadebalken
*** Blendet den Ladebalken ein und aus
****************************************/

function ShowLadebalken ( anaus ) {
	tmp = document.getElementsByName("ladebalken");
	if ( anaus ) {
		for ( x=0; x < tmp.length; x++ )
		{
			document.getElementsByName("ladebalken")[x].style.display = "inline";
		}
		//		document.getElementById("ladeanzeige").style.display = "block";
		//		ShowOverlay(true);
	}
	else {
		for ( x=0; x < tmp.length; x++ )
		{
			document.getElementsByName("ladebalken")[x].style.display = "none";
		}
		//		document.getElementById("ladeanzeige").style.display = "none";
		//		ShowOverlay(false);
	}
}

/****************************************
***	Funktion: SucheDisplay
*** Blendet Div-Layer ein und aus - Passt Dokomenten Titel an
****************************************/

function SucheDisplay ( lay_id ) {
	for (i=0; i < AnzahlLayer; i++) {
		if ( lay[i] != "startseite" ) {
			tmp = document.getElementsByName("btnfor_" + lay[i]);
			for ( x=0; x < tmp.length; x++ )
			{
				if ( lay[i] == lay_id ) {
					document.getElementsByName("btnfor_" + lay[i])[x].style.color = "#004885";
				}
				else {
					document.getElementsByName("btnfor_" + lay[i])[x].style.color = "#000000";
				}
			}
		}
		if ( lay[i] == lay_id ) {
			curr_layer = i;
			document.getElementById(lay[i]).style.display = "block";			
		}
		else {
			document.getElementById(lay[i]).style.display = "none";
		}
	}
	SeitenNavi();
	return false;
}

/****************************************
***	Funktion: cleanTbodyFromId
*** Leert den TBODY der Tabelle mit der _tableId_
****************************************/

function cleanTbodyFromId ( tableId ) {
	if ( document.getElementById(tableId) )
	{
		document.getElementById(tableId).style.display = "none";
		while ( document.getElementById(tableId).getElementsByTagName("tbody")[0].childNodes.length > 0 ) {
			tmpChild = document.getElementById(tableId).getElementsByTagName("tbody")[0].childNodes[0];
			if ( tmpChild ) {
				document.getElementById(tableId).getElementsByTagName("tbody")[0].removeChild(tmpChild);
			}
		}
	}
	return true;
}

/****************************************
***	Funktion: showImage
*** Zeigt eine Bilddatei an
****************************************/
function showImage ( file, x, y, text ) {
	MyImage = document.createElement("img");
	MyImage.src = file;
	MyImage.border = 0;
	MyImage.style.width = x;
	MyImage.style.height = y;
	/*
	MyLink = document.createElement("a");
	MyLink.href = "#";
	if (MyLink.addEventListener) {
		MyLink.addEventListener("click", function(evt) { 
			showImageExit();
   		}, false);
	}
	else if (MyLink.attachEvent) {
		MyLink.attachEvent("onclick", function(evt) { 
			showImageExit();
   		});
	}
	MyLink.appendChild(MyImage);
	*/
	document.getElementById("hierfoto").innerHTML = "";
	document.getElementById("hierfoto").appendChild(MyImage);
	
	if ( text != "" ) {
		document.getElementById("imgtitel").innerHTML = text;
	}


/*	MyTableCell = document.createElement("td");
	MyTableCell.style.textAlign = "center";
	MyTableCell.appendChild(MyLink);
	
	MyTableRow = document.createElement("tr");
	MyTableRow.appendChild(MyTableCell);
	
	MyTableBody = document.createElement("tbody");
	
	if ( text != "" ) {
		MyTableCell_Titel = document.createElement("th");
		MyTableCell_Titel.style.textAlign = "center";
		MyTableCell_Titel.innerHTML = '<h1>' + text + '</h1>';
	
		MyTableRow_Titel = document.createElement("tr");
		MyTableRow_Titel.appendChild(MyTableCell_Titel);
		
		MyTableBody.appendChild(MyTableRow_Titel);
	}

	MyTableBody.appendChild(MyTableRow);

	MyTable = document.createElement("table");
//	MyTable.style.height = "100%";
//	MyTable.style.width = "100%";
	MyTable.cellSpacing = 0;
	MyTable.cellPadding = 0;
	MyTable.appendChild(MyTableBody);
*/	
	MyImageContainer = document.getElementById("bildanzeige");	
/*
	MyTableCellOuter = document.createElement("td");
	MyTableCellOuter.style.textAlign = "center";
//	MyTableCellOuter.appendChild(MyTable);
	MyTableCellOuter.innerHTML = MyImageContainer.innerHTML;
	
	MyTableRowOuter = document.createElement("tr");
	MyTableRowOuter.appendChild(MyTableCellOuter);
	
	MyTableBodyOuter = document.createElement("tbody");
	MyTableBodyOuter.appendChild(MyTableRowOuter);

	MyTableOuter = document.createElement("table");
	MyTableOuter.style.height = "100%";
	MyTableOuter.style.width = "100%";
	MyTableOuter.appendChild(MyTableBodyOuter);

	MyImageContainer = document.getElementById("bildanzeige");
	MyImageContainer.innerHTML = "";
	MyImageContainer.appendChild(MyTableOuter);
*/
	ShowOverlay(true);
	window.scrollTo(0, 0);
	MyImageContainer.style.display = "block";
	return false;
}

/****************************************
***	Funktion: writeProdukteFinal
*** Schreibt die Produkte in die Tabelle mit der _tableId_
****************************************/

function writeProdukteFinal(tableId , tblid) {
	Sleep(waitTime);
	if ( xmlHttp.readyState == 4 ) {
		if (xmlHttp.status == 200) {
			var res = xmlHttp.responseXML;
			ShowLadebalken(true);
			for (var i=0; i<res.getElementsByTagName('Produkt').length; i++) {
				if( i % 2 == 0 ) {
					tmpStyle = 2;
				}
				else {
					tmpStyle = 1;
				}
				tmpProduktID = res.getElementsByTagName("Produkt")[i].getElementsByTagName("ID")[0].firstChild.nodeValue;
				tmpArtNr = res.getElementsByTagName("Produkt")[i].getElementsByTagName("ArtNr")[0].firstChild.nodeValue;
				tmpPreis = res.getElementsByTagName("Produkt")[i].getElementsByTagName("Preis")[0].firstChild.nodeValue;
				tmpGruppenID = res.getElementsByTagName("Produkt")[i].getElementsByTagName("GruppenID")[0].firstChild.nodeValue;
				tmpBezeichnung = res.getElementsByTagName("Produkt")[i].getElementsByTagName("Bezeichnung")[0].firstChild.nodeValue;
				tmpMotorTyp = res.getElementsByTagName("Produkt")[i].getElementsByTagName("MotorTyp")[0].firstChild.nodeValue;
				tmpGetriebe = res.getElementsByTagName("Produkt")[i].getElementsByTagName("Getriebe")[0].firstChild.nodeValue;
				tmpBaujahr = res.getElementsByTagName("Produkt")[i].getElementsByTagName("Baujahr")[0].firstChild.nodeValue;
				tmpErreichtAbgasnorm = res.getElementsByTagName("Produkt")[i].getElementsByTagName("ErreichtAbgasnorm")[0].firstChild.nodeValue;
				tmpStatus = res.getElementsByTagName("Produkt")[i].getElementsByTagName("Status")[0].firstChild.nodeValue;
				tmpBemerkungen = "";
				if ( res.getElementsByTagName("Produkt")[i].getElementsByTagName("Bemerkungen")[0].firstChild ) {
					tmpBemerkungen = res.getElementsByTagName("Produkt")[i].getElementsByTagName("Bemerkungen")[0].firstChild.nodeValue;
				}
				//alert("OK: " + tmpBemerkungen);
				tmpFileAmpel = res.getElementsByTagName("Produkt")[i].getElementsByTagName("FileAmpel")[0].firstChild.nodeValue;
				tmpTextAmpel = res.getElementsByTagName("Produkt")[i].getElementsByTagName("TextAmpel")[0].firstChild.nodeValue;
				tmpFilePlakette = "";
				if ( res.getElementsByTagName("Produkt")[i].getElementsByTagName("FilePlakette")[0].firstChild ) {
					tmpFilePlakette = res.getElementsByTagName("Produkt")[i].getElementsByTagName("FilePlakette")[0].firstChild.nodeValue;
				}
				tmpFilePDF = "";
				if ( res.getElementsByTagName("Produkt")[i].getElementsByTagName("FilePDF")[0].firstChild ) {
					tmpFilePDF = res.getElementsByTagName("Produkt")[i].getElementsByTagName("FilePDF")[0].firstChild.nodeValue;
				}
				tmpFileJPG = "";
				if ( res.getElementsByTagName("Produkt")[i].getElementsByTagName("Produktfoto")[0].getElementsByTagName("FileJPG")[0].firstChild ) {
					tmpFileJPG = res.getElementsByTagName("Produkt")[i].getElementsByTagName("Produktfoto")[0].getElementsByTagName("FileJPG")[0].firstChild.nodeValue;
					tmpFileJPG_X = res.getElementsByTagName("Produkt")[i].getElementsByTagName("Produktfoto")[0].getElementsByTagName("FileJPG_Breite")[0].firstChild.nodeValue;
					tmpFileJPG_Y = res.getElementsByTagName("Produkt")[i].getElementsByTagName("Produktfoto")[0].getElementsByTagName("FileJPG_Hoehe")[0].firstChild.nodeValue;
				}
				
				TableRow = document.createElement('tr');
				TableRow.className = "row" + tmpStyle;

				TableCell_ImgLinks = document.createElement('td');
				TableCell_ImgLinks.noWrap = true;
				TableCell_ImgLinks.className = "prod_zell_links" + tmpStyle;
				TableCell_ImgLinks.innerHTML = "";
				
				TableCell_ArtNr = document.createElement('td');
				TableCell_ArtNr.noWrap = true;
				TableCell_ArtNr.align = "center";
				TableCell_ArtNr.innerHTML = tmpArtNr;

				TableCell_Bezeichnung = document.createElement('td');
				TableCell_Bezeichnung.width = "100%";
				TableCell_Bezeichnung.innerHTML = "<b>" + tmpBezeichnung + "</b>";
	
				TableCell_MotorTyp = document.createElement('td');
				TableCell_MotorTyp.noWrap = true;
				TableCell_MotorTyp.align = "center";
				TableCell_MotorTyp.innerHTML = tmpMotorTyp;
	
				TableCell_Getriebe = document.createElement('td');
				TableCell_Getriebe.noWrap = true;
				TableCell_Getriebe.align = "center";
				TableCell_Getriebe.innerHTML = tmpGetriebe;
	
				TableCell_Baujahr = document.createElement('td');
				TableCell_Baujahr.noWrap = true;
				TableCell_Baujahr.align = "center";
				TableCell_Baujahr.innerHTML = tmpBaujahr;
	
				TableCell_ErreichtAbgasnorm = document.createElement('td');
				TableCell_ErreichtAbgasnorm.noWrap = true;
				TableCell_ErreichtAbgasnorm.align = "center";
				TableCell_ErreichtAbgasnorm.innerHTML = tmpErreichtAbgasnorm;
				
				TableCell_ImgRechts = document.createElement('td');
				TableCell_ImgRechts.noWrap = true;
				TableCell_ImgRechts.className = "prod_zell_rechts" + tmpStyle;
				TableCell_ImgRechts.innerHTML = "";
				
				TableRow.appendChild(TableCell_ImgLinks);
				TableRow.appendChild(TableCell_ArtNr);
				TableRow.appendChild(TableCell_Bezeichnung);
				TableRow.appendChild(TableCell_MotorTyp);
				TableRow.appendChild(TableCell_Getriebe);
				TableRow.appendChild(TableCell_Baujahr);
				TableRow.appendChild(TableCell_ErreichtAbgasnorm);
				TableRow.appendChild(TableCell_ImgRechts);
								
				tbody = document.getElementById(tableId).getElementsByTagName("tbody")[0];
				tbody = tbody.appendChild(TableRow);
				

				TableRow = document.createElement('tr');
				TableRow.className = "row" + tmpStyle;
				TableRow.vAlign = "top";
				
				TableCell_ImgLinks = document.createElement('td');
				TableCell_ImgLinks.noWrap = true;
				TableCell_ImgLinks.className = "prod_zell_links" + tmpStyle;
				TableCell_ImgLinks.innerHTML = "";
				
				TableCell_1 = document.createElement('td');
				TableCell_1.align = "center";
				tmpInhaltLinks = '<img border="0" src="gif/'+tmpFileAmpel+'" alt="' + tmpTextAmpel + '" vspace="5"><br><span class="text11schwarz" style="margin-bottom:5px;">' + tmpTextAmpel + '</span>';
				if ( ( tmpStatus == 1 || tmpGruppenID == 2 ) && tmpPreis != "0" && contextClient != "dk" )
				{
					if(tmpPreis == "siehe Vertriebspartner")
					{
						tmpInhaltLinks += '<p><b>siehe Vertriebspartner';
					}
					else
					{
						tmpInhaltLinks += '<p><b>' + tmpPreis + ' &#128;</b><br><span class="text10schwarz">UVP&nbsp;zzgl.&nbsp;MwSt.<br>und&nbsp;Einbaukosten</span>';
					}
				}
				TableCell_1.innerHTML = tmpInhaltLinks;

				tmpColSpan = 4;
//				if ( tmpFilePlakette != '' ) {
//					tmpColSpan = tmpColSpan - 1;
//				}
				if ( tmpFileJPG != "" ) {
					tmpColSpan = tmpColSpan - 2;
				}
				TableCell_2 = document.createElement('td');
				TableCell_2.width = "100%";
				TableCell_2.colSpan = tmpColSpan;
				TableCell_2.innerHTML = tmpBemerkungen;
				if ( tmpFileJPG != "" ) {
					TableCell_2a = document.createElement('td');
					TableCell_2a.width = "200";
					TableCell_2a.colSpan = 2;
					TableCell_2a.innerHTML = myRahmen ('<div align="center"><a class="gruen" href="'+tmpFileJPG+'" onClick="return showImage(\''+tmpFileJPG+'\','+tmpFileJPG_X+','+tmpFileJPG_Y+',\''+tmpBezeichnung+' ('+tmpArtNr+')\');" target="_blank"><img border="0" src="'+tmpFileJPG+'" width="196"></a></div>');
				}
				TableCell_3 = document.createElement('td');
				TableCell_3.align = "center";
				if ( tmpFilePlakette != '' )
				{
					TableCell_3.innerHTML = '<img border="0" src="gif/'+tmpFilePlakette+'">';
				}
				else
				{
					TableCell_3.innerHTML = "&nbsp;";				
				}
				
				TableCell_ImgRechts = document.createElement('td');
				TableCell_ImgRechts.noWrap = true;
				TableCell_ImgRechts.className = "prod_zell_rechts" + tmpStyle;
				TableCell_ImgRechts.innerHTML = "";
				
				TableRow.appendChild(TableCell_ImgLinks);
				TableRow.appendChild(TableCell_1);
				TableRow.appendChild(TableCell_2);
				if ( tmpFileJPG != "" ) {
					TableRow.appendChild(TableCell_2a);
				}
//				if ( tmpFilePlakette != '' ) {
					TableRow.appendChild(TableCell_3);
//				}
				TableRow.appendChild(TableCell_ImgRechts);
				tbody = document.getElementById(tableId).getElementsByTagName("tbody")[0];
				tbody = tbody.appendChild(TableRow);
				
				if ( tmpStatus == 1 ) {
					TableRow = document.createElement('tr');
					TableRow.className = "row" + tmpStyle;

					TableCell_ImgLinks = document.createElement('td');
					TableCell_ImgLinks.noWrap = true;
					TableCell_ImgLinks.className = "prod_zell_links" + tmpStyle;
					TableCell_ImgLinks.innerHTML = "";
					
					TableCell_1 = document.createElement('td');
					str = "";
					if ( (tmpGruppenID == 2 ||  tmpGruppenID == 6 ) && contextClient != "dk" ) {
						//  && tmpErreichtAbgasnorm != "PMK1" && tmpErreichtAbgasnorm != "PMK2" && tmpErreichtAbgasnorm != "PMK3"
						str = '<a class="gruen" href="berechnung.php?produktid=' + tmpProduktID + '" target="_blank"><img src="gif/geld.gif" border="0" hspace="4" vspace="0" align="bottom" alt="Nachrüstberechnung">Nachrüstberechnung</a>&nbsp;&nbsp;&nbsp;';
					}
					else if ( contextClient != "dk" && ( tmpGruppenID == 3  || tmpGruppenID == 4 || tmpGruppenID == 5 ) ) {
						str = '<a class="gruen" href="steuervorteil.php?produktid=' + tmpProduktID + '" target="_blank"><img src="gif/geld.gif" border="0" hspace="4" vspace="0" align="bottom" alt="Steuervorteil">Steuervorteil</a>&nbsp;&nbsp;&nbsp;';
					}
					if ( tmpFileJPG != "" ) {
//						str = str + '&nbsp;&nbsp;&nbsp;<a class="gruen" href="'+tmpFileJPG+'" onClick="return showImage(\''+tmpFileJPG+'\','+tmpFileJPG_X+','+tmpFileJPG_Y+',\''+tmpBezeichnung+' ('+tmpArtNr+')\');" target="_blank"><img src="gif/jpg.gif" border="0" hspace="3" vspace="2" align="absmiddle" alt="Produktbild">Produktbild</a>';
					}
					if ( tmpFilePDF != "" ) {
						str = str + '<a class="gruen" href="' + tmpFilePDF + '" target="_blank"><img src="gif/pdf.gif" border="0" hspace="4" vspace="0" align="bottom" alt="Einbau- und Betriebsanleitung">Einbau- und Betriebsanleitung</a>&nbsp;&nbsp;&nbsp;';
					}
					if ( contextClient != "dk" )
					{
						str = str + '<a class="gruen" href="index.php?suche=werkstatt" onClick="return SucheDisplay(\'werkstatt\');"><img src="gif/icon_werkstatt.gif" border="0" hspace="4" vspace="0" align="bottom" alt="Werkstattfinder">Werkstattfinder</a>';
					}
					
					TableCell_2 = document.createElement('td');
					TableCell_2.colSpan = 5;
					TableCell_2.innerHTML = str;
	
					TableCell_ImgRechts = document.createElement('td');
					TableCell_ImgRechts.noWrap = true;
					TableCell_ImgRechts.className = "prod_zell_rechts" + tmpStyle;
					TableCell_ImgRechts.innerHTML = "";
	
					TableRow.appendChild(TableCell_ImgLinks);
					TableRow.appendChild(TableCell_1);
					TableRow.appendChild(TableCell_2);
					TableRow.appendChild(TableCell_ImgRechts);
					
					tbody = document.getElementById(tableId).getElementsByTagName("tbody")[0];
					tbody = tbody.appendChild(TableRow);
				}
			}
			document.getElementById("letzteZeile"+tblid).className = "row" + tmpStyle;
			document.getElementById(tableId).style.display = "block";
			ShowLadebalken(false);
		}
	}
}


function myRahmen ( content )
{
//	tmpHTML = '<div class="rahmen_2">';
	tmpHTML = '<b class="rtop">';
	tmpHTML += '<b class="r1"></b> <b class="r2"></b> <b class="r3"></b> <b class="r4"></b></b>';
	tmpHTML += '<div class="rahmeninnen" style="padding:0px;">';
	tmpHTML += content;
	tmpHTML += '</div>';
	tmpHTML += '<b class="rbottom">';
	tmpHTML += '<b class="r4"></b> <b class="r3"></b> <b class="r2"></b> <b class="r1"></b></b>';
	return tmpHTML;
}

/************************************************************************************************************************
										HJS Lieferprogramm - Werkstattadressen
************************************************************************************************************************/

/****************************************
***	Funktion: getAdressen
*** Fragt die Adressen ab, ruft writeAdressen auf
****************************************/

function getAdressen( myForm ) {
	if ( myForm.plzort.value.length >= 2 ) {
		ShowLadebalken(true);

		xmlHttp = GetXmlHttpObject();
		if ( xmlHttp == null || useAJAX == false ) {
			return true;
		}
		else {
			cleanTbodyFromId("ajaxadressen");
			curr_plzort = myForm.plzort.value;
			SeitenNavi();
			var url = "http://www.hjs.com/lieferprogramm/ajax.php";
			var args = "suche=werkstatt&do=getAdressen&plzort=" + escape(myForm.plzort.value);
			xmlHttp.open("POST",url,true);
			xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
			xmlHttp.send(args);
			if ( !(xmlHttp.readyState == 4) ) {
				xmlHttp.onreadystatechange = writeAdressen;
			}
			else {
				writeAdressen();
			}
			return false;
		}
	}
	else {
		alert("Bitte geben Sie mindestens zwei Zeichen ein!");
		return false;
	}
}

/****************************************
***	Funktion: writeAdressen
*** Schreibt die Adressen in eine Tabelle, blendet die Tabelle ein
****************************************/

function writeAdressen() {
	Sleep(waitTime);
	if ( xmlHttp.readyState == 4 ) {
		if (xmlHttp.status == 200) {
			var res = xmlHttp.responseXML;
			tmpStyle = 1;
			if ( res.getElementsByTagName("Adresse").length > 0 )
			{
				for (var i=0; i<res.getElementsByTagName("Adresse").length; i++) {
					if( i % 2 == 0 ) {
						tmpStyle = 2;
					}
					else {
						tmpStyle = 1;
					}
					
					tmpFirma = "";
					if ( res.getElementsByTagName("Adresse")[i].getElementsByTagName("Firma")[0].firstChild ) {
						tmpFirma = res.getElementsByTagName("Adresse")[i].getElementsByTagName("Firma")[0].firstChild.nodeValue;
					}
					
					tmpStrasse = "";
					if ( res.getElementsByTagName("Adresse")[i].getElementsByTagName("Strasse")[0].firstChild ) {
						tmpStrasse = res.getElementsByTagName("Adresse")[i].getElementsByTagName("Strasse")[0].firstChild.nodeValue;
					}
					
					tmpPLZ = "";
					if ( res.getElementsByTagName("Adresse")[i].getElementsByTagName("PLZ")[0].firstChild ) {
						tmpPLZ = res.getElementsByTagName("Adresse")[i].getElementsByTagName("PLZ")[0].firstChild.nodeValue;
					}
					
					tmpOrt = "";
					if ( res.getElementsByTagName("Adresse")[i].getElementsByTagName("Ort")[0].firstChild ) {
						tmpOrt = res.getElementsByTagName("Adresse")[i].getElementsByTagName("Ort")[0].firstChild.nodeValue;
					}
					
					tmpTelefon = "";
					if ( res.getElementsByTagName("Adresse")[i].getElementsByTagName("Telefon")[0].firstChild ) {
						tmpTelefon = res.getElementsByTagName("Adresse")[i].getElementsByTagName("Telefon")[0].firstChild.nodeValue;
					}
					
					
					TableRowAdresse = document.createElement('tr');
					TableRowAdresse.className = "row" + tmpStyle;
	
					TableCell_ImgLinks = document.createElement('td');
					TableCell_ImgLinks.noWrap = true;
					TableCell_ImgLinks.className = "prod_zell_links" + tmpStyle;
					TableCell_ImgLinks.innerHTML = "";
	
					TableCell_Firma = document.createElement('td');
					TableCell_Firma.noWrap = true;
					TableCell_Firma.width = "35%";
					TableCell_Firma.innerHTML = tmpFirma;
	
					TableCell_Strasse = document.createElement('td');
					TableCell_Strasse.noWrap = true;
					TableCell_Strasse.width = "20%";
					TableCell_Strasse.innerHTML = tmpStrasse;
		
					TableCell_PLZ = document.createElement('td');
					TableCell_PLZ.noWrap = true;
					TableCell_PLZ.width = "10%";
					TableCell_PLZ.innerHTML = tmpPLZ;
		
					TableCell_Ort = document.createElement('td');
					TableCell_Ort.noWrap = true;
					TableCell_Ort.width = "20%";
					TableCell_Ort.innerHTML = tmpOrt;
		
					TableCell_Telefon = document.createElement('td');
					TableCell_Telefon.noWrap = true;
					TableCell_Telefon.width = "15%";
					TableCell_Telefon.innerHTML = tmpTelefon;
	
					TableCell_ImgRechts = document.createElement('td');
					TableCell_ImgRechts.noWrap = true;
					TableCell_ImgRechts.className = "prod_zell_rechts" + tmpStyle;
					TableCell_ImgRechts.innerHTML = "";
	
					TableRowAdresse.appendChild(TableCell_ImgLinks);
					TableRowAdresse.appendChild(TableCell_Firma);
					TableRowAdresse.appendChild(TableCell_Strasse);
					TableRowAdresse.appendChild(TableCell_PLZ);
					TableRowAdresse.appendChild(TableCell_Ort);
					TableRowAdresse.appendChild(TableCell_Telefon);
					TableRowAdresse.appendChild(TableCell_ImgRechts);
					
					tbody = document.getElementById("ajaxadressen").getElementsByTagName("tbody")[0];
					tbody = tbody.appendChild(TableRowAdresse);
				}
				document.getElementById("letzteZeileAdressen").className = "row" + tmpStyle;
				document.getElementById("ajaxadressen").style.display = "block";
			}
			else
			{
				alert(textKeineAdressen);
			}
			ShowLadebalken(false);
		}
	}
}

/************************************************************************************************************************
										HJS Lieferprogramm - Auswahlsuche
************************************************************************************************************************/

/****************************************
***	Funktion: getHersteller
*** Fragt alle Hersteller (Beziehung zum Kraftstoff) ab - ruft _writeHersteller_ auf
****************************************/
var loadingHerstellerStarted = false;
function getHersteller( myForm ) {
  if ( !loadingHerstellerStarted )
  {
    loadingHerstellerStarted = true;
  	ShowLadebalken(true);
  	
  	xmlHttp = GetXmlHttpObject();
  	if ( xmlHttp == null || useAJAX == false ) {
    		myForm.hersteller.selectedIndex = -1;
    		myForm.modell.selectedIndex = -1;
  		  myForm.fahrzeugtypen.selectedIndex = -1;
  		  myForm.submit();
  	}
  	else {
  		// Alles loeschen
  		cleanTbodyFromId("produkteAusgabe1");
		cleanTbodyFromId("produktestatic");
  		document.fahrzeugsuche.hersteller.length = 0;
  		document.fahrzeugsuche.modell.length = 0;
  		document.fahrzeugsuche.fahrzeugtypen.length = 0;
  		curr_hersteller = 0;
  		curr_typ = 0;
  		curr_modell = 0;
  		
  		var url = "http://www.hjs.com/lieferprogramm/ajax2.php";
  		var args = "suche=auswahl&do=getHersteller&kraftstoff=" + getRadioValue(myForm.kraftstoff);
  		xmlHttp.open("POST",url,true);
  		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
  		xmlHttp.send(args);
  		if ( !(xmlHttp.readyState == 4) ) {
  			xmlHttp.onreadystatechange = writeHersteller;
  		}
  		else {
  			writeHersteller();
  		}
  	}
   }	
}

/****************************************
***	Funktion: writeHersteller
*** Schreibt die Hersteller in eine Select Liste
****************************************/
function writeHersteller() {
	Sleep(waitTime);
	if ( xmlHttp.readyState == 4 ) {
		if (xmlHttp.status == 200) {
			var res = xmlHttp.responseXML;
			for (var i=0; i<res.getElementsByTagName('hersteller').length; i++) {
				tmpid = res.getElementsByTagName('hersteller')[i].getElementsByTagName('id')[0].firstChild.nodeValue;
		    	tmpheadline = res.getElementsByTagName('hersteller')[i].getElementsByTagName('Bezeichnung')[0].firstChild.nodeValue;
				NeuerEintrag = new Option(tmpheadline, tmpid, false, true);
				document.fahrzeugsuche.hersteller.options[document.fahrzeugsuche.hersteller.length] = NeuerEintrag;
			}
			document.fahrzeugsuche.hersteller.selectedIndex = -1;
		}
	}
	SeitenNavi();
	ShowLadebalken(false);
	loadingHerstellerStarted = false;
}

/****************************************
***	Funktion: getModelle
*** Fragt alle Modelle eines Herstellers ab - ruft _writeModelle_ auf
****************************************/
function getModelle( myForm ) {
	ShowLadebalken(true);
//	document.getElementById("ladeani_herst").style.display = "inline";

	xmlHttp = GetXmlHttpObject();
	if ( xmlHttp == null || useAJAX == false ) {
  		myForm.modell.selectedIndex = -1;
		myForm.fahrzeugtypen.selectedIndex = -1;
		myForm.submit();
	}
	else {
		// Alles loeschen
		cleanTbodyFromId("produkteAusgabe1");
		cleanTbodyFromId("produktestatic");
		document.fahrzeugsuche.modell.length = 0;
		document.fahrzeugsuche.fahrzeugtypen.length = 0;
		curr_hersteller = myForm.hersteller.value;
		curr_typ = 0;
		curr_modell = 0;
		
		var url = "http://www.hjs.com/lieferprogramm/ajax.php";
		var args = "suche=auswahl&do=getModelle&hersteller=" + myForm.hersteller.value + "&kraftstoff=" + getRadioValue(myForm.kraftstoff);
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.send(args);
		if ( !(xmlHttp.readyState == 4) ) {
			xmlHttp.onreadystatechange = writeModelle;
		}
		else {
			writeModelle();
		}
	}
}

/****************************************
***	Funktion: writeModelle
*** Schreibt die Modelle in eine Select Liste
****************************************/
function writeModelle() {
	Sleep(waitTime);
	if ( xmlHttp.readyState == 4 ) {
		if (xmlHttp.status == 200) {
			var res = xmlHttp.responseXML;
			for (var i=0; i<res.getElementsByTagName('modell').length; i++) {
				tmpid = res.getElementsByTagName('modell')[i].getElementsByTagName('id')[0].firstChild.nodeValue;
		    	tmpheadline = res.getElementsByTagName('modell')[i].getElementsByTagName('Bezeichnung')[0].firstChild.nodeValue;
				NeuerEintrag = new Option(tmpheadline, tmpid, false, true);
				document.fahrzeugsuche.modell.options[document.fahrzeugsuche.modell.length] = NeuerEintrag;
			}
			document.fahrzeugsuche.modell.selectedIndex = -1;
		}
	}
	SeitenNavi();
	ShowLadebalken(false);
//	document.getElementById("ladeani_herst").style.display = "none";
}

/****************************************
***	Funktion: getModelleTypen
*** Ruft alle Modelltypen zu einem Modell ab
****************************************/
function getModelleTypen( myForm ) {
	ShowLadebalken(true);
	
	xmlHttp = GetXmlHttpObject();
	if ( xmlHttp == null || useAJAX == false ) {
		myForm.fahrzeugtypen.selectedIndex = -1;
		myForm.submit();
	}
	else {
		// Alles loeschen
		cleanTbodyFromId("produkteAusgabe1");
		cleanTbodyFromId("produktestatic");
		document.fahrzeugsuche.fahrzeugtypen.length = 0;
		curr_typ = 0;
		curr_modell = myForm.modell.value;
		
		var url = "http://www.hjs.com/lieferprogramm/ajax.php";
		var args = "suche=auswahl&do=getTypen&modell=" + myForm.modell.value + "&kraftstoff=" + getRadioValue(myForm.kraftstoff);
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.send(args);
		if ( !(xmlHttp.readyState == 4) ) {
			xmlHttp.onreadystatechange = writeModelleTypen;
		}
		else {
			writeModelleTypen();
		}
	}
}

/****************************************
***	Funktion: writeModelleTypen
*** Schreibt die Modelltypen in eine Select-Liste
****************************************/
function writeModelleTypen() {
	Sleep(waitTime);
	if ( xmlHttp.readyState == 4 ) {
		if (xmlHttp.status == 200) {
			var res = xmlHttp.responseXML;
			for (var i=0; i<res.getElementsByTagName('FahrzeugTyp').length; i++) {
				tmpid = res.getElementsByTagName('FahrzeugTyp')[i].getElementsByTagName('id')[0].firstChild.nodeValue;
		    	tmpheadline = res.getElementsByTagName('FahrzeugTyp')[i].getElementsByTagName('Bezeichnung')[0].firstChild.nodeValue;
				NeuerEintrag = new Option(tmpheadline, tmpid, false, true);
				document.fahrzeugsuche.fahrzeugtypen.options[document.fahrzeugsuche.fahrzeugtypen.length] = NeuerEintrag;
			}
			document.fahrzeugsuche.fahrzeugtypen.selectedIndex = -1;
		}
	}
	SeitenNavi();
	ShowLadebalken(false);
}

/****************************************
***	Funktion: getProdukte
*** Ruft alle Produkte zu einem Modelltypen auf
****************************************/
function getProdukte( myForm ) {
	ShowLadebalken(true);

	xmlHttp = GetXmlHttpObject();
	if ( xmlHttp == null || useAJAX == false ) {
		myForm.submit();
	}
	else {
		cleanTbodyFromId("produkteAusgabe1");
		cleanTbodyFromId("produktestatic");
		curr_typ = myForm.fahrzeugtypen.value;
	
		var url = "http://www.hjs.com/lieferprogramm/ajax.php";
		var args = "suche=auswahl&do=getProdukte&fahrzeugtypen=" + myForm.fahrzeugtypen.value + "&kraftstoff=" + getRadioValue(myForm.kraftstoff);
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.send(args);
		if ( !(xmlHttp.readyState == 4) ) {
			xmlHttp.onreadystatechange = writeProdukte;
		}
		else {
			writeProdukte();
		}
	}
}

/****************************************
***	Funktion: writeProdukte
*** Ruft _writeProdukteFinal_ auf und uebergibt die Tabellen-ID
****************************************/
function writeProdukte() {
	writeProdukteFinal("produkteAusgabe1", 1);
	SeitenNavi();
}

/************************************************************************************************************************
										HJS Lieferprogramm - Schluesselnummersuche
************************************************************************************************************************/
var currentSchluesslHSN = "";
var currentSchluesslTSN = "";
/****************************************
***	Funktion: getModelleTypenS
*** Ruft die Modelltypen ab, wenn HSN und TSN eingeben wurden
****************************************/
var loadingSchluesslStarted = false;
function getModelleTypenS ( myForm ) {
	if ( !loadingSchluesslStarted )
  	{
    	loadingSchluesslStarted = true;
		if ( myForm.hsn.value != "" && myForm.tsn.value != "" ) {
			ShowLadebalken(true);
			
			xmlHttp = GetXmlHttpObject();
			if ( xmlHttp == null || useAJAX == false ) {
				return true;
			}
			else {
				curr_hsn = myForm.hsn.value;
				curr_tsn = myForm.tsn.value;
				currentSchluesslHSN = curr_hsn;
				currentSchluesslTSN = curr_tsn;
				cleanTbodyFromId("typenS");
				cleanTbodyFromId("produkteAusgabe2");
				cleanTbodyFromId("produktestatic");
				SeitenNavi();
				
				var url = "http://www.hjs.com/lieferprogramm/ajax.php";
				var args = "suche=schluesselnr&do=getTypenS&kraftstoff=" + getRadioValue(myForm.kraftstoff) + "&hsn=" + myForm.hsn.value + "&tsn=" + myForm.tsn.value;
	//			alert(args);
				xmlHttp.open("POST",url,true);
				xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
				xmlHttp.send(args);
				if ( !(xmlHttp.readyState == 4) ) {
					xmlHttp.onreadystatechange = writeModelleTypenS;
				}
				else {
					writeModelleTypenS();
				}
				return false;
			}
		}
		else {
			var count = 0;
			var txt = new Array(2);
			if ( myForm.hsn.value == "" ) {
				txt[count] = "zu 2 oder 2.1";
				count += 1;
			}
			if ( myForm.tsn.value == "" ) {
				txt[count] = "zu 3 oder 2.2";
				count += 1;
			}
			if (count >= 2) {
				text1 = "Folgende Felder müssen Sie noch ausgefüllen:\n";
			}
			else {
				text1 = "Füllen Sie bitte auch noch das folgende Feld aus:\n";
			}
	
			for (i=0; i < count; i++) {
				text1 += "- " + txt[i] + "\n";
			}
			alert(text1);
			return false;
		}
	}
}

/****************************************
***	Funktion: writeModelleTypenS
*** Schreibt die Modelle in eine Tabelle
****************************************/
function writeModelleTypenS () {
	Sleep(waitTime);
	anzahl = 0;
	if ( xmlHttp.readyState == 4 ) {
		if (xmlHttp.status == 200) {
			var res = xmlHttp.responseXML;
			for (var i=0; i<res.getElementsByTagName("FahrzeugTyp").length; i++) {
				anzahl = anzahl + 1;
				tmpKTypNr = res.getElementsByTagName("FahrzeugTyp")[i].getElementsByTagName("KTypNr")[0].firstChild.nodeValue;
				tmpHersteller = res.getElementsByTagName("FahrzeugTyp")[i].getElementsByTagName("Hersteller")[0].firstChild.nodeValue;
				tmpModell = res.getElementsByTagName("FahrzeugTyp")[i].getElementsByTagName("Modell")[0].firstChild.nodeValue;
				tmpBezeichnung = res.getElementsByTagName("FahrzeugTyp")[i].getElementsByTagName("Bezeichnung")[0].firstChild.nodeValue;
				tmpHubraum = res.getElementsByTagName("FahrzeugTyp")[i].getElementsByTagName("ccmTech")[0].firstChild.nodeValue;
				tmpKW = res.getElementsByTagName("FahrzeugTyp")[i].getElementsByTagName("kW")[0].firstChild.nodeValue;
				tmpPS = res.getElementsByTagName("FahrzeugTyp")[i].getElementsByTagName("PS")[0].firstChild.nodeValue;

				TableRow = document.createElement('tr');
				TableRow.className = "row3";
				TableRow.id = "styp" + tmpKTypNr;

				
				if (TableRow.addEventListener) {
					TableRow.addEventListener("mouseover", function(evt) { 
						obj = evt.target;
						while ( !(obj.tagName == "TR") )
						{
							obj = obj.parentNode;
						}
						tmpid = obj.id;
						document.getElementById(tmpid).className = 'row3over';
			   		}, false);
					TableRow.addEventListener("mouseout", function(evt) { 
						obj = evt.target;
						while ( !(obj.tagName == "TR") )
						{
							obj = obj.parentNode;
						}
						tmpid = obj.id;
						document.getElementById(tmpid).className = 'row3';
			   		}, false);
					TableRow.addEventListener("click", function(evt) { 
						obj = evt.target;
						while ( !(obj.tagName == "TR") )
						{
							obj = obj.parentNode;
						}
						tmpid = obj.id;
						document.schluesselnrsuche.fahrzeugtypen2.value = tmpid.replace("styp","");
						getProdukte2();
			   		}, false);
  				}
				else if (TableRow.attachEvent) {
    				TableRow.attachEvent("onmouseover", function(evt) { 
						obj = evt.srcElement;
						while ( !(obj.tagName == "TR") )
						{
							obj = obj.parentElement;
						}
						tmpid = obj.id;
						document.getElementById(tmpid).className = 'row3over'
			   		});
    				TableRow.attachEvent("onmouseout", function(evt) { 
						obj = evt.srcElement;
						while ( !(obj.tagName == "TR") )
						{
							obj = obj.parentElement;
						}
						tmpid = obj.id;
						document.getElementById(tmpid).className = 'row3'
			   		});
    				TableRow.attachEvent("onclick", function(evt) { 
						obj = evt.srcElement;
						while ( !(obj.tagName == "TR") )
						{
							obj = obj.parentElement;
						}
						tmpid = obj.id;
						document.schluesselnrsuche.fahrzeugtypen2.value = tmpid.replace("styp","");
						getProdukte2();
			   		});
				}

				TableCell_ImgLinks = document.createElement('td');
				TableCell_ImgLinks.noWrap = true;
				TableCell_ImgLinks.className = "prod_zell_links3";
				TableCell_ImgLinks.innerHTML = "";

				TableCell_Hersteller = document.createElement('td');
				TableCell_Hersteller.noWrap = true;
				TableCell_Hersteller.innerHTML = tmpHersteller;

				TableCell_Modell = document.createElement('td');
				TableCell_Modell.innerHTML = tmpModell;
	
				TableCell_Bezeichnung = document.createElement('td');
				TableCell_Bezeichnung.noWrap = true;
				TableCell_Bezeichnung.align = "center";
				TableCell_Bezeichnung.innerHTML = tmpBezeichnung;
	
				TableCell_Hubraum = document.createElement('td');
				TableCell_Hubraum.noWrap = true;
				TableCell_Hubraum.align = "center";
				TableCell_Hubraum.innerHTML = tmpHubraum + " ccm";
	
				TableCell_kWPS = document.createElement('td');
				TableCell_kWPS.noWrap = true;
				TableCell_kWPS.align = "center";
				TableCell_kWPS.innerHTML = tmpKW + "kW / " + tmpPS + " PS";

				TableCell_ImgRechts = document.createElement('td');
				TableCell_ImgRechts.noWrap = true;
				TableCell_ImgRechts.className = "prod_zell_rechts3";
				TableCell_ImgRechts.innerHTML = "";

				TableRow.appendChild(TableCell_ImgLinks);
				TableRow.appendChild(TableCell_Hersteller);
				TableRow.appendChild(TableCell_Modell);
				TableRow.appendChild(TableCell_Bezeichnung);
				TableRow.appendChild(TableCell_Hubraum);
				TableRow.appendChild(TableCell_kWPS);
				TableRow.appendChild(TableCell_ImgRechts);
				
				tbody = document.getElementById("typenS").getElementsByTagName("tbody")[0];
				tbody = tbody.appendChild(TableRow);
			}
			if ( anzahl > 0 ) {
				document.getElementById("typenS").style.display = "block";
				document.getElementById("schluessl_step2").style.display = "block";
				document.getElementById("schluessl_step1").style.display = "none";
			}
			else
			{
				alert("Dieses Fahrzeug ist nicht in unserem Programm. Prüfen Sie bitte die Kraftstoffart");
			}
		}
		tbody = document.getElementById("typenS").getElementsByTagName("tbody")[0];
	}
	ShowLadebalken(false);
	loadingSchluesslStarted = false;
}

/****************************************
***	Funktion: getProdukte2
*** Ruft die Produkte zu dem angeklickten Modelltypen ab
****************************************/
function getProdukte2( ) {
	ShowLadebalken(true);
	xmlHttp = GetXmlHttpObject();
	if ( xmlHttp == null || useAJAX == false ) {
		document.schluesselnrsuche.submit();
	}
	else {
		var curr_typ2 = document.schluesselnrsuche.fahrzeugtypen2.value;
		cleanTbodyFromId("produkteAusgabe2");
		cleanTbodyFromId("produktestatic");
		SeitenNavi();
		var url = "http://www.hjs.com/lieferprogramm/ajax.php";
		var args = "suche=auswahl&do=getProdukte2&fahrzeugtypen=" + document.schluesselnrsuche.fahrzeugtypen2.value;
		args = args + "&kraftstoff=" + getRadioValue(document.schluesselnrsuche.kraftstoff) + "&hsn=" + currentSchluesslHSN + "&tsn=" + currentSchluesslTSN;
		xmlHttp.open("POST",url,true);
		xmlHttp.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
		xmlHttp.send(args);
		if ( !(xmlHttp.readyState == 4) ) {
			xmlHttp.onreadystatechange = writeProdukte2;
		}
		else {
			writeProdukte2();
		}
	}
}

/****************************************
***	Funktion: writeProdukte
*** Ruft _writeProdukteFinal_ auf und uebergibt die Tabellen-ID
****************************************/
function writeProdukte2() {
	writeProdukteFinal("produkteAusgabe2", 2);
}

/****************************************
***	Funktion: rewriteSchlNrn
*** 
****************************************/
function rewriteSchlNrn ( frm )
{
	document.schluesselnrsuche2.hsn.value = frm.hsn.value;
	document.schluesselnrsuche2.tsn.value = frm.tsn.value;
}


function checkenter ( e, frm )
{
	ok = false;
	if(window.event) // IE
	{
		keynum = e.keyCode;
	}
	else if(e.which) // Netscape/Firefox/Opera
	{
		keynum = e.which;
	}

	if ( keynum == 13 )
	{
		ok = true;
		if ( getModelleTypenS(frm) )
		{
			frm.submit();
		}
	}
	return ok;
}

/************************************************************************************************************************
										HJS Lieferprogramm - DHTML History
************************************************************************************************************************/
if ( useHistory ) {
	window.dhtmlHistory.create();
	
	var isLinkForward = false;
	var Bugfix = 0;
	
	var yourListener = function(newLocation, historyData) {
		if ( !isLinkForward  && Bugfix == 0) {
			InitVars();
		}
		if ( Bugfix == 0 ) {
			Bugfix = 1;
		}
		else {
			Bugfix = 0;	
		}
		isLinkForward = false;
	}
}

/************************************************************************************************************************
												Libary
************************************************************************************************************************/

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

/****************************************
***	Funktion: Sleep
*** Verzoegert die Ausfuerung um ms-Millisekunden
****************************************/

function Sleep ( ms ) { 
	var zeit = (new Date()).getTime(); 
	var stoppZeit = zeit+ms; 
	while((new Date()).getTime()<stoppZeit){}; 
}

/****************************************
***	Funktion: getRadioValue
*** Holt den Value einer Radio Liste
****************************************/

function getRadioValue( obj ) {
	for ( i = 0; i < obj.length; i++ ) {
		if ( obj[i].checked) {
			return obj[i].value;
		}
  	}
	return false;
}

function grau2black ( feld )
{
	if ( feld.className == "grau" )
	{
		feld.value = "";
		feld.className = "";
	}
}

