

/* SmartLog-Version: 3.2.1 XL */

cSMBasket.prototype.LIreset=function(){
	var $g=this,$t=arguments,$1c=$g.base,$1k=$g.xml,$2n=($t[0])?$t[0]:false;
	if($2n){
		while($1k.selectNodes(_SMPrd).length()>0){
			$1k.removeChild($1k.selectSingleNode(_SMPrd));
		};
	};
};

function initLogin(){
	var sReturn = 'OK';
	var sTest_LI = '';
	try {
		sTest_LI = SMShop.getAttribute("UserLogin");
	} catch(e) { };
	if((sTest_LI.length==0) || (sTest_LI=="false")){
		SMShop.setAttribute("UserLogin", "false")
		SMShop.update();
		return('NO_USER');
	};
	sTest_LI = '';
	try {
		sTest_LI = SMShop.getAttribute("UserDiscount");
	} catch(e) { };
	if((sTest_LI.length==0) || (sTest_LI=="false")){
		SMShop.setAttribute("UserDiscount", "false")
		SMShop.update();
		return('NO_DISC');
	};
	return(sReturn);
};

function LogMeInData(sData){
	SMShop.setAttribute("UserLogin", sData);
	SMShop.update();
};

function UserLogout(){
	var sPathLogout = SMShop.getAttribute("LIuserLogoutPath");
	SMShop.basket.LIreset(true);
	SMShop.basket.update();
	SMShop.setAttribute("UserLogin", "false");
	SMShop.setAttribute("UserDiscount", "false");
	SMShop.setAttribute("StffDiscount", "false");
	SMShop.update();
	removeLoginDiscounts();
	SMProduct = null;
	SMProductLI = null;
	SMSession.removeSession(SMShop.id);
	SMSession.save();

	var http_sl_request = false;
	http_sl_request = false;
	if(window.XMLHttpRequest){
		http_sl_request = new XMLHttpRequest();
		if(http_sl_request.overrideMimeType){
			http_sl_request.overrideMimeType("text/xml");
		};
	} else if(window.ActiveXObject){
		try {
			http_sl_request = new ActiveXObject("Msxml2.XMLHTTP");
		} catch (e) { };
	} else try {
		http_sl_request = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (e) { };
	if (!http_sl_request) {
		//alert("Kann keine XMLHTTP-Instanz erzeugen");
	} else {;
		try{
			var url = "./modules/login/php/logout.php5";
			http_sl_request.open("GET",sPathLogout,true);
			http_sl_request.send(null);	
		} catch(e) { };
	};
	var oElem = document.getElementsByName("smartLog")[0];
	if(!oElem) var oElem = document.getElementById("smartLog");
	if(oElem){
		oElem.src = sPathLogout;
	} else if(arguments.length > 0){
		var sHTML = '<iframe name="FrmSmartLogInfoLogout" id="FrmSmartLogInfoLogout" src="' + arguments[0] + '" scrolling="no" frameborder="0" width="1" height="1"></iframe>';
		document.getElementById("smartLogInfoLogout").innerHTML = sHTML;
	} else {
		location.href = location.href;
	};
};

function setIframeDimensions(n,iAddWidth,iAddHeight){
 	var args = arguments;
 	if(args.length == 1) var n = args[0];
	if(args.length == 2) var iAddWidth = args[1];
	if(args.length == 3) var iAddHeight = args[2];
	var d = 15;
 	if(iAddHeight>0) d = iAddHeight;
 	try {
	  var ifObj = document.getElementsByName(n)[0];
  	if(!ifObj) var ifObj = document.getElementById(n);
	  if(!ifObj) return(false);
  	var p = (document.all)?'scroll':'offset';
		if(iAddWidth > 0){
			ifObj.style.width = String(iAddWidth) + "px";
		} else {
			eval("ifObj.style.height=Math.max(1,window.frames[n].document.getElementsByTagName('body')[0]."+p+"Width+"+d+")+'px'");
		};
 		eval("ifObj.style.height=Math.max(1,window.frames[n].document.getElementsByTagName('body')[0]."+p+"Height+"+d+")+'px'");
	 	return(true);
	} catch(e) { };
};

function LIExtractField(sChain, sPosit){
	var aChain = sChain.split("_;_");
	for(var i=0; i<aChain.length; i++){
		var aField = aChain[i].split("_=_");
		if(aField[0] == sPosit){return(aField[1]);};
	};
	return('');
};

function getUserName(){
	sLoginData = SMShop.getAttribute("UserLogin");
	return(LIExtractField(sLoginData, 'USERNAME'));
};

function LIUserIsIn(){
	sLoginData = SMShop.getAttribute("UserLogin");
	var sLI_Name = LIExtractField(sLoginData, 'BILLTO_LASTNAME');
	var sLI_Firstname = LIExtractField(sLoginData, 'BILLTO_FIRSTNAME');
	var sLI_Company = LIExtractField(sLoginData, 'BILLTO_COMPANY');
	var sLI_Salutation = LIExtractField(sLoginData, 'BILLTO_SALUTATION');
	var sLI_Prompt = '';
	var sLI_Result = '';
	if(sLI_Company.length>0) sLI_Prompt = sLI_Company;
	if(sLI_Name.length>0 && sLI_Firstname.length>0) sLI_Prompt = sLI_Firstname + ' ' + sLI_Name;
	if(sLI_Name.length>0 && sLI_Firstname.length==0 && sLI_Salutation.length>0) sLI_Prompt = sLI_Salutation + ' ' + sLI_Name;
	sLI_Result += 'Guten Tag_NAME_!<BR>Willkommen in unserem Shop!';
	if(sLI_Prompt.length>0){
		var userNameString = ' ' + sLI_Prompt;
	} else {
		var userNameString = sLI_Prompt;
	};
	sLI_Result = sLI_Result.replace(/_NAME_/,userNameString);
	document.write(sLI_Result);
	return(LIExtractField(sLoginData, 'USERNAME'));
};

function printLoginToForms(sType,iLfdNr,sContent){
	try {
		if(sContent.length == 0){
			var sLogin = SMShop.getAttribute("UserLogin");
		} else {
			var sLogin = sContent;
		};
	} catch(e) { };
	if((sLogin.length==0) || (sLogin=="false")){
		return(false);
	};
	var aLogin = sLogin.split("_;_");
	var aUserData = new Array;
	for(var i=0; i<aLogin.length; i++){
		var aField = aLogin[i].split("_=_");
		aUserData[i] = new Array();
		aUserData[i][0] = aField[0];
		aUserData[i][1] = aField[1];
	};
	for(var i=0; i<aUserData.length; i++){
		try {
			if(document.getElementsByName(aUserData[i][0]).length > 0){
				if(aUserData[i][0].indexOf("COUNTRY") > 0 && aUserData[i][1].length > 2){
					//document.getElementsByName(aUserData[i][0])[0].value = LIgetRegion(aUserData[i][1]);
				} else if(aUserData[i][0].indexOf("SALUTATION") > 0 && document.getElementsByName(aUserData[i][0]).length > 0){
					var sDDElem = document.getElementsByName(aUserData[i][0]);
					for(var j=0; j<sDDElem.length; j++){
						if(sDDElem.options[j].value == aUserData[i][1]){
							sDDElem.options[j].selected = true;
							break;
						};
					};
				} else {
					document.getElementsByName(aUserData[i][0])[0].value = aUserData[i][1];
				};
			};
		} catch(e) { };
	};
	var bShipToDiff = false;
	for(var i=0; i<aUserData.length; i++){
		if(aUserData[i][0].indexOf("SHIPTO")>=0 && aUserData[i][1].length>0){
			if(aUserData[i][0].indexOf("COUNTRY")>=0 || aUserData[i][0].indexOf("SALUT")>=0){
				//nothing
			} else {
				bShipToDiff = true;
			};
		};
	};
	if(bShipToDiff){
		if(document.getElementsByName("BILLTO_SHIPTO_DIFFERS").length > 0){
			document.forms.BILLTO.BILLTO_SHIPTO_DIFFERS.checked = true;
		};
	};
	// Contact Form
	if(iLfdNr == 1){
		sLogin = sLogin.replace(/BILLTO/g, "CONTACT");
		var sStreet1 = LIExtractField(sLogin, 'CONTACT_STREET_1');
		var sStreet2 = LIExtractField(sLogin, 'CONTACT_STREET_2');
		sLogin += '_;_CONTACT_STREET_=_';
		sLogin += sStreet1 + ' (' + sStreet2 + ')';
		printLoginToForms("CONTACT", 2, sLogin);
	};
	// Individual Form 1.Step
	if(iLfdNr == 2){
		sLogin = sLogin.replace(/CONTACT/g, "MAILFORM");
		printLoginToForms("MAILFORM", 3, sLogin);
	};
	//  Individual Form 2.Step
	if(iLfdNr == 3){
		var sLI_Name_IMF = LIExtractField(sLogin, 'MAILFORM_LASTNAME');
		var sLI_Firstname_IMF = LIExtractField(sLogin, 'MAILFORM_FIRSTNAME');
		var sLI_Mail_IMF = LIExtractField(sLogin, 'MAILFORM_EMAIL');
		var sLI_NewName_IMF = sLI_Firstname_IMF + ' ' + sLI_Name_IMF;
		sLogin += '_;_FromName_=_' + sLI_NewName_IMF;
		sLogin += '_;_FromMail_=_' + sLI_Mail_IMF;
		printLoginToForms("MAILFORM", 4, sLogin);
	};
};

function printLoginButtons(sURL2){
	var sHTMLf = '';
	sHTMLf += '<div id="divUserLogButtons" align="center">';
	sHTMLf += '<a href="javascript:UserLogout()"><img src="' + sURL2 + '" alt="abmelden"></a>';
	sHTMLf += '<br>abmelden';
	sHTMLf += '</div>';
	document.write(sHTMLf);
};

function printLoginButtonsAdmin(sURL2){
	var sHTMLf = '';
	sHTMLf += '<div style="padding-top:20px" align="center">&nbsp;</div>';
	sHTMLf += '<div id="divUserLogButtonsAdmin" style="width:250px;overflow:show;padding:10px" align="center">';
	sHTMLf += '<a href="javascript:UserLogout()"><img src="' + sURL2 + '" alt="abmelden"></a>';
	sHTMLf += '<br>abmelden';
	sHTMLf += '</div>';
	sHTMLf += '<div style="padding-bottom:20px" align="center">&nbsp;</div>';

	sHTMLf += '<div id="2ndLogoutButton" style="z-index:99999999; position:absolute; right:15px; top:20px; width:60px; height:60px" align="center">';
	sHTMLf += '<a href="javascript:UserLogout()"><img src="' + sURL2 + '" alt="abmelden"></a>';
	sHTMLf += '</div>';

	return(sHTMLf);
};

function RemoveSpecialSigns(sText){
	sText = sText.replace(/"/g, '');
	sText = sText.replace(/'/g, '');
	sText = sText.replace(/&/g, '');
	sText = sText.replace(/§/g, '');
	sText = sText.replace(/\\/g, '');
	sText = sText.replace(/²/g, '');
	sText = sText.replace(/³/g, '');
	sText = sText.replace(/\|/g, '');
	sText = sText.replace(/°/g, '');
	return(sText);
};

function LIFindHeight(){
	var y;
	if (self.innerHeight){
		y = self.innerHeight;
	}	else if (document.documentElement && document.documentElement.clientHeight){
		y = document.documentElement.clientHeight;
	} else if (document.body){
		y = document.body.clientHeight;
	};
	return(y);
};

function LIFindWidth(){
	var x;
	if (self.innerHeight){
		x = self.innerWidth;
	}	else if (document.documentElement && document.documentElement.clientHeight){
		x = document.documentElement.clientWidth;
	} else if (document.body){
		x = document.body.clientWidth;
	};
	return(x);
};

function ReloadLoginWindow(){
	location.href = location.href;	
};

function ShowAdminFrame(sURL){
	var oFrame = document.getElementsByTagName("body")[0];
	oFrame.style.overflow = "hidden";

	var oFrame = document.getElementById("SmartLogBackgroundFrame");
	var iScreenX = LIFindWidth();
	var iScreenY = LIFindHeight();
	oFrame.style.zIndex = "99999997";
	oFrame.style.position = "absolute";
	oFrame.style.left = "0px";
	oFrame.style.top = "0px";
	oFrame.style.width = String(iScreenX)+"px";
	oFrame.style.height = String(iScreenY)+"px";
	oFrame.style.backgroundImage = "url('" + sURL + "')";
	oFrame.style.backgroundRepeat = "repeat";
	oFrame.style.overflow = "hidden";

	var oFrame = document.getElementById("SmartLogAdminFrame");
	var iScreenX = LIFindWidth();
	var iScreenY = LIFindHeight();
	oFrame.style.zIndex = "99999998";
	oFrame.style.position = "absolute";
	oFrame.style.left = "0px";
	oFrame.style.top = "0px";
	oFrame.style.width = String(iScreenX)+"px";
	oFrame.style.height = String(iScreenY)+"px";
	oFrame.style.overflow = "scroll";
};

function setLogoutBackground(){  
	var sColor = "";
	try {
		sColor = SMShop.getAttribute("LIbgColor");
	} catch(e) { };
	if(sColor != ""){
		document.getElementById("divUserLogButtonsAdmin").style.backgroundColor = sColor;
	};
};

// ** M ->

cSMGDiscounts.prototype.addForLogin = function(id,$2C,$2D,$x,$2E){
	var $g=this,$1c=$g.base,$1k=$g.xml,$2F="",$2G="",$2H="",$2y="",$2I="",$2J="";
	if($1c.raiseEvent(7,true,true,$g,$2C,$x,$2E)){
		$2F=$1k.getAttribute(_SMAUniqueID);
		$2G=$1k.getAttribute(_SMAAmount);
		$2H=$1k.getAttribute(_SMAMode);
		$2y=$1k.getAttribute(_SMAValue);
		$2I=$1k.getAttribute(_SMATextBuffer);
		$2J=$1k.text;
		if(SMShop.getAttribute("finit")=="1"){
			$2F+=(($2F.length>0)?";":"")+id;
			$2G+=(($2G.length>0)?";":"")+fnSMRndCur($2C);
			$2H+=(($2H.length>0)?";":"")+$2D;
			$2y+=(($2y.length>0)?";":"")+fnSMRndCur($x);
			$2I+=(($2I.length>0)?";":"")+$2E.length;
			$2J+=$2E;
		};
		$1k.setAttribute(_SMAUniqueID,$2F);
		$1k.setAttribute(_SMAAmount,$2G);
		$1k.setAttribute(_SMAMode,$2H);
		$1k.setAttribute(_SMAValue,$2y);
		$1k.setAttribute(_SMATextBuffer,$2I);
		$1k.text=$2J;
		$1c.raiseEvent(8,false,null,$g,$2C,$x,$2E);
	}else $1c.raiseEvent(10,false,null,$g,$2C,$x,$2E);
};

cSMGDiscounts.prototype.remove = function(id,$2C,$2D,$x,$2E){
	var $g=this,$1c=$g.base,$1k=$g.xml,$2F="",$2G="",$2H="",$2y="",$2I="",$2J="";
	if($1c.raiseEvent(7,true,true,$g,$2C,$x,$2E)){
		$2F = id;
		$2G = fnSMRndCur($2C);
		$2H = $2D;
		$2y = fnSMRndCur($x);
		$2I = $2E.length;
		$2J = $2E;
		$1k.setAttribute(_SMAUniqueID,$2F);
		$1k.setAttribute(_SMAAmount,$2G);
		$1k.setAttribute(_SMAMode,$2H);
		$1k.setAttribute(_SMAValue,$2y);
		$1k.setAttribute(_SMATextBuffer,$2I);
		$1k.text=$2J;
		$1c.raiseEvent(8,false,null,$g,$2C,$x,$2E);
	}else $1c.raiseEvent(10,false,null,$g,$2C,$x,$2E);
};

function LogMeInDiscount(sData){
	SMShop.setAttribute("UserDiscount", sData);
	SMShop.update();
};

function LogMeInDiscountText(sData){
	SMShop.setAttribute("UserDiscountText", sData);
	SMShop.update();
};

function getUserDiscountText(sType){
	var sData = SMShop.getAttribute("UserDiscountText");
	var oData = sData.split("_X_");
	if(sType=="text") return(oData[0]);
	if(sType=="bool") return((oData[1]=="true" || oData[1]==true)?true:false);
	return("");
};

function setLoginDiscounts(){
	removeLoginDiscounts();
	var sData = SMShop.getAttribute("UserDiscount");
	if((sData.length==0) || (sData=="false")){return(false);};
	var aDiscounts = sData.split("_;_");
	SMShop.setAttribute("finit", "1");
	SMShop.update();
	for(var i=0; i<aDiscounts.length; i++){
		var aFields = aDiscounts[i].split("|");
		if(aFields[0].length == 0){
			if(aFields[2] == 0 && aFields[4] != 0){aFields[2] = 0.01;};
			with(SMShop.basket.discounts){addForLogin(aFields[1], aFields[2], (aFields[3] - 1), aFields[4], aFields[5]);};
			SMShop.basket.discounts.update();
			SMShop.basket.update();
			SMShop.update();
		};
	};
	SMShop.setAttribute("finit", "0");
	SMShop.update();
};

function removeLoginDiscounts(){
	SMShop.basket.discounts.remove(0,0,0,0,"Sie erhalten keine Rabatte.");
	SMShop.basket.discounts.update();
	SMShop.basket.update();
	SMShop.update();
};

function printLoginDiscountsDetail(sLink){
	var sHTMLh = sHTMLb = sHTMLf = '';
	sHTMLh += '<br>&nbsp;<br>';
	sHTMLh += '<div align="center">';
	sHTMLb += 'Sie erhalten keine Rabatte. Wenn Sie an einer persönlichen Rabatt-Staffelung interessiert sind, _START_LINK_setzen Sie sich bitte mit uns in Verbindung_END_LINK_.';
	sHTMLb = sHTMLb.replace(/_START_LINK_/,'<a href="' + sLink + '">');
	sHTMLb = sHTMLb.replace(/_END_LINK_/,'</a>');
	sHTMLf += '</div>';
	sHTMLf += '<span id="LoginInlineFrame">&nbsp;</span>';
	var sData = '';
	if(getUserDiscountText("text").length>0){
		document.write('<br>&nbsp;<br>' + getUserDiscountText("text") + '<br>&nbsp;');
	};
	try {
		sData = SMShop.getAttribute("UserDiscount");
	} catch(e) { };
	if((sData.length==0) || (sData=="false") || (sData==false)){
		try {
			sData = SMShop.getAttribute("StffDiscount");
		} catch(e) { };
		if(sData.length>0){
			//document.write("<br>&nbsp;<br>Sie erhalten auf verschiedene Hersteller, Kategorien oder Produkte gesonderte Rabattstaffeln. Diese werden bei den entsprechenden Produkten angezeigt. Details finden Sie auch auf der Login-Seite.");
			//return(false);
		} else {
			document.write(sHTMLb);
			return(false);
		};
	};
	var aDiscounts = sData.split("_;_");
	if(aDiscounts.length == 1){
		var aFields = aDiscounts[0].split("|");
		if(aFields[4] == 0){
			if(getUserDiscountText("bool")){
				document.write(sHTMLh + sHTMLb + sHTMLf);
			};
			return(false);
		};
	};
	if(!getUserDiscountText("bool")){
		document.write(sHTMLh + sHTMLf);
		return(false);
	};
	sHTMLb = '';
	sHTMLb += 'Sie erhalten folgende Rabatte:<br>&nbsp;<br>';
	sHTMLb += '<table class="LIDiscTab" cellspacing="0">';
	sHTMLb += '	<tr>';
	sHTMLb += '		<td class="LIDiscTabHead" style="color:#D2D2D2">Beschreibung</td>';
	sHTMLb += '		<td class="LIDiscTabHead" style="color:#D2D2D2">Rabatt-Art</td>';
	sHTMLb += '		<td class="LIDiscTabHead" style="color:#D2D2D2">Rabatt</td>';
	sHTMLb += '	</tr>';
	for(var i=0; i<aDiscounts.length; i++){
		var aFields = aDiscounts[i].split("|");
		aFields[2] = cprimary.format(aFields[2], SM_CGROUP + SM_CSYMBOL);
		aFields[2] = aFields[2].replace("&nbsp;", " ");
		if(String(aFields[3]) == "1"){
			aFields[4] = cprimary.format(aFields[4], SM_CGROUP + SM_CSYMBOL);
			aFields[4] = aFields[4].replace("&nbsp;", " ");
		} else if(String(aFields[3]) == "2"){
			aFields[4] = cprimary.format(aFields[4]) + "%";
		/* Tecberlin */
		} else if(parseInt(aFields[3],10) >= 4 && parseInt(aFields[3],10) <= 7){
			aFields[4] = cprimary.format(aFields[4]) + "%";
		/* Tecberlin */
		};
		if(String(aFields[3]) == "1"){
			aFields[3] = "Fester Rabattbetrag";
		} else if(String(aFields[3]) == "2"){
			aFields[3] = "Prozent";
		/* Tecberlin */
		} else if(String(aFields[3]) == "4"){
			aFields[3] = "Prozent-Stufe 1";
		} else if(String(aFields[3]) == "5"){
			aFields[3] = "Prozent-Stufe 2";
		} else if(String(aFields[3]) == "6"){
			aFields[3] = "Prozent-Stufe 3";
		} else if(String(aFields[3]) == "7"){
			aFields[3] = "Prozent-Stufe 4";
		/* Tecberlin */
		};
		if(aFields[5].length == 0){
			aFields[5] = "&nbsp;";
		}
		if(aFields[0].indexOf("product-price-sug") >= 0){
			sHTMLb += '	<tr>';
			sHTMLb += '		<td class="LIDiscTabBody">' + aFields[5] + '</td>';
			sHTMLb += '		<td class="LIDiscTabBody" align="center" colspan="2">verhandeln Sie den Preis</td>';
			sHTMLb += '	</tr>';
		} else if(aFields[0].indexOf("product-new-price") >= 0){
			sHTMLb += '	<tr>';
			sHTMLb += '		<td class="LIDiscTabBody">' + aFields[5] + '</td>';
			sHTMLb += '		<td class="LIDiscTabBody">&nbsp;</td>';
			sHTMLb += '		<td class="LIDiscTabBody" align="right">' + aFields[4] + '</td>';
			sHTMLb += '	</tr>';
		} else {
			sHTMLb += '	<tr>';
			sHTMLb += '		<td class="LIDiscTabBody">';
			if(aFields[0].length == 0){
				sHTMLb += aFields[5];
				if(aFields[5].length > 0) sHTMLb += '<br>';
				sHTMLb += 'auf den gesamten Warenkorb ab ' + aFields[2];
			} else {
				if(aFields[5].length == 0){
					sHTMLb += '&nbsp;';
				} else sHTMLb += aFields[5];
			};
			sHTMLb += '		</td>';
			sHTMLb += '		<td class="LIDiscTabBody">' + aFields[3] + '</td>';
			sHTMLb += '		<td class="LIDiscTabBody" align="right">' + aFields[4] + '</td>';
			sHTMLb += '	</tr>';
		};
	};
	sHTMLb += '	</table>';
	try {
		sData = SMShop.getAttribute("UserDiscount");
	} catch(e) { };
	if((sData.length==0) || (sData=="false") || (sData==false)){
		sHTMLb = 'Sie erhalten folgende Rabatte::<br>&nbsp;<br>';
	};
	document.write(sHTMLh + sHTMLb + sHTMLf);
	sData = SMShop.getAttribute("StffDiscount");
	if(sData.length>0 && sData!="false"){
		var sStffP = getSerializedStff("product");
		var sStffC = getSerializedStff("category");
		var sStffM = getSerializedStff("manufacturer");
		sHTMLb = '';
		sHTMLb += '<div style="padding:20px" align="center"><table class="LIDiscTab" cellspacing="0">';
		sHTMLb += '<tr>';
		if(sStffM!="none") sHTMLb += '<td class="LIDiscTabHead" style="color:#D2D2D2" align="center">Hersteller-Staffeln</td>';
		if(sStffC!="none") sHTMLb += '<td class="LIDiscTabHead" style="color:#D2D2D2" align="center">Kategorie-Staffeln</td>';
		if(sStffP!="none") sHTMLb += '<td class="LIDiscTabHead" style="color:#D2D2D2" align="center">Produkt-Staffeln</td>';
		sHTMLb += '</tr><tr>';
		if(sStffM!="none"){
			var aStffM = sStffM.split(", ");
			sHTMLb += '<td class="LIDiscTabBody">';
			sHTMLb += '<p><UL>';
			for(var i=0; i<aStffM.length; i++){
				sHTMLb += '<LI>' + aStffM[i] + '</LI>';
			};
			sHTMLb += '</UL></p>';
			sHTMLb += '</td>';
		};
		if(sStffC!="none"){
			var aStffC = sStffC.split(", ");
			var sCatList = '60==Schalldämpfer_;_79==GPZ 900 R-  GPZ 750 R_;_88==Krümmer_;_100==Yamaha_;_114==Yamaha_;_131==Blenden_;_158==Suzuki_;_162==Suzuki_;_172==Suzuki_;_177==ZZR 1100_;_195==Kawasaki_;_200==Kawasaki_;_210==Kawasaki_;_235==Eagle Sidewinder_;_238==Ersatzteile_;_240==Ersatzteile_;_265==Eagle Classic_;_1356==Komplettanlage_;_449==K 1200 S +R_;_359==CBR 1000 F_;_389==FJ 1200_;_390==GPZ 1000 RX_;_458==Ersatzteile_;_471==Eagle RST_;_472==Honda_;_473==Yamaha_;_1124==Komplettanlage_;_1432==Komplettanlagen_;_1706==Eagle Mach7_;_1164==CB1300_;_1165==Ninja 250 R_;_1166==GPZ500 -S_;_1167==ZZR 600_;_1168==ZX 6R + RR_;_1170==ER6n-f_;_1171==Versys_;_1172==ZXR 750_;_1173==ZX 7R_;_1228==GSX 1400_;_1229==GSX 1400 K1-K3_;_1230==GSX 1400 K4-_;_1231==Hayabusa GSX-R 1300_;_1232==B-King_;_1628==Bolton_;_1672==Slipon_;_1134==HOT DEALZZ_;_1119==Aprilia_;_1120==Slipon_;_1274==K 1300 GT_;_1275==K 1300 R+S_;_1276==R 1200  R_;_1277==Speed Four_;_1298==Bolton_;_985==GPZ 1100 UT_;_986==GPZ 750 UT_;_987==GPZ 750-Z750_;_1580==Slipon_;_1581==Slipon_;_1372==Slipon_;_522==XV 1600 Wild Star_;_1722==Slipon / Bolton_;_501==VTX 1300 C_;_475==Kawasaki_;_476==Ersatzteile_;_477==VT750 Shadow Aero-Spirit_;_478==VTX 1300_;_480==XVS 650 Drag Star_;_1137==Produktportfolio_;_1447==Slipon_;_530==VN 800 Classic_;_989==Z1R_;_1423==Komplettanlagen_;_1540==Komplettanlage_;_1622==Slipon_;_1623==Slipon_;_1417==Zephyr 750_;_1418==Komplettanlage_;_1421==Bolton_;_1422==Komplettanlagen_;_1155==CBF1000_;_1156==CBF1000F_;_1157==CB 1000 R_;_1730==Kawasaki_;_1731==Suzuki_;_1732==Yamaha_;_1426==Komplettanlage_;_1427==Komplettanlage_;_1428==Komplettanlage_;_1429==Komplettanlage_;_1431==Komplettanlage_;_1433==Komplettanlage_;_1434==Komplettanlage_;_1435==Komlettanlage_;_1436==Komplettanlage_;_1437==Komplettanlage_;_1438==Komplettanlage_;_1123==Komplettanlage_;_502==VN 1600 Meanstreak_;_1301==Slipon_;_1740==Komplettanlage_;_504==Harley Davidson Auspuffanlagen_;_1115==Yamaha_;_1220==GSX-R 1000 K5-K6_;_1221==GSX-R 1000 K7-K8_;_1222==GSX-R 1000 K9-L0,L1,Z_;_1223==TL 1000 S,R_;_1746==Slipon / Bolton_;_1747==Komplettanlagen_;_1307==Slipon_;_1308==Slipon_;_1309==Slipon_;_1310==Slipon_;_1312==Slipon_;_1313==Slipon_;_1314==Slipon_;_1315==Slipon_;_1316==Slipon_;_381==Zephyr 1100_;_383==FJ1100_;_474==Suzuki_;_1648==Slipon_;_1649==Slipon_;_1650==Slipon_;_1651==Slipon_;_1652==Slipon_;_1653==Slipon_;_1654==Slipon_;_1273==R 1200 S-R-GT-Sport_;_1644==Slipon_;_1317==Slipon_;_1673==Slipon_;_1318==Slipon_;_1319==Slipon_;_1320==Slipon_;_1321==Slipon_;_1322==Slipon_;_1323==Slipon_;_1324==Bolton_;_1325==Bolton_;_1326==Bolton_;_1327==Bolton_;_1328==Bolton_;_1150==VFR 800_;_1152==Honet 900_;_1153==CBR 900 RR_;_1154==CB 1000 Big One_;_1257==FJR 1300_;_1258==V-MAX_;_1259==XJR 1200_;_1260==XJR 1300_;_1261==G 650 GS_;_1262==F 650 CS Scarver_;_1263==F 650 GS - F 800 GS_;_1264==F 800 ST+S_;_1265==F 800 R_;_1266==R 850 R_;_1267==R 850 GS_;_1268==S 1000 RR_;_1269==R 1100 GS + R_;_1270==R 1150 GS + R + Rockster_;_1726==Komplettanlagen_;_495==VN 1600 Vulcan_;_497==DB-Killer_;_481==XVS 1100 Drag Star_;_482==XVS 1300 A Midnight Star_;_484==Roadstar Warrior XV 1700_;_485==XV 1900 Midnight Star_;_486==VL 800 Intruder Volusia_;_1158==CBR 1000RR Fireblade_;_1159==VTR 1000_;_1160==VTR 1000SP1_;_1161==VTR 1000SP2 Firestorm_;_1162==CBR 1100 - XX_;_1163==X-11_;_516==VLX 600 Shadow_;_1720==Predator_;_1113==BMW_;_398==Z1000 J+R- GPZ1100 - UT_;_1362==Komplettanlage_;_1733==GSX-R 750 L1-_;_1734==GSX - R 600 L1-_;_1735==Slipon_;_1736==Slipon_;_322==GPZ 750 UT- GPZ750_;_1059==HP2 1200_;_1707==Black Eagle_;_1708==Monster Eagle_;_517==VL 1500 LC Intruder_;_518==VZ 800 Marauder_;_519==VS 750/800_;_494==VN 1500 Meanstreak_;_1107==Suzuki_;_1109==Kawasaki_;_1111==Honda_;_1112==Slipon_;_1364==Komplettanlage_;_509==Kawasaki_;_1357==Komplettanlage_;_31==Honda_;_505==Classic Cruiser_;_506==Honda_;_965==VL 1500_;_966==VS 1400_;_967==VS 750 / 800_;_968==VZ 800 / 2000_;_970==XVS 1100_;_1737==Komplettanlage_;_1738==CB 750 Bol´dor; KZ;FA_;_1739==CB 900 Bol´dor; KZ;FA_;_1408==Bolton_;_1409==Bolton_;_1278==Dayatona 600 - 650_;_1748==Tiger 800_;_1749==Slipon_;_1750==Speed Triple (1060)_;_1751==Slipon_;_1618==Slipon_;_1640==Slipon_;_1641==Slipon_;_1642==Slipon_;_1522==GSX 750-1100-E-EF-Katana_;_1723==Komplettanlagen_;_972==XVS 650_;_974==XV 1700_;_976==VT 1100_;_977==VN 1500_;_978==VN 2000_;_981==CB 750 / 900 / 1100 F_;_983==GSX 1100_;_984==Katana_;_510==VF 750 Magna_;_1347==Komplettanlage_;_1350==Slipon_;_1351==Bolton_;_1352==Komplettanlage_;_1353==Slipon_;_1354==Bolton_;_1355==Komplettanlage_;_1358==Slipon_;_1359==Bolton_;_1360==Komplettanlage_;_1361==Komplettanlage_;_1363==Komplettanlage_;_1365==X 4_;_1366==Slipon_;_1367==Bolton_;_1369==Slipon_;_1370==Slipon_;_1371==Slipon_;_319==CB 750-CB 900 F-CB 1100 F_;_1729==Slipon Dämpfer_;_528==VN 1500/1600 Meansteak_;_529==VN 1600 Vulcan - Classic_;_1742==Z 1100 ST_;_1743==Komplettanlage_;_1744==Underseat_;_1745==Eagle/Predator Auspuffanlagen_;_1560==Slipon_;_962==Zubehör_;_1117==Triumph_;_1374==Slipon_;_1375==Slipon_;_1376==Slipon_;_1377==Slipon_;_1379==Slipon_;_1380==Slipon_;_1381==Slipon_;_1383==Slipon_;_1385==Slipon_;_1386==Slipon_;_1387==Slipon_;_1388==Slipon_;_1389==Slipon_;_1390==Slipon_;_1395==Bolton_;_1396==Bolton_;_1400==Bolton_;_1401==Bolton_;_1404==Bolton_;_1407==Bolton_;_1717==Komplettanlage_;_1718==Komplettanlage_;_36==Honda_;_1419==ZXR 400_;_1103==Monster 600-620_;_1104==600 - 800 Sport_;_508==Yamaha_;_1619==Slipon_;_1621==Slipon_;_1646==Slipon_;_1271==R 1200 GS_;_493==VN 1500 Vulcan_;_1439==Komplettanlage_;_1440==Komplettanlage_;_1441==GPZ 1100 Hurricane_;_1456==Slipon_;_1457==Slipon_;_1458==Slipon_;_1459==Slipon_;_1460==Slipon_;_1527==Komplettanlage_;_1528==GSX-R 750 L + M_;_1529==Slipon_;_1531==Komplettanlage_;_1532==GSX 1100 F_;_1535==Komplettanlage_;_1536==GSX-R 1100_;_1537==Komplettanlage_;_1563==Slipon_;_1564==Slipon_;_1566==Slipon_;_1567==Slipon_;_1568==Slipon_;_1569==Slipon_;_1570==Slipon_;_1464==Slipon_;_1467==Slipon_;_1468==Slipon_;_1469==Slipon_;_1470==Slipon_;_1471==Slipon_;_1475==Slipon_;_1476==Slipon_;_1477==Slipon_;_1478==Slipon_;_1479==Slipon_;_1480==Slipon_;_1481==Slipon_;_1482==Slipon_;_1694==GSX-R 750 K8-L0_;_1699==Slipon_;_1700==Slipon_;_1701==Bolton_;_1702==Bolton_;_1705==Komplettanlage_;_1233==RF 600F, R,RU_;_1234==GSX - R 600_;_1235==GSX- R 600 K1-K2_;_1236==GSX- R 600 K3-K5_;_1643==Slipon_;_1550==Komplettanlage_;_1551==Komplettanlage_;_1552==GSX-R 1100 W_;_1553==GSX 1100 G_;_1554==Komplettanlage_;_1555==Komplettanlage_;_1556==GSX-R 600 SRAD_;_1557==Komplettanlage_;_1558==K5-_;_1559==Slipon_;_1561==Slipon_;_1562==Slipon_;_988==Z 1000_;_1256==BT 1100 Bulldog_;_1571==Slipon_;_1573==Slipon_;_963==ABE DB-Killer Einsätze_;_1446==Slipon_;_1186==ZZR1400_;_1187==1400 GTR_;_1188==Gladius SFV 650_;_1189==GSX 600 F_;_487==M800 + C800 + Volusia 800_;_488==VL 1500 LC Intruder_;_489==Intruder C 1500_;_1691==GSX-R 750 K1-K2_;_1192==GSF 600 Bandit_;_1193==GSR 600 - GSR 400_;_1199==GSF 650 Bandit_;_1201==GSX 650 F_;_1202==SV 650_;_1203==V Strom DL 650_;_1247==TDM 850_;_1248==TRX 850_;_1249==FZ8_;_1414==Bolton_;_1538==Komplettanlage_;_1539==Komplettanlage_;_1302==Slipon_;_1303==Slipon_;_1304==Slipon_;_1305==Slipon_;_1306==Slipon_;_1329==Bolton_;_1330==Bolton_;_1331==Bolton_;_1332==Bolton_;_1333==Bolton_;_1335==Bolton_;_1336==Bolton_;_1647==Slipon_;_1413==Bolton_;_1072==Hyosung_;_1073==Comet GT 650 R - S_;_1607==Komplettanlage_;_1337==Bolton_;_1338==Bolton_;_1339==Bolton_;_1340==Bolton_;_1341==Bolton_;_1342==Bolton_;_1343==Bolton_;_1344==Bolton_;_1345==Bolton_;_1415==Bolton_;_1416==Komplettanlage_;_1724==Slipon/Bolton Dämpfer_;_1624==Slipon_;_1625==Slipon_;_1626==Slipon_;_1627==Bolton_;_1741==Komplettanlage_;_498==Dämpfer / Cartridge Einsätze_;_1254==FZS 1000 Fazer_;_1255==FZ1 - Fazer1000 - GT1000_;_1578==Slipon_;_1579==Slipon_;_1594==Bolton_;_1639==Slipon_;_1130==VN 2000_;_1178==ZX-9R Ninja_;_1179==Z1000 (+SX)_;_1181==ZX-10R Ninja_;_1182==ZRX1100_;_1183==ZRX 1200_;_1184==ZZR 1200_;_1208==GSX-R 750 W_;_1209==GSX-R 750 WT - SRAD_;_1216==RF 900_;_1217==GSX-R 1000_;_1218==GSX-R 1000 K1-K2_;_1219==GSX-R 1000 K3-K4_;_1671==Slipon_;_1424==Komplettanlage_;_1079==Cruiser-Chopper_;_1080==Pro Street_;_1725==Slipon/Bolton Dämpfer_;_1279==TT600_;_1280==Daytona 675_;_1281==Daytona_;_1283==Street Triple_;_1284==Speed Triple (1050)_;_1285==Sprint RS (Zweiarm)_;_1286==Sprint RS (Einarm) 955i_;_1287==Sprint ST 955i_;_1288==Tiger 1050_;_1289==Speed Triple_;_1443==Slipon_;_1272==R 1200 RT/ST_;_1541==GSX 1200 Inazuma_;_1544==Komplettanlage_;_1545==Komplettanlage_;_1546==Komplettanlage_;_1547==Komplettanlage_;_1549==Komplettanlage_;_1609==Komplettanlage_;_1425==Komplettanlage_;_523==XVS 650 Drag Star_;_524==XV 750/1000/1100 Virago_;_525==XVS 1100 Drag Star_;_526==Marauder VZ 1600_;_527==VN 1500 Classic_;_1294==R 1100 S_;_490==Marauder VZ 1600_;_491==Intruder M 1800 R_;_492==VN 900_;_409==CB 750 Sevenfifty_;_1448==Slipon_;_1411==Bolton_;_1674==Slipon_;_1675==RSV 1000 Mille +R_;_1676==Tuono 1000 Fighter_;_1677==Slipon_;_1680==Bolton_;_1681==Slipon_;_1682==Slipon_;_1683==Slipon_;_1684==Slipon_;_1685==Komplettanlage_;_1686==Predator_;_1687==Predator X2_;_1688==Eagle M7_;_1689==Bolton_;_1693==GSX-R 750 K6-K7_;_1149==XRV 750 Africa Twin_;_1100==Ducati_;_1101==Monster 900-1000-S4_;_1102==Monster 750-800_;_964==Katalysatoren_;_1574==Slipon_;_1575==Slipon_;_1576==Slipon_;_1577==Slipon_;_1709==GSF 1250 Bandit_;_1710==Slipon_;_1711==GSX 1250 F_;_1712==Slipon_;_1713==Bolton/Slipon Dämpfer_;_1714==Komplettanlagen_;_1132==Predator X1_;_1604==Komplettanlage_;_1605==Komplettanlage_;_1606==Komplettanlage_;_1612==Komplettanlage_;_1613==Komplettanlage_;_1616==Slipon_;_352==FZR 1000_;_521==VS 1400 Intruder_;_1523==GSX-R 750_;_1524==Slipon_;_1525==Bolton_;_1526==Komplettanlage_;_507==Suzuki_;_1721==Komplettanlagen_;_1645==Slipon_;_1127==VT 1100 C3 Shadow Aero_;_1141==CB250 R_;_1142==CB 500 N+S_;_1143==CBF 500_;_1144==CBR 600 F_;_1145==Hornet 600_;_1146==CBF 500 / 600_;_1147==CBR 600 RR_;_1148==VFR750F_;_520==VL 800 Intruder Volusia, C800, M800_;_1237==GSX- R 600 K6-K7_;_1238==GSX- R 600 K8-L0_;_1239==FZR 500_;_1240==FZR 600_;_1241==FZR 600 R_;_1242==YZF 600 R_;_1244==YZF R6_;_1245==FZS 600 Fazer_;_1246==YZF 750 R-SP_;_1250==TDM 900_;_1251==FZR 1000 Exup_;_1252==YZF 1000 R_;_1253==YZF R1_;_1174==ZR7/S_;_1176==Z750 (+S)_;_1177==Z 750R_;_1185==ZX12-R_;_1346==Bolton_;_1505==Bolton_;_1506==Bolton_;_1507==Bolton_;_1508==Bolton_;_1512==Bolton_;_1513==Bolton_;_1515==Bolton_;_1517==Bolton_;_1518==Bolton_;_1695==Komplettanlage_;_1519==Bolton_;_22==Honda_;_1205==GSX 750 F_;_1206==GSX 750 Inazuma_;_1690==GSX-R 750 SRAD_;_990==Z 650_;_991==Z 900_;_1224==SV 1000_;_1225==GSX 1200_;_1226==GSF 1200 Bandit_;_1227==GSX 1250 F - Bandit 1250_;_1462==Slipon_;_1463==Slipon_;_1719==Eagle Mach 7_;_1629==Bolton_;_1486==Bolton_;_1494==Bolton_;_1495==Bolton_;_1692==GSX-R 750 K3-K5_;_511==VT 1100 Shadow_;_512==VT 1100 C2 Ace_;_513==VTX 1300 C_;_514==VT 750 Shadow C2 Ace_;_515==VT 750 Shadow Aero-Spirit_;_435==Upgrades_;_1727==Slipon / Bolton_;_1728==Komplettanlage_;_1752==XJ 600 Diversion_;_1753==Slipon_;_1754==Komplettanlage_;_1755==Slipon High up_;_1756==VN 900_;_1757==VN 1500 Vulcan A/B_;_1758==Predator Vortex';
			var aCatList = sCatList.split("_;_");
			var oCatList = new Array();
			for(var i=0; i<aCatList.length; i++){
				oCatList[i] = aCatList[i].split("==");
			};
			sHTMLb += '<td class="LIDiscTabBody">';
			sHTMLb += '<p><UL>';
			for(var i=0; i<aStffC.length; i++){
				for(var j=0; j<aCatList.length; j++){
					if(aStffC[i]==oCatList[j][0]){
						aStffC[i] = oCatList[j][1];
						break;
					};
				};
				sHTMLb += '<LI>' + aStffC[i] + '</LI>';
			};
			sHTMLb += '</UL></p>';
			sHTMLb += '</td>';
		};
		if(sStffP!="none"){
			var aStffP = sStffP.split(", ");
			sHTMLb += '<td class="LIDiscTabBody">';
			sHTMLb += '<p><UL>';
			for(var i=0; i<aStffP.length; i++){
				sHTMLb += '<LI>' + aStffP[i] + '</LI>';
			};
			sHTMLb += '</UL></p>';
			sHTMLb += '</td>';
		};
		sHTMLb += '</tr>';
		sHTMLb += '</table></div>';
		document.write(sHTMLb);
	};

	return(true);
};

function printLoginDiscountsSummary(sLink){
	var sHTMLb = '';
	sHTMLb += '<br>Sie erhalten keine Rabatte. Wenn Sie an einer persönlichen Rabatt-Staffelung interessiert sind, _START_LINK_setzen Sie sich bitte mit uns in Verbindung_END_LINK_.';
	sHTMLb = sHTMLb.replace(/_START_LINK_/,'<a href="' + sLink + '">');
	sHTMLb = sHTMLb.replace(/_END_LINK_/,'</a>');
	var sData = '';
	if(getUserDiscountText("text").length>0){
		document.write('<br>&nbsp;<br>' + getUserDiscountText("text") + '<br>&nbsp;');
	};
	try {
		sData = SMShop.getAttribute("UserDiscount");
	} catch(e) { };
	if((sData.length==0) || (sData=="false") || (sData==false)){
		try {
			sData = SMShop.getAttribute("StffDiscount");
		} catch(e) { };
		if(sData.length>0){
			if(getUserDiscountText("bool")){
				document.write("<br>&nbsp;<br>Sie erhalten auf verschiedene Hersteller, Kategorien oder Produkte gesonderte Rabattstaffeln. Diese werden bei den entsprechenden Produkten angezeigt. Details finden Sie auch auf der Login-Seite.");
			};
			return(false);
		} else {
			document.write(sHTMLb);
			return(false);
		};
	};
	var aDiscounts = sData.split("_;_");
	if(aDiscounts.length == 1){
		var aFields = aDiscounts[0].split("|");
		if(aFields[4] == 0){
			if(getUserDiscountText("bool")){
				document.write(sHTMLb);
			};
			return(false);
		};
	};
	if(!getUserDiscountText("bool")){
		return(false);
	};
	var	sHTMLb = '';
	sHTMLb += '<br>Sie erhalten folgende Rabatte:';
	for(var i=0; i<aDiscounts.length; i++){
		var aFields = aDiscounts[i].split("|");
		var aRule = aFields[0].split("==");
		aFields[2] = cprimary.format(aFields[2], SM_CGROUP + SM_CSYMBOL);
		aFields[2] = aFields[2].replace("&nbsp;", " ");
		if(String(aFields[3]) == "1"){
			aFields[4] = cprimary.format(aFields[4], SM_CGROUP + SM_CSYMBOL);
			aFields[4] = aFields[4].replace("&nbsp;", " ");
		} else if(String(aFields[3]) == "2"){
			aFields[4] = cprimary.format(aFields[4]) + "%";
		/* Tecberlin */
		} else if(parseInt(aFields[3],10) >= 4 && parseInt(aFields[3],10) <= 7){
			aFields[4] = cprimary.format(aFields[4]) + "% (Stufe " + String(parseInt(aFields[3],10) - 3) + ")";
		/* Tecberlin */
		};
		if(aRule[0]=="manufacturer"){
			sHTMLb += '<p>' + aFields[5] + ': ' + aFields[4] + '</p>';
		} else if(aRule[0]=="category"){
			sHTMLb += '<p>' + aFields[5] + ': ' + aFields[4] + '</p>';
		} else if(aRule[0]=="product"){
			sHTMLb += '<p>' + aFields[5] + ': ' + aFields[4] + '</p>';
		} else if(aRule[0]=="product-new-price"){
			sHTMLb += '<p>' + aFields[5] + ': ' + aFields[4] + '</p>';
		} else if(aRule[0]=="product-price-sug"){
			sHTMLb += '<p>' + aFields[5] + '</p>';
		} else if(aRule[0]=="spaceline"|| aRule[0]=="spaceline2" || aRule[0]=="spaceline3"){
			sHTMLb += '';
		} else {
			sHTMLb += '<p>' + aFields[5] + ':<br>ab ' + aFields[2] + ' Warenwert: ' + aFields[4] + '</p>';
		};
	};
	sData = SMShop.getAttribute("StffDiscount");
	if(sData.length>0 && sData!="false"){
		sHTMLb += '<p>Sie erhalten auf verschiedene Hersteller, Kategorien oder Produkte gesonderte Rabattstaffeln. Diese werden bei den entsprechenden Produkten angezeigt. Details finden Sie auch auf der Login-Seite.</p>';
	};
	document.write(sHTMLb);
	return(true);
};

// <- M **

// ** L ->

cSMVariants.prototype.updateLI=function(iNewPrice2){
	var $g=this,$1c=$g.base,$1k=$g.xml,$38=null,$39=null,$3a=null,$1V=$g.parent,$2P=0,$3b=false,$3c=null;
	if($1c.raiseEvent(4,true,true,$g)){
		$39=$g.getActVariant();
		if($39!=null){
			$38=$39.xml;
			$38.setAttribute(_SMAPrice,iNewPrice2);
		};
	}else $1c.raiseEvent(6,false,null,$g)
};

function CheckVariants(){
	var sResult = 'NO_VARIANTS';
	var iCntForms = document.forms.length;
	var sFormName = '';
	var i = 0;
	while (i < iCntForms) {
  	sFormName = document.forms[i].name;
  	if(sFormName.indexOf("PD") == 0 && sFormName.indexOf("variants") > 0){
  		sResult = sFormName;
  		break;
  	};
  	i++;
	};
	return(sResult);
};

function reinitVariants(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();' + sFunc + ';MakeLIPriceReinit();};');
  		};
  	};
  	return(sFunc);
 	} else {
 		return('NO_VARIANTS');
 	};
};

function resetVariants(sFormName,sFunc){
	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"){
  	 		eval('elem1.onchange = function(){' + sFunc + ';};');
  		};
  	};
  	return('OK');
 	} else {
 		return('NO_VARIANTS');
 	};
};

function MakeLIPrice_init(){
	try {
		if(arguments.length > 0){
			var $g = arguments[0];
		} else {
			var $g = SMProductLI;
		};
	} catch(e) { };	
	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.getPrice();
	//var iOrgPrice = $g.getAttribute(_SMAPrice);
	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(){
	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(){
	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.getPrice();
	//var iOrgPrice = $g.getAttribute(_SMAPrice);
	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();
	MakeLIPrice(true);
};

function MakeLIPrice(bProductHasVariants){
	var $g = SMProductLI;
	//var iOrgPrice = $g.getPrice();
	var iNewPrice = getProdLIDiscount();
	if(iNewPrice < 0){
		var iOrgDisc = $g.getAttribute("CatDiscount");
		$g.setAttribute(_SMAPrdDiscount,iOrgDisc);
		$g.update();
		displayProductProperties($g);
		return(false);
	};
	$g.setAttribute(_SMAPrice,iNewPrice);
	if(bProductHasVariants){$g.variants.updateLI(iNewPrice);};
	$g.update();
	displayProductProperties($g);
	var iOrgPrice = parseFloat($g.getAttribute("VeryOrgPriceLI"));
	if(bInGross() != bOutGross()){
		var iTax = getVAT($g);
		if(!bInGross()){
			iOrgPrice = iOrgPrice * (1 + iTax);
		} else {
			iOrgPrice = iOrgPrice / (1 + iTax);
		};
	};
	var sOrgPrice = cprimary.format(iOrgPrice, SM_CGROUP + SM_CSYMBOL);
	var sHTML = sHTMLOrg = sHTMLDisc = '';
	if(document.getElementById("product_original_price")){
		showIdTag("product_original_price",sOrgPrice);
	} else {
		sHTMLOrg = document.getElementById("product_price").innerHTML;
		sHTML = '<div class="t-small t-em" style="text-decoration:line-through;" id="product_original_price">' + sOrgPrice + '</div>';
		sHTML += sHTMLOrg;
		document.getElementById("product_price").innerHTML = sHTML;
	};
	return(true);
};

function MakeLIPricePL(){
	var $g = arguments[0];
	var iNewPrice = getProdLIDiscount($g,arguments[1]);
	if(iNewPrice < 0){
		var iOrgDisc = $g.getAttribute("CatDiscount");
		$g.setAttribute(_SMAPrdDiscount,iOrgDisc);
		$g.update();
		return(false);
	};
	$g.setAttribute(_SMAPrice,iNewPrice);
	if(arguments[2] == true) $g.variants.updateLI(iNewPrice);
	$g.update();
	return(true);
};

function showIdTag(sTag,sCont){
	var oElem = document.getElementById(sTag);
	if(oElem){
		oElem.style.display = "inline";
		oElem.style.visibility = "visible";
		if(sCont.length>0) oElem.innerHTML = sCont;
	};
};

function hideIdTag(sTag,sCont){
	var oElem = document.getElementById(sTag);
	if(oElem){
		oElem.style.display = "none";
		oElem.style.visibility = "hidden";
		if(sCont.length>0) oElem.innerHTML = sCont;
	};
};

function getProdLIDiscount(){
	var sLogin = initLogin();
	if(sLogin != 'OK'){return(-1);};
	try {
		if(arguments.length > 0){
			var $g = arguments[0];
			var sProdNumber1 = RemoveSpecialSigns(arguments[1]);
		} else {
			var $g = SMProductLI;
			var sProdNumber1 = RemoveSpecialSigns($g.orgCode);
		}
	} catch(e) { };
	var iProdPrice = $g.getAttribute("OrgPriceLI");
	var iCatDiscount = parseFloat($g.getAttribute("CatDiscount"));
	if(isNaN(iCatDiscount)){iCatDiscount = 0;};
	var sProdManu = RemoveSpecialSigns(SX_uEsc($g.manufactName));
	//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 */
	iDiscAmntTyp2 += iCatDiscount;
	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("==");

// XXL ->
			if(aRule[0] == 'product-price-sug' && (aRule[1] == sProdNumber1 || aRule[1] == sProdNumber2)){
				$g.setAttribute("suggestion",String(aFields[i][2] + "_|_" + aFields[i][4]));
				$g.update();
			};
// <- XXL			
			if(aRule[0] == 'manufacturer' && aRule[1] == sProdManu){
				bIsDiscounted = true;
			};
			if(aRule[0] == 'product' && (aRule[1] == sProdNumber1 || aRule[1] == sProdNumber2)){
				bIsDiscounted = true;
			};
// XL ->
			if(aRule[0] == 'product-new-price' && (aRule[1] == sProdNumber1 || aRule[1] == sProdNumber2)){
				bIsDiscounted = true;
				bProdNewPrice = true;
				iProdNewPrice = aFields[i][4];
			};
// <- XL			
			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;
					};
				};
			};
			// Summiere Einzeldiskounts
			if(bIsDiscounted){
				// DiscountTyp, DiscountValue
				// Typ: 1=Fix
				//      2=%
				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(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){
		//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){
		//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){
		//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){
		//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){
		//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(bProdNewPrice){
		iProdPrice = iProdNewPrice;
		bDiscountDone = true;
	};
	if(bDiscountDone){
		return(iProdPrice);
	} else {
		return(-1);
	};
};

// <- L **

// ** XL ->

function hideAllProductPrices(){
	if(initLogin()=='NO_USER'){
		//product-detail
		var oElem = document.getElementsByTagName("div");
		var sElem = '';
		for(var i=0; i<oElem.length; i++){
			sElem = oElem[i].id;
			if(sElem.indexOf("pdPrice")>-1){
				document.getElementById(sElem).innerHTML = "";
				document.getElementById(sElem).style.visibility = "hidden";
				document.getElementById(sElem).style.display = "none";
			};
		};
		var oElem = document.getElementById("product_discounts");
		if(oElem){
			oElem.innerHTML = "";
			oElem.style.visibility = "hidden";
			oElem.style.display = "none";
		};
		//product-list
		var oElem = document.getElementsByTagName("script");
		var sElem = '';
		for(var i=0; i<oElem.length; i++){
			sElem = oElem[i].innerHTML;
			if(sElem.indexOf("SMProductList")>-1 && sElem.indexOf("t-price-list")>-1){
				var oElemP = oElem[i].parentNode;
				oElemP.style.display = "none";
				oElemP.style.visibility = "hidden";
			};
		};
	};
};

function LIsetVATstatus(){
	var sVAT = SMShop.getAttribute("UserVATtype");
	var iVATincl = 0;
	if(sVAT=="vatincl") iVATincl = 1;
	SMShop.setAttribute(_SMAOutGross, iVATincl);
	SMShop.update();
	SMShop.basket.update();
};

function SplitDiscounts(){
	var sData = SMShop.getAttribute("UserDiscount");
	var sDataNorm = sDataStff = '';
	var iDataNorm = iDataStff = 0;
	var aData = sData.split("_;_");
	for(var i=0; i<aData.length; i++){
		var aSet = aData[i].split("|");
		var aSetR = aSet[0].split("==");
		if(aSetR[0]=="manufacturer-stff" || aSetR[0]=="category-stff" || aSetR[0]=="product-stff"){
			if(iDataStff==0){
				sDataStff += String(aData[i]);
				iDataStff++;
			} else {
				sDataStff += '_;_';
				sDataStff += String(aData[i]);
			};
		} else {
			if(iDataNorm==0){
				sDataNorm += String(aData[i]);
				iDataNorm++;
			} else {
				sDataNorm += '_;_';
				sDataNorm += String(aData[i]);
			};
		};
	};
	SMShop.setAttribute("UserDiscount",sDataNorm);
	SMShop.setAttribute("StffDiscount",sDataStff);
	SMShop.update();
};

function LogMeInVAT(sData){
	if(sData.length==0){
		sData = SMShop.getAttribute(_SMAOutGross);
		sData = (sData=="1")?"vatincl":"vatexcl";
	};
	SMShop.setAttribute("UserVATtype", sData);
	SMShop.update();
};

function LogMeInPayShip(sData){
	SMShop.setAttribute("UserPayShip", sData);
	SMShop.update();
};

function LIprintVATstatusPDD(){
	var sIncl = 'inkl. MwSt';
	var sExcl = 'zzgl. MwSt';
	var oVATInfo = document.getElementById("VATinfo");
	if(!oVATInfo) return(0);
	if(bOutGross()){
		oVATInfo.innerHTML = sIncl;
	} else {
		oVATInfo.innerHTML = sExcl;
	};
};

function LIprintVATstatusPDL(){
	var sIncl = 'inkl. MwSt';
	var sExcl = 'zzgl. MwSt';
	var sVAT = SMShop.getAttribute("UserVATtype");
	var oElem = document.getElementsByTagName("div");
	var sElem = '';
	var sElem2 = '';
	for(var i=0; i<oElem.length; i++){
		sElem = oElem[i].innerHTML;
		if(sElem.indexOf(sIncl)>-1){
			if(sVAT=="vatexcl"){
				sElem2 = sElem.replace(sIncl,sExcl);
				oElem[i].innerHTML = sElem2;
			};
		};
		if(sElem.indexOf(sExcl)>-1){
			if(sVAT=="vatincl"){
				sElem2 = sElem.replace(sExcl,sIncl);
				oElem[i].innerHTML = sElem2;
			};
		};
	};
};

function LIhidePayMethodList(){
	var oPay = document.getElementById("paymethods");
	oPay.style.display = "none";
	oPay.style.visibility = "hidden";
};

function LIshowPayMethodList(){
	var oPay = document.getElementById("paymethods");
	oPay.style.display = "inline";
	oPay.style.visibility = "visible";
};

function LIhideShipMethodList(){
	var oPay = document.getElementById("shipmethodselector");
	oPay.style.display = "none";
	oPay.style.visibility = "hidden";
};

function LIshowShipMethodList(){
	var oPay = document.getElementById("shipmethodselector");
	oPay.style.display = "inline";
	oPay.style.visibility = "visible";
};

function LIsetPayShipStatus(sType){
	var oPayShip = SMShop.getAttribute("UserPayShip");
	var aPayShip = oPayShip.split("_;_");
	var aPS = new Array();
	var sDIVpay = "SMPAYMETHOD";
	var sDIVship = "shipmethods";
	var oDIVship = '';
	var bShipDefault = false;
	var sDIVid = '';
	var oDIV = null;
	for(var i=0; i<aPayShip.length; i++){
		aPS[i] = aPayShip[i].split("_|_");
		if(aPS[i][0]=="pay" && sType=="pay"){
			sDIVid = sDIVpay + String(aPS[i][1]);
			if(aPS[i][3]=="forbidden"){
				oDIV = document.getElementById(sDIVid);
				oDIV.style.display = "none";
				oDIV.style.visibility = "hidden";
			};
		};
		if(aPS[i][0]=="ship" && sType=="ship"){
			for (var j=0; j < document.forms.length; j++){
				if(document.forms[j].name == sDIVship){
					oDIVship = document.forms[j];
					break;
				};
			};
			for(var j=0; j<oDIVship.elements.length; j++){
				var oElem = oDIVship.elements[j];
  	 		if(oElem.type=="radio" && oElem.id==aPS[i][1]){
  	 			if(aPS[i][3]=="forbidden"){
						oElem.checked = false;
						oElem.disabled = true;
						var oElemParent = oElem.parentNode;
						var oElem2 = oElemParent.nextSibling;
						oElem2.innerHTML = oElem2.innerHTML + "<div><em>Diese Versandart steht Ihnen nicht zur Verfügung.</em></div>";
						oElem2 = oElem2.nextSibling;
						oElem2.innerHTML = "&nbsp;";
						break;
					} else if(!bShipDefault && SMShop.getActiveShipMethodId().length==0){
						oElem.checked = true;
					};
  	 		};
			};
		};
	};
};

function hideProductDiscounts(oProd){
	if(oProd.getAttribute("IndivProdDisc")=="false"){
		var $elem = document.getElementById("product_discounts");
		if($elem){
			$elem.style.display = "none";
			$elem.style.visibility = "hidden";
		};
	};
};

function getSerializedStff(sType){
	var sData = SMShop.getAttribute("StffDiscount");
	if(sData.length==0 || sData=="false"){
		return("none");
	};
	var aData = sData.split("_;_");
	var aMStff = new Array();
	var aCStff = new Array();
	var aPStff = new Array();
	var aSet = new Array();
	var aSetR = new Array();
	var bDouble = false;
	var sResult = '';
	for(var i=0; i<aData.length; i++){
		aSet[i] = aData[i].split("|");
		aSetR[i] = aSet[i][0].split("==");
		if(aSetR[i][0]=="product-stff"){
			if(aPStff.length==0){
				aPStff[aPStff.length] = aSetR[i][1];
			} else {
				for(var j=0; j<aPStff.length; j++){
					if(aPStff[j]==aSetR[i][1]){
						bDouble = true;
						break;
					};
				};
				if(!bDouble){
					aPStff[aPStff.length] = aSetR[i][1];
				} else {
					bDouble = false;
				};
			};
		};
		if(aSetR[i][0]=="category-stff"){
			if(aCStff.length==0){
				aCStff[aCStff.length] = aSetR[i][1];
			} else {
				for(var j=0; j<aCStff.length; j++){
					if(aCStff[j]==aSetR[i][1]){
						bDouble = true;
						break;
					};
				};
				if(!bDouble){
					aCStff[aCStff.length] = aSetR[i][1];
				} else {
					bDouble = false;
				};
			};
		};
		if(aSetR[i][0]=="manufacturer-stff"){
			if(aMStff.length==0){
				aMStff[aMStff.length] = aSetR[i][1];
			} else {
				for(var j=0; j<aMStff.length; j++){
					if(aMStff[j]==aSetR[i][1]){
						bDouble = true;
						break;
					};
				};
				if(!bDouble){
					aMStff[aMStff.length] = aSetR[i][1];
				} else {
					bDouble = false;
				};
			};
		};
	};
	if(sType=="product"){
		if(aPStff.length==0) return("none");
		for(var i=0; i<aPStff.length; i++){
			if(i>0) sResult += ", ";
			sResult += aPStff[i];
		};
	};
	if(sType=="category"){
		if(aCStff.length==0) return("none");
		for(var i=0; i<aCStff.length; i++){
			if(i>0) sResult += ", ";
			sResult += aCStff[i];
		};
	};
	if(sType=="manufacturer"){
		if(aMStff.length==0) return("none");
		for(var i=0; i<aMStff.length; i++){
			if(i>0) sResult += ", ";
			sResult += aMStff[i];
		};
	};
	return(sResult);
};

function SetProductStff(){
	var $g = arguments[0];
	/*
	if(initLogin()=='NO_USER'){
		hideProductDiscounts($g);
		return(false);
	};
	*/
	var sProdManu = RemoveSpecialSigns(SX_uEsc($g.manufactName));
	if(arguments[1] != "SMProductLI"){
		var sPN1 = RemoveSpecialSigns(arguments[2]);
	} else {
		var sPN1 = RemoveSpecialSigns($g.orgCode);
	};
	var sPN2 = RemoveSpecialSigns($g.getAttribute(_SMACode));
	var sData = SMShop.getAttribute("StffDiscount");
	if(sData.length==0 || sData=="false"){
		//hideProductDiscounts($g);
		return(false);
	};
	var aData = sData.split("_;_");
	var aSet = new Array();
	var aSetR = new Array();
	var bProdHasBaseDisc = false;
	var bCatDouble = false;
	var aMStff = new Array();
	var aCStff = new Array();
	var aPStff = new Array();
	var aCat = sProdToParentCats.split("_;_");
	var aCatDisc = new Array();
	for(var i=0; i<aCat.length; i++){
		aCatDisc[i] = aCat[i].split("_=_");
	};
	for(var i=0; i<aData.length; i++){
		aSet[i] = aData[i].split("|");
		aSetR[i] = aSet[i][0].split("==");
	};
	for(var i=0; i<aData.length; i++){
		if(aSetR[i][0]=="product-stff" && (aSetR[i][1]==sPN1 || aSetR[i][1]==sPN2)){
			aPStff[aPStff.length] = aData[i];
			if(aSet[i][2]==1) bProdHasBaseDisc = true;
		};
		if(aSetR[i][0]=="category-stff"){
			if(aCStff.length==0){
				for(var j=0; j<aCat.length; j++){
					for(var k=0; k<aData.length; k++){
						if(aCatDisc[j][0]==aSetR[k][1]){
							aCStff[aCStff.length] = aData[k];
							if(aSet[k][2]==1) bProdHasBaseDisc = true;
							break;
						};
					};
					if(aCStff.length>0) break;
				};
			} else {
				var aCPrior = aCStff[aCStff.length - 1].split("|");
				var sCPrior = aCPrior[0].split("==");
				if(sCPrior[1]==aSetR[i][1]){
					for(var j=0; j<aCStff.length; j++){
						if(aCStff[j]==aData[i]){
							bCatDouble = true;
							break;
						};
					};
					if(bCatDouble){
						bCatDouble = false;
					} else {
						aCStff[aCStff.length] = aData[i];
						if(aSet[i][2]==1) bProdHasBaseDisc = true;
					};
				};
			};
		};
		if(aSetR[i][0]=="manufacturer-stff" && aSetR[i][1]==sProdManu){
			aMStff[aMStff.length] = aData[i];
			if(aSet[i][2]==1) bProdHasBaseDisc = true;
		};
	};
	if(aMStff.length==0 && aCStff.length==0 && aPStff.length==0){
		//hideProductDiscounts($g);
		return(false);
	};
	$g.discounts.remove('','','','','',(arguments[1] != "SMProductLI") ? "LIST" : "");
	$g.discounts.update();
	$g.update();
	var bDiscDone = false;
	var sStff = '';
	if(aPStff.length>0 && !bDiscDone){
		for(var i=0; i<aPStff.length; i++){
			var oStff = aPStff[i].split("|");
			$g.discounts.addForLogin(oStff[2],oStff[3],oStff[4],String(oStff[5]),"false",(arguments[1] != "SMProductLI") ? "LIST" : "");
			if(i>0) sStff += '_;_';
			sStff += oStff[2] + '_|_' + oStff[3] + '_|_' + oStff[4] + '_|_' + String(oStff[5]) + '_|_false';
		};
		bDiscDone = true;
	};
	if(aCStff.length>0 && !bDiscDone){
		for(var i=0; i<aCStff.length; i++){
			var oStff = aCStff[i].split("|");
			$g.discounts.addForLogin(oStff[2],oStff[3],oStff[4],String(oStff[5]),"false",(arguments[1] != "SMProductLI") ? "LIST" : "");
			if(i>0) sStff += '_;_';
			sStff += oStff[2] + '_|_' + oStff[3] + '_|_' + oStff[4] + '_|_' + String(oStff[5]) + '_|_false';
		};
		bDiscDone = true;
	};
	if(aMStff.length>0 && !bDiscDone){
		for(var i=0; i<aMStff.length; i++){
			var oStff = aMStff[i].split("|");
			$g.discounts.addForLogin(oStff[2],oStff[3],oStff[4],String(oStff[5]),"false",(arguments[1] != "SMProductLI") ? "LIST" : "");
			if(i>0) sStff += '_;_';
			sStff += oStff[2] + '_|_' + oStff[3] + '_|_' + oStff[4] + '_|_' + String(oStff[5]) + '_|_false';
		};
		bDiscDone = true;
	};
	if(bProdHasBaseDisc && arguments[1] == "SMProductLI"){
		var oElem = document.getElementById("product_original_price");
		if(oElem){
			oElem.style.display = "inline";
			oElem.style.visibility = "visible";
		};
		bDiscDone = true;
	};
	$g.discounts.update();
	$g.setAttribute("HasStff","true");
	$g.setAttribute("IndivProdDisc",sStff);
	$g.update();
	var oProdDiscList = document.getElementById("product_discounts");
	if(oProdDiscList && arguments[1] == "SMProductLI"){
		oProdDiscList.style.display = "inline";
		oProdDiscList.style.visibility = "visible";
	};
	if(arguments[1] != "SMProductLI"){
		if(bProdHasBaseDisc){
			bDiscDone = true;
		} else {
			bDiscDone = false;
		};
	} else {
		displayProductProperties($g);
	};
	return(bDiscDone);
};

function bInGross(){
	var bTest = (SMShop.getAttribute(_SMAInGross)=="1")?true:false;
	return(bTest);
};
function bOutGross(){
	var bTest = (SMShop.getAttribute(_SMAOutGross)=="1")?true:false;
	return(bTest);
};
function getVAT(){
	var aRegion = SMShop.getActiveRegion();
	var $g = arguments[0];
	var iRegSet = parseInt($g.getAttribute(_SMARegion), 10);
	var iActTax = parseFloat(aRegion[iRegSet + 2]) / 100;
	return(iActTax);
};

// <- XL **

// ** XXL ->

function reinitVariantsForPriceSuggestion(sFormName){
	var frm1 = document[sFormName];
	var sNew = 'hidePriceForPriceSuggestion();document.getElementById("product_price_suggestion").innerHTML += \'<iframe src="\' + sProdSugObj + \'" name="smartLog_PriceSuggestion" id="smartLog_PriceSuggestion" scrolling="no" frameborder="0" width="1" height="1">\';';
	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);
  	 		if(sFunc.indexOf("product_price_suggestion") < 0)	eval('elem1.onchange = function(){' + sFunc + ';' + sNew + '};');
  		};
  	};
  	return(sFunc);
 	} else {
 		return('NO_VARIANTS');
 	};
};

function setNewPriceFromSuggestion(){
	var $g = SMProductLI;
	if($g.discounts.CheckDefault() > -1){
		if(CheckVariants() != 'NO_VARIANTS'){
			MakeLIPrice_init_BaseDisc();
			$g.discounts.rewrite("ProdPriceSug",parseFloat(arguments[1]));
			var fResetVariants = reinitVariantsForPriceSuggestion(CheckVariants());
		} else {;
			$g.discounts.rewrite("ProdPriceSug",parseFloat(arguments[1]));
		};
	} else {
		var iNewPrice = parseFloat(arguments[1]);
		if(bInGross() != bOutGross()){
			var iTax = getVAT($g);
			if(!bInGross()){
				iNewPrice = iNewPrice / (1 + iTax);
			} else {
				iNewPrice = iNewPrice * (1 + iTax);
			};
		};
		$g.setAttribute(_SMAPrice,iNewPrice);
		if(CheckVariants() != 'NO_VARIANTS'){
			var fResetVariants = reinitVariantsForPriceSuggestion(CheckVariants());
			$g.variants.updateLI(iNewPrice);
		};
		$g.update();
	};
	displayProductProperties($g);
	var iOrgPrice = parseFloat($g.getAttribute("VeryOrgPriceLI"));
	if(bInGross() != bOutGross()){
		var iTax = getVAT($g);
		if(!bInGross()){
			iOrgPrice = iOrgPrice * (1 + iTax);
		} else {
			iOrgPrice = iOrgPrice / (1 + iTax);
		};
	};
	var sOrgPrice = cprimary.format(iOrgPrice, SM_CGROUP + SM_CSYMBOL);
	var sHTML = sHTMLOrg = sHTMLDisc = '';
	if(document.getElementById("product_original_price")){
		showIdTag("product_original_price",sOrgPrice);
	} else {
		sHTMLOrg = document.getElementById("product_price").innerHTML;
		sHTML = '<div class="t-small t-em" style="text-decoration:line-through;" id="product_original_price">' + sOrgPrice + '</div>';
		sHTML += sHTMLOrg;
		document.getElementById("product_price").innerHTML = sHTML;
	};
	return(true);
};

function hidePriceForPriceSuggestion(){
	if(document.getElementById("product_original_price")) document.getElementById("product_original_price").innerHTML = "";
	if(document.getElementById("product_price")) document.getElementById("product_price").innerHTML = "";
};

function setNewPriceFromSuggestionLI(){
	var sPOID = arguments[0];
	var iVal = parseFloat(arguments[1]);
	eval("var $g = " + arguments[2] + ";");
	var sPKID = parseInt(arguments[3],10);
	if($g.discounts.CheckDefault() > -1){
		$g.discounts.rewrite("ProdPriceSug",parseFloat(arguments[1]));
	} else {
		var iNewPrice = parseFloat(arguments[1]);
		if(bInGross() != bOutGross()){
			var iTax = getVAT($g);
			if(!bInGross()){
				iNewPrice = iNewPrice / (1 + iTax);
			} else {
				iNewPrice = iNewPrice * (1 + iTax);
			};
		};
		$g.setAttribute(_SMAPrice,iNewPrice);
		$g.variants.updateLI(iNewPrice);
		$g.update();
	};
	if(document.getElementById("LI-product-price-" + sPKID)) document.getElementById("LI-product-price-" + sPKID).innerHTML = cprimary.format($g.getPrice(), SM_CGROUP + SM_CSYMBOL);
	if(document.getElementById("LI-product-baseprice-" + sPKID)) document.getElementById("LI-product-baseprice-" + sPKID).innerHTML = formatProductBasePrice($g);
	if(document.getElementById("LI-price-prefix-" + sPKID)) with(document.getElementById("LI-price-prefix-" + sPKID)){
		innerHTML = "Alter Preis:&nbsp;";
		style.display = "inline";
		style.visibility = "visible";
	};
	if(document.getElementById("LI-old-price-" + sPKID)) with(document.getElementById("LI-old-price-" + sPKID)){
		innerHTML = eval('cprimary.format(iOldPrice' + sPKID + ', SM_CGROUP + SM_CSYMBOL);');
		style.display = "inline";
		style.visibility = "visible";
	};
	if(document.getElementById("LI-discount-prefix-" + sPKID)) with(document.getElementById("LI-discount-prefix-" + sPKID)){
		innerHTML = "Ihr Preis:&nbsp;";
		style.display = "inline";
		style.visibility = "visible";
	};
	return(true);
};

function formatTimeForPriceSuggestion(){
 	var sTime = arguments[0];
 	var aTime = sTime.split(" ");
 	var aTimeT = aTime[1].split(":");
 	sTime = aTime[0] + " um " + aTimeT[0] + ":" + aTimeT[1] + " Uhr";
 	return(sTime);
};

function printPriceSuggestionResult(sText){
	var aMsg = new Array();
			aMsg[1] = 'Ihr Preisvorschlag wurde akzeptiert. Sie können diesen Artikel zu diesem Preis kaufen.';
			aMsg[2] = 'Wir haben Ihr Angebot abgelehnt, da es zu niedrig war. Sie können das Produkt aber weiterhin zum normalen Preis kaufen.';
			aMsg[3] = 'Vor kurzem haben Sie um den Preis dieses Produktes mit uns verhandelt. Wir haben Ihr Angebot akzeptiert und bieten Ihnen das Produkt zu diesem Preis an. Sie können frühestens am %time% ein neues Angebot abgeben.';
			aMsg[4] = 'Vor kurzem haben Sie um den Preis dieses Produktes mit uns verhandelt. Wir haben Ihr Angebot abgelehnt, da es zu niedrig war. Sie können das Produkt aber weiterhin zum normalen Preis kaufen. Sie können frühestens am %time% ein neues Angebot abgeben.';
	var Obj = document.getElementById("product_price_suggestion");
	var sHTML = aMsg[arguments[0]];
	var sMsg = String(arguments[0]);
	switch (sMsg){
  	case "3":
    	sHTML = sHTML.replace("%time%",formatTimeForPriceSuggestion(arguments[1]));
	    break;
  	case "4":
    	sHTML = sHTML.replace("%time%",formatTimeForPriceSuggestion(arguments[1]));
	    break;
	}
	Obj.innerHTML = sHTML;
};

function getVatSettings(){
	var $g = arguments[0];
	var sVAT = '';
	sVAT += '&vat=' + String(getVAT($g));
	if(bInGross()){
		sVAT += '&ing=1';
	} else {
		sVAT += '&ing=0';
	};
	if(bOutGross()){
		sVAT += '&outg=1';
	} else {
		sVAT += '&outg=0';
	};
	return(sVAT);
};

// <- XXL **
