<!--

// Bergmann 11.02.2010
//
// Offen: Warum steht in der Matrix " Press" mit Blank?

// Bergmann 16.08.2011: 
//   V2.1: 6er Serie eingefügt. 6x4er sind 354-kompatibel

var link1="";
var link2="";
var link3="";
var ofen_type354=new Array("AUSTROMAT 354 press-i-dent","AUSTROMAT 424","AUSTROMAT 444press","AUSTROMAT 654 press-i-dent","AUSTROMAT 644","AUSTROMAT 624");  //diese Öfen verwenden den gleichen "Datensatz" mit der Bez. 354
var ofen_typePress=new Array("AUSTROMAT 354 press-i-dent","AUSTROMAT 424","AUSTROMAT 444press","AUSTROMAT 654 press-i-dent","AUSTROMAT 644"); //die können Pressen

function ofen2parameter(ofen,parameter) {
	var kenn;
	if      (ofen == "AUSTROMAT D2"               ) {kenn = "d2";		mat=m; indx=0 }
	else if (ofen == "AUSTROMAT D4"               ) {kenn = "d4";		mat=m; indx=1 }
	else if (ofen == "AUSTROMAT M"                ) {kenn = "m";		mat=m; indx=2 }
	else if (ofen == "AUSTROMAT 3001"             ) {kenn = "3001";		mat=m; indx=3 }
	else if (ofen == "AUSTROMAT 3001 press-i-dent") {kenn = "press";	mat=m; indx=4 }
	
	else if (ofen == "AUSTROMAT D2HD"             ) {kenn = "d2hd";		mat=mr; indx=0 }
	else if (ofen == "AUSTROMAT D4press"          ) {kenn = "d4press";	mat=mr; indx=1 }
	else if (ofen == "AUSTROMAT µSiC"             ) {kenn = "msic";		mat=mr; indx=2 }
	else if (ofen == "AUSTROMAT baSiC"            ) {kenn = "bsic";		mat=mr; indx=2 } //same as msic
	
	else if (ofen == "AUSTROMAT 354 press-i-dent" ) {kenn = "354";		mat=m3; indx=1 }
	else if (ofen == "AUSTROMAT 424"              ) {kenn = "424";		mat=m3; indx=1 }
	else if (ofen == "AUSTROMAT 654 press-i-dent" ) {kenn = "654";		mat=m3; indx=1 }  //Pressofen
	else if (ofen == "AUSTROMAT 644"              ) {kenn = "644";		mat=m3; indx=1 }  //Pressofen
	else if (ofen == "AUSTROMAT 624"              ) {kenn = "624";		mat=m3; indx=1 }  // kein Pressofen

	else { kenn="??"}
	if ( parameter == "kennung") return kenn;
	if ( parameter == "matrix") return mat;
	if (parameter == "index" ) return indx;
}

function is354compat(ofen){ 
	var i;
	for ( i in ofen_type354 ) {
		if ( ofen_type354[i] == ofen ) return 1;
	}
	return 0;
}

function isPress(ofen){
	var i;
	for ( i in ofen_typePress ) {
		if ( ofen_typePress[i] == ofen ) return 1;
	}
	return 0;
}

function get_lang(){
	var sprache = document.getElementById("choice_lang").options[document.getElementById("choice_lang").selectedIndex].text;
	var lang;
	if      (sprache == "deutsch"  ) {lang = "de";}
	else if (sprache == "english"  ) {lang = "en";}
	else if (sprache == "francais" ) {lang = "fr";}
	else if (sprache == "espanol"  ) {lang = "es";}
	else if (sprache == "italiano" ) {lang = "it";}
	return lang;
}

function get_progtype(){
	var progtype = document.getElementById("choice_progtype").options[document.getElementById("choice_progtype").selectedIndex].text;
	var lang;
	if      (progtype == "Classic"  ) 	{lang = "c";}
	else if (progtype == "Professional"  ) 	{lang = "p";}
	else if (progtype == "Easy" ) 		{lang = "e";}
	return lang;
}

function updateChoice_oven() {
	
	var action0 = new Array("AUSTROMAT 654 press-i-dent","AUSTROMAT 644","AUSTROMAT 624",
		  "AUSTROMAT 354 press-i-dent","AUSTROMAT 3001 press-i-dent","AUSTROMAT D4press",
		  "AUSTROMAT 424","AUSTROMAT D4","AUSTROMAT D2","AUSTROMAT 3001","AUSTROMAT M","AUSTROMAT µSiC","AUSTROMAT baSiC")
	var action1 = new Array("AUSTROMAT µSiC","AUSTROMAT baSiC");
	var action2 = new Array("AUSTROMAT 654 press-i-dent","AUSTROMAT 644","AUSTROMAT 354 press-i-dent","AUSTROMAT 3001 press-i-dent","AUSTROMAT D4press");
	var action3 = new Array("AUSTROMAT 654 press-i-dent","AUSTROMAT 644","AUSTROMAT 624",
		  "AUSTROMAT 354 press-i-dent","AUSTROMAT 3001 press-i-dent","AUSTROMAT D4press","AUSTROMAT 424","AUSTROMAT D4","AUSTROMAT D2","AUSTROMAT 3001","AUSTROMAT M");
	var init_later = 1;
	var old_ofen = "";
	
	if (dateiformat=="pdf") { // keine PDFs für "neue" Öfen 424 und 354
	   action0 = new Array("AUSTROMAT 3001 press-i-dent","AUSTROMAT D4press","AUSTROMAT D4","AUSTROMAT D2","AUSTROMAT 3001","AUSTROMAT M","AUSTROMAT µSiC","AUSTROMAT baSiC")
	   action3 = new Array("AUSTROMAT 3001 press-i-dent","AUSTROMAT 3001","AUSTROMAT M","AUSTROMAT D2","AUSTROMAT D4","AUSTROMAT D4press");
	}
	 // bei den PDFs gibt es keine 354 und 424er.
	try { 
		old_ofen    = document.getElementById("choice_ofen").options[document.getElementById("choice_ofen").selectedIndex].text;
		actionindex = document.getElementById("choice_action").selectedIndex;
	}
	catch(err){
		actionindex = 0;
	}
	//actionindex = document.getElementById("choice_action").selectedIndex;
	//action    = document.getElementById("choice_action").options[document.getElementById("choice_action").selectedIndex].text;
	
	if (actionindex == 0) {
		document.getElementById("choice_ofen").length = action0.length;
		for (i=0;i<action0.length;i++) {
				document.getElementById("choice_ofen").options[i].text = action0[i]; 
				if (old_ofen == action0[i]) { 
					document.getElementById("choice_ofen").options[i].selected = true;
					init_later=0;
				}
		}
	}

	if (actionindex == 1) {
		document.getElementById("choice_ofen").length = action1.length;
		for (i=0;i<action1.length;i++) {
			document.getElementById("choice_ofen").options[i].text = action1[i]; 
			if (old_ofen == action1[i]) { document.getElementById("choice_ofen").options[i].selected = true;
				init_later=0;
			}
		}
	}

	if (actionindex == 2) {
		document.getElementById("choice_ofen").length = action2.length;
		for (i=0;i<action2.length;i++) {
			document.getElementById("choice_ofen").options[i].text = action2[i]; 
			if (old_ofen == action2[i]) { document.getElementById("choice_ofen").options[i].selected = true;
				init_later=0;
			}
		}
	}

    if (actionindex == 3) {
		document.getElementById("choice_ofen").length = action3.length;
		for (i=0;i<action3.length;i++) {
			document.getElementById("choice_ofen").options[i].text = action3[i]; 
			if (old_ofen == action3[i]) { document.getElementById("choice_ofen").options[i].selected = true;
				init_later=0;
			}
		}
	}
	if (init_later == 1){document.getElementById("choice_ofen").options[0].selected = true;}
	updateChoice_progtype()
}


function updateChoice_progtype() {
	
	ofen      = document.getElementById("choice_ofen").options[document.getElementById("choice_ofen").selectedIndex].text;

	if (isPress(ofen) == 1){
		document.getElementById("choice_progtype").length = 3
		document.getElementById("choice_progtype").options[0].text = "Easy";
		document.getElementById("choice_progtype").options[1].text = "Professional";
		document.getElementById("choice_progtype").options[1].selected = true;
		document.getElementById("choice_progtype").options[2].text = "Classic";
		displayDiv('progtype');
	}
	else hideDiv('progtype');
	updateChoice_herst()
}


function updateChoice_herst() {
	
	ofen      = document.getElementById("choice_ofen").options[document.getElementById("choice_ofen").selectedIndex].text;

	handle_oven(ofen);
	updatePhotos();
	
}


function hideDiv(id){
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function displayDiv(id){
	
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}	
}
	
	
function handle_oven(my_oven){

	var matrix=ofen2parameter(my_oven,"matrix");
	var matrix_index=ofen2parameter(ofen,"index");
	var actionindex = document.getElementById("choice_action").selectedIndex;
	var old_herst;

	if ( actionindex == 2 ){	//pressen: Hersteller wird versteckt und auf Pressprogramme gesetzt
			document.getElementById("choice_herst").length = 1;
			document.getElementById("choice_herst").options[0].text = " Press";
			document.getElementById("choice_herst").options[0].selected = true;
			hideDiv('hersteller');
			if (is354compat(my_oven)==1){
			  hideDiv('progtype');
			  matrix_index = 3;  //354pp (derzeit gibt es nur den pseudo-Hersteller "press", also "354pp-press-de.dds"
			}
			hidden_hersteller=1;
			return;
	} 

	else {  //wenn NICHT pressen:
		displayDiv('hersteller');
		hidden_hersteller=0;	

		if (is354compat(my_oven)==1){
			displayDiv('progtype');  //jetzt stimmt der Matrix_index!
			try {
			    progtype = document.getElementById("choice_progtype").options[document.getElementById("choice_progtype").selectedIndex].text;
			}
			catch(err){}
			switch (progtype){
				case "Classic":		matrix_index = 0;break;
				case "Easy":		matrix_index = 1;break;
				case "Professional": matrix_index = 2;break;
				default: matrix_index = 0;break;
			}
		
			
		
			// ... 354c   354e     354p   354pp  --
		}
		else{		// alter Ofen
			if (document.getElementById("choice_herst").selectedIndex >= 0) {
				try {
					hersteller = document.getElementById("choice_herst").options[document.getElementById("choice_herst").selectedIndex].text;
				}
				catch(err) {
					//hersteller="";
				}
			}
		}
		
	//	opera.postError(matrix_index + "  "+my_oven);
		try { 
			old_herst    = document.getElementById("choice_herst").options[document.getElementById("choice_herst").selectedIndex].text;
		}
		catch(err){	old_herst    = ""}
		j=0;
		document.getElementById("choice_herst").length = 200;  //erst riiichtig viele Options zulassen
		for (i=0;i<matrix.length;i++){
			if (matrix[i][matrix_index]>0) {
				if ( matrix[i][5]!="press" ) {
					document.getElementById("choice_herst").options[j].text = matrix[i][6];
					if (matrix[i][6]==old_herst) document.getElementById("choice_herst").options[j].selected=true;
					j++;
				}
			}
		}
		document.getElementById("choice_herst").length = j;  //auf richtige Länge bringen
	}
}
	

	
function updatePhotos() {

	var ofenindex 	= document.getElementById("choice_ofen").selectedIndex;
	var ofen      	= document.getElementById("choice_ofen").options[ofenindex].text;
	var hersteller  // könnte versteckt sein, wenn nur Press-Programme gehen
	var matrix		= ofen2parameter(ofen,"matrix");
	var matrix_index= ofen2parameter(ofen,"index");

	var kenn=ofen2parameter(ofen,"kennung");
	var lang=get_lang();

	try { hersteller	= document.getElementById("choice_herst").options[document.getElementById("choice_herst").selectedIndex].text;}
	catch(err){}
// versteckte Felder werden nicht immer konsistent behandelt, daher merken wir uns das über eine Variable, 
// denn wenn der Hersteller versteckt ist, dann muss es PRESS sein
	if (hidden_hersteller==1) hersteller=" Press";
	
	for (i=0; i<matrix.length; i++) {
		if (hersteller == matrix[i][6]) {  //im index=6 steht immer der Hersteller-Name
 				n2 = matrix[i][5];
				switch (matrix[i][matrix_index]){
					case "1":{s1 = "";   s2 = "-leer"; s3 = "-leer";break;}
					case "2":{s1 = "-1"; s2 = "-2";    s3 = "-leer";break;}
					case "3":{s1 = "-1"; s2 = "-2";    s3 = "-3"   ;break;}
				}
		}
	}

	if (dateiformat=="dds") {
		document.getElementById("photo01").src = "../../images/download/b-o-"+kenn+".gif";
		document.getElementById("photo04").src = "../../images/download/b-k-"+n2+".gif";
		document.getElementById("photo07").src = "../../images/download/b-s-dds"+s1+".gif";
		if (s2 == "-leer") {
			document.getElementById("photo02").src = "../../images/download/b-o-leer.gif";
			document.getElementById("photo05").src = "../../images/download/b-k-leer.gif";
			document.getElementById("photo08").src = "../../images/download/b-s-leer.gif";
		}
		else {
			document.getElementById("photo02").src = "../../images/download/b-o-"+kenn+".gif";
			document.getElementById("photo05").src = "../../images/download/b-k-"+n2+".gif";
			document.getElementById("photo08").src = "../../images/download/b-s-dds"+s2+".gif";
		}
		if (s3 == "-leer") {
			document.getElementById("photo03").src = "../../images/download/b-o-leer.gif";
			document.getElementById("photo06").src = "../../images/download/b-k-leer.gif";
			document.getElementById("photo09").src = "../../images/download/b-s-leer.gif";
		}
		else {
			document.getElementById("photo03").src = "../../images/download/b-o-"+kenn+".gif";
			document.getElementById("photo06").src = "../../images/download/b-k-"+n2+".gif";
			document.getElementById("photo09").src = "../../images/download/b-s-dds"+s3+".gif";
		}
		document.getElementById("photo10").src = "../../images/download/b-t-"+lang+s1+".gif";
		document.getElementById("photo11").src = "../../images/download/b-t-"+lang+s2+".gif";
		document.getElementById("photo12").src = "../../images/download/b-t-"+lang+s3+".gif";

	}
	else if (dateiformat=="pdf") {
					
		document.getElementById("photo1").src = "../../images/download/b-o-"+kenn+".gif";
		document.getElementById("photo2").src = "../../images/download/b-k-"+n2+".gif";
	
	}

	updateLinks();

}


function updateLinks() {
	var lang=get_lang();
	var kenn=ofen2parameter(ofen,"kennung"); // Ofenkennung, zB 3001, d4, 354
	var ekenn;  // Erweiterte Kennung für Multifunktions-Öfen: c,p,e,pp
	var actionindex = document.getElementById("choice_action").selectedIndex;
	var ptype="";
	if ( is354compat(ofen)==1 ) ptype=get_progtype();
	if ( isPress(ofen) && actionindex == 2 ) ptype="pp"; //Es gibt gerade nur ein Press-Programmset. In dem Fall heisst das Programm 354pp
	ekenn=kenn+ptype;
	if (dateiformat=="dds") {
		link1=ekenn+"-"+n2+"-"+lang+s1+".dds";
		link2=ekenn+"-"+n2+"-"+lang+s2+".dds";
		link3=ekenn+"-"+n2+"-"+lang+s3+".dds";
		
		if (s2 == "-leer" && s3 == "-leer") {
			link2=link1;
			link3=link1;
		}
		
		else if (s2 == "-2" && s3 == "-leer") {
			link3=link2;
		}

	}
	else if (dateiformat=="pdf") {
		link1=ekenn+"-"+n2+"-"+lang+".pdf";
		link2=link1;
		link3=link1;
	}
	
	linkloc1 = link1;  // linkloc: echter Dateiname ; link: unter diesem Namen wird die Datei serviert 
	linkloc2 = link2;
	linkloc3 = link3;
	if ( is354compat(ofen)==1 ){
		linkloc1 = link1.replace(kenn,"354");
		linkloc2 = link2.replace(kenn,"354");
		linkloc3 = link3.replace(kenn,"354");
	}
	if ( kenn == "bsic" ){
		linkloc1 = link1.replace(kenn,"msic");
		linkloc2 = link2.replace(kenn,"msic");
		linkloc3 = link3.replace(kenn,"msic");
	}

	linkloc1=dateiformat+"/"+linkloc1;  //hier noch das Verzeichnis (dds/ oder pdf/ einfügen
	linkloc2=dateiformat+"/"+linkloc2;
	linkloc3=dateiformat+"/"+linkloc3;
//opera.postError("serving: "+linkloc1+"&"+link1+"   "+linkloc2+"&"+link2+"    "+linkloc3+"&"+link3)
	

}

function linkme(link) {
	
	link1d="../../javascript/serve_dds.php?file="+linkloc1+"&t_name="+link1; // serviert eine Datei unter einem anderen Namen
	link2d="../../javascript/serve_dds.php?file="+linkloc2+"&t_name="+link2;
	link3d="../../javascript/serve_dds.php?file="+linkloc3+"&t_name="+link3;

	switch (link) {
		case 1: wd=window.open(link1d,'_blank');break;
		case 2: wd=window.open(link2d,'_blank');break;
		case 3: wd=window.open(link3d,'_blank');break;
		default: break;
	}

}



// -->

