var shippingCost; var subTotal; var grandTotal; var shippingMethod; var shipMethodReg; var hasokforusps = 0; var UPSshippingMethod; var tmpmethod; var tmpcost; function changeShippingMethod(cost,method,usps,ups){ if(!method){ alert('no method'); return; } //shippingMethod != UPSshippingMethod && if(UPSshippingMethod && !hasokforusps && usps == '1'){ displayUSPSMessage(cost,method); } else { if( ups ){ UPSshippingMethod = method; UPSshippingCost = cost; } //alert('UPS: ' + UPSshippingMethod + ', shippingMethod: ' + shippingMethod + ', hasokforusps: ' + hasokforusps + ', usps: ' + usps); savethechange(cost,method); } } function savethechange(cost,method){ tmpmethod = method; tmpcost = cost; jQuery.ajax({ url: "assets/ajax/adjustShippingOptions.php?method=" + method, cache: false }); shippingCost = tmpcost; shippingMethod = tmpmethod; grandTotal = eval(subTotal) + eval(shippingCost); handleDisplayUpdates(); } var uspsmsg = "
WARNING
The United States Postal Service (USPS) frequently loses packages and is significantly less reliable than UPS and more difficult to track. If you choose this shipping method and your package is lost, damaged, or stolen in transit, BSW will not be able to assist in any way whatsoever. You assume ALL RISK and understand that BSW strongly recommends UPS but offers USPS as a lower-cost, higher-risk option.

"; function displayUSPSMessage(cost,method){ var ok = 0; jQuery.prompt(uspsmsg,{ prefix:'ahqa', buttons:{ "I AGREE":1,"I'll use UPS instead":0 }, submit: function(v,m,f){ if(v){ //hasokforusps = 1; savethechange(cost,method); } else { var tid = method + "_cost"; if(!UPSshippingMethod || UPSshippingMethod=='' || UPSshippingMethod=='0'){ //var UPSshippingMethod = shippingMethod; //var UPSshippingCost = shippingCost; } if(!UPSshippingCost || UPSshippingCost=='' || UPSshippingCost=='0'){ //var UPSshippingMethod = shippingMethod; //var UPSshippingCost = shippingCost; } if(document.getElementById(UPSshippingMethod)){ document.getElementById(UPSshippingMethod).checked = 1; savethechange(UPSshippingCost,UPSshippingMethod); } else { document.write('nope'); } } } }); return ok; } function handleDisplayUpdates() { if(document.getElementById('shipping_cost_display')){ document.getElementById('shipping_cost_display').innerHTML = "$" + CurrencyFormatted(shippingCost); } if(document.getElementById('grand_total_display')){ document.getElementById('grand_total_display').innerHTML = '$' + CurrencyFormatted(grandTotal); } setSelectedShippingMethodClass(); } function setSelectedShippingMethodClass(){ var list; if(document.shipformname.shipMethod){ list = document.shipformname.shipMethod; } else if(document.shipformname.userShippingMethod){ list = document.shipformname.userShippingMethod; } else { return; } var id; for (var i=0; i < list.length; i++) { id = "ship_method_" + list[i].value; if (list[i].checked) { if(document.getElementById(id)){ document.getElementById(id).className = "ship_selected"; list[i].checked = 1; } } else { // unselect it if(document.getElementById(id)){ document.getElementById(id).className = "ship_not_selected"; } } } } function CurrencyFormatted(amount) { var i = parseFloat(amount); if(isNaN(i)) { i = 0.00; } var minus = ''; if(i < 0) { minus = '-'; } i = Math.abs(i); i = parseInt((i + .005) * 100); i = i / 100; s = new String(i); if(s.indexOf('.') < 0) { s += '.00'; } if(s.indexOf('.') == (s.length - 2)) { s += '0'; } s = minus + s; return s; } function submitZip() { // change picture if( document.getElementById('submit_zip_button') ){ document.getElementById('submit_zip_button').src = "./images/loadinfotransparent24.gif"; } setTimeout("pause()",1500); return false; } function pause() { document.shipformname.submit(); return false; }