
// L-Datei

cSMDiscounts.prototype.addForLogin=function($2C,$2D,$x,$2E,$36){
	var $g=this,$1c=$g.base,$1k=$g.xml,$1V=$g.parent,$2G=$2H=$2y=$2I=$2J=$37="";
	if($1c.raiseEvent(7,true,true,$g,$2C,$2D,$x,$2E)&&!$1V.$4P){
		$2G=$1k.getAttribute(_SMAAmount);
		$2H=$1k.getAttribute(_SMAMode);
		$37=$1k.getAttribute(_SMAHidden);
		$2y=$1k.getAttribute(_SMAValue);
		$2I=$1k.getAttribute(_SMATextBuffer);
		$2J=$1k.text;
		$2G+=(($2G.length>0)?";":"")+fnSMPIt($2C);
		$2H+=(($2H.length>0)?";":"")+$2D;
		$2y+=(($2y.length>0)?";":"")+fnSMRndCur($x);
		//$37+=(($37.length>0)?";":"")+($36?"1":"0");
		$37+=(($37.length>0)?";":"")+$36;
		$2I+=(($2I.length>0)?";":"")+$2E.length;
		$2J+=$2E;
		$1k.setAttribute(_SMAAmount,$2G);
		$1k.setAttribute(_SMAMode,$2H);
		$1k.setAttribute(_SMAHidden,$37);
		$1k.setAttribute(_SMAValue,$2y);
		$1k.setAttribute(_SMATextBuffer,$2I);
		$1k.text=$2J;
		$1c.raiseEvent(8,false,null,$g,$2C,$2D,$x,$2E);

		var oProdDiscList = document.getElementById("product_discounts");
		if(oProdDiscList){
			if(arguments.length > 5){
				if(arguments[5] == "LIST"){
					//nothing;
				} else {
					oProdDiscList.style.display = "inline";
					oProdDiscList.style.visibility = "visible";
				};
			} else {
				oProdDiscList.style.display = "inline";
				oProdDiscList.style.visibility = "visible";
			};
		};

	}else $1c.raiseEvent(10,false,null,$g,$2C,$2D,$x,$2E);
};

cSMDiscounts.prototype.remove=function($2C,$2D,$x,$2E,$36){
	var $g=this,$1c=$g.base,$1k=$g.xml,$1V=$g.parent,$2G=$2H=$2y=$2I=$2J=$37="";
	if($1c.raiseEvent(7,true,true,$g,$2C,$2D,$x,$2E)&&!$1V.$4P){
		$2G=$2C;
		$2H=$2D;
		$37=$36;
		$2y=$x;
		$2I='';
		$2J=$2E;
		$1k.setAttribute(_SMAAmount,$2G);
		$1k.setAttribute(_SMAMode,$2H);
		$1k.setAttribute(_SMAHidden,$37);
		$1k.setAttribute(_SMAValue,$2y);
		$1k.setAttribute(_SMATextBuffer,$2I);
		$1k.text=$2J;
		$1c.raiseEvent(8,false,null,$g,$2C,$2D,$x,$2E);
		var oProdDiscList = document.getElementById("product_discounts");
		if(oProdDiscList){
			if(arguments.length > 5){
				if(arguments[5] == "LIST") {
					//nothing;
				} else {
					//nothing;
				};
			} else {
				oProdDiscList.style.display = "none";
				oProdDiscList.style.visibility = "hidden";
			};
		};
	}else $1c.raiseEvent(10,false,null,$g,$2C,$2D,$x,$2E);
};

cSMDiscounts.prototype.CheckDefault = function(){
	var $k=this, $g=$k.parent;
	var bProdHasDefDisc = -1;
	var iTypeProdDefDisc = -1;
	var oIndivProdDisc = $g.getAttribute("IndivProdDisc");
	var aIndivProdDisc = oIndivProdDisc.split("_;_");
	var aProdDisc = new Array();
	for(var i=0; i<aIndivProdDisc.length; i++){
		aProdDisc[i] = aIndivProdDisc[i].split("_|_");
		if(parseFloat(aProdDisc[i][0])==1){
			bProdHasDefDisc = i;
			iTypeProdDefDisc = aProdDisc[i][1];
		};
	};
	return(bProdHasDefDisc);
};

cSMDiscounts.prototype.rewrite = function(){
	var $k=this, $g=$k.parent;
	var bProdHasDefDisc = -1;
	var iTypeProdDefDisc = -1;
	var iNewProdPrice = 0;
	var bProdIsDiscounted = false;
	var bSuggDone = false;
	var oIndivProdDisc = $g.getAttribute("IndivProdDisc");
	if(oIndivProdDisc=="false") return(0);
			$g.setAttribute("HasBaseDisc","false");
			$g.update();
			$g.discounts.remove('','','','','',(arguments[1] == "LIST") ? "LIST" : "");
			$g.discounts.update();
			$g.update();
			var aIndivProdDisc = oIndivProdDisc.split("_;_");
			var aProdDisc = new Array();
			for(var i=0; i<aIndivProdDisc.length; i++){
				aProdDisc[i] = aIndivProdDisc[i].split("_|_");
				if(parseFloat(aProdDisc[i][0])==1){
					bProdHasDefDisc = i;
					iTypeProdDefDisc = aProdDisc[i][1];
				};
			};
			for(var i=0; i<aIndivProdDisc.length; i++){
				var bProdHasActDisc = false;
				//Preisvorschlag
				if(arguments.length > 0) if(arguments[0] == "ProdPriceSug"){
						iPriceOrg = arguments[1];
						if(bInGross() != bOutGross()){
							var iTax = getVAT($g);
							if(!bInGross()){
								iPriceOrg = iPriceOrg / (1 + iTax);
							} else {
								iPriceOrg = iPriceOrg * (1 + iTax);
							};
						};
						bProdIsDiscounted = true;
						bProdHasActDisc = true;
						aProdDisc[i][2] = iPriceOrg;
						aProdDisc[i][1] = 0;
				};
				//Sonderpreis
				if(aProdDisc[i][1]==0 && arguments[0] != "ProdPriceSug") {	
					var iPriceOrg = aProdDisc[i][2];
					if(bInGross() != bOutGross()){
						var iTax = getVAT($g);
						if(!bInGross()){
							iPriceOrg = iPriceOrg * (1 + iTax);
						} else {
							iPriceOrg = iPriceOrg / (1 + iTax);
						};
					};
					if(getIndivProdDiscount(iPriceOrg,'',$g)>-1){
						iPriceOrg = getIndivProdDiscount(iPriceOrg,'',$g);
						bProdIsDiscounted = true;
						bProdHasActDisc = true;
					};
					if(bInGross() != bOutGross()){
						var iTax = getVAT($g);
						if(!bInGross()){
							iPriceOrg = iPriceOrg / (1 + iTax);
						} else {
							iPriceOrg = iPriceOrg * (1 + iTax);
						};
					};
					aProdDisc[i][2] = iPriceOrg;
				};
				//Prozent-Rabatt
				if(aProdDisc[i][1]==1 && bProdHasDefDisc>-1){
					var iPriceOrg = $g.getPrice();
					iPriceOrg = iPriceOrg*(100 - aProdDisc[i][2])/100;
					if(getIndivProdDiscount(iPriceOrg,'',$g)>-1){
						iPriceOrg = getIndivProdDiscount(iPriceOrg,'',$g);
						bProdIsDiscounted = true;
						bProdHasActDisc = true;
					};
					iPriceOrg = 100-((iPriceOrg/$g.getPrice())*100);
					aProdDisc[i][2] = iPriceOrg;
				};
				//Fix-Rabatt
				if(aProdDisc[i][1]==3 && bProdHasDefDisc>-1){
					var iPriceOrg = $g.getPrice();
					if(bInGross() != bOutGross()){
						var iTax = getVAT($g);
						if(!bInGross()){
							aProdDisc[i][2] = aProdDisc[i][2] * (1 + iTax);
						} else {
							aProdDisc[i][2] = aProdDisc[i][2] / (1 + iTax);
						};
					};
					iPriceOrg = iPriceOrg - aProdDisc[i][2];
					if(getIndivProdDiscount(iPriceOrg,'',$g)>-1){
						iPriceOrg = getIndivProdDiscount(iPriceOrg,'',$g);
						bProdIsDiscounted = true;
						bProdHasActDisc = true;
					};
					iPriceOrg = $g.getPrice() - iPriceOrg;
					if(bInGross() != bOutGross()){
						var iTax = getVAT($g);
						if(!bInGross()){
							iPriceOrg = iPriceOrg / (1 + iTax);
						} else {
							iPriceOrg = iPriceOrg * (1 + iTax);
						};
					};
					aProdDisc[i][2] = iPriceOrg;
				};
				//if(bProdHasActDisc){
					$g.discounts.addForLogin(aProdDisc[i][0],aProdDisc[i][1],aProdDisc[i][2],String(aProdDisc[i][3]),aProdDisc[i][4],(arguments[1] == "LIST") ? "LIST" : "");
				//};
				bProdHasActDisc = false;
			};
			$g.discounts.update();
			if(bProdHasDefDisc>-1){
				$g.setAttribute("HasBaseDisc","true");
			};
			$g.update();
			if(arguments.length > 0 && arguments[1] != "LIST"){
				displayProductProperties($g);
			};
			return(bProdIsDiscounted);
};

function getIndivProdDiscount(iProdPrice,sBreaker,oObj){
	var iProdPrice = arguments[0];
	var sBreaker = arguments[1];
	var oObj = arguments[2];
	if(oObj != '' && oObj != null){
		var $g = oObj;
	} else {
		var $g = SMProductLI;
	};
	var sProdManu = RemoveSpecialSigns(SX_uEsc($g.manufactName));
	if($g.getAttribute("OrgProdIdLIPL").length > 0){
		var sProdNumber1 = RemoveSpecialSigns($g.getAttribute("OrgProdIdLIPL"));
	} else {
		var sProdNumber1 = RemoveSpecialSigns($g.orgCode);
	};
	var sProdNumber2 = RemoveSpecialSigns($g.getAttribute(_SMACode));
	var sData = SMShop.getAttribute("UserDiscount");
	var aDiscounts = sData.split("_;_");
	var aFields = new Array();
	var bIsDiscounted = false;
	var bDiscountDone = false;
	var bProdNewPrice = false;
	var iProdNewPrice = 0;
	var iDiscAmntTyp1 = 0;
	var iDiscAmntTyp2 = 0;
	/* Tecberlin */
	var iDiscAmntTyp4 = 0;
	var iDiscAmntTyp5 = 0;
	var iDiscAmntTyp6 = 0;
	var iDiscAmntTyp7 = 0;
	/* Tecberlin */
	for(var i=0; i<aDiscounts.length; i++){
		aFields[i] = aDiscounts[i].split("|");
		if(aFields[i][0].length>0){
			var aRule = aFields[i][0].split("==");
			if(aRule[0] == 'product-price-sug' && (aRule[1] == sProdNumber1 || aRule[1] == sProdNumber2)){
				$g.setAttribute("suggestion",String(aFields[i][2] + "_|_" + aFields[i][4]));
				$g.update();
			};
			if(aRule[0] == 'manufacturer' && aRule[1] == sProdManu){
				bIsDiscounted = true;
			};
			if(aRule[0] == 'product' && (aRule[1] == sProdNumber1 || aRule[1] == sProdNumber2)){
				bIsDiscounted = true;
			};
			if(aRule[0] == 'product-new-price' && (aRule[1] == sProdNumber1 || aRule[1] == sProdNumber2)){
				bIsDiscounted = true;
				bProdNewPrice = true;
				iProdNewPrice = aFields[i][4];
			};
			if(aRule[0] == 'category'){
				var aCat = sProdToParentCats.split("_;_");
				var aCatDisc = new Array();
				for(var j=0; j<aCat.length; j++){
					aCatDisc[j] = aCat[j].split("_=_");
				};
				for(var j=0; j<aCat.length; j++){
					if(aRule[1] == aCatDisc[j][0] || aRule[1] == aCatDisc[j][1]){
						bIsDiscounted = true;
						break;
					};
				};
			};
			if(bIsDiscounted){
				var iDiscType = aFields[i][3];
				var iDiscAmou = aFields[i][4];
				iDiscAmou = iDiscAmou.replace(",",".");
				iDiscAmou = parseFloat(iDiscAmou);
				if(isNaN(iDiscAmou)){iDiscAmou = 0;};
				if(iDiscType == 1){
					iDiscAmntTyp1 += iDiscAmou;
				};
				if(iDiscType == 2){
					iDiscAmntTyp2 += iDiscAmou;
				};
				/* Tecberlin */
				if(iDiscType == 4){
					iDiscAmntTyp4 += iDiscAmou;
				};
				if(iDiscType == 5){
					iDiscAmntTyp5 += iDiscAmou;
				};
				if(iDiscType == 6){
					iDiscAmntTyp6 += iDiscAmou;
				};
				if(iDiscType == 7){
					iDiscAmntTyp7 += iDiscAmou;
				};
				/* Tecberlin */
			};
			bIsDiscounted = false;
		};
	};
	// Typ: 1=Fix
	//      2=%
	if(iDiscAmntTyp1 > 0){
		if(sBreaker=="getFixDiscount" && !bProdNewPrice) return(iDiscAmntTyp1);
		if(bInGross() != bOutGross()){
			var iTax = getVAT($g);
			if(!bInGross()){
				iProdPrice = iProdPrice / (1 + iTax);
			} else {
				iProdPrice = iProdPrice * (1 + iTax);
			};
		};
		iProdPrice = iProdPrice - iDiscAmntTyp1;
		if(bInGross() != bOutGross()){
			var iTax = getVAT($g);
			if(!bInGross()){
				iProdPrice = iProdPrice * (1 + iTax);
			} else {
				iProdPrice = iProdPrice / (1 + iTax);
			};
		};
		if(iProdPrice < 0){iProdPrice = 0;};
		bDiscountDone = true;
	};
	if(iDiscAmntTyp2 > 0){
		if(sBreaker=="getRelDiscount" && !bProdNewPrice) return(iDiscAmntTyp2);
		//iProdPrice = Math.round((iProdPrice*((100 - iDiscAmntTyp2) / 100)) / 0.01) * 0.01;
		iProdPrice = iProdPrice * ((100 - iDiscAmntTyp2) / 100);
		if(iProdPrice < 0){iProdPrice = 0;};
		bDiscountDone = true;
	};
	/* Tecberlin */
	if(iDiscAmntTyp4 > 0){
		if(sBreaker=="getRelDiscount1" && !bProdNewPrice) return(iDiscAmntTyp4);
		//iProdPrice = Math.round((iProdPrice*((100 - iDiscAmntTyp4) / 100)) / 0.01) * 0.01;
		iProdPrice = iProdPrice * ((100 - iDiscAmntTyp2) / 100);
		if(iProdPrice < 0){iProdPrice = 0;};
		bDiscountDone = true;
	};
	if(iDiscAmntTyp5 > 0){
		if(sBreaker=="getRelDiscount2" && !bProdNewPrice) return(iDiscAmntTyp5);
		//iProdPrice = Math.round((iProdPrice*((100 - iDiscAmntTyp5) / 100)) / 0.01) * 0.01;
		iProdPrice = iProdPrice * ((100 - iDiscAmntTyp2) / 100);
		if(iProdPrice < 0){iProdPrice = 0;};
		bDiscountDone = true;
	};
	if(iDiscAmntTyp6 > 0){
		if(sBreaker=="getRelDiscount3" && !bProdNewPrice) return(iDiscAmntTyp6);
		//iProdPrice = Math.round((iProdPrice*((100 - iDiscAmntTyp6) / 100)) / 0.01) * 0.01;
		iProdPrice = iProdPrice * ((100 - iDiscAmntTyp2) / 100);
		if(iProdPrice < 0){iProdPrice = 0;};
		bDiscountDone = true;
	};
	if(iDiscAmntTyp7 > 0){
		if(sBreaker=="getRelDiscount4" && !bProdNewPrice) return(iDiscAmntTyp7);
		//iProdPrice = Math.round((iProdPrice*((100 - iDiscAmntTyp7) / 100)) / 0.01) * 0.01;
		iProdPrice = iProdPrice * ((100 - iDiscAmntTyp2) / 100);
		if(iProdPrice < 0){iProdPrice = 0;};
		bDiscountDone = true;
	};
	/* Tecberlin */
	if(sBreaker=="getFixDiscount" || sBreaker=="getRelDiscount" || sBreaker=="getRelDiscount1" || sBreaker=="getRelDiscount2" || sBreaker=="getRelDiscount3" || sBreaker=="getRelDiscount4") return(0);
	if(bProdNewPrice){
		iProdPrice = iProdNewPrice;
		bDiscountDone = true;
	};
	if(bDiscountDone){
		return(iProdPrice);
	} else {
		return(-1);
	};
};

cSMDiscounts.prototype.LIrenderHTML = function(){
	var $t = this, $x = $t.xml, $go = false, $h = $n = "", $vl = $md = $o = $op = 0, $a = $v = $vd = $id = $tB = $hd = null;
	var Product = $t.parent;
	var oIndivProdDisc = Product.getAttribute("IndivProdDisc");
	var bProdHasDefDisc = -1;
	var iTypeProdDefDisc = -1;
	var aIndivProdDisc = oIndivProdDisc.split("_;_");
	var aProdDisc = new Array();
	for(var i=0; i<aIndivProdDisc.length; i++){
		aProdDisc[i] = aIndivProdDisc[i].split("_|_");
		if(parseFloat(aProdDisc[i][0])==1){
			bProdHasDefDisc = i;
			iTypeProdDefDisc = aProdDisc[i][1];
		};
	};
	try {
		var iFixDisc = getIndivProdDiscount(1,"getFixDiscount",Product);
		var iRelDisc = getIndivProdDiscount(1,"getRelDiscount",Product);
		var iRelDisc1 = getIndivProdDiscount(1,"getRelDiscount1",Product);
		var iRelDisc2 = getIndivProdDiscount(1,"getRelDiscount2",Product);
		var iRelDisc3 = getIndivProdDiscount(1,"getRelDiscount3",Product);
		var iRelDisc4 = getIndivProdDiscount(1,"getRelDiscount4",Product);
	}	catch(e) { };
	var sLoginDiscountFix = sLoginDiscountRel = sLoginDiscountRel1 = sLoginDiscountRel2 = sLoginDiscountRel3 = sLoginDiscountRel4 = '';
	if(iFixDisc>0) sLoginDiscountFix = cprimary.format(iFixDisc, SM_CGROUP + SM_CSYMBOL);
	if(iRelDisc>0) sLoginDiscountRel = cprimary.format(iRelDisc, 0.00) + "%";
	if(iRelDisc1>0) sLoginDiscountRel1 = cprimary.format(iRelDisc1, 0.00) + "%";
	if(iRelDisc2>0) sLoginDiscountRel2 = cprimary.format(iRelDisc2, 0.00) + "%";
	if(iRelDisc3>0) sLoginDiscountRel3 = cprimary.format(iRelDisc3, 0.00) + "%";
	if(iRelDisc4>0) sLoginDiscountRel4 = cprimary.format(iRelDisc4, 0.00) + "%";
	$op = $t.parent.getOriginalPrice();
	$md = $x.getAttribute(_SMAMode).split(";");
	$vl = $x.getAttribute(_SMAValue).split(";");
	$a = $x.getAttribute(_SMAAmount).split(";");
	$vd = $x.getAttribute(_SMAValueDiscount).split(";");
	$id = $x.getAttribute(_SMAItemDiscount).split(";");
	$tB = $x.getAttribute(_SMATextBuffer).split(";");
	$hd = $x.getAttribute(_SMAHidden).split(";");
	$qu = $x.parentNode.getAttribute(_SMAOQtyUnit);
	$qt = $x.getAttribute(_SMAMode).split(";");
	$h += "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\" class=\"discounts-list\">";
	$h += "<thead><tr><td colspan=\"4\" class=\"discounts-headline\">Rabatte</td></tr>";
	$h += "<tr>";
	$h += "<th class=\"discounts-name\">&nbsp;</th>";
	$h += "<th class=\"discounts-from-amount\">Ab " + $qu + "</th>";
	$h += "<th class=\"discounts-value\">Preis:/" + $qu + "</th>";
	$h += "<th class=\"discounts-saving\">Ersparnis</th>";
	$h += "</tr></thead><tbody>";
	for(var i=0; i<$a.length; i++){
		if($hd[i]!="1"){
			$go = true;
			$n = $x.text.substring($o, $o + parseInt($tB[i]));
			$o += parseInt($tB[i]);
			$h += "<tr valign=\"top\">";
			$h += "<td class=\"discounts-name\">" + $n + "&nbsp;</td>";
			$h += "<td class=\"discounts-from-amount\">" + $a[i] + "</td>";
			if(cint($qt[i]) != 2){
				$h += "<td class=\"discounts-value\">" + cprimary.format(fnSMPFt($vd[i]), SM_CGROUP + SM_CSYMBOL) + "</td>";
			} else {
				$h += "<td class=\"discounts-value\">+" + $id[i] + " " + $qu + " kostenlos</td>";
			};
			$h += "<td class=\"discounts-value\">";
			if(cint($qt[i]) != 2){

				if(iFixDisc>0 || iRelDisc>0){
					$h += "<div style=\"border-bottom: solid 1px #557535; text-align: right; white-space: nowrap;\">";
					$h += cprimary.format(Product.getOriginalPrice(), SM_CGROUP + SM_CSYMBOL) + "<br>";
					var iOldDiscPrice = 0;
					var iNewDiscPrice = 0;
					var sOldDiscPrice = '';
					if(aProdDisc[i][1]==0){
						iOldDiscPrice = Product.getOriginalPrice();
						iNewDiscPrice = aProdDisc[i][2];
						if(bInGross() != bOutGross()){
							var iTax = getVAT(Product);
							if(!bInGross()){
								iNewDiscPrice = iNewDiscPrice * (1 + iTax);
							} else {
								iNewDiscPrice = iNewDiscPrice / (1 + iTax);
							};
						};
						sOldDiscPrice += "-" + cprimary.format(iOldDiscPrice - iNewDiscPrice, SM_CGROUP + SM_CSYMBOL) + " = " + cprimary.format(iNewDiscPrice, SM_CGROUP + SM_CSYMBOL);
					};
					if(aProdDisc[i][1]==1){
						iOldDiscPrice = Product.getOriginalPrice() - (Product.getOriginalPrice() * ((100 - aProdDisc[i][2]) / 100));
						iNewDiscPrice = Product.getOriginalPrice() * ((100 - aProdDisc[i][2]) / 100);
						sOldDiscPrice += "-" + aProdDisc[i][2] + "% (" + cprimary.format(iOldDiscPrice, SM_CGROUP + SM_CSYMBOL) + ") = " + cprimary.format(iNewDiscPrice, SM_CGROUP + SM_CSYMBOL);
					};
					if(aProdDisc[i][1]==3){
						if(bInGross() != bOutGross()){
							var iTax = getVAT(Product);
							if(!bInGross()){
								aProdDisc[i][2] = aProdDisc[i][2] * (1 + iTax);
							} else {
								aProdDisc[i][2] = aProdDisc[i][2] / (1 + iTax);
							};
						};
						iOldDiscPrice = Product.getOriginalPrice() - (Product.getOriginalPrice() - aProdDisc[i][2]);
						iNewDiscPrice = Product.getOriginalPrice() - aProdDisc[i][2];
						sOldDiscPrice += "-" + cprimary.format(aProdDisc[i][2], SM_CGROUP + SM_CSYMBOL) + " = " + cprimary.format(iNewDiscPrice, SM_CGROUP + SM_CSYMBOL);
					};		
					$h += sOldDiscPrice + "<br>";
					if(iFixDisc>0){
						if(bInGross() != bOutGross()){
							var iTax = getVAT(Product);
							if(!bInGross()){
								iFixDisc = iFixDisc * (1 + iTax);
							} else {
								iFixDisc = iFixDisc / (1 + iTax);
							};
						};
						iNewDiscPrice = iNewDiscPrice - iFixDisc;
						$h += "<i>";
						$h += "-" + cprimary.format(iFixDisc, SM_CGROUP + SM_CSYMBOL) + " = " + cprimary.format(iNewDiscPrice, SM_CGROUP + SM_CSYMBOL);
						$h += "</i>";
					};
					if(iRelDisc>0){
						if(iFixDisc>0) $h += "<br>";
						sOldDiscPrice = iNewDiscPrice - (iNewDiscPrice * ((100 - iRelDisc) / 100));
						$h += "<i>";
						$h += "-" + iRelDisc + "% (" + cprimary.format(sOldDiscPrice, SM_CGROUP + SM_CSYMBOL) + ") = " + cprimary.format(iNewDiscPrice - sOldDiscPrice, SM_CGROUP + SM_CSYMBOL);
						$h += "</i>";
						iNewDiscPrice = iNewDiscPrice - sOldDiscPrice;
					};

					if(iRelDisc1>0){
						$h += "<br>";
						sOldDiscPrice = iNewDiscPrice - (iNewDiscPrice * ((100 - iRelDisc1) / 100));
						$h += "<i>";
						$h += "-" + iRelDisc1 + "% (" + cprimary.format(sOldDiscPrice, SM_CGROUP + SM_CSYMBOL) + ") = " + cprimary.format(iNewDiscPrice - sOldDiscPrice, SM_CGROUP + SM_CSYMBOL);
						$h += "</i>";
						iNewDiscPrice = iNewDiscPrice - sOldDiscPrice;
					};
					if(iRelDisc2>0){
						$h += "<br>";
						sOldDiscPrice = iNewDiscPrice - (iNewDiscPrice * ((100 - iRelDisc2) / 100));
						$h += "<i>";
						$h += "-" + iRelDisc2 + "% (" + cprimary.format(sOldDiscPrice, SM_CGROUP + SM_CSYMBOL) + ") = " + cprimary.format(iNewDiscPrice - sOldDiscPrice, SM_CGROUP + SM_CSYMBOL);
						$h += "</i>";
						iNewDiscPrice = iNewDiscPrice - sOldDiscPrice;
					};
					if(iRelDisc3>0){
						$h += "<br>";
						sOldDiscPrice = iNewDiscPrice - (iNewDiscPrice * ((100 - iRelDisc3) / 100));
						$h += "<i>";
						$h += "-" + iRelDisc3 + "% (" + cprimary.format(sOldDiscPrice, SM_CGROUP + SM_CSYMBOL) + ") = " + cprimary.format(iNewDiscPrice - sOldDiscPrice, SM_CGROUP + SM_CSYMBOL);
						$h += "</i>";
						iNewDiscPrice = iNewDiscPrice - sOldDiscPrice;
					};
					if(iRelDisc4>0){
						$h += "<br>";
						sOldDiscPrice = iNewDiscPrice - (iNewDiscPrice * ((100 - iRelDisc4) / 100));
						$h += "<i>";
						$h += "-" + iRelDisc4 + "% (" + cprimary.format(sOldDiscPrice, SM_CGROUP + SM_CSYMBOL) + ") = " + cprimary.format(iNewDiscPrice - sOldDiscPrice, SM_CGROUP + SM_CSYMBOL);
						$h += "</i>";
						iNewDiscPrice = iNewDiscPrice - sOldDiscPrice;
					};

					$h += "</div>";
				};
				//$h += (($md[i]==1) ? $vl[i] + "% = " : "") + cprimary.format($op - fnSMPFt($vd[i]), SM_CGROUP + SM_CSYMBOL);
				$h += "<b>";
				//$h += "- ";
				$h += cprimary.format($op - fnSMPFt($vd[i]), SM_CGROUP + SM_CSYMBOL);
				$h += "</b>";
			} else {
				$h += cprimary.format($id[i] * $op, SM_CGROUP + SM_CSYMBOL);
			};
			$h += "</td>";
			$h += "</tr>";
			};
		};
	$h += "</tbody></table>";
	if(!$go) $h = "";
	return($h);
};

function displayProductProperties(Product){
	var $image = null, $elem = null, $basePriceTemplate = "", $fSetData = function(){ var $elem = null; try{ $elem = document.getElementById(arguments[0]); if($elem!=null) $elem.innerHTML = arguments[1]; } catch(e){ }; };
	var iFixDisc = 0;
	var iRelDisc = 0;
	var sOldPrice = '';
	try {
		if(initLogin()=='OK'){
			var iFixDisc = parseFloat(getIndivProdDiscount(1,"getFixDiscount",Product));
			var iRelDisc = parseFloat(getIndivProdDiscount(1,"getRelDiscount",Product));
		};
	}	catch(e) { };
	if(iFixDisc>0 || iRelDisc>0){
		var $OrgPrice1 = parseFloat(Product.getOriginalPrice());
		var $OrgPrice2 = parseFloat(Product.getPrice());
		$OrgPrice2 = $OrgPrice2 / ((100 - iRelDisc) / 100);
		$OrgPrice2 = $OrgPrice2 + iFixDisc;
		sOldPrice += cprimary.format(Product.getOriginalPrice(), SM_CGROUP + SM_CSYMBOL);
	};
	try {$image = new Image(); $image.src = Product.image;}	catch(e) {$image = null;};
	try {
	with(document){
		if($image!=null&&Product.image!=""){if(getElementById("product_picture")){getElementById("product_picture").src = $image.src;};};
		$fSetData("product_name", Product.name);
		$fSetData("product_desc", Product.desc);
		$fSetData("product_id", Product.getAttribute(_SMACode));
		$fSetData("product_weight", nprimary.format(Product.getAttribute(_SMAWeight), SM_CGROUP));
		if(Product.getAttribute("HasBaseDisc")=="true" && sOldPrice.length>0){
			$fSetData("product_original_price", sOldPrice);
		} else {
			$fSetData("product_original_price", cprimary.format(Product.getOriginalPrice(), SM_CGROUP + SM_CSYMBOL));
		};
		$fSetData("product_price", cprimary.format(Product.getPrice(), SM_CGROUP + SM_CSYMBOL));
		$fSetData("product_price_seccur", csecondary.format(Product.getPrice(), SM_CGROUP + SM_CSYMBOL));
		if(Product.getAttribute("HasBaseDisc")=="true" && Product.getAttribute("HasStff")!="true"){
			$fSetData("product_discounts", Product.discounts.LIrenderHTML());
		} else {
			$fSetData("product_discounts", Product.discounts.renderHTML());
		};
		$fSetData("product_base_price", formatProductBasePrice(Product));
		if(Product.deliveryTimeFKID!=0){$fSetData("product_delivery_caption", unescape(SMShop.deliveryTimes[Product.deliveryTimeFKID][1]));};
		$elem = getElementById("product_delivery_img");
		if($elem&&Product.deliveryTimeFKID!=0){try {$image = new Image();$image.src = $elem.src.replace(/(.+\/[^\d\/]+)\d+(\.[a-z]+)/gi, "$1" + Product.deliveryTimeFKID + "$2");}	catch(e) {$image = null};if($image!=null) $elem.src = $image.src;};
	};
	if(Product.getPrice() != Product.getOriginalPrice()){
		showIdTag("product_price_prefix","Alter Preis:&nbsp;");
		showIdTag("product_discount_prefix","Ihr Preis:&nbsp;");
	} else {
		var iOrgPrice = parseFloat(Product.getAttribute("VeryOrgPriceLI"));
		if(isNaN(iOrgPrice)) iOrgPrice = 0;
		if(bInGross() != bOutGross()){
			var iTax = getVAT(Product);
			if(!bInGross()){
				iOrgPrice = iOrgPrice * (1 + iTax);
			} else {
				iOrgPrice = iOrgPrice / (1 + iTax);
			};
		};
		iOrgPrice = Math.round(iOrgPrice * 100) / 100;
		if((Math.round(Product.getPrice() * 100) / 100)!=iOrgPrice && iOrgPrice>0){
			showIdTag("product_price_prefix","Alter Preis:&nbsp;");
			showIdTag("product_discount_prefix","Ihr Preis:&nbsp;");
			showIdTag("product_original_price",cprimary.format(iOrgPrice, SM_CGROUP + SM_CSYMBOL));
		} else {;
			hideIdTag("product_price_prefix","");
			hideIdTag("product_original_price","");
			hideIdTag("product_discount_prefix","");
		};
	};
	}	catch(e) { };
};

function reinitVariantsBaseDisc(sFormName){
	var frm1 = document[sFormName];
	if(frm1!=null){
 		for(var i=0; i<frm1.elements.length; i++){
		  var elem1 = frm1.elements[i];
  	 	if(elem1.type=="select-one"){
  	 		var sFunc = String(elem1.onchange);
  	 		var iFunc = sFunc.indexOf("{");
  	 		sFunc = sFunc.substr(iFunc + 1);
  	 		iFunc = sFunc.lastIndexOf("}");
  	 		sFunc = sFunc.substring(0, iFunc);
  	 		eval('elem1.onchange = function(){MakeLIPriceReset_BaseDisc();' + sFunc + ';MakeLIPriceReinit_BaseDisc();};');
  		};
  	};
  	return(sFunc);
 	} else {
 		return('NO_VARIANTS');
 	};
};

function MakeLIPrice_init_BaseDisc(){
	if(arguments.length >= 1){
		var $g = arguments[0];
	} else {
		var $g = SMProductLI;
	};
	var sBaseDiscount = '';
	var iCatDiscount = parseFloat($g.getAttribute(_SMAPrdDiscount));
	if(isNaN(iCatDiscount)){iCatDiscount = 0;};
	if(iCatDiscount > 0){
		$g.setAttribute("CatDiscount",iCatDiscount);
		$g.setAttribute(_SMAPrdDiscount,0);
		$g.update();
	};
	var iOrgPrice = $g.getOriginalPrice();
	if(bInGross() != bOutGross()){
		var iTax = getVAT($g);
		if(!bInGross()){
			iOrgPrice = iOrgPrice / (1 + iTax);
		} else {
			iOrgPrice = iOrgPrice * (1 + iTax);
		};
	};
	$g.setAttribute("OrgPriceLI",iOrgPrice);
	$g.setAttribute("VeryOrgPriceLI",iOrgPrice);
	$g.update();
};

function MakeLIPriceReset_BaseDisc(){
	var $g=SMProductLI;
	var iOrgPrice = $g.getAttribute("VeryOrgPriceLI");
	var iOrgDisc = $g.getAttribute("CatDiscount");
	$g.setAttribute(_SMAPrice,iOrgPrice);
	$g.setAttribute(_SMAPrdDiscount,iOrgDisc);
	$g.variants.updateLI(iOrgPrice);
	$g.update();
};

function MakeLIPriceReinit_BaseDisc(){
	var $g=SMProductLI;
	var iCatDiscount = parseInt($g.getAttribute(_SMAPrdDiscount), 10);
	if(isNaN(iCatDiscount)){iCatDiscount = 0;};
	if(iCatDiscount > 0){
		$g.setAttribute("CatDiscount",iCatDiscount);
		$g.setAttribute(_SMAPrdDiscount,0);
		$g.update();
	};
	var iOrgPrice = $g.getOriginalPrice();
	if(bInGross() != bOutGross()){
		var iTax = getVAT($g);
		if(!bInGross()){
			iOrgPrice = iOrgPrice / (1 + iTax);
		} else {
			iOrgPrice = iOrgPrice * (1 + iTax);
		};
	};
	$g.setAttribute("OrgPriceLI",iOrgPrice);
	$g.setAttribute("VeryOrgPriceLI",iOrgPrice);
	$g.update();
	$g.discounts.rewrite();
};
