var AllTotal;
var AllTotalVisible = 0;
var AllTotalOption = 0;
var AllTotalOptionNotVisible = 0;
var AllTotalVisible2 = 0;
var AllTotalNotVisible = 0;
var AllTotalBoomAffilliate = 0;
var AllTotalBackbaseAffilliate = 0;
var AllTotalBoomAffilliate2 = 0;
var AllTotalBackbaseAffilliate2 = 0;
var fileWin;
var BugString = "";
var dbug;
var totalAffiliate = 0;
var totalFSP = 0;
var PerAffiliate;
var fromStaffel = 0;
var affword = '';
var affword2 = '';
var affword3 = '';
var affword4 = '';
var fspword = '';
var fspword2 = '';
var fspword3 = '';
var BackBaseAff = 0;
var BoomAff = 0;
var BugString2 = '';
var BugString3 = '';
var dbug2 = 0;
var dbug3 = 0;
var dbug4 = 0;
var BugString4 = '';
var CurrentBackAff = 0;
var CurrentStafBack = 0;
var optselect = "";

function ViewOtherCurr(curr, amount) {
    var fileName
    fileName = 'chkPriceOtherCurr.asp?curr=' + curr + '&value=' + amount
    if (fileWin) {
        fileWin.close()
    }
    var leftPos = (screen.availWidth - 700) / 2
    var topPos = (screen.availHeight - 500) / 2
    fileWin = window.open(fileName, 'viewChkCurr', 'width=700,height=300,scrollbars=yes,status=yes,resizable=yes,titlebar=0,top=' + topPos + ',left=' + leftPos);
    fileWin.focus()
}


function fnNavigate(url) {
    for (i = 0; i < document.all.length; i++) {
        if (document.all(i).tagName == "IFRAME") {
            document.all(i).contentWindow.location = url
        }
    }
}


function fnSearch() {
    if (document.getElementById('searchMain') != null) {
        var objSearch = document.getElementById('searchMain')
        fnNavigate('webshaper/pcm/user/searchProduct.asp?searchText=' + objSearch.value)
    }
} <!--Begin
function addbookmark() {}
var fileWinPicBig
function enlargePicture(url) {
    if (fileWinPicBig) {
        fileWinPicBig.close()
    }
    filename = "viewEnlargePicture.asp?url=" + url
    var leftPos = (screen.availWidth - 700) / 2
    var topPos = (screen.availHeight - 500) / 2
    fileWinPicBig = window.open(filename, 'ViewBigPic', 'width=400,height=300,scrollbars=yes,status=yes,resizable=yes,titlebar=0,top=' + topPos + ',left=' + leftPos);
    fileWinPicBig.focus()
}
imagename = '';

function update() {
    doc = lrgewin.document;
    doc.open('text/html');
    doc.write('<HTML><HEAD><TITLE>Enlarged Image<\/TITLE><\/HEAD><BODY bgcolor="white" onLoad="if     (self.resizeTo)self.resizeTo((document.images[0].width+30),(document.images[0].height+80))" topmargin="4" leftmargin="0"    rightmargin="0" bottommargin="0"><table width=""' + document.images[0].width + '" border="0" cellspacing="0" cellpadding="0"><tr><td>');
    doc.write('<IMG SRC="' + imagename + '"><\/td><\/tr><tr><td><form name="viewn"><input type="image" src="../0img/close.gif" align="right" value="Close Window" onClick="self.close()"><\/td><\/tr><\/table>');
    doc.write('<\/form><\/BODY><\/HTML>');
    doc.close();
}


function CookieSetText(yesText, noText) {
    var cookieEnabled = (navigator.cookieEnabled) ? true : false
    if (typeof navigator.cookieEnabled == "undefined" && !cookieEnabled) {
        document.cookie = "testcookie"
        cookieEnabled = (document.cookie.indexOf("testcookie") != -1) ? true : false
    }
    if (cookieEnabled) {} else {
        alert(noText);
        return;
    }
}
function CookieLimitCheck()
{
    if(document.cookie.length >= 3800)
    {
        alert("U kunt niet meer producten bestellen voor deze aanvraag.Verstuur uw aanvraag en start evt. een extra aanvraag");
        location.href="viewcart.asp";
        return false;        
    }
}

function InsertCartViewProd() {
	CookieLimitCheck();
    CookieSetText("Your browser supports cookies. You may shop", "The Browser does not support Cookies. Shopping is not possible.Please enable cookies.");
    CalculatePrice();
    var f = document.FormViewProd
    for (i = 0; i < f.TotalProduct.value; i++) {
        var bQtyValid;
        if (parseInt(f.TotalProduct.value) > 1) {
            var objQtyProduct = eval('f.qtyProduct' + i)
            if (objQtyProduct.value.length == 0) {
                bQtyValid = false
            } else if (isNaN(objQtyProduct.value)) {
                bQtyValid = false
            } else {
                bQtyValid = true
            }
        } else if (parseInt(f.TotalProduct.value) == 1) {
            bQtyValid = true;
        }
        if (bQtyValid) {
            var objPKProduct = eval('f.iPKProduct' + i)
            totalProductOpt = eval('f.TotalProdOpt_' + objPKProduct.value)
            if (totalProductOpt) {
                for (j = 0; j < totalProductOpt.value; j++) {
                    objProdOpt = eval('f.idProdOpt_' + objPKProduct.value + '_' + j)
                    objProdOptChk = eval('f.idProdOptChk_' + objPKProduct.value + '_' + objProdOpt.value)
                    objProdOptName = eval('f.idProdOptName_' + objPKProduct.value + '_' + objProdOpt.value)
                    if (objProdOptChk.value == '1') {
                        objProdOptAttrs = eval('f.idProdOptAttr_' + objPKProduct.value + '_' + objProdOpt.value)
                        if (objProdOptAttrs.options.selectedIndex == 0) {
                            alert('Please select the product option \'' + objProdOptName.value + '\'')
                            return;
                        }
                    }
                }
            }
        }
    }
    if (document.getElementById('txtSide0') != null && document.getElementById('txtSideColor') != null) {
        document.getElementById('txtSide0').value = document.getElementById('txtSideColor').value;
    }
    if (document.getElementById('txtBaseColor0') != null && document.getElementById('txtColorPick') != null) document.getElementById('txtBaseColor0').value = document.getElementById('txtColorPick').value;
    f.action = '/webshaper/store/cartAddItem.asp'
    f.submit();
}

function storeInsertCartViewProd() {
    CookieSetText("Your browser supports cookies. You may shop", "The Browser does not support Cookies. Shopping is not possible.Please enable cookies.");
    //CalculatePrice();
    var f = document.FormViewProd
    for (i = 0; i < f.TotalProduct.value; i++) {
        var bQtyValid;
        if (parseInt(f.TotalProduct.value) > 1) {
            var objQtyProduct = eval('f.qtyProduct' + i)
            if (objQtyProduct.value.length == 0) {
                bQtyValid = false
            } else if (isNaN(objQtyProduct.value)) {
                bQtyValid = false
            } else {
                bQtyValid = true
            }
        } else if (parseInt(f.TotalProduct.value) == 1) {
            bQtyValid = true;
        }
        if (bQtyValid) {
            
        }
    }
    if (document.getElementById('txtSide0') != null && document.getElementById('txtSideColor') != null) {
        document.getElementById('txtSide0').value = document.getElementById('txtSideColor').value;
    }
    if (document.getElementById('txtBaseColor0') != null && document.getElementById('txtColorPick') != null) document.getElementById('txtBaseColor0').value = document.getElementById('txtColorPick').value;
	document.getElementById("qtyProduct0").value=document.getElementById('addtxtTotal').value;
    f.action = '/webshaper/store/cartAddItem.asp'
    f.submit();
}


function GoTranslate() {
    var f = document.FormViewProd;
    var url = 'http://translate.google.com/translate?';
    var subUrl = 'u=' + encodeURIComponent(location.href) + '&' + 'langpair=' + encodeURIComponent(f.langpair.options[f.langpair.selectedIndex].value) + '&' + 'hl=' + encodeURIComponent(f.hl.value) + '&' + 'ie=' + encodeURIComponent(f.ie.value) + '&' + 'oe=' + encodeURIComponent(f.oe.value) + '&' + 'prev=' + encodeURIComponent(f.prev.value);
    var fullURL = url + subUrl;
    windowName = 'winTranslate';
    window.open(fullURL, windowName, 'top=100,left=100,height=400,width=750,location=no,resizable=yes,scrollbars=yes,status=yes');
    return false;
}


function ChangeView() {
    if (document.getElementById('productA').style.display == 'block') {
        document.getElementById('product').style.display = 'block';
        document.getElementById('productA').style.display = 'none';
        document.getElementById('Meer_Info').innerHTML = "meer info";
    } else {
        document.getElementById('product').style.display = 'none';
        document.getElementById('productA').style.display = 'block';
        document.getElementById('Meer_Info').innerHTML = "minder info";
    }
}


function Validate() {
    return false;
}


function onEnter(evt) {
    var keyCode = null;
    if (evt.which) {
        keyCode = evt.which;
    } else if (evt.keyCode) {
        keyCode = evt.keyCode;
    }
    if (keyCode == 13) {
        CalculatePrice();
    }
    return false;
}


function getQueryVariable(variable) {
    var query = window.location.search.substring(1);
    var vars = query.split("&");
    for (var i = 0; i < vars.length; i++) {
        var pair = vars[i].split("=");
        if (pair[0] == variable) {
            return pair[1];
        }
    }
}


function trim(str) {
    if (!str || typeof str != 'string') return null;
    return str.replace(/^[\s]+/, '').replace(/[\s]+$/, '').replace(/[\s]{2,}/, ' ');
}


function StartLiveCalc() {
    var i;
    if (SpeedOrder > 0) {
        if (document.getElementById('divShowSpeed') != null) {
            document.getElementById('divShowSpeed').style.display = "inline";
        }
        if (document.getElementById('Optional_Costs') != null) {
            document.getElementById('Optional_Costs').style.visibility = "visible";
        }
    } else {
        if (document.getElementById('divShowSpeed') != null) {
            document.getElementById('divShowSpeed').style.display = "none";
        }
    }
    for (i = 2; i <= PrintSurfaces; i++) {
        if (document.getElementById("rowside" + i) != null) {
            document.getElementById("rowside" + i).style.display = "none";
        }
    }
    if (LotSize > 0) {
        if (document.getElementById('txtBesteleenheid') != null && document.getElementById('txtAfronding') != null && document.getElementById('addtxtNearest') != null) {
            document.getElementById('txtBesteleenheid').style.visibility = "visible";
            document.getElementById('txtBesteleenheid').innerHTML = LotSize;
            document.getElementById('txtAfronding').style.visibility = "visible";
            document.getElementById('addtxtNearest').style.visibility = "visible";
        }
    } else {
        if (document.getElementById('txtBesteleenheid') != null && document.getElementById('txtAfronding') != null && document.getElementById('addtxtNearest') != null) {
            document.getElementById('txtBesteleenheid').style.visibility = "hidden";
            document.getElementById('txtAfronding').style.visibility = "hidden";
            document.getElementById('addtxtNearest').style.visibility = "hidden";
        }
    }
	if (document.getElementById('txtItemlist') != null)
	{
		if (document.getElementById('txtItemlist').value !="")
		{
			if (parseInt(document.getElementById('txtItemlist').value)>=0)
			{
				fillindata();
			}
		}
	}
}

function fillindata()
{
	var elist;
    var temp = new Array();
	var ttemp;
	
    var enlist;
    var enl;
   
    if (document.getElementById("txtEenmaliglist") != null) {
        enlist = document.getElementById("txtEenmaliglist").value;
        enl = enlist.split("|");
    }
    if (document.getElementById('txtOptionlist') != null) {
        elist = document.getElementById('txtOptionlist').value;
        temp = elist.split("|");
    }
	
	var myArray = [];

	var datarr;
	var pcookie=readCookie("item" + document.getElementById('txtItemlist').value);
	var pcookiearr=pcookie.split("&");
	for (var k=0;k<pcookiearr.length;k++)
	{
		datarr=pcookiearr[k].split("=");
		myArray[datarr[0]] = datarr[1];
	}
	document.getElementById('addtxtTotal').value=myArray['txtQtySebenar'];
	Select_Value_Set('txtSide1Color',myArray['SideColor']);
	ttemp=unescape(myArray['txtOptionValue']);
	var ttemp2=ttemp.split("^");
	var newtemp=ttemp2[0].replace("+","") + " - " + ttemp2[1].replace("+","") + "  EUR - " + ttemp[3].replace("+","") + "#";
	for (k=0;k<temp.length;k++)
	{
		if (document.getElementById('idProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + temp[k]) != null) {
			Select_Value_Set('idProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + temp[k],newtemp);
		}
	}
	ttemp=unescape(myArray['EenmaligName']);
	newtemp=ttemp.replace("+"," ");
	newtemp=newtemp.replace("+"," ");
	for (k=0;k<enl.length;k++)
	{
		if (document.getElementById('EnmaligName' + enl[k]) != null && newtemp != null && document.getElementById('EnmaligName' + enl[k]).value==newtemp) {
			document.getElementById('txtEnmalig' + enl[k]).checked=true;
			CalculateAddon('divEnmalig' + enl[k],document.getElementById('txtEnmalig' + enl[k]).checked,enl[k],document.getElementById('EnmaligName' + enl[k]).value,'EnmaligNameValue' + enl[k]);
		}
	}
}

function Select_Value_Set(SelectName, Value) {
  var SelectObject = document.getElementById(SelectName).options;
  for(var index = 0; index < SelectObject.length; index++) {
   if(SelectObject[index].value == Value)
     SelectObject.selectedIndex = index;
   }
}

function addElement(divName, divWord, divPrice, HideWord) {
    if (document.getElementById('layerAddon') != null) {
        var ni = document.getElementById('layerAddon');
        var newdiv = document.createElement('div');
        var divIdName = divName;
        newdiv.setAttribute('id', divName);
        newdiv.innerHTML = '<div id="lbl' + divName + '" class="LiveCalcsubline">' + divWord + '</div><div id="lbc' + divName + '" class="LiveCalcsubRight"> ' + divPrice + ' </div> <div class="clear"><!-- No Content --></div>';
        ni.appendChild(newdiv);
        if (divName != "divspeed") {
            document.getElementById(HideWord).value = divPrice;
        }
    }
}


function ShowSides(tside) {
    var i;
    var y;
    var enlist;
    var enl;
    var color1;
    var color2;
    if (document.getElementById("txtEenmaliglist") != null) {
        enlist = document.getElementById("txtEenmaliglist").value;
        enl = enlist.split("|");
    }
    for (i = 1; i <= PrintSurfaces; i++) {
        if (i <= parseInt(tside)) {
            document.getElementById("txtSide" + i + "Color0").value = document.getElementById("txtSide" + i + "Color").value;
        } else {
            document.getElementById("txtSide" + i + "Color0").value = 0;
        }
    }
    for (i = 1; i <= parseInt(PrintSurfaces); i++) {
        if (i <= parseInt(tside)) {
            document.getElementById("rowside" + i).style.display = "block";
        } else {
            document.getElementById("rowside" + i).style.display = "none";
        }
    }
    for (y = 1; y <= enl.length; y++) {
        color1 = enl[y - 1];
        color2 = color1.split("[");
        color1 = color2[1];
        color1 = color1.replace("]", "");
        if (document.getElementById("showEnmalig" + enl[y - 1]) != "undefined" && document.getElementById("showEnmalig" + enl[y - 1]) != null && parseInt(color1) <= parseInt(tside)) document.getElementById("showEnmalig" + enl[y - 1]).style.display = "block";
        else document.getElementById("showEnmalig" + enl[y - 1]).style.display = "none";
    }
}


function removeElement(divName, hideWord) {
    if (typeof(document.getElementById(divName)) != "undefined") {
        var d = document.getElementById('layerAddon');
        var olddiv = document.getElementById(divName);
        d.removeChild(olddiv);
        if (divName != "divspeed") {
            document.getElementById(hideWord).value = "";
        }
    }
}


function FindVisible(vvalue, color) {
    var CurrentPrice;
    var i;
    var qty;
    if (document.getElementById('addtxtTotal') != null) {
        qty = document.getElementById('addtxtTotal').value;
    }
    CurrentPrice = 0;
    for (i = 1; i < VisibleCostList.length; i++) {
        if (parseInt(VisibleCostList[i]) == parseInt(vvalue)) {
            CurrentPrice = CalculateVisible(qty, color, i);
            BugString2 = BugString2 + "VValue (" + vvalue + ") = " + CurrentPrice + "\n";
        }
    }
    return CurrentPrice;
}


function CalculateAddon(vname, vadd, vvalue, vword, vWord2) {
    var Col;
    var WantAdd;
    var y;
    var i;
    var TotalSide;
    var color;
    var vvalue2;
    var vvalue3;
    var tax1, tax2;
    var visaff = 0;
    dbug2 = 0;
    BugString2 = "";
	 BugString2 = BugString2 + "Name=" + vname + ",Type = " + vadd + ",value=" + vvalue + ",word=" + vword + ",word2=" + vWord2 + "\n";
   
    if (document.getElementById("txtSide1Color") != null) {
        color = document.getElementById("txtSide1Color").value;
    }
    if (parseInt(vvalue) == 0) {
        WantAdd = SpeedOrder;
    }
    if (vadd == true) {
        if (vname == "divspeed") {
			if (document.getElementById('divspeed')!=null)
            {
				removeElement(vname, vWord2);
				
			}
			addElement(vname, vword, WantAdd.toFixed(2), vWord2);
            visaff = CalculateVisibleBackbaseAffilliateMargin(WantAdd, color);
            WantAdd = WantAdd + visaff;
            AllTotalBackbaseAffilliate = AllTotalBackbaseAffilliate + visaff;
            visaff = CalculateVisibleAffilliateMargin(WantAdd);
            AllTotalBoomAffilliate = parseFloat(AllTotalBoomAffilliate) + parseFloat(visaff);
            totalAffiliate = parseFloat(totalAffiliate) + parseFloat(visaff);
			AllTotal = AllTotal + parseFloat(WantAdd);
            AllTotalVisible = AllTotalVisible + parseFloat(WantAdd);
        } else {
            TotalSide = document.getElementById('txtSideColor').value;
            vvalue2 = vvalue.split("[");
            vvalue3 = parseInt(vvalue2[0]);
            BugString2 = BugString2 + "Color = " + color + "\n";
            WantAdd = FindVisible(vvalue3, color);
            BugString2 = BugString2 + "1. " + WantAdd + "\n";
            visaff = CalculateVisibleBackbaseAffilliateMargin(WantAdd, color);
            AllTotalBackbaseAffilliate = AllTotalBackbaseAffilliate + visaff;
            WantAdd = WantAdd + visaff;
            totalAffiliate = parseFloat(totalAffiliate) + parseFloat(visaff);
            visaff = CalculateVisibleAffilliateMargin(WantAdd);
            AllTotalBoomAffilliate = AllTotalBoomAffilliate + visaff;
            WantAdd = WantAdd + visaff;
            totalAffiliate = parseFloat(totalAffiliate) + parseFloat(visaff);
            if (vword != "none") {
                addElement(vname, vword, WantAdd.toFixed(2), vWord2);
            } else {
                document.getElementById('lbc' + vname).innerHTML = WantAdd.toFixed(2);
            }
            AllTotal = AllTotal + parseFloat(WantAdd);
            AllTotalVisible = AllTotalVisible + parseFloat(WantAdd);
        }
    } else {
        if (vname == "divspeed") {
			if (document.getElementById('divspeed')!=null)
			{
				color = document.getElementById("txtSide1Color").value;
				removeElement(vname, vWord2);
				//visaff = CalculateVisibleBackbaseAffilliateMargin(WantAdd, color);
				//WantAdd = WantAdd + visaff;
				//AllTotalBackbaseAffilliate = AllTotalBackbaseAffilliate - visaff;
				//visaff = CalculateVisibleAffilliateMargin(WantAdd);
				//AllTotalBoomAffilliate = parseFloat(AllTotalBoomAffilliate) - parseFloat(visaff);
				//totalAffiliate = parseFloat(totalAffiliate) - parseFloat(visaff);
				//AllTotal = AllTotal - parseFloat(WantAdd);
				//AllTotalVisible = AllTotalVisible - parseFloat(WantAdd);
			}
        } else if (vword != "none") {
            removeElement(vname, vWord2);
            TotalSide = document.getElementById('txtSideColor').value;
            vvalue2 = vvalue.split("[");
            vvalue3 = parseInt(vvalue2[0]);
            WantAdd = FindVisible(vvalue, color);
            BugString2 = BugString2 + "1. " + WantAdd + "\n";
            visaff = CalculateVisibleBackbaseAffilliateMargin(WantAdd, color);
            WantAdd = WantAdd + visaff;
            AllTotalBackbaseAffilliate = AllTotalBackbaseAffilliate - visaff;
            totalAffiliate = parseFloat(totalAffiliate) - parseFloat(visaff);
            visaff = CalculateVisibleAffilliateMargin(WantAdd);
            AllTotalBoomAffilliate = AllTotalBoomAffilliate - visaff;
            WantAdd = WantAdd + visaff;
            totalAffiliate = parseFloat(totalAffiliate) - parseFloat(visaff);
            AllTotal = AllTotal - parseFloat(WantAdd);
            AllTotalVisible = AllTotalVisible - parseFloat(WantAdd);
        }
    }
    if (vname == "divspeed" && vadd == true) {
        if (document.getElementById("txtSpeed0") != null) {
            document.getElementById("txtSpeed0").value = SpeedOrder;
        }
    } else if (vname == "divspeed" && vadd == false) {
        if (document.getElementById("txtSpeed0") != null) {
            document.getElementById("txtSpeed0").value = 0;
        }
    }
    Col = parseFloat(AllTotal + AllTotalOption);
    if (document.getElementById("bigtotal") != null && document.getElementById("allProduct0") != null) {
        document.getElementById("bigtotal").innerHTML = Col.toFixed(2);
        document.getElementById("allProduct0").value = Col.toFixed(2);
    }
    if (document.getElementById('txtTax') != null) {
        var TaxValue = parseInt(document.getElementById('txtTax').innerHTML);
        Col = (AllTotal - AllTotalVisible - AllTotalVisible2) * parseInt(TaxValue) / 100;
    }
    tax1 = Col;
    Col = (AllTotalVisible + AllTotalVisible2 + AllTotalOption) * 19 / 100;
    tax2 = Col;
    if (parseInt(TaxValue) == 19) Col = Col + tax1;
    if (document.getElementById("lblothertaxcaption") != null && document.getElementById("txtothertax") != null && document.getElementById("txtOtherTaxValue0") != null) {
        document.getElementById("lblothertaxcaption").innerHTML = "BTW 19%";
        document.getElementById("txtothertax").innerHTML = Col.toFixed(2);
        document.getElementById("txtOtherTaxValue0").value = Col.toFixed(0);
    }
    var TotalPrice2 = parseFloat(AllTotal.toFixed(2)) + parseFloat(tax2.toFixed(2)) + parseFloat(AllTotalOption.toFixed(2));
	
    if (!isNaN(tax1)) TotalPrice2 = TotalPrice2 + parseFloat(tax1.toFixed(2));
    if (document.getElementById("bigtotalbtw")) document.getElementById("bigtotalbtw").innerHTML = TotalPrice2.toFixed(2);
    TotalPrice2 = AllTotalBackbaseAffilliate2 + AllTotalBackbaseAffilliate;
    if (document.getElementById('lblbackaff') != null) document.getElementById('lblbackaff').innerHTML = TotalPrice2.toFixed(2);
    TotalPrice2 = parseFloat(AllTotalBoomAffilliate2) + parseFloat(AllTotalBoomAffilliate);
    if (document.getElementById('lblboomaff') != null) document.getElementById('lblboomaff').innerHTML = TotalPrice2.toFixed(2);
    if (document.getElementById(vWord2) != null) document.getElementById(vWord2).value=WantAdd;
	BugString2=BugString2 + "Final : " + WantAdd + "\n";
	if (dbug2 == 1) alert(BugString2);
    if (vname != "divspeed") {
        if (document.getElementById("Optional_cost_alert") != null) {
            if (vadd == true) {
                document.getElementById('Optional_cost_alert').style.display = 'block';
            } else if (vadd == false) {
                document.getElementById('Optional_cost_alert').style.display = 'none';
            }
        }
    }
	
    CalculatePrice();
}


function CalculateAllAddon() {
    var elist;
    var temp = new Array();
    AllTotalVisible = 0;
	AllTotalOption=0;
	if (document.getElementById('txtSpeedCheck') != null) {
        CalculateAddon('divspeed',document.getElementById('txtSpeedCheck').checked,0,'Spoed (in overleg)');
    }
    if (document.getElementById('txtEenmaliglist') != null) {
        elist = document.getElementById('txtEenmaliglist').value;
        temp = elist.split("|");
    }
    var i;
    for (i = 0; i < temp.length; i++) {
        if (typeof(document.getElementById('divEnmalig' + temp[i])) != "undefined" && document.getElementById('divEnmalig' + temp[i]) != null) {
            CalculateAddon('divEnmalig' + temp[i], document.getElementById('txtEnmalig' + temp[i]).checked, temp[i], 'none', 'EnmaligNameValue' + temp[i]);
        }
    }
}


function ShowOptionAlert(value) {
    var AlertText;
    if (value != "") {
        if (value.split('#')[1] != null || value.split('#')[1] != "") {
            AlertText = value.split('#')[1];
            document.getElementById('Options_alert').innerHTML = AlertText;
            document.getElementById('Options_alert').style.display = 'block';
            if (document.getElementById('Options_alert').innerHTML == "") {
                document.getElementById('Options_alert').style.display = 'none';
            }
        }
    } else {
        document.getElementById('Options_alert').style.display = 'none';
    }
}

function ShowColorAlert(value) {
    var AlertText;
    if (value != "") {
        if (value.split('#')[1] != null || value.split('#')[1] != "") {
            AlertText = value.split('#')[1];
            document.getElementById('Color_alert').innerHTML = AlertText;
            document.getElementById('Color_alert').style.display = 'block';
            if (document.getElementById('Color_alert').innerHTML == "") {
                document.getElementById('Color_alert').style.display = 'none';
            }
        }
    } else {
        document.getElementById('Color_alert').style.display = 'none';
    }
}


function CalculateAllOption() {
    var elist;
    var temp = new Array();
    AllTotalOption = 0;
	AllTotalOptionNotVisible = 0;
    var Prd_OptValue;
    optselect = "";
    var arrValue;
	var npercent=false;
	
    if (document.getElementById('txtOptionlist') != null) {
        elist = document.getElementById('txtOptionlist').value;
        temp = elist.split("|");
    }
	
    var i;
    for (i = 0; i < temp.length; i++) {
		
        if (document.getElementById('idProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + temp[i]) != null) {
			
            if (document.getElementById('idProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + temp[i])) {
				
                AddProductOption('idProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + temp[i], document.getElementById('idProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + temp[i]).value);
                if (document.getElementById('idProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + temp[i]).value != "") {
                    arrValue = document.getElementById('idProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + temp[i]).value.split("-");
                    if (optselect != "") optselect = optselect + "|";
                    optselect = optselect + arrValue[0];
                    if (arrValue[1] != null && trim(arrValue[1]).split(" ")[1] == "%") {
                        if (document.getElementById('addtxtTotPrice') != null) {
                            Prd_OptValue = parseFloat(AllTotalNotVisible) * parseInt(arrValue[1]) / 100;
							npercent=true;
                        }
                    } else {
                        Prd_OptValue = parseFloat(trim(arrValue[1]).split(" ")[0]);
						npercent=false;
                    }
					
                    CalculateOption(Prd_OptValue, temp[i], arrValue[0],npercent);
                    optselect = optselect + "^" + arrValue[2];
                }
            }
        } else {
			 if (document.getElementById('idProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + temp[i]) != null) {
				if (document.getElementById('idProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + temp[i]).value != "") {
					arrValue = document.getElementById('idProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + temp[i]).value.split("-");
					if (optselect != "") optselect = optselect + "|";
					optselect = optselect + arrValue[0];
					if (arrValue[1] != null && trim(arrValue[1]).split(" ")[1] == "%") {
						if (document.getElementById('addtxtTotPrice') != null) {
							Prd_OptValue = parseFloat(AllTotalNotVisible) * parseInt(arrValue[1]) / 100;
							npercent=true;
							}
					} else {
						Prd_OptValue = parseFloat(trim(arrValue[1]).split(" ")[0]);
						npercent=false;
					}
					CalculateOption(Prd_OptValue, temp[i], arrValue[0],npercent);
					optselect = optselect + "^" + arrValue[2];
				}
            }
			
        }
    }
    document.getElementById('txtOptionSelected').value = optselect;
	if (isaff == 1)
	{
    	Col = parseFloat(AllTotalNotVisible + AllTotalOption + AllTotalVisible + AllTotalVisible2-totalAffiliate);
	}
	else
	{
		Col = parseFloat(AllTotalNotVisible + AllTotalOption + AllTotalVisible + AllTotalVisible2);
	}
	AllTotal=Col;
    if (document.getElementById("bigtotal") != null && document.getElementById("allProduct0") != null) {
        document.getElementById("bigtotal").innerHTML = Col.toFixed(2);
        document.getElementById("allProduct0").value = Col.toFixed(2);
    }
    if (document.getElementById('txtTax') != null) {
        var TaxValue = parseInt(document.getElementById('txtTax').innerHTML);
        Col = (AllTotal - AllTotalVisible - AllTotalVisible2) * parseInt(TaxValue) / 100;
    }
    tax1 = Col;
    Col = (AllTotalVisible + AllTotalVisible2 + AllTotalOption) * 19 / 100;
	
    tax2 = Col;
    if (parseInt(TaxValue) == 19) Col = Col + tax1;
	
    if (document.getElementById("lblothertaxcaption") != null && document.getElementById("txtothertax") != null && document.getElementById("txtOtherTaxValue0") != null) {
        document.getElementById("lblothertaxcaption").innerHTML = "BTW 19%";
        document.getElementById("txtothertax").innerHTML = Col.toFixed(2);
        document.getElementById("txtOtherTaxValue0").value = Col.toFixed(0);
    }
	
    var TotalPrice2;
	if (isaff == 1)
	{
		TotalPrice2= parseFloat(AllTotalNotVisible + AllTotalOption + AllTotalVisible + AllTotalVisible2-totalAffiliate) + parseFloat(tax2);
	}
	else
	{
		TotalPrice2= parseFloat(AllTotalNotVisible + AllTotalOption + AllTotalVisible + AllTotalVisible2) + parseFloat(tax2);
	}
	if (!isNaN(tax1)) TotalPrice2 = TotalPrice2 + parseFloat(tax1);
    if (document.getElementById("bigtotalbtw")) document.getElementById("bigtotalbtw").innerHTML = TotalPrice2.toFixed(2);
    TotalPrice2 = AllTotalBackbaseAffilliate2 + AllTotalBackbaseAffilliate;
    if (document.getElementById('lblbackaff') != null) document.getElementById('lblbackaff').innerHTML = TotalPrice2.toFixed(2);
    TotalPrice2 = parseFloat(AllTotalBoomAffilliate2) + parseFloat(AllTotalBoomAffilliate);
    if (document.getElementById('lblboomaff') != null) document.getElementById('lblboomaff').innerHTML = TotalPrice2.toFixed(2);
}


function CalculateOption(Prd_OptValue, id, optname,npercent) {
    var color;
    if (document.getElementById("txtSide1Color") != null) {
        color = document.getElementById("txtSide1Color").value;
    }
	 var qty;
    if (document.getElementById('addtxtTotal') != null) {
        qty = document.getElementById('addtxtTotal').value;
    }
	
    var NearLot = GetNearestLot(qty);
    visaff = CalculateVisibleBackbaseAffilliateMargin(Prd_OptValue, color);
	if (npercent==false)
	{
		Prd_OptValue = Prd_OptValue * NearLot;
	}
	else
	{
	}
    Prd_OptValue = parseFloat(Prd_OptValue) + visaff;
	AllTotalOption = AllTotalOption + Prd_OptValue;
    visaff = CalculateVisibleAffilliateMargin(Prd_OptValue);
    AllTotalOption = AllTotalOption + visaff;
	//AllTotalOptionNotVisible = AllTotalOptionNotVisible + Prd_OptValue;
    //AllTotalOptionNotVisible = AllTotalOptionNotVisible + visaff;
	
    optselect = optselect + "^" + Prd_OptValue;
    optselect = optselect + "^" + document.getElementById('idProdOptName_' + document.getElementById('iPKProduct0').value + '_' + id).value;
    if (parseFloat(Prd_OptValue) > 0) {
        document.getElementById('div_NidProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + id).innerHTML = optname;
        document.getElementById('div_VidProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + id).innerHTML = Prd_OptValue.toFixed(2);
    } else {
        if (document.getElementById('div_VidProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + id)) document.getElementById('div_VidProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + id).innerHTML = "";
        if (document.getElementById('div_NidProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + id)) document.getElementById('div_NidProdOptAttr_' + document.getElementById('iPKProduct0').value + '_' + id).innerHTML = "";
    }
}


function DisplayStaffel() {
    var i;
    var NotGroup = NotVisibleStaffelPriceGroup[NotVisibleCostList[1]][230];
    var pprice45;
    var perprice45;
    fromStaffel = 1;
    dbug4 = 0;
    var color;
    if (document.getElementById("txtSide1Color") != null) {
        color = document.getElementById("txtSide1Color").value;
    }
	 BugString = BugString + "****color : " + color + "\n";
    for (i = 1; i <= 5; i++) {
		
        perprice45 = 0;
        pprice45 = 0;
        if (i <= TotalStaffel[NotGroup]) {
            BugString4 = BugString4 + "Column " + i + "\n";
            if (document.getElementById('tblstaffelHeader' + i) != null) {
                document.getElementById('tblstaffelHeader' + i).innerHTML = StaffelData[NotGroup][i];
            }
            pprice45 = parseFloat(CalculateNotVisibleStaffel(StaffelData[NotGroup][i], color));
            perprice45 = parseFloat(pprice45) / parseFloat(StaffelData[NotGroup][i]) * parseFloat(PriceQty);
            if (document.getElementById('tblstaffelData' + i) != null) {
                document.getElementById('tblstaffelData' + i).innerHTML = perprice45.toFixed(2);
            }
        } else {
            if (document.getElementById('tblstaffelHeader' + i) != null && document.getElementById('tblstaffelData' + i) != null) {
                document.getElementById('tblstaffelHeader' + i).style.visibility = "hidden";
                document.getElementById('tblstaffelData' + i).style.visibility = "hidden";
            }
        }
    }
    if (parseInt(color) == 7) {
        if (document.getElementById('tblstaffelColor') != null) {
            document.getElementById('tblstaffelColor').innerHTML = "full kleur";
        }
    } else {
        if (document.getElementById('tblstaffelColor') != null) {
            document.getElementById('tblstaffelColor').innerHTML = color + " kleur";
        }
    }
    if (dbug4 == 1) alert(BugString4);
    if (document.getElementById('txtVanaf') != null) {
        document.getElementById('txtVanaf').innerHTML = perprice45.toFixed(2);
    }
}


function CalculateVisible(qty, color, i) {
    var TotalVisible;
    var NearLot;
    var j;
    var VisibleResult;
    var TotalSide;
    if (document.getElementById("txtSideColor") != null) {
        TotalSide = document.getElementById("txtSideColor").value;
    }
    NearLot = GetNearestLot(qty);
    BugString2 = BugString2 + "Quantity : " + qty + "\n";
    BugString2 = BugString2 + "Near Lot : " + NearLot + "\n";
    BugString2 = BugString2 + "Total Side : " + TotalSide + "\n";
    TotalVisible = 0;
    if (typeof(VisibleCostList[i]) != "undefined") {
        BugString2 = BugString2 + "Sales Component Subject : " + VisibleCostType[VisibleCostList[i]] + "\n";
        BugString2 = BugString2 + "------------------------------------------------\n";
        if (VisibleCostType[VisibleCostList[i]] == 1 || VisibleCostType[VisibleCostList[i]] == 4 || VisibleCostType[VisibleCostList[i]] == 5 || VisibleCostType[VisibleCostList[i]] == 6) {
            BugString2 = BugString2 + "Color : " + color + "\n";
            VisibleResult = parseFloat(GetVisibleColor(color, i, NearLot));
            BugString2 = BugString2 + "Visible Result : " + VisibleResult + "\n";
            BugString2 = BugString2 + "Total Visible : " + TotalVisible + " + " + VisibleResult + " = " + (parseFloat(TotalVisible) + parseFloat(VisibleResult)) + "\n";
            TotalVisible = TotalVisible + VisibleResult;
        } else if (VisibleCostType[VisibleCostList[i]] == 2 || VisibleCostType[VisibleCostList[i]] == 3) {
            for (j = 1; j <= parseInt(TotalSide); j++) {
                BugString2 = BugString2 + "Side : " + j + "\n";
                BugString2 = BugString2 + "===============================================\n";
                if (document.getElementById("txtSide" + j + "Color") != null) {
                    color = document.getElementById("txtSide" + j + "Color").value;
                    BugString2 = BugString2 + "Color : " + color + "\n";
                    VisibleResult = parseFloat(GetVisibleColor(color, i, NearLot));
                    BugString2 = BugString2 + "Total Visible : " + TotalVisible + " + " + VisibleResult + " = " + (parseFloat(TotalVisible) + parseFloat(VisibleResult)) + "\n";
                    TotalVisible = TotalVisible + VisibleResult;
                }
                BugString2 = BugString2 + "===============================================\n";
            }
        }
    }
    return TotalVisible;
}


function CalculateNotVisible(qty, color) {
    var TotalNotVisible;
    var TotalNotVisible1;
    var TotalNotVisible2;
    var NearLot;
    var minusprice;
    var i;
    var j;
    var NotVisibleResult;
    var TotalSide;
    if (document.getElementById("txtSideColor") != null) {
        TotalSide = document.getElementById("txtSideColor").value;
    }
    NearLot = GetNearestLot(qty);
    TotalNotVisible1 = 0;
    TotalNotVisible2 = 0;
	BugString=BugString + "   1.1.1 Total Not Visible Cost List : " + NotVisibleCostList.length + "\n";
    for (i = 1; i < NotVisibleCostList.length; i++) {
        if (typeof(NotVisibleCostList[i]) != "undefined") {
			BugString=BugString + "     1.1.2 Not Visible " + i + " : " + NotVisibleCostList[i] + "\n";
			BugString=BugString + "                Type : " + NotVisibleCostType[i] + "\n";
            if (NotVisibleCostType[i] == 1 || NotVisibleCostType[i] == 3) {
                if (document.getElementById("txtSide1Color") != null) {
                    color = document.getElementById("txtSide1Color").value;
                    NotVisibleResult = parseFloat(GetNotVisibleColor(color, i, NearLot));
                    TotalNotVisible1 = TotalNotVisible1 + NotVisibleResult;
                }
            } else if (NotVisibleCostType[i] == 2 || NotVisibleCostType[i] == 4) {
                //for (j = 1; j <= parseInt(TotalSide); j++) {
                //    if (document.getElementById("txtSide" + j + "Color") != null) {
                        //color = document.getElementById("txtSide" + j + "Color").value;
						color = document.getElementById("txtSide1Color").value;
                        NotVisibleResult = parseFloat(GetNotVisibleColor(color, i, NearLot));
                        TotalNotVisible2 = TotalNotVisible2 + NotVisibleResult;
                //    }
               // }
            }
        }
    }
    if (fromStaffel == 0) BugString = BugString + "1. Total Not Visible : " + TotalNotVisible1 + " x " + NearLot + " = ";
    TotalNotVisible1 = parseFloat(TotalNotVisible1) * parseInt(NearLot);
    if (fromStaffel == 0) BugString = BugString + TotalNotVisible1 + "\n";
    TotalNotVisible = parseFloat(TotalNotVisible1) + parseFloat(TotalNotVisible2);
    if (fromStaffel == 0) BugString = BugString + "1. Total Not Visible : " + TotalNotVisible1 + " + " + TotalNotVisible2 + " = " + TotalNotVisible + "\n";
    BackBaseAff = TotalNotVisible2;
    minusprice = 0;
    return TotalNotVisible;
}


function GetNotVisibleColorStaffel(color, i, NearLot) {
    var y;
    var fromlist;
    var minusprice;
    var affprice1;
    var NomPrice = parseFloat(NotVisibleColorPrice[NotVisibleCostList[i]][color]);
    BugString4 = BugString4 + "NotVisibleColorPrice : " + NotVisibleColorPrice[NotVisibleCostList[i]][color] + "\n";
    var CurrentPrice = NomPrice;
    if (NotVisibleCostType[i] == 1 || NotVisibleCostType[i] == 3) {
        NomPrice = (NomPrice / parseInt(PriceQty));
        CurrentPrice = NomPrice;
    }
    minusprice = 0;
    BugString4 = BugString4 + "   Color: " + color + " ,i : " + i + " ,Qty : " + NearLot + "\n";
    BugString4 = BugString4 + "Type : " + NotVisibleCostType[i] + "\n";
    BugString4 = BugString4 + "Price : " + CurrentPrice + "\n";
    BugString4 = BugString4 + "NotVisibleCostList : " + NotVisibleCostList[i] + "\n";
    if (typeof(NotVisibleStaffelLinkList[NotVisibleCostList[i]]) != "undefined") {
        for (y = 1; y <= NotVisibleStaffelLinkList[NotVisibleCostList[i]].length; y++) {
	
            minusprice = 0;
			
            if (NotVisibleStaffelLinkList[NotVisibleCostList[i]][y] == color) {
                fromlist = NotVisibleStaffelLink[NotVisibleCostList[i]][y];
                if (typeof(fromlist) != "undefined" && typeof(NotVisibleStaffelPriceGroup[NotVisibleCostList[i]][NotVisibleStaffelLink[NotVisibleCostList[i]][y]])!="undefined") {
                    currentstaffel = FindCurrentStaffel(i, NearLot,y);
                    BugString4 = BugString4 + "CurrentStaffel : " + currentstaffel + "\n";
                    if (typeof(NotVisibleStaffelPricePerc[NotVisibleCostList[i]][fromlist]) != "undefined") {
                        if (fromlist == 230) {
                            if (NotVisibleCostType[i] == 1) {
                                if (NotVisibleStaffelPricePerc[NotVisibleCostList[i]][fromlist] == 2) {
                                    if (typeof(NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel]) == "undefined") staffelprice = 0;
                                    else staffelprice = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel];
                                    minusprice = (CurrentPrice * (staffelprice / 100));
                                } else if (typeof(NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist]) != "undefined" && typeof(NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel]) != "undefined") {
                                    if (typeof(NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel]) == "undefined") staffelprice = 0;
                                    else staffelprice = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel];
                                    minusprice = staffelprice;
                                } else {
                                    minusprice = 0;
                                }
                            }
                        } else if (fromlist == 231) {
                            if (NotVisibleCostType[i] == 1) {
                                if (NotVisibleStaffelPricePerc[NotVisibleCostList[i]][fromlist] == 2) {
                                    if (typeof(NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel]) == "undefined") staffelprice = 0;
                                    else staffelprice = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel];
                                    minusprice = (parseFloat(CurrentPrice) * (staffelprice / 100));
                                } else {
                                    if (typeof(NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel]) == "undefined") staffelprice = 0;
                                    else staffelprice = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel];
                                    minusprice = staffelprice;
                                }
                                var temp1;
                                temp1 = parseFloat(minusprice) * parseInt(NearLot);
                                minusprice = 0;
                            }
                        } else {
                            if (NotVisibleStaffelPricePerc[NotVisibleCostList[i]][fromlist] == 2) {
                                if (typeof(NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel]) == "undefined") staffelprice = 0;
                                else staffelprice = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel];
                                minusprice = (NomPrice * (staffelprice / 100));
                            } else {
                                if (typeof(NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel]) == "undefined") staffelprice = 0;
                                else staffelprice = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel];
                                if (NotVisibleCostType[i] == 1 || NotVisibleCostType[i] == 3) {
                                    minusprice = staffelprice / parseInt(PriceQty);
                                } else {
                                    minusprice = staffelprice;
                                }
                            }
                        }
                        if (typeof(minusprice) == "undefined") minusprice = 0;
                        if (NotVisibleStaffelPriceType[NotVisibleCostList[i]][fromlist] == 1) {
                            CurrentPrice = parseFloat(CurrentPrice) + parseFloat(minusprice);
                        } else {
                            CurrentPrice = parseFloat(CurrentPrice) + parseFloat(minusprice);
                        }
                    }
                }
            }
        }
    }
    return CurrentPrice;
}


function CalculateNotVisibleStaffel(qty, color) {
    var TotalNotVisible;
    var TotalNotVisible1;
    var TotalNotVisible2;
    var NearLot;
    var minusprice;
    var i;
    var j;
    var NotVisibleResult;
    var TotalSide;
    if (document.getElementById("txtSideColor") != null) {
        TotalSide = document.getElementById("txtSideColor").value;
    }
    BugString4 = BugString4 + "===============================================\n";
    NearLot = GetNearestLot(qty);
    BugString4 = BugString4 + "Qty = " + qty + " , Near Lot = " + NearLot + "\n";
    TotalNotVisible1 = 0;
    TotalNotVisible2 = 0;
    for (i = 1; i < NotVisibleCostList.length; i++) {
        if (typeof(NotVisibleCostList[i]) != "undefined") {
            if (NotVisibleCostType[i] == 1 || NotVisibleCostType[i] == 3) {
                NotVisibleResult = parseFloat(GetNotVisibleColorStaffel(color, i, NearLot));
                TotalNotVisible1 = TotalNotVisible1 + NotVisibleResult;
            } else if (NotVisibleCostType[i] == 2 || NotVisibleCostType[i] == 4) {
                //for (j = 1; j <= parseInt(TotalSide); j++) {
                    NotVisibleResult = parseFloat(GetNotVisibleColorStaffel(color, i, NearLot));
                    TotalNotVisible2 = TotalNotVisible2 + NotVisibleResult;
                    BugString4 = BugString4 + "===============================================\n";
                //}
            }
        }
    }
    TotalNotVisible1 = parseFloat(TotalNotVisible1) * parseInt(NearLot);
    TotalNotVisible = parseFloat(TotalNotVisible1) + parseFloat(TotalNotVisible2);
    minusprice = 0;
    return TotalNotVisible;
}


function GetVisibleColor(color, i, NearLot) {
    var y;
    var fromlist;
    var minusprice;
    var NomPrice = parseFloat(VisibleColorPrice[VisibleCostList[i]][color]);
    var CurrentPrice = NomPrice;
    if (VisibleCostType[VisibleCostList[i]] == 1 || VisibleCostType[VisibleCostList[i]] == 3) {
        NomPrice = (NomPrice / PriceQty) * NearLot;
        CurrentPrice = NomPrice;
    }
    BugString2 = BugString2 + "=================from get visible color=======================\n";
    BugString2 = BugString2 + "1. Visible price : " + CurrentPrice + "\n";
    BugString3 = BugString3 + "1. Visible price : " + CurrentPrice + "\n";
    if (typeof(VisibleStaffelLinkList[VisibleCostList[i]]) != "undefined") {
        for (y = 1; y <= VisibleStaffelLinkList[VisibleCostList[i]].length; y++) {
            if (VisibleStaffelLinkList[VisibleCostList[i]][y] == color) {
                fromlist = VisibleStaffelLink[VisibleCostList[i]][y];
                currentstaffel = FindCurrentVisibleStaffel(i);
                BugString2 = BugString2 + "1. Current Staffel : " + currentstaffel + "\n";
				if (typeof(VisibleStaffelPricePerc[VisibleCostList[i]])!="undefined")
				{
					if (VisibleStaffelPricePerc[VisibleCostList[i]][fromlist] == 2) {
						minusprice = NomPrice * (VisibleStaffelPrice[VisibleCostList[i]][fromlist][currentstaffel] / 100);
						BugString2 = BugString2 + "1.1 Price : " + NomPrice + " x " + VisibleStaffelPrice[VisibleCostList[i]][fromlist][currentstaffel] + " / 100 = " + minusprice + "\n";
					} else {
						if (VisibleCostType[VisibleCostList[i]] == 1 || VisibleCostType[VisibleCostList[i]] == 3) {
							minusprice = VisibleStaffelPrice[VisibleCostList[i]][fromlist][currentstaffel] * NearLot;
							BugString2 = BugString2 + "1.2 Price : " + VisibleStaffelPrice[VisibleCostList[i]][fromlist][currentstaffel] + " x " + NearLot + " / 100 = " + minusprice + "\n";
						} else {
							minusprice = VisibleStaffelPrice[VisibleCostList[i]][fromlist][currentstaffel];
							BugString2 = BugString2 + "1.3 Price : " + VisibleStaffelPrice[VisibleCostList[i]][fromlist][currentstaffel] + "\n";
							BugString2 = BugString2 + "1.3.1 " + "VisibleStaffelPrice[" + VisibleCostList[i] + "][" + fromlist + "][" + currentstaffel + "]\n";
						}
					}
				}
				if (typeof(VisibleStaffelPriceType[VisibleCostList[i]])!="undefined")
				{
					if (VisibleStaffelPriceType[VisibleCostList[i]][fromlist] == 1) {
						BugString2 = BugString2 + "1.4 Price : " + CurrentPrice + " - " + minusprice + " = " + (parseFloat(CurrentPrice) - parseFloat(minusprice)) + "\n";
						CurrentPrice = parseFloat(CurrentPrice) - parseFloat(minusprice);
					} else {
						BugString2 = BugString2 + "1.5 Price : " + CurrentPrice + " + " + minusprice + " = " + (parseFloat(CurrentPrice) + parseFloat(minusprice)) + "\n";
						CurrentPrice = parseFloat(CurrentPrice) + parseFloat(minusprice);
					}
				}
            }
        }
    }
    if (VisibleCostType[VisibleCostList[i]] == 1 || VisibleCostType[VisibleCostList[i]] == 3) {
        if (VisibleFSPType == 2) {
            BugString2 = BugString2 + "Price : " + CurrentPrice + " + " + VisibleFSP[currentstaffel] + "% per " + PriceQty + "\n";
            BugString3 = BugString3 + "Price : " + CurrentPrice + " + " + VisibleFSP[currentstaffel] + "% per " + PriceQty + "\n";
            CurrentPrice = parseFloat(CurrentPrice) + ((parseFloat(CurrentPrice) * parseFloat(VisibleFSP[currentstaffel]) / 100));
        } else {
            BugString2 = BugString2 + "Price : " + CurrentPrice + " + " + (VisibleFSP[currentstaffel]) + "\n";
            BugString3 = BugString3 + "Price : " + CurrentPrice + " + " + (VisibleFSP[currentstaffel]) + "\n";
            CurrentPrice = CurrentPrice + VisibleFSP[currentstaffel];
        }
    }
    BugString2 = BugString2 + "===========End From Get Visible Color==========\n";
    return CurrentPrice;
}


function GetNotVisibleColor(color, i, NearLot) {
    var y;
    var fromlist;
    var minusprice;
    var affprice1;
    var stafelprice;
    if (fromStaffel == 0) BugString = BugString + "           Color: " + color + " ,i : " + i + " ,Qty : " + NearLot + "\n";
	if (fromStaffel == 0) BugString = BugString + "           Price: " + NotVisibleColorPrice[NotVisibleCostList[i]][color] + "\n";
    var NomPrice = parseFloat(NotVisibleColorPrice[NotVisibleCostList[i]][color]);
    var CurrentPrice = NomPrice;
    if (NotVisibleCostType[i] == 1 || NotVisibleCostType[i] == 3) {
        NomPrice = (NomPrice / parseInt(PriceQty));
        CurrentPrice = NomPrice;
    }
    minusprice = 0;
    if (typeof(NotVisibleStaffelLinkList[NotVisibleCostList[i]]) != "undefined") {
		if (fromStaffel == 0) BugString = BugString + "   Total Not Visible Link List " + NotVisibleCostList[i] + " = " + NotVisibleStaffelLinkList[NotVisibleCostList[i]].length + "\n";
        for (y = 1; y <= NotVisibleStaffelLinkList[NotVisibleCostList[i]].length; y++) {
            minusprice = 0;
			if (fromStaffel == 0) BugString = BugString + "   Problem start here with color " + color + "\n";
			if (fromStaffel == 0) BugString = BugString + "   Problem start here with not visible cost list " + NotVisibleCostList[i] + "\n";
			if (fromStaffel == 0) BugString = BugString + "   Not Visible Link List " + NotVisibleCostList[i] + " number " + y + " color is " + NotVisibleStaffelLinkList[NotVisibleCostList[i]][y] + "\n";
            if (NotVisibleStaffelLinkList[NotVisibleCostList[i]][y] == color) {
				
				fromlist = NotVisibleStaffelLink[NotVisibleCostList[i]][y];
				
                if (typeof(fromlist) != "undefined" && typeof(NotVisibleStaffelPriceGroup[NotVisibleCostList[i]][NotVisibleStaffelLink[NotVisibleCostList[i]][y]])!="undefined") {
                    currentstaffel = FindCurrentStaffel(i, NearLot,y);
					
                    if (fromStaffel == 0) BugString = BugString + "   Current Staffel : " + currentstaffel + "\n";
					
                    if (typeof(NotVisibleStaffelPricePerc[NotVisibleCostList[i]][fromlist]) != "undefined") {
                        if (fromlist == 230) {
                            BugString = BugString + "       from list = 230 \n";
                            BugString = BugString + "       not visible cost type = " + NotVisibleCostType[i] + " \n";
                            BugString = BugString + "       staffel price = " + NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel] + " \n";
                            if (NotVisibleCostType[i] == 1 || NotVisibleCostType[i] == 3) {
                                if (NotVisibleStaffelPricePerc[NotVisibleCostList[i]][fromlist] == 2) {
                                    if (typeof(NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel]) == "undefined") staffelprice = 0;
                                    else staffelprice = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel];
                                    minusprice = (CurrentPrice * (staffelprice / 100));
                                    if (fromStaffel == 0) BugString = BugString + "   1.2. FSP Margin : (" + NotVisibleCostList[i] + ")" + CurrentPrice + " x " + staffelprice + " % = " + minusprice + "\n";
                                } else if (typeof(NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist]) != "undefined" && typeof(NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel]) != "undefined") {
                                    minusprice = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel];
                                    if (fromStaffel == 0) BugString = BugString + "   1.2. FSP Margin (fixed): " + minusprice + "\n";
                                } else {
                                    minusprice = 0;
                                }
								Col = minusprice * parseInt(NearLot);
								if (fromStaffel == 0) BugString = BugString + "   1.2. FSP Margin : (" + minusprice + " x " + NearLot + ") + " + totalFSP + "  = " + (Col+totalFSP) + "\n";
                                totalFSP = totalFSP + (minusprice * parseInt(NearLot));
                                fspword = fspword + "Backbase FSP" + "<br>";
                                fspword2 = fspword2 + Col.toFixed(2) + "<br>";
                                
                                 if (document.getElementById('txtBackFSPValue')!=null) document.getElementById('txtBackFSPValue').value = totalFSP.toFixed(2);
                                if (document.getElementById('lblfspmargin')!=null) document.getElementById('lblfspmargin').innerHTML = totalFSP.toFixed(2);
                            }
                        } else if (fromlist == 231) {
                            if (fromStaffel == 0) {
                                CurrentStafBack = currentstaffel;
                                CurrentBackAff = NotVisibleCostList[i];
                            }
                            if (NotVisibleCostType[i] == 1 || NotVisibleCostType[i]==3) {
                                if (NotVisibleStaffelPricePerc[NotVisibleCostList[i]][fromlist] == 2) {
                                    if (typeof(NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel]) == "undefined") staffelprice = 0;
                                    else staffelprice = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel];
                                    minusprice = (parseFloat(CurrentPrice) * (staffelprice / 100));
                                    if (fromStaffel == 0) BugString = BugString + "   1.3. Backbase Afiilliate Margin : " + CurrentPrice + " x " + staffelprice + " % = " + minusprice + "\n";
                                } else {
                                    if (typeof(NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel]) == "undefined") staffelprice = 0;
                                    else staffelprice = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel];
                                    minusprice = staffelprice;
                                    if (fromStaffel == 0) BugString = BugString + "   1.3. Backbase Afiilliate Margin (fixed) : " + minusprice + " % " + "\n";
                                }
                                totalAffiliate = parseFloat(totalAffiliate) + (minusprice * parseInt(NearLot));
                                affword = affword + "Backbase Affiliate" + "<br>";
                                var temp1;
                                temp1 = parseFloat(minusprice) * parseInt(NearLot);
                                if (fromStaffel == 0) BugString = BugString + "   1.4. Backbase Afiilliate Margin : " + minusprice + " x " + NearLot + " = " + temp1 + "\n";
                                affword2 = affword2 + temp1.toFixed(2) + "<br>";
                                if (document.getElementById('lblaffiliate')!=null) document.getElementById('lblaffiliate').innerHTML = temp1.toFixed(2);
                                if (affktype == 1) CurrentPrice = CurrentPrice - minusprice;
                                minusprice = 0;
                            } else if (vafftype == 2 || vafftype == 1) {
                                if (NotVisibleStaffelPricePerc[NotVisibleCostList[i]][fromlist] == 2) {
                                    minusprice = (CurrentPrice * (NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel] / 100));
                                    if (fromStaffel == 0) BugString2 = BugString2 + "   Current Staffel" + currentstaffel + "\n";
                                    if (fromStaffel == 0) BugString = BugString + "   1.5. Backbase Affilliate per Order Cost : " + CurrentPrice + " x " + NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel] + " % = " + minusprice + "\n";
                                } else {
                                    minusprice = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel];
                                    if (fromStaffel == 0) CurrentBackAff = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel];
                                    if (fromStaffel == 0) BugString = BugString + "   1.5. Backbase Affilliate per Order Cost : " + NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel] + " % " + "\n";
                                }
                                totalAffiliate = totalAffiliate + minusprice;
                                affword3 = affword3 + "Backbase Affiliate (Order Cost)" + "<br>";
                                fspword3 = fspword3 + "Backbase FSP (Order Cost)" + "<br>";
                                var temp1;
                                temp1 = minusprice;
                                var sumprice;
                                if (fromStaffel == 0) AllTotalBackbaseAffilliate2 = parseFloat(AllTotalBackbaseAffilliate2) + parseFloat(temp1);
                                sumprice = parseFloat(AllTotalBackbaseAffilliate2) + parseFloat(AllTotalBackbaseAffilliate);
                                affword4 = affword4 + "<span id='lblbackaff'>" + sumprice.toFixed(2) + "</span><br>";
                                if (affmargin > 0) {
                                    if (affpercent == 1) {
                                        minusprice = (CurrentPrice * affmargin / 100);
                                        if (fromStaffel == 0) BugString = BugString + "   1.6. Other Cost : " + CurrentPrice + " x " + affmargin + " % = " + minusprice + "\n";
                                        if (isaff == 1) {
                                            affword3 = affword3 + "Boom Affilliate (Order Cost)" + "<br>";
                                            fspword3 = fspword3 + "Boom FSP (Order Cost)" + "<br>";
                                            if (fromStaffel == 0) AllTotalBoomAffilliate2 = AllTotalBoomAffilliate2 + minusprice;
                                            sumprice = AllTotalBoomAffilliate + minusprice;
                                            affword4 = affword4 + "<span id='lblboomaff'>" + sumprice.toFixed(2) + "</span><br>";
                                        }
                                    } else {
                                        minusprice = affmargin;
                                        if (isaff == 1) {
                                            affword3 = affword3 + "Boom Affilliate (order cost)" + "<br>";
                                            fspword3 = fspword3 + "Boom FSP (Order Cost)" + "<br>";
                                            if (fromStaffel == 0) AllTotalBoomAffilliate2 = AllTotalBoomAffilliate2 + minusprice;
                                            sumprice = AllTotalBoomAffilliate + affmargin;
                                            affword4 = affword4 + "<span id='lblboomaff'>" + sumprice.toFixed(2) + "</span><br>";
                                        }
                                    }
                                    totalAffiliate = totalAffiliate + minusprice;
                                }
                            }
                        } else {
                            if (NotVisibleStaffelPricePerc[NotVisibleCostList[i]][fromlist] == 2) {
                                minusprice = (NomPrice * (NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel] / 100));
                                if (fromStaffel == 0) BugString = BugString + "   1.6. Other Cost : " + NomPrice + " x " + NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel] + " % = " + minusprice + "\n";
                            } else {
                                if (NotVisibleCostType[i] == 1 || NotVisibleCostType[i] == 3) {
                                    minusprice = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel] / parseInt(PriceQty);
                                    if (fromStaffel == 0) BugString = BugString + "   1.6. Other Cost (Article Cost) : " + NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel] + " / " + PriceQty + " = " + minusprice + "\n";
                                } else {
									var xlast = TotalStaffel[NotVisibleStaffelPriceGroup[NotVisibleCostList[i]][fromlist]];
									if (fromStaffel == 0) BugString = BugString + "   Total Staffel : " + xlast + "\n    Last Staffel : " + LastStaffel[NotVisibleStaffelPriceGroup[NotVisibleCostList[i]][fromlist]] + "\n";
									if (NearLot<=LastStaffel[NotVisibleStaffelPriceGroup[NotVisibleCostList[i]][fromlist]] && NearLot>=addminimumorder[NotVisibleStaffelPriceGroup[NotVisibleCostList[i]][fromlist]])
									{
                                    	minusprice = NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel];
                                   	 	if (fromStaffel == 0) BugString = BugString + "   1.6. Other Cost (Order Cost) : " + NotVisibleStaffelPrice[NotVisibleCostList[i]][fromlist][currentstaffel] + "\n";
									}
                                }
                            }
                        }
                        if (typeof(minusprice) == "undefined") minusprice = 0;
                        if (NotVisibleStaffelPriceType[NotVisibleCostList[i]][fromlist] == 1) {
                            if (fromStaffel == 0) BugString = BugString + "   1.7.1. Not Visible Price : " + CurrentPrice + " - " + minusprice + " = ";
                            CurrentPrice = parseFloat(CurrentPrice) - parseFloat(minusprice);
                            if (fromStaffel == 0) BugString = BugString + CurrentPrice + "\n";
                        } else {
                            if (fromStaffel == 0) BugString = BugString + "   1.7.2. Not Visible Price : " + CurrentPrice + " + " + minusprice + " = ";
                            CurrentPrice = parseFloat(CurrentPrice) + parseFloat(minusprice);
                            if (fromStaffel == 0) BugString = BugString + CurrentPrice + "\n";
                        }
                    }
                }
            }
        }
    }
    return CurrentPrice;
}


function GetNearestLot(tQty) {
    var NearLot;
    var txtNearest = tQty % LotSize;
    if (txtNearest > 0) NearLot = tQty - parseFloat(txtNearest) + LotSize;
    else NearLot = tQty;
    return NearLot;
}


function ChangeSideValue(tside, tQty) {
    if (document.getElementById('txtSide' + tside + "Color0") != null) {
        document.getElementById('txtSide' + tside + "Color0").value = tQty;
    }
}


function CalculatePrice() {
    var totalcount;
    if (document.getElementById('addtxtTotal') != null) {
        totalcount = document.getElementById('addtxtTotal').value;
    }
    var currentstaffel;
    var i;
    var y;
    var colornow2;
    var colornow;
    if (document.getElementById("txtSide1Color") != null) {
        colornow = document.getElementById("txtSide1Color").value;
    }
    var TotalSide;
    if (document.getElementById("txtSideColor") != null) {
        TotalSide = document.getElementById("txtSideColor").value;
    }
    var z;
    affword = '';
    fspword = '';
    affword2 = '';
    affword3 = '';
    affword4 = '';
    fspword2 = '';
    fspword3 = '';
    fspword4 = '';
    dbug = 0;
    dbug3 = 0;
    BoomAff = 0;
    AllTotalBoomAffilliate2 = 0;
    AllTotalBackbaseAffilliate2 = 0;
    fromStaffel = 0;
    totalAffiliate = 0;
    totalFSP = 0;
    var visaff;
    BugString = '';
    BugString2 = '';
    BugString3 = '';
    AllTotalVisible2 = 0;
	AllTotal=0;
    var minusprice = 0;
		
    if (document.getElementById('txtEenmaliglist') != null && document.getElementById('divShowSpeed') != null) {
        if (document.getElementById('txtEenmaliglist').value == "" && document.getElementById('divShowSpeed').style.display == 'none') {
            document.getElementById('Optional_Costs').style.visibility = "hidden";
        }
    }
    if (document.getElementById("lblrightquantity")) document.getElementById("lblrightquantity").innerHTML = totalcount;
    if (NotVisibleStaffelLink.length > 0) {
        var fromlist = NotVisibleStaffelLink[NotVisibleCostList[TotalSide]][colornow];
        var last = TotalStaffel[NotVisibleStaffelPriceGroup[NotVisibleCostList[TotalSide]][fromlist]];
        if (typeof(last) == "undefined") last = 5;
        try {
            if (LastStaffel[NotVisibleStaffelPriceGroup[NotVisibleCostList[1]][230]] <= totalcount) {
                if (document.getElementById('divNotOverMax') != null && document.getElementById('divOverMax') != null) {
                    document.getElementById('divNotOverMax').style.display = "none";
                    document.getElementById('divOverMax').style.display = "inline";
                }
                return false;
            } else {
                if (document.getElementById('divNotOverMax') != null && document.getElementById('divOverMax') != null) {
                    document.getElementById('divNotOverMax').style.display = "inline";
                    document.getElementById('divOverMax').style.display = "none";
                }
            }
        } catch(ex) {}
    }
	
    if (typeof(colornow) == "undefined") colornow = 1;
    if (totalcount != '') {
        if (isNaN(trim(totalcount)) == false) {
            if (typeof(addminimumorder[staffelminimumorder[colornow]]) != "undefined" && parseInt(totalcount) < addminimumorder[staffelminimumorder[colornow]]) {
                if (document.getElementById('Minimum_order_alert') != null) {
                    document.getElementById('Minimum_order_alert').innerHTML = 'Minimum order ' + addminimumorder[staffelminimumorder[colornow]];
                    document.getElementById('Minimum_order_alert').style.display = 'block';
                }
            } else if (typeof(addminimumorder[staffelminimumorder[colornow]]) == "undefined" && parseInt(totalcount) < addminimumorder[maingroup]) {
                if (document.getElementById('Minimum_order_alert') != null) {
                    document.getElementById('Minimum_order_alert').innerHTML = 'Minimum order ' + addminimumorder[maingroup];
                    document.getElementById('Minimum_order_alert').style.display = 'block';
                }
            } else {
                if (document.getElementById('Minimum_order_alert') != null) {
                    document.getElementById('Minimum_order_alert').style.display = 'none';
                }
                if (document.getElementById('txtper') != null) {
                    document.getElementById("txtper").innerHTML = PriceQty;
                }
                var TotalPrice;
                TotalPrice = 0;
                var Col;
                var VPrice;
                var TotalNotVisible;
                var TotalVisible;
                TotalVisible = 0;
                TotalNotVisible = 0;
                var TaxValue;
                if (document.getElementById('txtTax') != null) {
                    TaxValue = parseInt(document.getElementById('txtTax').innerHTML);
                }
                var NearLot = GetNearestLot(totalcount);
                var tax1, tax2;
                if (document.getElementById("addtxtNearest") != null && document.getElementById("txtLotNearValue0") != null && document.getElementById("addtxtBestel") != null) {
                    document.getElementById("addtxtNearest").innerHTML = NearLot;
                    document.getElementById("txtLotNearValue0").value = NearLot;
                    document.getElementById("addtxtBestel").innerHTML = NearLot;
                }
                if (NearLot != totalcount && document.getElementById("lblratio")) document.getElementById("lblratio").style.display = "block";
                else document.getElementById("lblratio").style.display = "none";
                TotalNotVisible = 0;
                if (document.getElementById('qtyProduct0') != null && document.getElementById('txtQtySebenar0') != null) {
                    document.getElementById('qtyProduct0').value = NearLot;
                    document.getElementById('txtQtySebenar0').value = totalcount;
                }
                if (fromStaffel == 0) BugString = BugString + "1. Calculate Non Visible Price\n";
                if (fromStaffel == 0) BugString = BugString + "   1.1. Current Price : " + TotalNotVisible + "\n";
                TotalNotVisible = CalculateNotVisible(totalcount, colornow);
                if (fromStaffel == 0) BugString = BugString + "2. Calculate Boom FSP Margin\n";
                if (fromStaffel == 0) BugString = BugString + "   2.1. Current Price : " + TotalNotVisible + "\n";
				
                if (fspmargin > 0 && txtboomfsp == 0) {
                    if (fsppercent == 1) {
                        minusprice = (TotalNotVisible * fspmargin / 100);
                        fspword = fspword + "Boom FSP" + "<br>";
                        fspword2 = fspword2 + minusprice.toFixed(2) + "<br>";
                        if (fromStaffel == 0) BugString = BugString + "        2.1.2. Boom FSP Margin : " + TotalNotVisible + " x " + fspmargin + " % = " + minusprice + "\n";
                        document.getElementById('txtBoomFSPValue').value = minusprice;
                        if (isad == 1) document.getElementById('lblboomfspmargin').innerHTML = minusprice.toFixed(2);
                    } else {
                        minusprice = fspmargin;
                        fspword = fspword + "Boom FSP" + "<br>";
                        Col = parseFloat(fspmargin);
                        fspword2 = fspword2 + Col.toFixed(2) + "<br>";
                        if (fromStaffel == 0) BugString = BugString + "        2.1.2. Boom FSP Margin (fixed) : " + fspmargin + "\n";
                        document.getElementById('txtBoomFSPValue').value = fspmargin;
                        if (isad == 1) document.getElementById('lblboomfspmargin').innerHTML = fspmargin.toFixed(2);
                    }
                    if (fspminus == 1) {
                        if (fromStaffel == 0) BugString = BugString + "        2.1.2. Total FSP Margin : " + totalFSP + " + " + minusprice + " = ";
                        totalFSP = parseFloat(totalFSP) + parseFloat(minusprice);
                        if (fromStaffel == 0) BugString = BugString + totalFSP + "\n";
                        if (fromStaffel == 0) BugString = BugString + "        2.1.2. Total Not Visible Price : " + TotalNotVisible + " - " + minusprice + " = ";
                        TotalNotVisible = parseFloat(TotalNotVisible) - parseFloat(minusprice);
                        if (fromStaffel == 0) BugString = BugString + TotalNotVisible + "\n";
                    } else {
                        if (fromStaffel == 0) BugString = BugString + "        2.1.2. Total FSP Margin : " + totalFSP + " + " + minusprice + " = ";
                        totalFSP = parseFloat(totalFSP) + parseFloat(minusprice);
                        if (fromStaffel == 0) BugString = BugString + totalFSP + "\n";
                        if (fromStaffel == 0) BugString = BugString + "        2.1.2. Total Not Visible Price : " + TotalNotVisible + " + " + minusprice + " = ";
                        TotalNotVisible = parseFloat(TotalNotVisible) + parseFloat(minusprice);
                        if (fromStaffel == 0) BugString = BugString + TotalNotVisible + "\n";
                    }
                } else {
                    fspword = fspword;
                    fspword2 = fspword2 + "0.00";
                    if (fromStaffel == 0 && txtboomfsp == 1) {
                        BugString = BugString + "        2.1.2. New Boom FSP feature : \n";
                    } else {
                        BugString = BugString + "        2.1.2. No Boom FSP Margin : 0\n";
                    }
                }
                if (fromStaffel == 0) BugString = BugString + "3. Calculate Boom Affilliate  Margin\n";
                if (fromStaffel == 0) BugString = BugString + "   3.1. Current Price : " + TotalNotVisible + "\n";
                if (affmargin > 0) {
                    if (affpercent == 1) {
                        minusprice = ((TotalNotVisible - BackBaseAff) * affmargin / 100);
                        if (fromStaffel == 0) BugString = BugString + "        3.1.2. Boom Affilliate Margin : (" + TotalNotVisible + " - " + BackBaseAff + ") x " + affmargin + " % = " + minusprice + "\n";
                        if (isaff == 1) {
                            affword = affword + "Boom Affilliate" + "<br>";
                            affword2 = affword2 + minusprice.toFixed(2) + "<br>";
                        }
                    } else {
                        minusprice = affmargin;
                        if (fromStaffel == 0) BugString = BugString + "        3.1.2. Boom FSP Margin (fixed) : " + affmargin + "\n";
                        if (isaff == 1) {
                            affword = affword + "Boom Affilliate" + "<br>";
                            affword2 = affword2 + affmargin.toFixed(2) + "<br>";
                        }
                    }
                    if (fromStaffel == 0) BugString = BugString + "        3.1.3. Total Afflliate : " + totalAffiliate + " + " + minusprice + " = ";
                    totalAffiliate = parseFloat(totalAffiliate) + parseFloat(minusprice);
                    document.getElementById('txtBoomAffValue').value = minusprice;
                    if (document.getElementById('lblboomaffiliate')!=null) document.getElementById('lblboomaffiliate').innerHTML = minusprice.toFixed(2);
                    if (fromStaffel == 0) BugString = BugString + totalAffiliate + "\n";
                } else {
                    if (fromStaffel == 0) BugString = BugString + "        3.1.2. No Boom Affilliate Margin : 0\n";
                    affword = affword + "Boom Affilliate" + "<br>";
                    affword2 = affword2 + "0.00" + "<br>";
                    document.getElementById('txtBoomAffValue').value = 0;
                    if (document.getElementById('lblboomaffiliate')!=null) document.getElementById('lblboomaffiliate').innerHTML = "0.00";
                }
                if (document.getElementById('txtFSP') != null) {
                    document.getElementById('txtFSP').value = minusprice;
                }
                if (document.getElementById('txtPrice0') != null) {
                    document.getElementById('txtPrice0').value = parseFloat(TotalNotVisible) / parseFloat(NearLot);
                }
                TotalNotVisible = TotalNotVisible;
                if (txtboomfsp == 1) {
                    var boomcarstaff;
                    BugString = BugString + "3.1.2           group :  " + 1 + " , count :" + totalcount + "\n";
                    boomcarstaff = FindCurrentStaffel(1, totalcount,1);
					if (txtFSPBoomStafel[boomcarstaff])
					{
						
						BugString = BugString + "3.1.2           stafel :  " + boomcarstaff + "\n";
						if (fromStaffel == 0) BugString = BugString + "3.1.2           New Boom FSP Feature ( " + boomcarstaff + "): " + TotalNotVisible + " x " + txtFSPBoomStafel[boomcarstaff] + "/ 100  = ";
						TotalNotVisible = TotalNotVisible + (TotalNotVisible * txtFSPBoomStafel[boomcarstaff] / 100);
						var tfvalue = TotalNotVisible * txtFSPBoomStafel[boomcarstaff] / 100;
						document.getElementById('txtBoomFSPValue').value = tfvalue.toFixed(2);
						if (document.getElementById('lblboomfspmargin')!=null) document.getElementById('lblboomfspmargin').innerHTML = tfvalue.toFixed(2);
						totalFSP = totalFSP + tfvalue;
					}
                    if (fromStaffel == 0) BugString = BugString + TotalNotVisible + "\n";
                }
                if (fromStaffel == 0) BugString = BugString + "4.0 Total Not Visible : " + TotalPrice + " + " + TotalNotVisible + " = ";
						
                TotalPrice = TotalPrice + TotalNotVisible;
				AllTotalNotVisible=TotalNotVisible;
                if (fromStaffel == 0) BugString = BugString + TotalPrice + " + " + TotalNotVisible + "\n";
                Col = parseFloat(TotalNotVisible) / (parseInt(NearLot) / parseInt(PriceQty));
                if (document.getElementById('addtxtPricePerUnit') != null && document.getElementById("addtxtTotPrice") != null) {
                    document.getElementById("addtxtPricePerUnit").innerHTML = Col.toFixed(2);
					if (isaff==1) 
					{
						var totwithoutaff=TotalNotVisible-totalAffiliate;
						document.getElementById("addtxtTotPrice").innerHTML = totwithoutaff.toFixed(2);
						document.getElementById("priceProduct0").value = totwithoutaff.toFixed(2);
					}
					else 
					{
						document.getElementById("addtxtTotPrice").innerHTML = TotalNotVisible.toFixed(2);
						document.getElementById("priceProduct0").value = TotalNotVisible.toFixed(2);
					}
                }
				if (isaff==1) 
				{
						var Col=(TotalNotVisible-totalAffiliate)* TaxValue / 100;
				}
				else
				{
                	Col = TotalNotVisible * TaxValue / 100;
				}
                tax1 = Col;
                if (document.getElementById('txttaxproduct') != null && document.getElementById('txtProductTaxValue0') != null && document.getElementById("priceProduct0") != null) {
                    if (parseInt(TaxValue) == 6) document.getElementById('txttaxproduct').innerHTML = Col.toFixed(2);
                    document.getElementById('txtProductTaxValue0').value = Col.toFixed(2);
					if (isaff==1) 
					{
						document.getElementById("priceProduct0").value = TotalNotVisible-totalAffiliate;
					}
					else
					{
						document.getElementById("priceProduct0").value = TotalNotVisible;
					}
                    
                }
                for (i = 1; i < VisibleCostList.length; i++) {
                    if (VisibleCostType[VisibleCostList[i]] == 1 || VisibleCostType[VisibleCostList[i]] == 2 || VisibleCostType[VisibleCostList[i]] == 3 || VisibleCostType[VisibleCostList[i]] == 4) {
                        VPrice = parseFloat(CalculateVisible(totalcount, colornow, i));
                        if (fromStaffel == 0) BugString3 = BugString3 + "2.0 Total Visible : " + VPrice + "\n";
                        visaff = CalculateVisibleFSPMargin(VPrice);
                        if (fromStaffel == 0) BugString3 = BugString3 + "3.0 FSP margin : " + visaff + "\n";
                        VPrice = VPrice + visaff;
                        visaff = CalculateVisibleAffilliateMargin(VPrice);
                        if (fromStaffel == 0) BugString3 = BugString3 + "4.0 Affilliate margin : " + visaff + "\n";
                        VPrice = VPrice + visaff;
                        totalAffiliate = parseFloat(totalAffiliate) + parseFloat(visaff);
                        if (document.getElementById("addPrice" + VisibleCostList[i]) != 'undefined' && document.getElementById("addPrice" + VisibleCostList[i]) != null) document.getElementById("addPrice" + VisibleCostList[i]).innerHTML = VPrice.toFixed(2);
                        if (document.getElementById("VVisibleNameValue" + VisibleCostList[i]) != 'undefined' && document.getElementById("VVisibleNameValue" + VisibleCostList[i]) != null) document.getElementById("VVisibleNameValue" + VisibleCostList[i]).value = VPrice.toFixed(2);
                        TotalVisible = TotalVisible + parseFloat(VPrice);
                        TotalPrice = TotalPrice + parseFloat(VPrice);
                    }
                }
				
				if (isaff == 1)
				{
                	TotalPrice = TotalPrice + AllTotalNotVisible + AllTotalVisible-totalAffiliate ;
				}
				else
				{
					TotalPrice = TotalPrice + AllTotalNotVisible + AllTotalVisible ;
					
				}
				AllTotal=TotalPrice;
                AllTotalVisible2 = TotalVisible;
                if (document.getElementById("bigtotal") != null && document.getElementById("allProduct0") != null) {
                    document.getElementById("bigtotal").innerHTML = TotalPrice.toFixed(2);
                    document.getElementById("allProduct0").value = TotalPrice.toFixed(2);
                }
                Col = (AllTotalVisible2 + AllTotalVisible) * 19 / 100;
                tax2 = Col;
                if (parseInt(TaxValue) == 19) Col = Col + tax1;
                if (document.getElementById("lblothertaxcaption") != null && document.getElementById("txtothertax") != null && document.getElementById("txtOtherTaxValue0") != null) {
                    document.getElementById("lblothertaxcaption").innerHTML = "BTW 19%";
                    document.getElementById("txtothertax").innerHTML = Col.toFixed(2);
                    document.getElementById("txtOtherTaxValue0").value = Col.toFixed(2);
                }
                var TotalPrice2 = parseFloat(TotalPrice.toFixed(2)) + parseFloat(tax2.toFixed(2));
                if (!isNaN(tax1)) TotalPrice2 = TotalPrice2 + parseFloat(tax1.toFixed(2));
                if (document.getElementById("bigtotalbtw")) document.getElementById("bigtotalbtw").innerHTML = TotalPrice2.toFixed(2);
                AllTotal = TotalPrice;
                AllTotalVisible2 = TotalVisible;
            }
        }
    }
	
	if (isaff==1) 
					{
						document.getElementById("priceProduct0").value = TotalNotVisible-totalAffiliate;
					}
					else
					{
						document.getElementById("priceProduct0").value = TotalNotVisible;
					}
    if (fromStaffel == 0) {
        Col = parseFloat(totalAffiliate)
			
				if (document.getElementById('lblboomaffiliate')!=null) BoomAff = parseFloat(document.getElementById('lblboomaffiliate').innerHTML);
				var totalColBoomAff = parseFloat(Col.toFixed(2)) + parseFloat(BoomAff.toFixed(2));
        if (document.getElementById('lblaffiliate')!=null) document.getElementById('lblaffiliate').innerHTML = totalColBoomAff.toFixed(2); 
        document.getElementById('txtBackAffValue').value = Col.toFixed(2);
        if (document.getElementById('txtAffiliate') != null) {
            document.getElementById('txtAffiliate').value = minusprice + totalAffiliate;
        }
        var fpminus;
        fpminus = totalFSP - totalAffiliate;
        if (document.getElementById('lblotherfspmarginword')!=null) document.getElementById('lblotherfspmarginword').innerHTML = "<strong>Total FSP</strong><br><br><strong>FSP - Affilliate</strong>";
        if (document.getElementById('lblotherfspmargin')!=null) document.getElementById('lblotherfspmargin').innerHTML = "<strong>" + totalFSP.toFixed(2) + "</strong><br><br><strong>" + fpminus.toFixed(2) + "</strong>";
    }
    CalculateAllOption();
    if (dbug == 1) alert(BugString);
}


function CalculateVisibleFSPMargin(tprice) {
    var minusprice = 0;
    if (fspmargin > 0) {
        if (fsppercent == 1) {
            BugString2 = BugString2 + "   " + tprice + " x " + fspmargin + " % = ";
            minusprice = (tprice * fspmargin / 100);
            BugString2 = BugString2 + minusprice + "\n";
        } else {
            BugString2 = BugString2 + "   " + fspmargin + "\n";
            minusprice = fspmargin;
        }
    }
    return minusprice;
}


function CalculateVisibleAffilliateMargin(tprice) {
    var minusprice = 0;
    if (vafftype == 2) {
        if (affmargin > 0) {
            if (affpercent == 1) {
                BugString2 = BugString2 + "   Boom Affilliate = " + tprice + " x " + affmargin + " % = ";
                BugString3 = BugString3 + "   Boom Affilliate = " + tprice + " x " + affmargin + " % = ";
                minusprice = (tprice * affmargin / 100);
                BugString2 = BugString2 + minusprice + "\n";
                BugString3 = BugString3 + minusprice + "\n";
            } else {
                BugString2 = BugString2 + "   Boom Affilliate = " + fspmargin + "\n";
                BugString3 = BugString3 + "   Boom Affilliate = " + fspmargin + "\n";
                minusprice = affmargin;
            }
        }
    }
    return minusprice;
}


function CalculateVisibleBackbaseAffilliateMargin(tprice, i) {
    var CurrentStaffel;
    if (document.getElementById('addtxtTotal') != null) {
        CurrentStaffel = FindCurrentVisibleStaffel(i);
    }
    var minusprice = 0;
    if (vafftype == 2) {
        if (NotVisibleStaffelPricePerc[CurrentBackAff][231] == 2) {
            minusprice = tprice * NotVisibleStaffelPrice[CurrentBackAff][231][CurrentStaffel] / 100;
            BugString2 = BugString2 + "   Backbase Affilliate = " + tprice + " x " + NotVisibleStaffelPrice[CurrentBackAff][231][CurrentStaffel] + " % = " + minusprice + "\n";
        } else {
            minusprice = NotVisibleStaffelPrice[CurrentBackAff][231][CurrentStaffel];
            BugString2 = BugString2 + "   Backbase Affilliate = " + minusprice + "\n";
        }
    }
    return minusprice;
}


function FindCurrentStaffel(i, qty,y) {
	var dbugstaffel=1;
	
	if (dbugstaffel==1) BugString=BugString + "--------------------------------------------------\n\n";
    var currentstaffel = 0;
    var NearLot = GetNearestLot(qty);
	
    var z;
	if (typeof(NotVisibleCostList[i])=="undefined") i=1;
	//var groupt=NotVisibleStaffelPriceGroup[NotVisibleCostList[i]][NotVisibleStaffelLink[NotVisibleCostList[i]][i]];
	//var groupt=NotVisibleStaffelPriceGroup[NotVisibleCostList[i]][NotVisibleStaffelLink[NotVisibleCostList[i]][1]];
	var groupt=NotVisibleStaffelPriceGroup[NotVisibleCostList[i]][NotVisibleStaffelLink[NotVisibleCostList[i]][y]];
		var totals = TotalStaffel[groupt];
		if (dbugstaffel==1) BugString=BugString + "Total Staffel = " + TotalStaffel[groupt] + "\n";
		if (totals > 1) {
			for (z = 1; z < totals; z++) {
				if (dbugstaffel==1) BugString=BugString + StaffelData[groupt][z] + " < " + NearLot + " > " + StaffelData[groupt][z + 1] + "\n";
				if (StaffelData[groupt][z] <= NearLot && StaffelData[groupt][z + 1] > NearLot) {
					currentstaffel = z;
				}
			}
			if (NearLot >= StaffelData[groupt][totals]) currentstaffel = totals;
		} else {
			z = 1;
			if (StaffelData[groupt][z] == NearLot) {
				currentstaffel = z;
			}
		}
	if (dbugstaffel==1) BugString=BugString + "--------------------------------------------------\n\n";
    return currentstaffel;
}


function FindCurrentVisibleStaffel(i,y) {
    var qty;
    if (document.getElementById('addtxtTotal') != null) {
        qty = document.getElementById('addtxtTotal').value;
    }
    var color;
    if (document.getElementById("txtSide1Color") != null) {
        color = document.getElementById("txtSide1Color").value;
    }
    var NearLot = GetNearestLot(qty);
    var z;
    var currentstaffel = 0;
    for (z = 1; z < TotalStaffel[maingroup]; z++) {
        if (StaffelData[maingroup][z] <= NearLot && StaffelData[maingroup][z + 1] >= NearLot) {
            currentstaffel = z;
        }
    }
    if (currentstaffel == 0) {
		if (typeof(y)=="undefined") y=1;
        currentstaffel = FindCurrentStaffel(i, qty,y);
    }
    return currentstaffel;
}


function Check_OptionalCostSelected() {
	if (document.getElementById('Minimum_order_alert') != null && document.getElementById('Minimum_order_alert').style.display == 'block') {
         alert(document.getElementById('Minimum_order_alert').innerHTML);
    }
	else
	{
		if (document.getElementById('txtEenmaliglist') != null) 
		{
			if (document.getElementById('txtEenmaliglist').value != null && document.getElementById('txtEenmaliglist').value != "") 
			{
				if(document.getElementById('Optional_cost_alert') != null)
				{
					if (document.getElementById('Optional_cost_alert').style.display == 'none' ) 
					{
						if(document.getElementById('ConfirmCheckbox') != null)
						{
							document.getElementById('ConfirmCheckbox').style.display = 'inline';
						}
					} 
					else 
					{
						InsertCartViewProd();
					}
				}
				else
				{
					InsertCartViewProd();
				}
			} 
			else 
			{
				InsertCartViewProd();
			}
		}
		else 
		{
			InsertCartViewProd();
		}
	}
}

function ShowStyleDocsAlert() {
    if (document.getElementById('txtStyleDocs').checked == 1) {
        document.getElementById('StyleDocs_alert').style.display = 'block';
        document.getElementById('txtStyleDocsSelected').value = document.getElementById('styledocslist').value;
    } else {
        document.getElementById('StyleDocs_alert').style.display = 'none';
        document.getElementById('txtStyleDocsSelected').value = "";
    }
}


function ChangeClaimView() {
    if (document.getElementById('Claim_Info') != null && document.getElementById('c_senderEmail') != null && document.getElementById('Mail_Sent') != null && document.getElementById('Confirm_Email') != null && document.getElementById('Claim') != null) {
        if (document.getElementById('Claim_Info').style.display == 'none') {
            document.getElementById('c_senderEmail').value = "";
            document.getElementById('c_senderName').value == ""
            document.getElementById('Mail_Sent').style.display = 'none';
            document.getElementById('Confirm_Email').style.display = 'block';
            document.getElementById('Claim_Info').style.display = 'block';
            document.getElementById('Claim').style.display = 'none';
        } else {
            document.getElementById('Claim_Info').style.display = 'none';
            document.getElementById('Claim').style.display = 'block';
        }
    }
}


function SendMail() {
    if (document.getElementById('c_senderName') != null && document.getElementById('Confirm_Email') != null && document.getElementById('Sending_Mail') != null && document.getElementById('iPKProduct0') != null) {
        if (document.getElementById('c_senderName').value == "") {
            alert("Please enter name");
            return;
        }
        if (document.getElementById('c_senderEmail').value == "") {
            alert("Please enter valid e-mail address");
            return;
        } else {
            var emailRegEx = /^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$/;
            str = document.getElementById('c_senderEmail').value;
            if (str.match(emailRegEx)) {} else {
                alert('Please enter a valid email address.');
                return;
            }
            document.getElementById('Confirm_Email').style.display = 'none';
            document.getElementById('Sending_Mail').style.display = 'block';
            SendClaimMail(document.getElementById('iPKProduct0').value);
            setTimeout("ShowClaimMailSent()", 8000);
        }
    }
}


function ShowClaimMailSent() {
    if (document.getElementById('c_senderEmail') != null && document.getElementById('Sending_Mail') != null && document.getElementById('Mail_Sent') != null) {
        document.getElementById('c_senderEmail').value = "";
        document.getElementById('Sending_Mail').style.display = 'none';
        document.getElementById('Mail_Sent').style.display = 'block';
        setTimeout("ChangeClaimView()", 4000);
    }
}


function SendClaimMail(pkProductItem) {
    if (document.getElementById('txtColorPick') != null && document.getElementById('txtSide1Color') != null && document.getElementById('addtxtBestel') != null && document.getElementById('bigtotal') != null && document.getElementById('lblothertaxcaption') != null && document.getElementById('txtothertax') != null && document.getElementById('bigtotalbtw') != null) {
        var XMLObject;
        var ClaimEmailID = "";
        var txtTotoal = addtxtTotal.value;
        var txtColorPick = document.getElementById('txtColorPick').options[document.getElementById('txtColorPick').selectedIndex].text;
        var txtSide1Color = document.getElementById('txtSide1Color').options[document.getElementById('txtSide1Color').selectedIndex].text;
        var addtxtBestel = document.getElementById('addtxtBestel').innerHTML + " stuks\t" + addtxtTotPrice.innerHTML;
        var bigtotal = document.getElementById('bigtotal').innerHTML;
        var lblothertaxcaption = document.getElementById('lblothertaxcaption').innerHTML;
        var txtothertax = document.getElementById('txtothertax').innerHTML;
        var bigtotalbtw = document.getElementById('bigtotalbtw').innerHTML;
        var speedValue = "";
        var VisibleData = "";
        var txtTax = "";
        var txttaxproduct = "";
        var AddonData = "";
        if (document.getElementById('divspeed') != null) {
            speedValue = document.getElementById('divspeed').firstChild.nextSibling.innerHTML;
        }
        if (document.getElementById('txtTax') != null) {
            txtTax = document.getElementById('txtTax').innerHTML;
        }
        if (document.getElementById('txttaxproduct') != null) {
            txttaxproduct = document.getElementById('txttaxproduct').innerHTML;
        }
        var c_senderName = document.getElementById('c_senderName').value;
        var a1;
        if (document.getElementById('layerAddon') != null) {
            a1 = document.getElementById('layerAddon').childNodes;
        }
        if (a1.length != 0) {
            for (var i = 1; i < a1.length; i = i + 2) {
                try {
                    if (a1[i].innerHTML != "" || a1[i].innerHTML != null) {
                        var sDetail = "Child (" + i + ") has name: " + a1[i].nodeName + " and type:" + a1[i].nodeType + " and value:" + a1[i].nodeValue + " and innerHTML:" + a1[i].innerHTML;
                        AddonData += a1[i].innerHTML;
                    }
                }
                catch(ex) {};
            }
        }
        if (AddonData != "" || AddonData != null) {} else {
            AddonData = "";
        }
        var a;
        if (document.getElementById('VisibleCost') != null) {
            a = document.getElementById('VisibleCost').childNodes;
        }
        for (var i = 1; i < a.length; i = i + 2) {
            try {
                if (a[i].innerHTML != "" || a[i].innerHTML != null) {
                    var sDetail = "Child (" + i + ") has name: " + a[i].nodeName + " and type:" + a[i].nodeType + " and value:" + a[i].nodeValue + " and innerHTML:" + a[i].innerHTML;
                    VisibleData += a[i].innerHTML;
                }
            }
            catch(ex) {};
        }
        if (VisibleData != "" || VisibleData != null) {} else {
            VisibleData = "";
        }
        ClaimEmailID = document.getElementById("c_senderEmail").value;
        if (window.XMLHttpRequest && !(window.ActiveXObject)) {
            try {
                XMLObject = new XMLHttpRequest();
            }
            catch(e) {}
        } else if (window.ActiveXObject) {
            try {
                XMLObject = new ActiveXObject("Msxml2.XMLHTTP");
            }
            catch(e) {
                try {
                    XMLObject = new ActiveXObject("Microsoft.XMLHTTP");
                }
                catch(e) {
                    alert('browser not compatible');
                    return;
                }
            }
        }
        var url = "http://" + location.host + "/webshaper/store/claimEMail.asp?pkProductItem=" + pkProductItem + " &ClaimEmailID=" + ClaimEmailID + " &txtTotoal=" + txtTotoal + " &txtColorPick=" + txtColorPick + " &txtSide1Color=" + txtSide1Color + " &addtxtBestel=" + addtxtBestel + " &bigtotal=" + bigtotal + " &txtothertax=" + txtothertax + " &bigtotalbtw=" + bigtotalbtw + " &lblothertaxcaption=" + lblothertaxcaption + " &speedValue=" + speedValue + " &txtTax=" + txtTax + " &txttaxproduct=" + txttaxproduct + " &c_senderName=" + c_senderName + " &AddonData=" + AddonData + " &VData=" + VisibleData;
        XMLObject.open("GET", url, true);
        XMLObject.onreadystatechange = function () {
            if (XMLObject.readyState == 4) {
                if (XMLObject.status == 200) {
                    var ReturnData = XMLObject.responseXML;
                }
            }
        }
        XMLObject.send(null);
    }
}


function AddProductOption(id, Value) {
    var ProductOptionDiv;
    ProductOptionDiv = document.getElementById('ProductOptions');
    if (ProductOptionDiv.hasChildNodes) {
        for (var i = 0; i < ProductOptionDiv.childNodes.length; i++) {
            if (ProductOptionDiv.childNodes[i].id == 'div' + id) {
                ProductOptionDiv.removeChild(ProductOptionDiv.childNodes[i]);
            }
        }
    }
    var ProductOption;
    var ProductOptionName;
    var ProductOptionValue;
    var Prd_OptValue;
    var clearDiv;
    var arrValue;
	arrValue = Value.split("-");
	ProductOption = document.createElement('div');
	ProductOption.setAttribute('id', 'div' + id);
	ProductOptionName = document.createElement('div');
	ProductOptionName.setAttribute('id', 'div_N' + id);
	ProductOptionValue = document.createElement('div');
	ProductOptionValue.setAttribute('id', 'div_V' + id);
	clearDiv = document.createElement('div');
	clearDiv.setAttribute('id', 'clear');
		
	ProductOptionName.innerHTML = arrValue[0];
	if (trim(arrValue[1]).split(" ")[1] == "%") {
		if (document.getElementById('addtxtTotPrice') != null) {
			Prd_OptValue = parseInt(document.getElementById('addtxtTotPrice').innerHTML) * parseInt(arrValue[1]) / 100;
		}
	} else {
		Prd_OptValue = trim(arrValue[1]).split(" ")[0];
	}
	ProductOptionName.className = "LiveCalcsubline";
	ProductOptionValue.className = "LiveCalcsubRight";
	ProductOptionValue.cssText = "width:30%";
	clearDiv.className = "clear";
	ProductOption.appendChild(ProductOptionName);
	ProductOption.appendChild(ProductOptionValue);
	ProductOption.appendChild(clearDiv);
	ProductOptionDiv.appendChild(ProductOption);
}

