
/*--------------------------------------------------------------------------
 *  CAD Download-Configurator
 *  (c) 2008 Anton Fuchs
 *  25.07.2008
 *--------------------------------------------------------------------------*/	


/*--------------------------------------------------------------------------
 *  Füllen der Combobox P1
 *--------------------------------------------------------------------------*/		
function fillP1 () {

	var i1 = -1;
	var merk = new Object();
	for (var i2 = 0; i2 < PropValues.length -1 ; i2++) {
		
		if (typeof( merk[PropValues[i2][4]]) == "undefined"){
	        	merk[PropValues[i2][4]]=true;
			i1++;
			document.FOconfigurator.P1.options[i1] = new Option(unescape(PropValueText[pLanguage + "-1-" + PropValues[i2][4]]),PropValues[i2][4]);
	        }
	}
	changedP1();	
}
/*--------------------------------------------------------------------------
 *  Füllen der Combobox P2
 *--------------------------------------------------------------------------*/		
function fillP2 () {


	var Anz = document.FOconfigurator.P2.length;
	for (var i2 = 0; i2 <= Anz; i2++){
		document.FOconfigurator.P2.options[0]=null;
        }

	var i1 = -1;
	var merk = new Object();
	for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4]){
			if (typeof( merk[PropValues[i2][5]]) == "undefined"){
		        	merk[PropValues[i2][5]]=true;
				i1++;
				document.FOconfigurator.P2.options[i1] = new Option(unescape(PropValueText[pLanguage + "-2-" + PropValues[i2][5]]),PropValues[i2][5]);
		        }
		}
	}
	changedP2();
}
/*--------------------------------------------------------------------------
 *  Füllen der Combobox P3
 *--------------------------------------------------------------------------*/		
function fillP3 () {
	var Anz = document.FOconfigurator.P3.length;
	for (var i2 = 0; i2 <= Anz; i2++){
		document.FOconfigurator.P3.options[0]=null;
        }
	var i1 = -1;
	var merk = new Object();
	for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] &&  
		    document.FOconfigurator.P2.value == PropValues[i2][5]){
			if (typeof( merk[PropValues[i2][6]]) == "undefined"){
		        	merk[PropValues[i2][6]]=true;
				i1++;
				document.FOconfigurator.P3.options[i1] = new Option(unescape(PropValueText[pLanguage + "-3-" + PropValues[i2][6]]),PropValues[i2][6]);
		        }
		}
	}
	changedP3();	
}
/*--------------------------------------------------------------------------
 *  Füllen der Combobox P4
 *--------------------------------------------------------------------------*/		
function fillP4 () {
	var Anz = document.FOconfigurator.P4.length;
	for (var i2 = 0; i2 <= Anz; i2++){
		document.FOconfigurator.P4.options[0]=null;
        }
	var i1 = -1;
	var merk = new Object();
	for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] &&  
		    document.FOconfigurator.P2.value == PropValues[i2][5] &&
		    document.FOconfigurator.P3.value == PropValues[i2][6]){
			if (typeof( merk[PropValues[i2][7]]) == "undefined"){
		        	merk[PropValues[i2][7]]=true;
				i1++;
				document.FOconfigurator.P4.options[i1] = new Option(unescape(PropValueText[pLanguage + "-4-" + PropValues[i2][7]]),PropValues[i2][7]);
		        }
		}
	}
	changedP4();	
}
/*--------------------------------------------------------------------------
 *  Füllen der Combobox P5
 *--------------------------------------------------------------------------*/		
function fillP5 () {
	var Anz = document.FOconfigurator.P5.length;
	for (var i2 = 0; i2 <= Anz; i2++){
		document.FOconfigurator.P5.options[0]=null;
        }
	var i1 = -1;
	var merk = new Object();
	for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] &&  
		    document.FOconfigurator.P2.value == PropValues[i2][5] &&
		    document.FOconfigurator.P3.value == PropValues[i2][6] &&
		    document.FOconfigurator.P4.value == PropValues[i2][7]){
			if (typeof( merk[PropValues[i2][8]]) == "undefined"){
		        	merk[PropValues[i2][8]]=true;
				i1++;
				document.FOconfigurator.P5.options[i1] = new Option(unescape(PropValueText[pLanguage + "-5-" + PropValues[i2][8]]),PropValues[i2][8]);
		        }
		}
	}
	changedP5();	
}
/*--------------------------------------------------------------------------
 *  Füllen der Combobox P6
 *--------------------------------------------------------------------------*/		
function fillP6 () {
	var Anz = document.FOconfigurator.P6.length;
	for (var i2 = 0; i2 <= Anz; i2++){
		document.FOconfigurator.P6.options[0]=null;
        }
	var i1 = -1;
	var merk = new Object();
	for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] &&  
		    document.FOconfigurator.P2.value == PropValues[i2][5] &&
		    document.FOconfigurator.P3.value == PropValues[i2][6] &&
		    document.FOconfigurator.P4.value == PropValues[i2][7] &&
		    document.FOconfigurator.P5.value == PropValues[i2][8]){
			if (typeof( merk[PropValues[i2][9]]) == "undefined"){
		        	merk[PropValues[i2][9]]=true;
				i1++;
				document.FOconfigurator.P6.options[i1] = new Option(unescape(PropValueText[pLanguage + "-6-" + PropValues[i2][10]]),PropValues[i2][10]);
		        }
		}
	}
	changedP6();	
}
/*--------------------------------------------------------------------------
 *  Füllen der Combobox P7
 *--------------------------------------------------------------------------*/		
function fillP7 () {
	var Anz = document.FOconfigurator.P7.length;
	for (var i2 = 0; i2 <= Anz; i2++){
		document.FOconfigurator.P7.options[0]=null;
        }
	var i1 = -1;
	var merk = new Object();
	for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] &&  
		    document.FOconfigurator.P2.value == PropValues[i2][5] &&
		    document.FOconfigurator.P3.value == PropValues[i2][6] &&
		    document.FOconfigurator.P4.value == PropValues[i2][7] &&
		    document.FOconfigurator.P5.value == PropValues[i2][8] &&
		    document.FOconfigurator.P6.value == PropValues[i2][9]){
			if (typeof( merk[PropValues[i2][10]]) == "undefined"){
		        	merk[PropValues[i2][10]]=true;
				i1++;
				document.FOconfigurator.P7.options[i1] = new Option(unescape(PropValueText[pLanguage + "-7-" + PropValues[i2][10]]),PropValues[i2][10]);
		        }
		}
	}
	changedP7();	
}
/*--------------------------------------------------------------------------
 *  Füllen der Combobox P8
 *--------------------------------------------------------------------------*/		
function fillP8 () {
	var Anz = document.FOconfigurator.P8.length;
	for (var i2 = 0; i2 <= Anz; i2++){
		document.FOconfigurator.P8.options[0]=null;
        }
	var i1 = -1;
	var merk = new Object();
	for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] &&  
		    document.FOconfigurator.P2.value == PropValues[i2][5] &&
		    document.FOconfigurator.P3.value == PropValues[i2][6] &&
		    document.FOconfigurator.P4.value == PropValues[i2][7] &&
		    document.FOconfigurator.P5.value == PropValues[i2][8] &&
		    document.FOconfigurator.P6.value == PropValues[i2][9] &&
		    document.FOconfigurator.P7.value == PropValues[i2][10]){
			if (typeof( merk[PropValues[i2][11]]) == "undefined"){
		        	merk[PropValues[i2][11]]=true;
				i1++;
				document.FOconfigurator.P8.options[i1] = new Option(unescape(PropValueText[pLanguage + "-8-" + PropValues[i2][11]]),PropValues[i2][11]);
		        }
		}
	}
	changedP8();	
}








/*--------------------------------------------------------------------------
 *  Haupteinrichtungsscript beim Laden Der Seite
 *--------------------------------------------------------------------------*/		
function loadPage ( ){
	
	if (PropCount > 0) {
		document.FOconfigurator.P1.style.display = 'inline';	
		document.getElementById('P1Label').innerHTML = PropNames[pLanguage][0];
	}
	if (PropCount > 1) {
		document.FOconfigurator.P2.style.display = 'inline';	
		document.getElementById('P2Label').innerHTML = PropNames[pLanguage][1];
	}
	if (PropCount > 2) {
		document.FOconfigurator.P3.style.display = 'inline';	
		document.getElementById('P3Label').innerHTML = PropNames[pLanguage][2];
	}
	if (PropCount > 3) {
		document.FOconfigurator.P4.style.display = 'inline';	
		document.getElementById('P4Label').innerHTML = PropNames[pLanguage][3];
	}
	if (PropCount > 4) {
		document.FOconfigurator.P5.style.display = 'inline';	
		document.getElementById('P5Label').innerHTML = PropNames[pLanguage][4];
	}
	if (PropCount > 5) {
		document.FOconfigurator.P6.style.display = 'inline';	
		document.getElementById('P6Label').innerHTML = PropNames[pLanguage][5];
	}
	if (PropCount > 6) {
		document.FOconfigurator.P7.style.display = 'inline';	
		document.getElementById('P7Label').innerHTML = PropNames[pLanguage][6];
	}
	if (PropCount > 7) {
		document.FOconfigurator.P8.style.display = 'inline';	
		document.getElementById('P8Label').innerHTML = PropNames[pLanguage][7];
	}
	
	
	
     if (PropCount > 0) {
		fillP1();
	}
     else {
     	fillArticle();
     }
}


/*--------------------------------------------------------------------------
 *  Combobox 1 wurde geändert
 *--------------------------------------------------------------------------*/	
function changedP1(){
     if (PropCount > 1){
          fillP2();
     }
     else {
     	fillArticle();
     }
}	
/*--------------------------------------------------------------------------
 *  Combobox 2 wurde geändert
 *--------------------------------------------------------------------------*/	
function changedP2(){
    if (PropCount > 2){
          fillP3();
    }
    else {
     	fillArticle();
    }
}
/*--------------------------------------------------------------------------
 *  Combobox 3 wurde geändert
 *--------------------------------------------------------------------------*/	
function changedP3(){
    if (PropCount > 3){
          fillP4();
    }
    else {
     	fillArticle();
    }
}
/*--------------------------------------------------------------------------
 *  Combobox 4 wurde geändert
 *--------------------------------------------------------------------------*/	
function changedP4(){
    if (PropCount > 4){
          fillP5();
    }
    else {
     	fillArticle();
    }
}
/*--------------------------------------------------------------------------
 *  Combobox 5 wurde geändert
 *--------------------------------------------------------------------------*/	
function changedP5(){
    if (PropCount > 5){
          fillP6();
    }
    else {
     	fillArticle();
    }
}
/*--------------------------------------------------------------------------
 *  Combobox 6 wurde geändert
 *--------------------------------------------------------------------------*/	
function changedP6(){
    if (PropCount > 6){
          fillP7();
    }
    else {
     	fillArticle();
    }
}
/*--------------------------------------------------------------------------
 *  Combobox 7 wurde geändert
 *--------------------------------------------------------------------------*/	
function changedP7(){
    if (PropCount > 7){
          fillP8();
    }
    else {
     	fillArticle();
    }
}
/*--------------------------------------------------------------------------
 *  Combobox 8 wurde geändert
 *--------------------------------------------------------------------------*/	
function changedP8(){
     	fillArticle();
}
/*--------------------------------------------------------------------------
 *  schreiben der Artikelnummer, Artikellinks, Bild und Langtext
 *--------------------------------------------------------------------------*/	
function fillArticle(){
	var BildName = ""
        if (PropCount == 1) {
	    for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] ){
		    	ArticleNumber = PropValues[i2][0];
			Picture =  PropValues[i2][1];
			PictureScaleWidth =  PropValues[i2][2];
			PictureScaleHeight=  PropValues[i2][3];
		    	BildName = BildName + "_" + document.FOconfigurator.P1.value ;
		}
	    }
        }
        else if (PropCount == 2) {
	    for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] &&  
		    document.FOconfigurator.P2.value == PropValues[i2][5] ){
		    	ArticleNumber = PropValues[i2][0];
			Picture =  PropValues[i2][1];
			PictureScaleWidth =  PropValues[i2][2];
			PictureScaleHeight=  PropValues[i2][3];
		    	BildName = BildName + "_" + document.FOconfigurator.P1.value + "_" + document.FOconfigurator.P2.value ;
		}
	    }
        }
        else if (PropCount == 3) {
	    for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] &&  
		    document.FOconfigurator.P2.value == PropValues[i2][5] &&
		    document.FOconfigurator.P3.value == PropValues[i2][6] ){
		    	ArticleNumber = PropValues[i2][0];
			Picture =  PropValues[i2][1];
			PictureScaleWidth =  PropValues[i2][2];
			PictureScaleHeight=  PropValues[i2][3];
		    	BildName = BildName + "_" + document.FOconfigurator.P1.value + "_" + document.FOconfigurator.P2.value + "_" + document.FOconfigurator.P3.value ;
		}
	    }
        }
        else if (PropCount == 4) {
	    for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] &&  
		    document.FOconfigurator.P2.value == PropValues[i2][5] &&
		    document.FOconfigurator.P3.value == PropValues[i2][6] &&
		    document.FOconfigurator.P4.value == PropValues[i2][7] ){
		    	ArticleNumber = PropValues[i2][0];
			Picture =  PropValues[i2][1];
			PictureScaleWidth =  PropValues[i2][2];
			PictureScaleHeight=  PropValues[i2][3];
		    	BildName = BildName + "_" + document.FOconfigurator.P1.value + "_" + document.FOconfigurator.P2.value + "_" + document.FOconfigurator.P3.value + "_" + document.FOconfigurator.P4.value ;
		}
	    }
        }
        else if (PropCount == 5) {
	    for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] &&  
		    document.FOconfigurator.P2.value == PropValues[i2][5] &&
		    document.FOconfigurator.P3.value == PropValues[i2][6] &&
		    document.FOconfigurator.P4.value == PropValues[i2][7] &&
		    document.FOconfigurator.P5.value == PropValues[i2][8] ){
		    	ArticleNumber = PropValues[i2][0];
			Picture =  PropValues[i2][1];
			PictureScaleWidth =  PropValues[i2][2];
			PictureScaleHeight=  PropValues[i2][3];
		    	BildName = BildName + "_" + document.FOconfigurator.P1.value + "_" + document.FOconfigurator.P2.value + "_" + document.FOconfigurator.P3.value + "_" + document.FOconfigurator.P4.value + "_" + document.FOconfigurator.P5.value ;
		}
	    }
        }
        else if (PropCount == 6) {
	    for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] &&  
		    document.FOconfigurator.P2.value == PropValues[i2][5] &&
		    document.FOconfigurator.P3.value == PropValues[i2][6] &&
		    document.FOconfigurator.P4.value == PropValues[i2][7] &&
		    document.FOconfigurator.P5.value == PropValues[i2][8] &&
		    document.FOconfigurator.P6.value == PropValues[i2][9] ){
		    	ArticleNumber = PropValues[i2][0];
			Picture =  PropValues[i2][1];
			PictureScaleWidth =  PropValues[i2][2];
			PictureScaleHeight=  PropValues[i2][3];
		    	BildName = BildName + "_" + document.FOconfigurator.P1.value + "_" + document.FOconfigurator.P2.value + "_" + document.FOconfigurator.P3.value + "_" + document.FOconfigurator.P4.value + "_" + document.FOconfigurator.P5.value  + "_" + document.FOconfigurator.P6.value ;
		}
	    }
        }
        else if (PropCount == 7) {
	    for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] &&  
		    document.FOconfigurator.P2.value == PropValues[i2][5] &&
		    document.FOconfigurator.P3.value == PropValues[i2][6] &&
		    document.FOconfigurator.P4.value == PropValues[i2][7] &&
		    document.FOconfigurator.P5.value == PropValues[i2][8] &&
		    document.FOconfigurator.P6.value == PropValues[i2][9] &&
		    document.FOconfigurator.P7.value == PropValues[i2][10] ){
		    	ArticleNumber = PropValues[i2][0];
			Picture =  PropValues[i2][1];
			PictureScaleWidth =  PropValues[i2][2];
			PictureScaleHeight=  PropValues[i2][3];
		    	BildName = BildName + "_" + document.FOconfigurator.P1.value + "_" + document.FOconfigurator.P2.value + "_" + document.FOconfigurator.P3.value + "_" + document.FOconfigurator.P4.value + "_" + document.FOconfigurator.P5.value  + "_" + document.FOconfigurator.P6.value  + "_" + document.FOconfigurator.P7.value ;
		}
	    }
        }
        else if (PropCount == 8) {
	    for (var i2 = 0; i2 < PropValues.length; i2++) {
		if (document.FOconfigurator.P1.value == PropValues[i2][4] &&  
		    document.FOconfigurator.P2.value == PropValues[i2][5] &&
		    document.FOconfigurator.P3.value == PropValues[i2][6] &&
		    document.FOconfigurator.P4.value == PropValues[i2][7] &&
		    document.FOconfigurator.P5.value == PropValues[i2][8] &&
		    document.FOconfigurator.P6.value == PropValues[i2][9] &&
		    document.FOconfigurator.P7.value == PropValues[i2][10] &&
		    document.FOconfigurator.P8.value == PropValues[i2][11]){
		    	ArticleNumber = PropValues[i2][0];
			Picture =  PropValues[i2][1];
			PictureScaleWidth =  PropValues[i2][2];
			PictureScaleHeight=  PropValues[i2][3];
		    	BildName = BildName + "_" + document.FOconfigurator.P1.value + "_" + document.FOconfigurator.P2.value + "_" + document.FOconfigurator.P3.value + "_" + document.FOconfigurator.P4.value + "_" + document.FOconfigurator.P5.value  + "_" + document.FOconfigurator.P6.value  + "_" + document.FOconfigurator.P7.value + "_" + document.FOconfigurator.P8.value ;
		}
	    }
        }
        
        
        BildName = BildName.replace("/","-");
        BildName = BildName.replace("\\","-");
        
        if (pLanguage == "deu")  document.getElementById('ArticleNumber').innerHTML = "Artikelnummer: " + ArticleNumber;
        if (pLanguage == "eng")  document.getElementById('ArticleNumber').innerHTML = "Item Number: " + ArticleNumber;

	document.getElementById('LongText').innerHTML = ArticleLongText[pLanguage + "-" + ArticleNumber];
	
	document.getElementById('ArticleImage').src = "../artikel-bilder/" + SeriesId + "/" + Picture + ".jpg";
	document.getElementById('ArticleImage').alt = ArticleNumber + BildName;
	
	document.getElementById('ArticleImage').width = PictureScaleWidth;
	document.getElementById('ArticleImage').height = PictureScaleHeight;
		
	
	
	if (Mode == "Download") {
		document.getElementById('Link3DV').href = "../artikel-3dv/" + SeriesId + "/" + Picture + ".ZIP";
		document.getElementById('Link3DF').href = "../artikel-3df/" + SeriesId + "/" + Picture + ".ZIP";
		document.getElementById('Link2D').href = "../artikel-2d/" + SeriesId + "/" + Picture + ".ZIP";
	}
	if (Mode == "Sketcher") {
		document.getElementById('LinkSketcher').href = "../artikel-edwg/" + SeriesId + "/" + Picture + ".dwg";
	}	                                                 
}
