/* Copyright (c) On Technology Australia Pty Ltd - All Rights Reserved. * * This source may be used only by registered customers of the AWP "eziMerchant" range * of products. Use of this code by unregistered parties is an offence that will be prosecuted. * * */ // cookie cart columns var colProductID = 0; var colQuantity = 1; var colCustomFields = 2; // product columns var colProductPrice = 0; var colFreightLocal = 1; var colFreightDomestic = 2; var colFreightInternational = 3; var colProductWeight = 4; var colTaxLocal = 5; var colTaxDomestic = 6; var colTaxInternational = 7; // product info columns var colProductCode = 0; var colProductDesc = 1; var colCustomFieldKeys = 2; // data structs var arrCookie = document.cookie.split("; "); var arrItem; var arrLine; var bProcessCart = false; /* * Creates a new array with X elements, with the supplied argument value or default * */ function nA() { var myProductArray = new Array(0,0,0,0,0,0,0,0); for (var x = 0; x < arguments.length; x++) { myProductArray[x] = arguments[x]; } return myProductArray; } /* getProductPrice * */ function getProductPrice(curSymbol, thousandsSeparator, decPlaces, decSeparator, truncateDec, blnSymbolAtFront, pid, local, domestic, international, defaultRegion, blnIncludeTax) { var curPrice; var region = defaultRegion.toString(); if (getItem("region") != "") region = getItem("region"); if (region != "0" && region != "1" && region != "2") region = 2; if (!blnIncludeTax) region = "99"; switch(region) { case "0": curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxLocal]); break; case "1": curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxDomestic]); break; case "2": curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxInternational]); break; case "99": curPrice = getProduct(pid)[colProductPrice]; break; } return formatCurrency(curSymbol, thousandsSeparator, decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curPrice); } function getPriceInfo(pid,local, domestic, international, defaultRegion, blnIncludeTax) { var strTaxString; var curPrice; var region = defaultRegion.toString(); if (getItem("region") != "") region = getItem("region"); if (region != "0" && region != "1" && region != "2") region = 2; if (!blnIncludeTax) region = "99"; switch(region) { case "0": curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxLocal]); if (curPrice != getProduct(pid)[colProductPrice]) strTaxString = local; else strTaxString = ""; break; case "1": curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxDomestic]); if (curPrice != getProduct(pid)[colProductPrice]) strTaxString = domestic; else strTaxString = ""; break; case "2": curPrice = getProduct(pid)[colProductPrice] * (1 + getProduct(pid)[colTaxInternational]); if (curPrice != getProduct(pid)[colProductPrice]) strTaxString = international; else strTaxString = ""; break; case "99": curPrice = getProduct(pid)[colProductPrice]; strTaxString = ""; break; } return strTaxString; } /* addProductToCart(frm) * adds the product represented by the HTML form - frm. This includes custom fields. * If the product being added is identical (including custom fields) the quantity of * the item in the cart is added to the amount being added through the form. * * input - * frm: a HTML form object that contains a qty and pid element along with any * custom fields that are required. */ function addProductToCart(frm, strAddMessage, strErrMsg, strFileName) { var iLineIdx = getLineCount(); var iProdID = parseInt(frm.elements["pid"].value); var fltQty = parseInt(frm.elements["qty"].value); // check the quantity if ((fltQty.toString() == "NaN") || (fltQty - frm.elements["qty"].value != 0) || (fltQty <= 0)) { if (typeof(document.all) != "undefined") { if (strFileName != ""){ showModalDialog(strFileName, "", "dialogHeight: 145px; dialogWidth: 256px; dialogTop: px; dialogLeft: px; center: Yes; help: No; resizable: No; status: No; scroll: No;edge: raised"); } } else { if (strErrMsg != ""){ alert(strErrMsg); } } frm.elements["qty"].focus(); frm.elements["qty"].select(); return false; } // get the posted custom fields var arrCustomField = new Array(0); for (var i = 0; i "; strCart +="

We're Sorry"; strCart +="
"; strCart +="It appears your browser is set to refuse cookies. Our online purchasing "; strCart +="system requires that you have cookies enabled on your browser.
"; strCart +="

If you don't know how to enable this "; strCart +="feature we have provided instructions on enabling cookies for various "; strCart +="browsers at www.ezimerchant.com"; strCart +="

 "; return strCart; } var strCart = ""; var iColSpan = 4 + (showExTax ? 1 : 0) + (showTaxPercent ? 1 : 0) + (showTaxAmount ? 1 : 0) + (showIncTax ? 1 : 0); var curTaxTotal = 0; var curSubTotal = 0; var region = defaultRegion.toString(); if (getItem("region") != "") region = getItem("region"); if (region != "0" && region != "1" && region != "2") region = 2; var lineCount = getLineCount(); if (lineCount == 0) { strCart += ""; } else { strCart += ""; strCart += ""; strCart += ""; strCart += ""; strCart += showExTax ? "" : ""; strCart += showTaxPercent ? "" : ""; strCart += showTaxAmount ? "" : ""; strCart += showIncTax ? "" : ""; strCart += ""; strCart += ""; for(var i = 0; i " + "" + "" + ""; strCart += showExTax ? "" : ""; strCart += showTaxPercent ? "" : ""; strCart += showTaxAmount ? "" : ""; strCart += showIncTax ? "" : ""; strCart += ""; strCart += ""; if (iCustomFieldCount > 0) { strCart += ""; } if (truncateDec) { curTaxTotal += Math.floor(fltQty * curTaxAmount * Math.pow(10, decPlaces)) / Math.pow(10, decPlaces); }else { curTaxTotal += Math.round(fltQty * curTaxAmount * Math.pow(10, decPlaces)) / Math.pow(10, decPlaces); } curSubTotal += curPriceSubTotal; } iUseBackgnd = lineCount + 1; if (curTaxTotal > 0) { strCart += "" + "" + ""; } else { strCart += ""; } strCart += ""; strCart += ""; } strCart += "
" + emptyCart + "
" + headerText[0] + "" + headerText[1] + "" + headerText[2] + "" + headerText[3] + "" + headerText[4] + "" + headerText[5] + "" + headerText[6] + "" + headerText[7] + " 
" + getProductInfo(iProdID)[colProductDesc] + "" + getProductInfo(iProdID)[colProductCode] + "" + formatCurrency(curSymbol, thousandsSeparator, decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curPrice) + "" + l_taxRate * 100 + "%" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curTaxAmount) + "" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curPriceIncTax) + "" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curPriceSubTotal) + ""; // hidden fields sent to server per orderline strCart += ""; strCart += ""; strCart += ""; strCart += ""; strCart += ""; strCart += ""; strCart += ""; strCart += ""; strCart += ""; strCart += ""; // process custom fields into hidden fields to be sent to server var strCustomFieldNames = ""; var strCustomFieldValues = ""; var iCustomFieldCount = getLineSubCount(i, colCustomFields); if (iCustomFieldCount > 0) { for(var iCustomField = 0; iCustomField 0) { strCustomFieldNames += "|"; strCustomFieldValues += "|"; } strCustomFieldNames += escape(getCustomField(getProductInfo(iProdID)[colCustomFieldKeys][iCustomField])); strCustomFieldValues += escape(getLineSubItem(i, colCustomFields, iCustomField)); } } strCart += ""; strCart += ""; strCart += "
 "; for(var iCustomField = 0; iCustomField " + getCustomField(getProductInfo(iProdID)[colCustomFieldKeys][iCustomField]) + ":"; } strCart += "
" + getLineSubItem(i, colCustomFields, iCustomField) + "
" + "" + "" + totLabel + " (" + totTaxLabel + " " + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curTaxTotal) + "):" + "" + "" + "" + "" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curSubTotal) + "" + "" + "
" + totLabel + ":" + formatCurrency(curSymbol, thousandsSeparator,decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curSubTotal) + "
"; strCart += ""; strCart += ""; strCart += "
"; strCart += "
"; if (NotRegMsg !="") { strCart += "
"; } else { strCart += "
"; } strCart += "
"; strCart += ""; return strCart; } /* formatCurrency(curSymbol, thousandsSeparator, decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curValue) * * takes a currency value and decorates it with currency formatting * * input - * curSymbol: the actual symbol used to indicate this is currency * decPlaces: the number of decimals to display to the right of the separator * decSeparator: the symbol used to separate the whole from the fractional portion of the currency * blnSymbolAtFront: whether to put the currency symbol at the front or back * curValue: the actual money value to display */ function formatCurrency(curSymbol, thousandsSeparator, decPlaces, decSeparator, truncateDec, blnSymbolAtFront, curValue) { var strCurrency; if (truncateDec) { strCurrency = Math.floor(parseFloat(curValue) * Math.pow(10, decPlaces)); }else { strCurrency = Math.round(parseFloat(curValue) * Math.pow(10, decPlaces)); } strCurrency = strCurrency.toString(); while (strCurrency.length <= decPlaces) strCurrency = "0" + strCurrency; var decValue = strCurrency.substr(strCurrency.length - decPlaces, strCurrency.length); strCurrency = strCurrency.substr(0, strCurrency.length - decPlaces); var s; if (strCurrency.length > 3) { s = strCurrency.substr(strCurrency.length-3, 3); for (var i = 4; i <= strCurrency.length; i++){ if (((i - 4) % 3) == 0){ s = strCurrency.substr(strCurrency.length - i,1) + thousandsSeparator + s; } else{ s = strCurrency.substr(strCurrency.length - i,1) + s; } } } else { s = strCurrency; } if (decPlaces != 0) { strCurrency = s + decSeparator + decValue; }else{ strCurrency = s; } return blnSymbolAtFront ? curSymbol + strCurrency : strCurrency + curSymbol; } /* safeString(str) * * takes a str and returns another safe to put into a value attribute on an input tag * * input - * str: the string that is dirty */ function safeString(str) { if (str.constructor != String) str = new String(str); return str.replace("\"", """); } /* setRegion(region) * * takes the region specified and persists it for the current user * this allows prices to shown in the region relative to the merchant appropriately * * input - * region: 0 for a local (interstate) sale * 1 for a domestic (national) sale * 2 for an international sale */ function setRegion(region) { setItem("region", region); window.location = window.location.pathname; return false; } function getRegion(defaultregion) { var region = defaultregion.toString(); if (getItem("region") != "") region = getItem("region"); if (region != "0" && region != "1" && region != "2") region = 2; return region; } function getLocalButton(defaultregion, OnlyInCart) { if (OnlyInCart) { var lineCount = getLineCount(); if (lineCount == 0){ return ""; } } var strBtn = ""; strBtn += getRegion(defaultregion) == 0 ? "" : ""; return strBtn; } function getDomesticButton(defaultregion, OnlyInCart) { if (OnlyInCart) { var lineCount = getLineCount(); if (lineCount == 0){ return ""; } } var strBtn = ""; strBtn += getRegion(defaultregion) == 1 ? "" : ""; return strBtn; } function getInternationalButton(defaultregion, OnlyInCart) { if (OnlyInCart) { var lineCount = getLineCount(); if (lineCount == 0){ return ""; } } var strBtn = ""; strBtn += getRegion(defaultregion) == 2 ? "" : ""; return strBtn; } function getItem(key) { var idx = private_getItemIndex(key); if (idx == -1) { return ""; } return unescape(arrItem[idx][1]); } function setItem(key, value) { var idx = private_getItemIndex(key); if (idx == -1) idx = arrItem.length; arrItem[idx] = new Array(key, escape(value)); return private_UpdateItems(); } function getLineItem(line, key) { var idx = private_getLineItemIndex(line, key); if (idx == -1) { return ""; } return unescape(arrLine[line][idx]); } function setLineItem(line, key, value) { var idx = private_getLineItemIndex(line, key); if (idx == -1) { if (typeof(arrLine) == "undefined") { arrLine = new Array(); } if (typeof(arrLine[line]) == "undefined") { arrLine[line] = new Array(0); } idx = key; } if (typeof(value) == "string") { arrLine[line][idx] = escape(value); } else { arrLine[line][idx] = value; } return private_UpdateLines(); } function deleteLine(line) { var arrLineTmp = new Array(0); if (arrLine.length > line) { for(var i = 0; i 4096) return false; document.cookie = strLines; return true; } function private_getItemIndex(key) { if (typeof(arrItem) == "undefined") return -1; for(var i = 0; i