function openOrderForm() { var cart =window.open(document.location,"_self"); if(navigator.appName == "Netscape") { cart.focus(); } } function fmtPrice(value) { amount = Math.round(value*Math.pow(10,2))/Math.pow(10,2); amount -= 0; return (amount == Math.floor(amount)) ? amount + '.00' : ( (amount*10 == Math.floor(amount*10)) ? amount + '0' : amount); } function displaySum(index) { eval("document.basket.sum"+index+".value=fmtPrice("+quantity_array[index]*price_array[index]+")"); document.basket.formsubtotal.value=fmtPrice(subtotal); } function isInt(elm) { var elmstr = '' + elm; if (elmstr == '') return false; for (var i = 0; elmstr.length>i; i++) { if ( "0">elmstr.charAt(i) || elmstr.charAt(i) > "9") { return false; } } return true; } function RoundQty(elm) { var elmstr = "" + elm; if (elmstr == "") return 0; DotExist=0; DigitAfterDecimal=0; for (var i = 0; elmstr.length>i; i++) { if ( "0">elmstr.charAt(i) || elmstr.charAt(i) > "9") { if ((elmstr.charAt(i) == ".") && (DotExist == 0)) DotExist = 1; else return 0; } else if (DotExist == 1) { if (2>DigitAfterDecimal ) DigitAfterDecimal = DigitAfterDecimal + 1 ; else { if (elmstr.charAt(i)>="5") { var sTmp100 = elmstr.substring(0, i-3) + elmstr.substring(i-2, i); nTmp = Number( sTmp100 ) ; nTmp = nTmp + 1; var sTmp = "" + nTmp; if (2>sTmp.length) sTmp = sTmp.substring(0, sTmp.length - 2) + ".0" + sTmp.substring(sTmp.length - 2, sTmp.length ); else sTmp = sTmp.substring(0, sTmp.length - 2) + "." + sTmp.substring(sTmp.length - 2, sTmp.length ); return sTmp ; } else return Number( elmstr.substring(0, i) ); } } } return elm; } function updateQuantity(Qty, index, acceptZero, lineNumber, ajaxPath) { if (!acceptZero && (Qty>=10000 || Qty==0)) { alert ("Please enter a valid number that is greater than 0.01 and less than 9999.99!"); Eval("document.basket.quan"+index+".value=quantity_array[index]"); } else { $.ajax({ type: "POST", cache: false, url: ajaxPath + "?dt=" + (new Date().getTime()), data: 'bid=' + lineNumber + '&qu=' + parseInt( Qty ), dataType: "json", success: function(response) { var subtotal = 0; for ( var i=0; i < arrPrices.length; i++ ) { var sQF = "input[name$='Order_ItemQuantity_"+i+"']"; var sQF_sub = "input[name$='sum_"+i+"']"; var lineTotal = parseFloat( arrPrices[i] ) * parseInt( $(sQF).val() ); $(sQF).val(parseInt($(sQF).val())); $(sQF_sub).val(fmtPrice(lineTotal)); subtotal += lineTotal; } $("#subtotal").val( fmtPrice(subtotal) ); if ( subtotal >= 150 ) { $("#shipping_offer").text( 'This order qualifies for free shipping!' ); } else { $("#shipping_offer").text( 'You are $' + fmtPrice(150-subtotal) + ' away from qualifying for free shipping!' ); } }, error: function (xhr, ajaxOptions, thrownError){ alert("Error: Failed to update basket."); //alert(xhr.responseText); } }); } }