// ----------------------------- // The subroutine to show product details // ----------------------------- var winHandle; function openDetailsWindow(product_id) { // Pop up new window containing php script comment viewer if (winHandle != undefined) { winHandle.close(); } var moreinfo_url = "product-details.php?product_id="+product_id; winHandle = window.open(moreinfo_url, "pfxMoreInfoWindow", "dependent=yes,directories=no,menubar=no,personalbar=no,resizable=yes,screenX=200,screenY=200," + "scrollbars=yes,status=no,titlebar=yes,toolbar=no"); winHandle.focus(); } // // jsFormatPrice // // Expects a numeric argument. Returns a formatted representation. // function jsFormatPrice(price, showPlusForPositiveValue, showWhenZero) { if (price == 0) { if (!showWhenZero) { return ""; } else { price = "0"; } } var positive = 1; if (price < 0) { positive = 0; price = -price; } var rvStr = ""+price; var decimalPointIndex = rvStr.indexOf("."); //alert("rvStr='"+rvStr+"'; decimalPointIndex="+decimalPointIndex+", rvStr.length="+rvStr.length); if (decimalPointIndex == -1) { // Whole dollar amount - append ".00" rvStr += ".00"; } else if (decimalPointIndex == rvStr.length - 2) { // Only one decimal place came through - append another 0 rvStr += "0"; } else if (decimalPointIndex < rvStr.length - 3) { // truncate decimal figures after 2 places rvStr = rvStr.substr(0, decimalPointIndex + 3); } rvStr = "$"+rvStr; if (!positive) { rvStr = "-"+rvStr; } else if (showPlusForPositiveValue) { rvStr = "+"+rvStr; } // Now pad out with spaces to enforce right alignment. //while (rvStr.length < 9) { // rvStr = " "+rvStr; //} return rvStr; } // Show a JS popup window containing the requested page var info_window; function show_popup(pagename) { info_window = window.open(pagename, "pctorque_info_window", "dependent=yes,directories=no,width=450,height=550,location=no,menubar=no,personalbar=no,resizable=yes,screenx=100,screeny=100,scrollbars=auto,toolbar=no"); } //function parse_price(pricestring) { // var rv = ""; // //pricestring = pricestring.trim(); // if (pricestring.length > 0 && pricestring.substr(0, 1) == "$") { // pricestring = pricestring.substr(pricestring, 1); // } // return parseFloat(pricestring); //} var cash_discount = 2.5; function apply_cash_discount(amt) { var discount = amt * (cash_discount / 100.0); return Math.round( (amt - discount) * 100) / 100; }