﻿var prc = document.getElementById("ctl00_lblCartTotal"); var newTypeInfoSet; var priceUpdated = new Array(); var priceIndex = 0; var priceUpdatedPostback = new Array(); var priceIndexPostback = 0; var maxcpriceNum = 20; var maxgcpriceNum = 200; var maxRowNum = 10; var currencydisplay = false; function setpriceUpdatedDdl() { var b = document.getElementById("ddlistcomp"); if (b) { for (var a = 0; a < b.length; a++) { b.options[a].innerHTML = findPricePart(b.options[a].text) } } } function setpriceUpdated() { addpriceUpdated("ewebprice"); addpriceUpdated("retailprice"); addpriceUpdated("percsaving"); addpriceUpdated("webprice"); addpriceUpdated("surchrg"); addpriceUpdated("exclvatprice"); addpriceUpdated("inclvatprice"); addpriceUpdated("exclvatsurchrg"); addpriceUpdated("inclvatsurchrg"); addpriceUpdated("rebateprice"); addpriceUpdated("priceoverride"); addpriceUpdated("pricematch"); addpriceUpdated("clubprice"); addpriceUpdated("clubpercsaving"); addpriceUpdated("addph"); addpriceUpdatedSet("multipricing"); addpriceUpdatedSet("ekitprice"); addpriceUpdatedSet("ekitpricesurchrg"); addpriceUpdatedSet("ekitpriceexclvat"); addpriceUpdatedSet("ekitpriceinclvat"); addpriceUpdatedSet("ekitpriceexclvatsurchrg"); addpriceUpdatedSet("ekitpriceinclvatsurchrg"); addpriceUpdated("custpriceperchar"); addpriceUpdated("custprice"); addpriceUpdatedSet("cretailprice"); addpriceUpdatedSet("cpercsaving"); addpriceUpdatedSet("cwebprice"); addpriceUpdatedSet("csurchrg"); addpriceUpdatedSet("cexclvatprice"); addpriceUpdatedSet("cinclvatprice"); addpriceUpdatedSet("cexclvatsurchrg"); addpriceUpdatedSet("cinclvatsurchrg"); addpriceUpdatedSet("crebateprice"); addpriceUpdatedSet("cpriceoverride"); addpriceUpdatedSet("cpricematch"); addpriceUpdatedSet("cclubprice"); addpriceUpdatedSet("cclubpercsaving"); addpriceUpdatedSet("caddph"); addpriceUpdatedSet1("cmultipricing"); addgridpriceUpdatedSet("gcretailprice"); addgridpriceUpdatedSet("gcpercsaving"); addgridpriceUpdatedSet("gcwebprice"); addgridpriceUpdatedSet("gcsurchrg"); addgridpriceUpdatedSet("gcexclvatprice"); addgridpriceUpdatedSet("gcinclvatprice"); addgridpriceUpdatedSet("gcexclvatsurchrg"); addgridpriceUpdatedSet("gcinclvatsurchrg"); addgridpriceUpdatedSet("gcrebateprice"); addgridpriceUpdatedSet("gcpriceoverride"); addgridpriceUpdatedSet("gcpricematch"); addgridpriceUpdatedSet("gcclubprice"); addgridpriceUpdatedSet("gcclubpercsaving"); addgridpriceUpdatedSet("gcaddph"); addgridpriceUpdatedSet1("gcmultipricing"); addpriceUpdatedSet1("gwebprice"); addpriceUpdatedSet1("gsurchrg"); addpriceUpdatedSet1("ginclvatprice"); addpriceUpdatedSet1("gexclvatprice"); addpriceUpdatedSet1("ginclvatsurchrg"); addpriceUpdatedSet1("gexclvatsurchrg"); addpriceUpdatedSet1("grebateprice"); addpriceUpdatedSet1("gclubprice"); addpriceUpdatedSet1("rwebprice"); addpriceUpdatedSet1("rsurchrg"); addpriceUpdatedSet1("rwebpricemax"); addpriceUpdatedSet1("rexclvatprice"); addpriceUpdatedSet1("rinclvatprice"); addpriceUpdatedSet1("rexclvatsurchrg"); addpriceUpdatedSet1("rinclvatsurchrg"); addpriceUpdatedSet1("rrebateprice"); addpriceUpdatedSet1("rrebatepricemax"); addpriceUpdatedSet1("rclubprice"); addpriceUpdatedSet1("rpwebprice"); addpriceUpdatedSet1("rpsurchrg"); addpriceUpdatedSet1("rpwebpricemax"); addpriceUpdatedSet1("rpexclvatprice"); addpriceUpdatedSet1("rpinclvatprice"); addpriceUpdatedSet1("rpexclvatsurchrg"); addpriceUpdatedSet1("rpinclvatsurchrg"); addpriceUpdatedSet1("rprebateprice"); addpriceUpdatedSet1("rprebatepricemax"); addpriceUpdatedSet1("rpclubprice"); addpriceUpdatedSet1("twebprice"); addpriceUpdatedSet1("tsurchrg"); addpriceUpdatedSet1("twebpricemax"); addpriceUpdatedSet1("texclvatprice"); addpriceUpdatedSet1("tinclvatprice"); addpriceUpdatedSet1("texclvatsurchrg"); addpriceUpdatedSet1("tinclvatsurchrg"); addpriceUpdatedSet1("trebateprice"); addpriceUpdatedSet1("trebatepricemax"); addpriceUpdatedSet1("tclubprice"); addpriceUpdatedSet1("tpwebprice"); addpriceUpdatedSet1("tpsurchrg"); addpriceUpdatedSet1("tpwebpricemax"); addpriceUpdatedSet1("tpexclvatprice"); addpriceUpdatedSet1("tpinclvatprice"); addpriceUpdatedSet1("tpexclvatsurchrg"); addpriceUpdatedSet1("tpinclvatsurchrg"); addpriceUpdatedSet1("tprebateprice"); addpriceUpdatedSet1("tprebatepricemax"); addpriceUpdatedSet1("tpclubprice") } function addpriceUpdatedSet1(a) { var d; for (var c = 1; c < maxcpriceNum; c++) { for (var b = 0; b < maxRowNum; b++) { d = document.getElementById(a + b.toString() + "-" + c.toString()); if (d) { priceUpdated[priceIndex] = d.id; priceIndex++ } } } } function addgridpriceUpdatedSet1(a) { var d; for (var c = 1; c < maxgcpriceNum; c++) { for (var b = 0; b < maxRowNum; b++) { d = document.getElementById(a + b.toString() + "-" + c.toString()); if (d) { priceUpdated[priceIndex] = d.id; priceIndex++ } } } } function addpriceUpdatedSet(a) { var c; for (var b = 1; b < maxcpriceNum; b++) { c = document.getElementById(a + b.toString()); if (c) { priceUpdated[priceIndex] = a + b.toString(); priceIndex++ } } } function addgridpriceUpdatedSet(a) { var c; for (var b = 1; b < maxgcpriceNum; b++) { c = document.getElementById(a + b.toString()); if (c) { priceUpdated[priceIndex] = a + b.toString(); priceIndex++ } } } function addpriceUpdated(a) { var b = document.getElementById(a); if (b) { priceUpdated[priceIndex] = a; priceIndex++ } } function findPricePart(c) { var b = c; var a = c.indexOf("$"); if (a > -1) { b = c.substr(a, c.length - a); var d = b.split(/\s/g); b = getInitPrice(d[0]); b = c.replace(d[0], b) } return b } function getInitPriceMultipricing(b) { var a = (((b.toLowerCase().replace("<br>", " <br>")).replace("</br>", " </br>")).replace("<br />", " <br />")).replace("<br/>", " <br/>"); return getInitPriceSaving(a) } function getInitPriceSaving(d) { var c = d.split(/\s/); var a = ""; for (var b = 0; b < c.length; b++) { if (c[b].indexOf("$") > -1) { a += " " + getInitPrice(c[b]) } else { a += " " + c[b] } } return a } function getInitPriceByRate(c) { c = c.replace(/,/g, ""); c = (c * defaultRate / defaultTypeInfo.Rate).toFixed(2).toString(); var a = c.split("."); if (a[0].length > 3) { c = a[0].substr(0, a[0].length - 3) + "," + a[0].substr(a[0].length - 3, 3); var b = "00"; if (a.length > 1) { b = a[1] } c += "." + b } return c } function getPriceNumber(a) { if (a.indexOf("$") > -1) { a = a.replace("$", "") } if (a.indexOf("€") > -1) { a = a.replace("€", "") } if (a.indexOf("£") > -1) { a = a.replace("£", "") } return a } function getInitPrice(e) { var f; var a = false; e = getPriceNumber(e); if (e.indexOf("-") > -1) { e = e.replace("-", ""); a = true } e = getInitPriceByRate(e); var b = e.toString().split("."); var d = "00"; if (b.length > 1) { d = b[1] } if (defaultTypeInfo.DecimalSeparator == "~") { defaultTypeInfo.DecimalSeparator = "," } if (defaultTypeInfo.ThousandSeparator == "~") { defaultTypeInfo.ThousandSeparator = "," } var c; if (b[0].indexOf(",") > 0) { c = b[0].replace(",", defaultTypeInfo.ThousandSeparator) } else { if (b[0].length > 3) { c = b[0].substr(0, b[0].length - 3) + defaultTypeInfo.ThousandSeparator + b[0].substr(b[0].length - 3) } else { c = b[0] } } if (a) { f = "-" + c + defaultTypeInfo.DecimalSeparator + d } else { f = c + defaultTypeInfo.DecimalSeparator + d } if (defaultTypeInfo.SymbolPrefix == true) { f = defaultTypeInfo.Symbol + f } else { f = f + defaultTypeInfo.Symbol } return f } function setInitPrice() { currencydisplay = true; setpriceUpdated(); if (priceUpdated.length > 0) { for (var b = 0; b < priceUpdated.length; b++) { var a = document.getElementById(priceUpdated[b]); if (a.id.indexOf("saving") != -1 || a.id.indexOf("ekitprice") != -1 || a.id.indexOf("addph") != -1 || a.id.indexOf("custpriceperchar") != -1) { a.innerHTML = getInitPriceSaving(a.innerHTML) } else { if (a.id.indexOf("multipricing") != -1) { a.innerHTML = getInitPriceMultipricing(a.innerHTML) } else { if (a.id.indexOf("priceoverride") != -1) { a.value = removeHTMLEntities(getInitPrice("0")) } else { a.innerHTML = getInitPrice(a.innerHTML) } } } } } setpriceUpdatedDdl() } function onSuccess(a) { if (a != "undefined") { newTypeInfoSet = a.split("^"); prc = document.getElementById("ctl00_lblCartTotal"); if (prc) { prc.innerHTML = getUpdatedPrice(prc.innerHTML, a) } prc = document.getElementById("ctl00_lblFreeShpMsg"); if (prc) { prc.innerHTML = getUpdatedPriceSaving(prc.innerHTML, a) } prc = document.getElementById("ctl00_lblEasyPayTag"); if (prc) { prc.innerHTML = getUpdatedPriceSaving(prc.innerHTML, a) } for (var b = 0; b < priceUpdated.length; b++) { prc = document.getElementById(priceUpdated[b]); if (prc) { if (prc.id.indexOf("saving") != -1 || prc.id.indexOf("multipricing") != -1 || prc.id.indexOf("ekitprice") != -1 || prc.id.indexOf("addph") != -1 || prc.id.indexOf("custpriceperchar") != -1) { prc.innerHTML = getUpdatedPriceSaving(prc.innerHTML, a) } else { if (prc.id.indexOf("priceoverride") != -1) { var c = new RegExp("[0-9]"); if (c.test(prc.value)) { prc.value = removeHTMLEntities(getUpdatedPrice(prc.value, a)) } else { prc.value = removeHTMLEntities(getUpdatedPrice("0", a)) } } else { if (prc.id.indexOf("lblShippingChrg") != -1) { var c = new RegExp("[0-9]"); if (c.test(prc.innerHTML)) { prc.innerHTML = getUpdatedPrice(prc.innerHTML, a) } } else { prc.innerHTML = getUpdatedPrice(prc.innerHTML, a) } } } } } defaultTypeInfo.Type = newTypeInfoSet[5]; defaultTypeInfo.Symbol = newTypeInfoSet[0]; defaultTypeInfo.SymbolPrefix = newTypeInfoSet[1]; if (defaultTypeInfo.SymbolPrefix == "True") { defaultTypeInfo.SymbolPrefix = true } else { defaultTypeInfo.SymbolPrefix = false } defaultTypeInfo.DecimalSeparator = newTypeInfoSet[2]; defaultTypeInfo.ThousandSeparator = newTypeInfoSet[3]; defaultTypeInfo.Rate = newTypeInfoSet[4] } } function onError(a) { alert(a.get_message()) } function isNumberKey(b) { var a = (b.which) ? b.which : event.keyCode; if (a > 31 && (a < 48 || a > 57)) { return false } return true } function removeHTMLEntities(a) { var b = document.createElement("div"); b.innerHTML = a; return b.innerHTML } function getUpdatedPriceSaving(f, a) { var g = /\d+/i; var e = /-/i; var d = f.split(/\s/); var b = ""; defaultTypeInfo.Symbol = removeHTMLEntities(defaultTypeInfo.Symbol); for (var c = 0; c < d.length; c++) { if ((d[c].indexOf(defaultTypeInfo.Symbol) > -1 && d[c - 1].search(g) > -1 && d[c - 1].search(e) == -1) || (d[c].search(g) > -1 && d[c].search(e) == -1 && d[c - 1].indexOf(defaultTypeInfo.Symbol) > -1)) { b += d[c] } else { b += " " + d[c] } } d = b.split(/\s/); b = ""; for (var c = 0; c < d.length; c++) { if (d[c].indexOf(defaultTypeInfo.Symbol) > -1) { b += " " + getUpdatedPrice(d[c], a) } else { b += " " + d[c] } } return b } function getUpdatedPrice(h, b) { var d = defaultTypeInfo.Symbol; if (d == h && defaultTypeInfo.Type != 1) { return "" } var c = false; if (h.indexOf("-") > -1) { h = h.replace("-", ""); c = true } var g = h; var f = d.length; if (d.startsWith("&#") == true) { f = 1 } if (defaultTypeInfo.SymbolPrefix == true) { h = h.substr(f, h.length) } else { h = h.substr(0, h.length - f) } if (h != "0" && h != "") { if (defaultTypeInfo.DecimalSeparator == "~") { defaultTypeInfo.DecimalSeparator = "," } var e = h.split(defaultTypeInfo.DecimalSeparator); if (defaultTypeInfo.ThousandSeparator == "~") { defaultTypeInfo.ThousandSeparator = "," } if (e[0].indexOf(defaultTypeInfo.ThousandSeparator) > -1) { e[0] = e[0].replace(defaultTypeInfo.ThousandSeparator, "") } g = e[0] + "." + e[1] } else { g = "0" } var a = defaultTypeInfo.Rate; g = (g * a / newTypeInfoSet[4]).toFixed(2); e = g.split("."); if (e[0].length > 3) { e[0] = e[0].substr(0, e[0].length - 3) + newTypeInfoSet[3] + e[0].substr(e[0].length - 3, 3) } g = e[0] + newTypeInfoSet[2] + e[1]; if (newTypeInfoSet[1] == "True") { g = newTypeInfoSet[0] + g } else { g = g + newTypeInfoSet[0] } if (c) { g = "-" + g } return g } function setPostBackPrice() { if (!currencydisplay) { return } priceUpdatedPostback = new Array(); priceIndexPostback = 0; addpriceUpdatedPostback("retailprice"); addpriceUpdatedPostback("percsaving"); addpriceUpdatedPostback("webprice"); addpriceUpdatedPostback("surchrg"); addpriceUpdatedPostback("exclvatprice"); addpriceUpdatedPostback("inclvatprice"); addpriceUpdatedPostback("exclvatsurchrg"); addpriceUpdatedPostback("inclvatsurchrg"); addpriceUpdatedPostback("rebateprice"); addpriceUpdatedPostback("priceoverride"); addpriceUpdatedPostback("pricematch"); addpriceUpdatedPostback("clubprice"); addpriceUpdatedPostback("clubpercsaving"); addpriceUpdatedPostback("addph"); addpriceUpdatedSetPostback("multipricing"); if (priceUpdatedPostback.length > 0) { for (var b = 0; b < priceUpdatedPostback.length; b++) { var a = document.getElementById(priceUpdatedPostback[b]); if (a.id.indexOf("saving") != -1 || a.id.indexOf("addph") != -1) { a.innerHTML = getInitPriceSaving(a.innerHTML) } else { if (a.id.indexOf("multipricing") != -1) { a.innerHTML = getInitPriceMultipricing(a.innerHTML) } else { if (a.id.indexOf("priceoverride") != -1) { a.value = removeHTMLEntities(getInitPrice("0")) } else { a.innerHTML = getInitPrice(a.innerHTML) } } } } } } function addpriceUpdatedSetPostback(a) { var c; for (var b = 1; b < maxcpriceNum; b++) { c = document.getElementById(a + b.toString()); if (c) { priceUpdatedPostback[priceIndexPostback] = a + b.toString(); priceIndexPostback++ } else { break } } } function addpriceUpdatedPostback(a) { var b = document.getElementById(a); if (b) { priceUpdatedPostback[priceIndexPostback] = a; priceIndexPostback++ } } function setCustCalPrice(a) { if (!currencydisplay) { return a } return getInitPrice(a) };
