
// ----- FIT START - Template: $RCSfile: scripts_variations_cache.isml,v $ - $Source: /home/web/cvsroot/es6_baur/bv_catalog/staticfiles/cartridge/templates/de/inc/scripts_variations_cache.isml,v $ - START FIT -----







	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	
	




//Detailview-Object mit allerlei Eigenschaften und Methoden
detailview = {
	//Basis-Eigenschaften 
	ArticleName: "",
	ArticleSKU: "",
	ArticleRefId: "",
	DefaultOrderId: "",
	givenOrderId: "",
	
	
	VideoProduktVideo: "",
	VideoFlag_3D: "",
	VideoFlag_3D_Format: "",
	VideoFlag_360: "",
	VideoFlag_360_Format: "",
	
	VideosObject:
	{
		Flag_3D: [],
		Flag_360: []
	},
	StyleImageIterator: ['abschluss'],
	
	StyleImageRoles: [],
	
	StyleImageLevels: [],
	StyleImageZoom: ['abschluss'],
	BundleImageIterator: ['abschluss'],
	BundleDefaultImageName : '',
	BundleImageZoom: ['abschluss'],
	
	BundleImageRoles: [],
	
	Ratenanzahl: 3,
	Ratenfrompopup: 0,
	Zahlpausefrompopup: 0,
	ShowRatenText: false,
	
	Unit: "",
	  
	
	
	Variations : [
	{
			ProductSKU: "",
			ProductRefId: "",
			OrderId: "",
			
			Dimension1: "0",
			Dimension3: "0",
			Dimension4: "0",
			Size: "0",
			Var_Promo: "0",
			PromoIsPromo: "1",
			
			Price: "",
			OldPrice: "",
			
			PriceReduction: "",
			hasUVP: "false",
			UVP: "",
			

			SellingUnitText: "",
			PricePerSellingUnit: "",
			
			isAvailable: "",
			AvailabilityCode: "",
			AvailbilityText: "",//wird aus Code per Steuerungstabelle ausgelesen
			AvailbilityInfos: "",
			
			VideoFlag_3D: "",
			VideoFlag_3D_Format: "",
			VideoFlag_360: "",
			VideoFlag_360_Format: "",
			
			DefaultImageName: "",
			ImageIterator: [],
			
			
			
			ImagesZoom: [],
			
			Abschluss: ""
			
		}],
		VariationsCount: "1",
	
	currentSelectedVariation:"",
	
	//folgende Eigenschaften werden durch initVariations geladen
	OrderIds: [],
	OrderIdsPromo: [],
	Promos: [],
	Dimensions1: [],
	Dimensions3: [],
	Dimensions4: [],
	DimKombi: [],
	Var_Promos: [],
	HasWarranty: false,
	//wird durch initImageIterator in geladen
	ImageIterator: [],
	ArticleImageIterator: [],
	SizeImageIterator: [],
	currentSelectedImageObject:"",
		
	//Laden/Befüllen der Variations-Arrays
	initVariations: function(promoArt)
	{
		if (this.Variations && this.Variations.length>0)
		{
			for (var i = 0; i < this.Variations.length; i++)
			{
				var arrOrdId = this.OrderIds;
				var arrDim1 = this.Dimensions1;
				var arrDim3 = this.Dimensions3;
				var arrDim4 = this.Dimensions4;
				var arrVarPromo = this.Var_Promos;
				
				var orderIdsPromo = this.OrderIdsPromo;
				var promos = this.Promos;
				var valOrderId = this.Variations[i].OrderId;
				var valDim1 = this.Variations[i].Dimension1;
				var valDim3 = this.Variations[i].Dimension3;
				var valDim4 = this.Variations[i].Dimension4;
				var valPromo = this.Variations[i].Var_Promo;				
				
				if (valPromo != "" && valPromo != "0")
				{
					this.HasWarranty = true;
					//if (!detailview.isInArray(DecodeString(valDim1), arrDim1) && !detailview.isInArray(DecodeString(valDim3), arrDim3))
					if (!detailview.isInArray(valOrderId,arrOrdId))
					{
						arrOrdId.push(valOrderId);
						if (arrDim1 && valDim1 != "" && valDim1 != 0) arrDim1.push(DecodeString(valDim1));
						if (arrDim3 && valDim3 != "" && valDim3 != 0) arrDim3.push(DecodeString(valDim3));
						if (arrDim4 && valDim4 != "" && valDim4 != 0) arrDim4.push(DecodeString(valDim4));
						if (arrVarPromo && valPromo != "" && valPromo != 0) arrVarPromo.push(DecodeString(valPromo));
					}					
				}
				else
				{
					
					if (!detailview.isInArray(valOrderId,arrOrdId))
					{
						arrOrdId.push(valOrderId);
						if (arrDim1 && valDim1 != "" && valDim1 != 0) arrDim1.push(DecodeString(valDim1));
						if (arrDim3 && valDim3 != "" && valDim3 != 0) arrDim3.push(DecodeString(valDim3));
						if (arrDim4 && valDim4 != "" && valDim4 != 0) arrDim4.push(DecodeString(valDim4));
					}
				}
				var dimObject = valDim1 + "|" + valDim3 + "|" + valDim4 + "|" + valPromo;

				if (!detailview.isInArray(dimObject,this.DimKombi)) this.DimKombi.push(dimObject);
			}
		}
		detailview.initImageIterator();
		this.currentSelectedVariation = this.Variations[0];
	},
	
	//ImagesArray laden
	initImageIterator: function()
	{
		//Artikel und Grössen-Bilder hinzufügen
		if (this.Variations && this.Variations.length>0)
		{
			for (var i = 0; i < this.Variations.length; i++)
			{
				var vari = this.Variations[i];
				for (var j = 0; j < vari.ImageIterator.length; j++)
				{
					var image = vari.ImageIterator[j];
					if (image != "abschluss")
					{
						var imageZoom = "";
						if (typeof(vari.ImagesZoom[j]) != "undefined") imageZoom = vari.ImagesZoom[j];
						var imageRoles = (typeof vari.ImageRoles) == "undefined" ? "" : vari.ImageRoles[j];
						var imageLevel = (typeof vari.ImagesLevel) == "undefined" ? "" : vari.ImagesLevel[j];
						
						if (imageLevel == "art" && !detailview.imageInArray(this.ArticleImageIterator, image)) 
						{
							this.ArticleImageIterator.push({image: image, imageZoom: imageZoom, orderId: vari.OrderId, ProductRefId: vari.ProductRefId, rolle: imageRoles, level: imageLevel});
						}
						if (imageLevel == "gr" && !detailview.imageInArray(this.SizeImageIterator, image)) 
						{
							this.SizeImageIterator.push({image: image, imageZoom: imageZoom, orderId: vari.OrderId, ProductRefId: vari.ProductRefId, rolle: imageRoles, level: imageLevel});
						}
						if (!detailview.imageInArray(this.ImageIterator, image))
						{
							
							this.ImageIterator.push({image: image, imageZoom: imageZoom, orderId: vari.OrderId, ProductRefId: vari.ProductRefId, rolle: imageRoles, level: imageLevel});
						}
					}
				}
				if (vari.VideoFlag_3D != "")
				{
					
					var videoName = vari.VideoFlag_3D;
					
					if (!detailview.isInArray(videoName,this.VideosObject.Flag_3D)) this.VideosObject.Flag_3D.push(videoName);
					
				}
				if (vari.VideoFlag_360 != "")
				{
					
					var videoName = vari.VideoFlag_360;
					
					if (!detailview.isInArray(videoName,this.VideosObject.Flag_360)) this.VideosObject.Flag_360.push(videoName);
				}
				
			}
		}
		//Style-Bilder hinzufügen
		if (this.StyleImageIterator && this.StyleImageIterator.length>0)
		{
			for (var j = 0; j< this.StyleImageIterator.length; j++)
			{
				var image = this.StyleImageIterator[j];
				if (image != "abschluss")
				{
					var imageZoom = "";
					if (typeof(this.StyleImageZoom[j]) != "undefined") imageZoom = this.StyleImageZoom[j];
					if (!detailview.imageInArray(this.ImageIterator, image))
					this.ImageIterator.push({image: image, imageZoom: imageZoom, orderId: this.DefaultOrderId, ProductRefId: this.ArticleRefId, rolle: this.StyleImageRoles[j], level: this.StyleImageLevels[j]});
				}
			}
		}
		
		if (this.BundleImageIterator && this.BundleImageIterator.length>0)
		{
			for (var j = 0; j< this.BundleImageIterator.length; j++)
			{
				var image = this.BundleImageIterator[j];
				if (image != "abschluss")
				{
					var imageZoom = "";
					if (typeof(this.BundleImageZoom[j]) != "undefined") imageZoom = this.BundleImageZoom[j];
					if (!detailview.imageInArray(this.ImageIterator, image))
					this.ImageIterator.push({image: image, imageZoom: imageZoom, orderId: this.DefaultOrderId, ProductRefId: this.ArticleRefId, rolle: this.BundleImageRoles[j], level: 'none'});
				}
			}
			detailview.setImageByImageName(this.BundleDefaultImageName);
		}
		
	},
	
	getAttribute: function (object,atrributeName)
	{
		return object[atrributeName];
	},
	
	//Farb-Selectbox mit Inhalt befüllen / wird in Include inc/detailview_variations aufgerufen
	colorInit: function(promoArt){
		var select_dim_1 = document.pulldown.colorselection;
		var dims = [];
		for (var i=0; i < this.OrderIds.length;i++)
		{
			var options = document.createElement("OPTION");
			
			var dim1 = ((typeof this.Dimensions1[i]) != "undefined" ? this.Dimensions1[i] : "");
			var dim3 = ((typeof this.Dimensions3[i]) != "undefined" ? this.Dimensions3[i] : "");
			var dim4 = ((typeof this.Dimensions4[i]) != "undefined" ? this.Dimensions4[i] : "");
			
			var obj = detailview.getVariationsByOrderId(this.OrderIds[i]);
			/*dim1 = ((typeof obj.Dimension1) != "undefined" ? obj.Dimension1 : "");
			dim3 = ((typeof obj.Dimension3) != "undefined" ? obj.Dimension3 : "");
			dim4 = ((typeof obj.Dimension4) != "undefined" ? obj.Dimension4 : "");
			*/
			var trenner1 = dim1 != "" && dim3 != "" ? ", " : "";
			var trenner2 = dim1 != "" && dim4 != "" ? ", " : "";
			trenner2 = dim3 != "" && dim4 != "" ? ", " : trenner2;
			var dim = dim1 + trenner1 + dim3 + trenner2+  dim4 ;
			if (!detailview.isInArray(dim, dims))
			{
				dims.push(dim);
				options.value = dim;
				var newtext = document.createTextNode(options.value);
				options.appendChild(newtext);
				//options.text = options.value;
				select_dim_1.appendChild(options);
			}
		}
		
		var currentVariation = detailview.getVariationsByOrderId(this.OrderIds[0]);
		if (promoArt != "")
		{
			var art = String(promoArt);
			currentVariation=detailview.getVariationsByOrderIdWithoutPromo(art.substr(0,6));
			if ((typeof currentVariation) == "undefined" || currentVariation == "")
			{
				currentVariation = this.Variations[0];
				art = this.Variations[0].OrderId;
			}
			detailview.preSelectColorByOrderIdWithoutPromo(art.substr(0,6));
			detailview.changeVariations(select_dim_1);
		}
		
		jQuery("#artikelnr").html("Art.Nr: " + currentVariation.OrderId);
		detailview.setImageByVariationsObject(currentVariation);
		
		this.currentSelectedVariation = currentVariation;
		//für Artikel ohne Grösse gleich den Preis aktualisieren - kein ab-Preis
		
		detailview.setPricefieldsOnDetailview(currentVariation);
				
		if (this.ShowRatenText)
		{
			var pr = jQuery('#price_dv').html().replace(/ab EUR /g,'');
			
			detailview.showRatenInfo(pr);
			
		}
	},
	
	changeVideo3dButton: function(currentFlash3dVideo){
		var getVideoFlag3dButtonObj = jQuery("#but_rundumansicht");
		if( currentFlash3dVideo != '' ){
			getVideoFlag3dButtonObj.removeClass("skipElement").attr({ 
				href : "javascript:spinImageView('/format3d/" + currentFlash3dVideo + ".swf');" 
			});
		} else {
			getVideoFlag3dButtonObj.addClass("skipElement");
		}
	},
	
	//Grössen-Selectbox mit Inhalt befüllen / wird in Include inc/detailview_variations aufgerufen
	selectSize: function(changePrice,promoArt, currentSelectedVariation)
	{
		if ((typeof currentSelectedVariation.OrderId) == "undefined")	currentSelectedVariation = this.Variations[0];
		if (detailview.hasSizes(currentSelectedVariation.OrderId))
		{
			
			var wformColor = document.pulldown.colorselection;
			var wformSize = document.pulldown.sizeselection;
			var currentOrderId = "";
			if (currentSelectedVariation) currentOrderId = currentSelectedVariation.OrderId;
			else if (currentOrderId == "" && wformColor) currentOrderId = this.OrderIds[wformColor.selectedIndex];
			else if  (currentOrderId == "") currentOrderId = this.Variations[0].OrderId;
			jQuery(wformSize).empty();
			var options = document.createElement("OPTION");
			options.value = "";
			var newtext = document.createTextNode("Bitte wählen Sie eine Größe aus");
			options.appendChild(newtext);
			//options.text = "Bitte wählen Sie eine Größe aus";
			wformSize.appendChild(options);
			var preis = 0;
			for (var i = 0;i < this.Variations.length; i ++)
			{
				if (this.Variations[i].OrderId == currentOrderId)
				{
					var options = document.createElement("OPTION");
					options.value = DecodeString(this.Variations[i].Size);

					var newtext = document.createTextNode(options.value);
					options.appendChild(newtext);
					//options.text = options.value;
					wformSize.appendChild(options);

					if (changePrice)
					{
						if (preis == 0 || preis < detailview.prepare_number(this.Variations[i].Price))
						{
							preis = detailview.prepare_number(this.Variations[i].Price);
							jQuery('#price_dv').html("EUR " + this.Variations[i].Price);
							if (this.Variations[i].Price != this.Variations[i].OldPrice && this.Variations[i].OldPrice != "" && this.Variations[i].OldPrice != "0")
								jQuery('#oldprice_dv').html("statt EUR " + this.Variations[i].OldPrice);
							if (this.Variations[i].PriceReduction != "" && this.Variations[i].PriceReduction != "0")
								jQuery('#prozent_dv').html(this.Variations[i].PriceReduction + "%");
						}	
					}
					this.currentSelectedVariation = this.Variations[i];
				}
			}
			kal_delivery.getXMLResponse();
			jQuery("#size").removeClass("skipElement");
		}
		else
		{
			jQuery("#size").addClass("skipElement");
		}
	},
	
	//Garantie-Selectbox mit Inhalt befüllen / wird in Include inc/detailview_variations aufgerufen
	warrantyselect: function(promoArt)
	{
		var wformColor = document.pulldown.colorselection;
		var wformWarranty = document.pulldown.warrantyselection;
		var currentOrderId = "";
		var currentDim1 = "";
		var currentDim3 = "";
		var currentDim4 = "";
		if (wformColor)
		{
			currentOrderId = this.OrderIds[wformColor.selectedIndex];
			currentDim1 = this.Dimensions1[wformColor.selectedIndex];
			
			currentDim1 = ((typeof this.Dimensions1[wformColor.selectedIndex]) != "undefined" ? this.Dimensions1[wformColor.selectedIndex] : "");
			currentDim3 = ((typeof this.Dimensions3[wformColor.selectedIndex]) != "undefined" ? this.Dimensions3[wformColor.selectedIndex] : "");
			currentDim4 = ((typeof this.Dimensions4[wformColor.selectedIndex]) != "undefined" ? this.Dimensions4[wformColor.selectedIndex] : "");
			var trenner1 = currentDim1 != "" && currentDim3 != "" ? ", " : "";
			var trenner2 = currentDim1 != "" && currentDim4 != "" ? ", " : "";
			trenner2 = currentDim3 != "" && currentDim4 != "" ? "," : trenner2;
			var dim = currentDim1 + trenner1 + currentDim3 + trenner2+  currentDim4 ;
		}
		else
		{
			currentOrderId = this.OrderIds[0];
			currentDim1 = this.Dimensions1[0];
		}
		jQuery(wformWarranty).empty();
		var var_promos = [];
		for (var i = 0;i < this.Variations.length; i ++)
		{
			
			if (wformColor)
			{
			
				var thisDim1 = DecodeString(this.Variations[i].Dimension1) == "0" ? "" : DecodeString(this.Variations[i].Dimension1);
				var thisDim3 = DecodeString(this.Variations[i].Dimension3) == "0" ? "" : DecodeString(this.Variations[i].Dimension3);
				var thisDim4 = DecodeString(this.Variations[i].Dimension4) == "0" ? "" : DecodeString(this.Variations[i].Dimension4);
				//alert(thisDim1 + " = " + currentDim1 + " - " +  thisDim3 + " = " + currentDim3 + " - " +  thisDim4 + " = " + currentDim4);
				if (thisDim1 == currentDim1 && thisDim3 == currentDim3 && thisDim4 == currentDim4)
				{
					var options = document.createElement("OPTION");
					if (!detailview.isInArray(DecodeString(this.Variations[i].Var_Promo),var_promos)) 
					{
						var_promos.push(DecodeString(this.Variations[i].Var_Promo));
						options.value = DecodeString(this.Variations[i].ProductSKU);
						var newtext = document.createTextNode(DecodeString(this.Variations[i].Var_Promo));
						options.appendChild(newtext);
						//options.text = DecodeString(this.Variations[i].Var_Promo);
						wformWarranty.appendChild(options);
						/*jQuery('#price_dv').html("EUR " + this.Variations[i].Price);
						if (this.Variations[i].Price != this.Variations[i].OldPrice && this.Variations[i].OldPrice != "" && this.Variations[i].OldPrice != "0")
							jQuery('#oldprice_dv').html("statt EUR " + this.Variations[i].OldPrice);
						if (this.Variations[i].PriceReduction != "" && this.Variations[i].PriceReduction != "0")
							jQuery('#prozent_dv').html(this.Variations[i].PriceReduction + "%");*/
					}
					
				}
			}
			else
			{
				var options = document.createElement("OPTION");
				options.value = DecodeString(this.Variations[i].ProductSKU);
				var newtext = document.createTextNode(DecodeString(this.Variations[i].Var_Promo));
				options.appendChild(newtext);
				//options.text = DecodeString(this.Variations[i].Var_Promo);
				wformWarranty.appendChild(options);
				/*jQuery('#price_dv').html("EUR " + this.Variations[i].Price);
				if (this.Variations[i].Price != this.Variations[i].OldPrice && this.Variations[i].OldPrice != "" && this.Variations[i].OldPrice != "0")
					jQuery('#oldprice_dv').html("statt EUR " + this.Variations[i].OldPrice);
				if (this.Variations[i].PriceReduction != "" && this.Variations[i].PriceReduction != "0")
					jQuery('#prozent_dv').html(this.Variations[i].PriceReduction + "%");*/
			}
		}
		var currentVariation = detailview.getVariationsByOrderId(this.OrderIds[0]);

		detailview.setPricefieldsOnDetailview(currentVariation);
		
		this.currentSelectedVariation = currentVariation;
		
		if (this.ShowRatenText)
		
		
			detailview.showRatenInfo(currentVariation.Price);
		
		detailview.setImageByVariationsObject(currentVariation);
	},
	
	
	//Aufruf Change-Event in Select-Boxen (Var_1,3,4, Grösse. Garantie)
	changeVariations: function(select)
	{
		
		//Dim_1 - Select-Feldes geändert	
		if (select != null && select.name == "colorselection")
		{
			var wform = document.pulldown.colorselection;
			var wformSize = document.pulldown.sizeselection;
			var wformWarranty = document.pulldown.warrantyselection;
			jQuery("#artikelnr").html("Art.Nr: " + this.OrderIds[wform.selectedIndex]); //Artikelnummer ändern
			var currentVariation = detailview.getVariationsByOrderId(this.OrderIds[wform.selectedIndex]);
			detailview.selectSize(true,"",currentVariation);
			
			//else if (detailview.hasSizes(currentVariation.OrderId))
			if (wformWarranty) detailview.warrantyselect();
			detailview.setImageByVariationsObject(currentVariation);
			
    			kal_delivery.setDeliveryText();
    
                //prüfen ob ausverkauft
                if(detailview.hasSizes(this.currentSelectedVariation.OrderId)){
                    kal_delivery.showRedButton(wformSize);
                } else {
                    kal_delivery.showRedButton();
                }
			
			
			
				if (this.ShowRatenText) detailview.showRatenInfo(currentVariation.Price);
			
			
			
			// VideoFlag_3D
			detailview.changeVideo3dButton(currentVariation.VideoFlag_3D);
			
			
			this.currentSelectedVariation = currentVariation;
		}
		//Grössen-Feld geändert
		if (select != null && select.name == "sizeselection")
		{
			var currentVariation = this.currentSelectedVariation;
			var wformColor = document.pulldown.colorselection;
			var wformSize = document.pulldown.sizeselection;
			if ( wformSize.options[wformSize.selectedIndex].text != "Bitte wählen Sie eine Größe aus")
			{
				var currentOrderId = "";
				
				if (currentOrderId == "" && wformColor) currentOrderId = this.OrderIds[wformColor.selectedIndex];
				else if (this.currentSelectedVariation) currentOrderId = this.currentSelectedVariation.OrderId;
				else if  (currentOrderId == "") currentOrderId = this.Variations[0].OrderId;
				var currentSize = wformSize.options[wformSize.selectedIndex].value;
				currentVariation = detailview.getVariationsBySizeOrderId(currentOrderId, currentSize);
				
				//Preise der Grösse schreiben
				if (currentVariation.Price != currentVariation.OldPrice && currentVariation.OldPrice != "" && currentVariation.OldPrice != "0")
					jQuery('#oldprice_dv').html("statt EUR " + currentVariation.OldPrice);
				if (currentVariation.PriceReduction != "" && currentVariation.PriceReduction != "0")
					jQuery('#prozent_dv').html("-" + currentVariation.PriceReduction + "%");
				if (this.ShowRatenText)
				
					detailview.showRatenInfo(currentVariation.Price);
				
				
				if (this.SizeImageIterator.length>0)
				{
					var sizeImage = detailview.getSizeImageByProdRef(currentVariation.ProductRefId);
					if (sizeImage) detailview.setImageByVariationsObject(currentVariation);
				}
				
				this.currentSelectedVariation = currentVariation;
				
				//prüfen ob akt. Grösse ausverkauft
				kal_delivery.showRedButton(wformSize); 
			}
		}
		//Garantie-Feld geändert
		if (select != null && select.name == "warrantyselection")
		{
			var wformColor = document.pulldown.colorselection;
			var wformWarranty = document.pulldown.warrantyselection;
			var currentSKU = document.pulldown.warrantyselection.options[wformWarranty.selectedIndex].value;
			var currentVariation = detailview.getVariationsByProdSKU(currentSKU);
			jQuery("#artikelnr").html("Art.Nr: " + currentVariation.OrderId); //Artikelnummer ändern
			if (currentVariation.Price != currentVariation.OldPrice && currentVariation.OldPrice != "" && currentVariation.OldPrice != "0")
				jQuery('#oldprice_dv').html("statt EUR " + currentVariation.OldPrice);
			if (currentVariation.PriceReduction != "" && currentVariation.PriceReduction != "0")
				jQuery('#prozent_dv').html(currentVariation.PriceReduction + "%");
			if (this.ShowRatenText)
			
				detailview.showRatenInfo(currentVariation.Price);
			
			this.currentSelectedVariation = currentVariation;
		}
		//Längen/Breiten-Masse geändert
		var has_lenght = false;
		var has_u_lenght = false;
		var has_u_width = false;
		var has_q_lenght = false;
		var has_q_width = false;
		
		if (document.pulldown.meter_length_selection) {has_lenght = true;}
		if (document.pulldown.u_meter_length_selection) {has_u_lenght = true;}
		if (document.pulldown.u_meter_width_selection) {has_u_width = true;}
		if (document.pulldown.q_meter_length_selection) {has_q_lenght = true;}
		if (document.pulldown.q_meter_width_selection) {has_q_width = true;}
		var tmp_preis = (this.currentSelectedVariation) ? this.currentSelectedVariation.Price : this.Price;
		if (has_lenght) 
		{
			
			document.pulldown.meter_length_selection.value = parseInt(document.pulldown.meter_length_selection.value);
			if (document.pulldown.meter_length_selection.value.toString() == "NaN") {
				alert ("Sie haben keine gültige Länge eingegeben");
				document.pulldown.meter_length_selection.value = 100;
			}
			tmp_preis = detailview.prepare_number(tmp_preis);

			// tmp_preis = tmp_preis / vari[n][1];
			tmp_preis = tmp_preis / 100;
			tmp_preis = tmp_preis * document.pulldown.meter_length_selection.value;
			
			tmp_preis = parseInt(tmp_preis * 100 + 0.5 )/100;
			
			//tmp_preis = tmp_preis.toString();
			//tmp_preis = tmp_preis.replace(/\./,",");
			tmp_preis = detailview.prepare_string(tmp_preis);
		} 
		else 
		{
			if (has_u_lenght && has_u_width) 
			{
				document.pulldown.u_meter_length_selection.value = parseInt(document.pulldown.u_meter_length_selection.value);
				if (document.pulldown.u_meter_length_selection.value.toString() == "NaN") 
				{
					alert ("Sie haben keine gültige Länge eingegeben");
					document.pulldown.u_meter_length_selection.value = 100;
				}
				document.pulldown.u_meter_width_selection.value = parseInt(document.pulldown.u_meter_width_selection.value);
				if (document.pulldown.u_meter_width_selection.value.toString() == "NaN") 
				{
					alert ("Sie haben keine gültige Breite eingegeben");
					document.pulldown.u_meter_width_selection.value = 100;
				}
			
				tmp_preis = detailview.prepare_number(tmp_preis);
				// tmp_preis = tmp_preis.replace(/\./,"");
				// tmp_preis = tmp_preis.replace(/\,/,".");

				tmp_preis = tmp_preis / 100;
				tmp_preis = tmp_preis * (2*document.pulldown.u_meter_length_selection.value + 2*document.pulldown.u_meter_width_selection.value);
				
				tmp_preis = parseInt(tmp_preis * 100 + 0.5)/100;
				
				//tmp_preis = tmp_preis.toString();
				//tmp_preis = tmp_preis.replace(/\./,",");
				tmp_preis = detailview.prepare_string(tmp_preis);
			} 
			else 
			{
				if (has_q_lenght && has_q_width) 
				{
					document.pulldown.q_meter_length_selection.value = parseInt(document.pulldown.q_meter_length_selection.value);
					if (document.pulldown.q_meter_length_selection.value.toString() == "NaN") 
					{
						alert ("Sie haben keine gültige Länge eingegeben");
						document.pulldown.q_meter_length_selection.value = 100;
					}
					document.pulldown.q_meter_width_selection.value = parseInt(document.pulldown.q_meter_width_selection.value);
					if (document.pulldown.q_meter_width_selection.value.toString() == "NaN") 
					{
						alert ("Sie haben keine gültige Breite eingegeben");
						document.pulldown.q_meter_width_selection.value = 100;
					}

					tmp_preis = detailview.prepare_number(tmp_preis);

					tmp_preis = tmp_preis / 10000;
					tmp_preis = tmp_preis * document.pulldown.q_meter_length_selection.value * document.pulldown.q_meter_width_selection.value;
					
					tmp_preis = parseInt(tmp_preis * 100 + 0.5)/100;
					
					tmp_preis = detailview.prepare_string(tmp_preis);
					//tmp_preis = tmp_preis.replace(/\./,",");
				}
			}
		}
		if (this.ShowRatenText) detailview.showRatenInfo(tmp_preis);
		
			detailview.showRatenInfo(tmp_preis);
		
		if (select != null && (select.name == "colorselection" || select.name == "warrantyselection" || select.name == "sizeselection"))
		{
			detailview.setPricefieldsOnDetailview(currentVariation,select.name);
		}
        
		if(has_lenght || (has_u_lenght && has_u_width) || (has_q_lenght && has_q_width))
		{
            tmp_preis = detailview.prepare_string(tmp_preis);
			jQuery('#price_dv').html("EUR " + tmp_preis);
			if ((typeof ab) == "undefined") ab ="";
			var checkpriceReduction = detailview.getPriceReduction(this.currentSelectedVariation);
			if (checkpriceReduction != "" && checkpriceReduction != "0" && !isNaN(checkpriceReduction))
				jQuery('#prozent_dv').html(ab + "-" + checkpriceReduction + "%");
			else jQuery('#prozent_dv').hide();
		}
		
		// bei Preisen nach Grundpreisverordnung:	
		var tmp_grundmenge = (this.currentSelectedVariation) ? this.currentSelectedVariation.SellingUnitText : this.SellingUnitText;
		var tmp_grundpreis = (this.currentSelectedVariation) ? this.currentSelectedVariation.PricePerSellingUnit : this.PricePerSellingUnit;
		if (tmp_grundmenge.length > 0 && tmp_grundpreis.length > 0)
		{
			jQuery('#grundpreis_dv').html(tmp_grundmenge + " EUR " + detailview.prepare_string(tmp_grundpreis));
			jQuery('#grundpreis_dv').show();
		}
		else
		{
			jQuery('#grundpreis_dv').html("");
			jQuery('#grundpreis_dv').hide();
		}
		
		
		 
		if (this.VideosObject.Flag_3D.length>0 || this.VideosObject.Flag_360.length>0)
		{
			//alert('hasVideosArticles');
		}
		 
	},
	
	//Schreibt Preise (Alt/Min/UVP/Reduzierung) auf Detailview in die jeweiligen divs/Spans
	setPricefieldsOnDetailview: function(currentVariation,selecttype)
	{
		var ab  = "";
		if (detailview.hasSizes(currentVariation.OrderId) && detailview.hasDifferentPrices(currentVariation.OrderId)) ab = "ab ";
				
		var curMinPrice = detailview.getVariationPrices(currentVariation.OrderId,"Price");
		var curMinOldPrice = detailview.getVariationPrices(currentVariation.OrderId,"OldPrice");
		if (currentVariation.hasUVP == 'true')
		{
			curMinOldPrice = detailview.getVariationPrices(currentVariation.OrderId,"UVP");
			
			$('#price_uvp').html("Unverbindliche Preisempfehlung:");
			$('#price_uvp').show();
			$('#oldprice_dv').attr("class","");
		}
		else
		{
			$('#price_uvp').hide();
			$('#oldprice_dv').attr("class","oldprice");	
		}
		
		var curPriceReduction = detailview.getVariationMaxReduction(currentVariation.OrderId);
		var curMinPriceVal = parseFloat(curMinPrice.replace(',','.'));
		var curMinOldPriceVal = parseFloat(curMinOldPrice.replace(',','.'));
		
		if ((typeof selecttype) != "undefined" && selecttype == "sizeselection")
		{
			ab  = "";
			curMinPrice = currentVariation.Price;
			curMinOldPrice =currentVariation.OldPrice;
			
			curPriceReduction = detailview.getPriceReduction(currentVariation);
			curMinPriceVal = parseFloat(currentVariation.Price.replace(',','.'));
			curMinOldPriceVal = parseFloat(currentVariation.OldPrice.replace(',','.'));
		}
		
		jQuery('#price_dv').html(ab + "EUR " + curMinPrice);
		if (currentVariation.hasUVP != 'true')
		{
			if (curMinOldPrice && curMinPriceVal < curMinOldPriceVal && curMinOldPrice != "" && curMinOldPrice != "0" )
			{
				jQuery('#oldprice_dv').html("statt " + ab + "EUR " + curMinOldPrice);
				jQuery('#oldprice_dv').show();
			}
			else
			{
				jQuery('#oldprice_dv').hide();
			}
		}
		if (ab != "") ab = "bis zu ";
		if (curPriceReduction != "" && curPriceReduction != "0")
			jQuery('#prozent_dv').html(ab + "-" + curPriceReduction + "%");
		else jQuery('#prozent_dv').hide();
		jQuery('#meterware_preis_span').html("EUR " + curMinPrice);
	},
	
	//Vorauswahl der Farbe durch SKU
	preSelectColorBySKU : function( prodSKU ) {
		var variation = detailview.getVariationsByProdSKU( prodSKU );
		this.preSelectColorByOrderId( variation.OrderId );
	},
	
	//Vorauswahl der Farbe durch Artikelnummer
	preSelectColorByOrderId : function( orderId ) {
		var select = document.pulldown.colorselection;
       	if( select ){
        	for( i=0; i < this.OrderIds.length; i++) {
                if( orderId == this.OrderIds[i] ) {
                    select.selectedIndex = i;
                    break;
                }
            }
        }
	},
	
	//Vorauswahl der Farbe durch Artikelnummer ohne Promo
	preSelectColorByOrderIdWithoutPromo : function( orderId6 ) {
		var select = document.pulldown.colorselection;
       	if( select ){
        	for( i=0; i < this.OrderIds.length; i++) {
                if( orderId6 == this.OrderIds[i].substr(0,6) ) {
                    select.selectedIndex = i;
                    break;
                }
            }
        }
	},
	
	//Vorauswahl der Grösse durch SKU
	preSelectSizeBySKU : function( prodSKU ) {
		var variation = detailview.getVariationsByProdSKU( prodSKU );
		this.preSelectSizeBySize( variation.Size );
	},
	
	//Vorauswahl der Grösse durch Grösse
	preSelectSizeBySize : function( size ) {
		size = DecodeString( size );
		var select = document.pulldown.sizeselection;
       	if( select ){
        	for( i=0; i < select.options.length; i++) {
                if( select.options[i].value == size ) {
                    select.selectedIndex = i;
                    break;
                }
            }
        }
	},
	
	//Vorauswahl durch SKU
	preSelectionBySKU : function( prodSKU ) {
		this.preSelectColorBySKU( prodSKU );
		this.changeVariations( document.pulldown.colorselection );
		this.preSelectSizeBySKU( prodSKU );
		this.changeVariations( document.pulldown.sizeselection );
		/* to do: warranty */
	},
	
	//Bild ändern (nur hier kann der Bildpfad geänderzt werden) - wird durch sämtliche setImageXYZ-Methoden aufrufen
	setImage: function(image)
	{
		if ((typeof image) != "undefined" && image != "" && image != "undefined")
			jQuery('#main_img').attr('src','http://bilder.baur.de/pool/baur_format_p/' + image);
	},
	
	setImageByVariationsObject: function(obj)
	{
		var currentImage = obj.DefaultImageName;
		detailview.setSevenStepImages(obj);
		if (currentImage != "" && currentImage != "leer.gif")
		{	this.currentSelectedImageObject = detailview.getImageObjectByImageName(currentImage);
			detailview.setImage(currentImage);
		}
	},
		
	setImageByProdRef: function(prodRef)
	{
		detailview.setImageByVariationsObject(detailview.getVariationsByProdRef(prodRef));
	},
	
	setImageByImageName: function(imageName)
	{
		var imageObject = detailview.getImageObjectByImageName(imageName);
		detailview.setImageByImageObject(imageObject);
	},
	
	setImageByImageObject: function(obj)
	{
		this.currentSelectedImageObject = obj;
		detailview.setImage(obj.image);
	},
	
	getImageObjectByImageName: function(imageName)
	{
		for (var i = 0; i < this.ImageIterator.length; i++)
		{
			if (this.ImageIterator[i].image == imageName)
				return this.ImageIterator[i];
		}
		return false;
	},
	
	//Hauptbild ändern und Farbe in Select-Box anhand des Bildes ändern (wird durch Bildleiste aufgerufen)
	setAsMainImage: function(imgObject)
	{
		detailview.setImageByImageName(imgObject.id);
		var obj = detailview.getImageObjectByImageName(imgObject.id);
		var orderIdOfImage = obj.orderId;
		var currentVariation = detailview.getVariationsByOrderId(obj.orderId);
		detailview.setSevenStepImages(currentVariation);
		for (var i = 0; i < this.OrderIds.length;i++)
		{
			if (orderIdOfImage == this.OrderIds[i])
			{
				document.pulldown.colorselection.selectedIndex = i;
				
				break;
			}
		}
		detailview.setPricefieldsOnDetailview(currentVariation);
		this.currentSelectedVariation = currentVariation;
		jQuery("#artikelnr").html("Art.Nr: " + orderIdOfImage); //Artikelnummer ändern
			
		// VideoFlag_3D
		detailview.changeVideo3dButton(currentVariation.VideoFlag_3D);
	},
	
	//6-Stepbilder anzeigen
	setSevenStepImages: function(obj)
	{jQuery('#sevenstep').empty();
		if (obj.SevenStepImages && obj.SevenStepImages.length>0)
		{	
			for (i=0;i < obj.SevenStepImages.length;i++)
			{
				
				if (i == 0) currentImage=obj.SevenStepImages[i];
				var sevenStepImgDiv = BonusLayer.addNewDivLayer("sevenstep_" + obj.SevenStepImages[i].replace(/.jpg/g,''), 'left');
				jQuery(sevenStepImgDiv).html('<img onmouseover="this.className=\'sevenstepborderover\';detailview.setImageByImageName(\'' + obj.SevenStepImages[i] + '\')" onmouseout="this.className=\'sevenstepborderout\'" class="sevenstepborderout" src="http://bilder.baur.de/pool/formate/' + obj.SevenStepImages[i] + '">');
				
				jQuery('#sevenstep').append(sevenStepImgDiv);
			}
		}
	},
	
	//Grössenbilder anhand ProdRef ermitteln
	getSizeImageByProdRef: function(prodref)
	{
		for (var i = 0; i < this.SizeImageIterator.length; i++)
		{
			if (this.SizeImageIterator[i].ProductRefId == prodref)
				return this.SizeImageIterator[i];
		}
		return false;
	},
	
	getVariationsBySizeOrderId: function(orderId, size)
	{
		for (var i = 0; i < this.Variations.length; i++)
		{
			if (this.Variations[i].OrderId == orderId && DecodeString(this.Variations[i].Size) == size)
				return this.Variations[i];
		}
		return false;
	},
	
	getVariationsByOrderId: function(orderId)
	{
		for (var i = 0; i < this.Variations.length; i++)
		{
			if (this.Variations[i].OrderId == orderId)
				return this.Variations[i];
		}
		return false;
	},
	
	getVariationsByOrderIdWithoutPromo: function(orderId)
	{
		for (var i = 0; i < this.Variations.length; i++)
		{
			if (this.Variations[i].OrderId.substr(0,6) == orderId)
				return this.Variations[i];
		}
		return false;
	},
	
	getVariationsByProdRef: function(prodRef)
	{
		for (var i = 0; i < this.Variations.length; i++)
		{
			if (this.Variations[i].ProductRefId == prodRef)
				return this.Variations[i];
		}
		return false;
	},
	
	getVariationsByProdSKU: function(prodSKU)
	{
		for (var i = 0; i < this.Variations.length; i++)
		{
			if (this.Variations[i].ProductSKU == prodSKU)
				return this.Variations[i];
		}
		return false;
	},
	
	imageInArray: function(arr, image)
	{
		if (arr && image)
		{
			for (var i = 0; i < arr.length; i++)
			{
				if (arr[i].image == image) return true;
			}
		}
		return false;
	},
	
	//Hilfs-Methode um Arrays (arr) auf Inhalt (value) zu prüfen
	isInArray: function(value,arr)
	{
		if (arr.length>0)
		{
			for (var i=0; i < arr.length;i++)
			{
				if (arr[i] == value)
				{
					return true;
				}
			}
		}
		return false;
	},
	
	//Ermittelt MinPrice der Artikelnummer - attribute:Price oder OldPrice
	getVariationPrices: function(artnr,attribute)
	{
		var price = 0;
		for (i=0;i < this.Variations.length;i++)
		{
			var vari = this.Variations[i];
			if (vari.OrderId == artnr)
			{
				
				var checkPrice = parseFloat(detailview.prepare_number(vari[attribute]));
				if (checkPrice < price || price == 0) price = checkPrice;
				
			}
		}
		if (isNaN(price)) return false;
		else return detailview.prepare_string(price);
	},
	
	//Ermittelt Preisreduzierung des detailview-Objects
	getPriceReduction: function(obj)
	{
		var oldPrice = detailview.prepare_number(obj.OldPrice);
		var price = detailview.prepare_number(obj.Price);
		var priceReduction = parseInt(((price / oldPrice) - 1) * (-100));
		return priceReduction;
	},
	
	//Ermittelt max. Preisreduzierung der Artikelnummer
	getVariationMaxReduction: function(artnr)
	{
		var priceReduction = 0;
		for (i=0;i<this.Variations.length;i++)
		{
			var vari = this.Variations[i];
			if (vari.OrderId == artnr)
			{
				var checkpriceReduction = parseInt(detailview.getPriceReduction(vari));
				if (checkpriceReduction > priceReduction || priceReduction == 0) priceReduction = checkpriceReduction;
			}
		}
		if (isNaN(priceReduction)) return false;
		else return priceReduction.toFixed(0);
	},
	
	//Ob Artikelnummer Grössenläufe beinhaltet
	hasSizes: function(artnr)
	{
		var sizeCount = 0;
		for (i=0;i<this.Variations.length;i++)
		{
			if (this.Variations[i].Size !="" && this.Variations[i].Size!= "0" && this.Variations[i].OrderId==artnr)
				sizeCount++;
		}
		if (sizeCount>0) return true;
		return false;
	},
	
	//Ob Artikelnummer Grössenläufe mit verschiedenen Preisen beinhaltet
	hasDifferentPrices: function(artnr)
	{
		var sizeCount = 0;
		var price = 0;
		var hasDifferentPrices = false;
		var isFirstPrice = true;
		for (i=0;i < this.Variations.length;i++)
		{
			
			if (this.Variations[i].Size !="" && this.Variations[i].Size!= "0" && this.Variations[i].OrderId==artnr)
			{
				if (price != this.Variations[i].Price && !isFirstPrice)
				{
					hasDifferentPrices=true;
					break
				}
				price = this.Variations[i].Price;
				isFirstPrice = false;
			}
		}

		return hasDifferentPrices;
	},
	
	//Hilfsfunktion zum Formatieren von String in Zahl
	prepare_number: function(param)
	{
		var p_wert = param.toString();
		var p_vorkomma = 0;
		var p_nachkomma = 0;
		var start_dez = 0;
		var reg_exp_0 = /[^0^1^2^3^4^5^6^7^8^9^,^.]/;
		var reg_exp_1 = /\.[0-9]+$/;
		var reg_exp_2 = /\,[0-9]+$/;
		var reg_exp_3 = /\./;
		var reg_exp_4 = /\,/;
		while (p_wert.search(reg_exp_0) != -1) p_wert = p_wert.replace (reg_exp_0,"");
		
		start_dez = p_wert.search (reg_exp_1);
		if (start_dez == -1) start_dez = p_wert.search (reg_exp_2);
		if (start_dez == -1) start_dez = p_wert.length;
		
		p_vorkomma = p_wert.substr (0,start_dez);
		if (start_dez != p_wert.length) p_nachkomma = p_wert.substr (start_dez + 1, p_wert.length);
		
		while (p_vorkomma.search(reg_exp_3) != -1) p_vorkomma = p_vorkomma.replace (reg_exp_3,"");
		while (p_vorkomma.search(reg_exp_4) != -1) p_vorkomma = p_vorkomma.replace (reg_exp_4,"");
		
		return p_vorkomma + "." + p_nachkomma;
	},
	
	//Hilfsfunktion zum Formatieren von Zahl in String
	prepare_string: function(tmp_preis) 
	{
		
		
		tmp_preis = "" + tmp_preis;
		tmp_preis = tmp_preis.replace( /\./, "," );
		var trennzeichen = ",";
		

		if (tmp_preis.indexOf(trennzeichen)==-1) 
		{
			
			tmp_preis = tmp_preis + trennzeichen + "00";
			
		} 
		else 
		{
			if (tmp_preis.indexOf(trennzeichen)==tmp_preis.length-2) 
			{
				tmp_preis = tmp_preis + "0";
			}
			
		}
		if (tmp_preis.indexOf(trennzeichen)==0) 
		{
			tmp_preis = "0" + tmp_preis;
			
		}
		return tmp_preis;
	},
	
	//Funktion zum Ausverkauft-Button anzeigen, falls Artikel/Grösse ausverkauft
	showButtonSoldOut: function(soldout, hrefset)
	{
		if ( soldout )
		{
 			jQuery('#in_den_warenkorb_legen').attr('class','globalButton artikel_ausverkauft');
			jQuery('#in_den_warenkorb_legen').attr('title','Artikel ist ausverkauft');
			jQuery('#in_den_warenkorb_legen').attr('href','javascript:void(0);');
		}
		else
		{
  			jQuery('#in_den_warenkorb_legen').attr('class','globalButton in_den_warenkrob_legen');
			jQuery('#in_den_warenkorb_legen').attr('title','In den Warenkorb legen');
			jQuery('#in_den_warenkorb_legen').attr('href','javascript:basket_add(\'false\')');
		}
	},
	
	
	
	
	 
	
	
	getRatenRecommendation: function(tmp_preis_val)
	{
		var raten = 0;
		if ( tmp_preis_val < 27 ) 
			raten = 0;
		else if ( tmp_preis_val < 54 ) 	 
			raten = 3;
		else if ( tmp_preis_val < 90 ) 	 
			raten = 6;
		else if ( tmp_preis_val < 126 ) 	 
			raten = 10;
		else if ( tmp_preis_val < 180 ) 	 
			raten = 14;
		else if ( tmp_preis_val < 216 ) 	 
			raten = 20;
		else if ( tmp_preis_val < 324 ) 	 
			raten = 24;
		else if ( tmp_preis_val < 432 ) 	 
			raten = 36;
		else 
			raten = 48;
		return raten;
	},
	
	showRatenInfo: function(tmp_preis)
	{
		var tmp_preis_val = detailview.prepare_number(tmp_preis);
		if (this.Ratenfrompopup == "0")
		{
			raten = detailview.getRatenRecommendation( tmp_preis_val );
			if ( raten > 0 )
			{
				var monatsrate = calcRate( raten, tmp_preis_val );
				this.Ratenanzahl = raten;
				jQuery('#ratentext').html('oder EUR ' + detailview.prepare_string( monatsrate ) + ' in ' + raten + ' Raten');
			}
			else
			{
				jQuery('#ratentext').html('');
			}
		}
		else
		{				   
			var raten = this.Ratenanzahl;
			var monatsrate = calcRate( raten, tmp_preis_val );
			jQuery('#ratentext').html('oder EUR ' + detailview.prepare_string( monatsrate ) + ' in ' + raten + ' Raten');
		}	
	},
	
	getUVSAvailability: function()
	{
		var sendForm = document.pulldown;
		if ( (sendForm.sizeselection && sendForm.sizeselection[ sendForm.sizeselection.selectedIndex ].value == "") && !jQuery("#size").hasClass("skipElement"))
		{
			alert( 'Bitte wählen Sie eine Größe aus!' );
			return;
		}
		else
		{
			var sku = this.currentSelectedVariation.ProductSKU;
			var skuelems = sku.split("-"); 
			var articelnr = skuelems[0];
			
			var articelquantity = 100;
			var articelsize = 100;
			
			if (articelquantity==null) {articelquantity=1;}
			if (articelsize==null) {articelsize=0;}
			var ajaxurl = "http://www.baur.de/is-bin/INTERSHOP.enfinity/WFS/Baur-BaurDe-Site/de_DE/-/EUR/BV_ViewDeliveryInfo-IncludeDelivery?articelnr=" + articelnr + "&articelsize=" + articelsize + "&articelquantity=" + articelquantity;
			$.get(ajaxurl, function(data) {
				
				if (data.indexOf("ausverkauft")>-1)
				{
					setTimeout("detailview.showButtonSoldOut( true, true )",100); 
				}
				else
				{
					setTimeout("detailview.showButtonSoldOut( false, true )",100); 
				}
				
				jQuery('#lieferauskunft').html(data);
			});
		}		
	},
	
	convertText: function(desc){
		var newText ='';
		for (i=0;i<desc.length;i++)
		{
			newText = desc.substr(i,1) + newText;
		}
		return newText;
	},
	
	getMinRateUVS: function( ratenbetrag )
	{
		var Mindestrate = 10;	 
		if ( ratenbetrag > 100 ) Mindestrate = 12;
		if ( ratenbetrag > 150 ) Mindestrate = 14;
		if ( ratenbetrag > 360 ) Mindestrate = 15;
		if ( ratenbetrag > 400 ) Mindestrate = 16;
		if ( ratenbetrag > 500 ) Mindestrate = 19;
		if ( ratenbetrag > 600 ) Mindestrate = 22;
		if ( ratenbetrag > 700 ) Mindestrate = Math.round( 100.0 * 0.030324 * ratenbetrag ) / 100.0;
		return Mindestrate;
	},
	
	getMinRateSwiss: function( ratenbetrag )
	{
		var Mindestrate = 15;	 
		if ( ratenbetrag > 150 ) Mindestrate = 18;
		if ( ratenbetrag > 225 ) Mindestrate = 21;
		if ( ratenbetrag > 600 ) {
			Mindestrate = Math.round( 100.0 * 0.034197 * ratenbetrag ) / 100.0;
			if (Mindestrate < 21) Mindestrate = 21;
		}	
		return Mindestrate;
	},
	
	getAnzahlungProz: function( betrag ) 
	{
		var anzahlungProz = 10;
		if ( betrag > 220 ) anzahlungProz = 20;
		return anzahlungProz;
	},
	
	getAnzahlungProzSwiss: function( betrag ) 
	{
		return 0;
	},
	
	getAnzahlung: function( betrag ) 
	{
		return Math.round( 1.0 * detailview.getAnzahlungProz(betrag ) * betrag )/100.0;
	},
	
	getAnzahlungSwiss: function( betrag ) 
	{
		return Math.round( 1.0 * detailview.getAnzahlungProzSwiss(betrag ) * betrag )/100.0;
	},
	
	getMinRateUVSFromTotal: function( betrag )
	{
		return detailview.getMinRateUVS( betrag - detailview.getAnzahlung( betrag ) );
	},
	
	getMinRateSwissFromTotal: function( betrag )
	{
		return detailview.getMinRateSwiss( betrag - detailview.getAnzahlungSwiss( betrag ) );
	},
	
	showRatenInfoAllUvs: function(tmp_preis, writeString, vonwo)
	{
		var tmp_preis_val = detailview.prepare_number(tmp_preis);
		// attention: similiar calculations in ratenrechner_uvs.js
		if ( tmp_preis_val>50 )
		{
			var anzahlungproz = detailview.getAnzahlungProz( tmp_preis_val );
			var anzahlung = detailview.getAnzahlung( tmp_preis_val );
			 
			var ratenbetrag = tmp_preis_val - anzahlung;	 
			
			var Mindestrate = detailview.getMinRateUVS( ratenbetrag );	 
			 
			var q = 1.0165; // Zinsfaktor, monatlich
			var ratenzahl = Math.round( 10.0 * Math.log( Mindestrate/(Mindestrate-ratenbetrag*(q-1)) ) / Math.log( q ) ) / 10.0;
			 
			this.Ratenanzahl = ratenzahl;
			var ratentext = "";
			/*if (writeString)
			{
				jQuery('#ratentext').html("ab EUR " + detailview.prepare_string( Mindestrate ) + " monatlich");
			}
			else
			{
				jQuery('#ratentext').html(detailview.prepare_string( Mindestrate ));
			}*/
			jQuery('#ratentext').html("ab EUR " + detailview.prepare_string( Mindestrate ) + " monatlich");
			ratenzahlstr = "" + ratenzahl;
			ratenzahlstr = ratenzahlstr.replace( /\./, "," );
			
			if ((typeof messages) == "undefined") messages = new Array();
			
			if (vonwo == 'basket')
				messages['detailviewprice_uvs'] = 'wählen Sie hierfür im bestellschritt 3 die Zahlungsart "Ratenzahlung" aus - bei ' + anzahlungproz + '% Anzahlung und ' + ratenzahlstr + ' Raten';
			else
				messages['detailviewprice_uvs'] = '<strong>bei ' + anzahlungproz + '% Anzahlung und ' + ratenzahlstr + ' Raten</strong>';

			jQuery('#ratentextzusatz').html(messages);
		}
	},
	
	showRatenInfoUvs: function(tmp_preis, writeString)
	{
		var wo = "";
		detailview.showRatenInfoAllUvs(tmp_preis, writeString, wo)
	},
	
	showRatenInfoAllSwiss: function(tmp_preis, writeString, vonwo)
	{
		var tmp_preis_val = detailview.prepare_number(tmp_preis);
		// attention: similiar calculations in ratenrechner_uvs.js
		if ( tmp_preis_val>50 && tmp_preis_val <= 400 )
		{
			var anzahlungproz = detailview.getAnzahlungProzSwiss( tmp_preis_val );
			var anzahlung = detailview.getAnzahlungSwiss( tmp_preis_val );
			 
			var ratenbetrag = tmp_preis_val - anzahlung;	 
			
			var Mindestrate = detailview.getMinRateSwiss( ratenbetrag );	 
			 
			var q = 1.0117; // Zinsfaktor, monatlich
			var jahreszins = "15%";
			var ratenzahlExakt = Math.log( Mindestrate/(Mindestrate-ratenbetrag*(q-1)) ) / Math.log( q );
			var ratenzahl = Math.round( 10.0 * ratenzahlExakt ) / 10.0;
			var gesamtbetrag = Math.round( 100.0 * ratenzahlExakt * Mindestrate ) / 100.0;
			 
			this.Ratenanzahl = ratenzahl;
			var ratentext = "";
			/*if (writeString)
			{
				jQuery('#ratentext').html("ab EUR " + detailview.prepare_string( Mindestrate ) + " monatlich");
			}
			else
			{
				jQuery('#ratentext').html(detailview.prepare_string( Mindestrate ));
			}*/
			
			jQuery('#ratentext').html("ab EUR " + detailview.prepare_string( Mindestrate ) + " monatlich");
			ratenzahlstr = detailview.prepare_string(ratenzahl);//ratenzahlstr.replace( /\./, "," );
			gesamtbetragstr = detailview.prepare_string(gesamtbetrag);//gesamtbetragstr.replace( /\./, "," );
			var posi = gesamtbetragstr.indexOf( "," );
			/*if ( gesamtbetragstr.length > posi + 3 ) 
				gesamtbetragstr = gesamtbetragstr.substring( 0, posi + 3 );
			*/
			if ((typeof messages) == "undefined") messages = new Array();
			if (vonwo == 'basket')
				messages['detailviewprice_uvs'] = 'wählen Sie hierfür im Bestellschritt 3 die Zahlungsart "Ratenzahlung" aus - bei ' + anzahlungproz + '% Anzahlung und ' + ratenzahlstr + ' Raten';
			else
				messages['detailviewprice_uvs'] = '<strong>bei ' + ratenzahlstr + ' Raten ( Gesamtbetrag ' + gesamtbetragstr + ', ' + jahreszins + ' effektiver Jahreszins )</strong>';
			jQuery('#ratentextzusatz').html(messages);
		}
	},
	
	showRatenInfoSwiss: function(tmp_preis, writeString)
	{
		var wo = "";
		detailview.showRatenInfoAllSwiss(tmp_preis, writeString, wo)
	},
	
	//Abschluss-Element, muss letztes Element sein, um Probleme mit Komma im IE zu vermeiden
	Abschluss: ""
}
//initiales Aufrufen zum erstellen des detailview-Objects
detailview.initVariations("");
