function cur(a) { a+=''; a+=(a.indexOf(".")==-1 ? ".":"")+"00"; return a.substring(0,a.indexOf(".")+3); } base=3.99; maxdiscount=50; minpurchase=4320; /* terms = [ {name:'1 Month', discount:0, period:1}, {name:'3 Months', discount:5, period:3}, {name:'6 Months', discount:10, period:6}, {name:'1 Year', discount:15, period:12} ]; qty = [ {qty:1, discount:0}, {qty:3, discount:15}, {qty:10, discount:30}, {qty:20, discount:50} ]; */ function calcdiscount(qty, term) { var a = (qty*term/30-1)/1; if (a<0) return 0; return (a>maxdiscount) ? maxdiscount : Math.round(a); } terms = [ {name:'1 Month', period:30}, {name:'3 Months', period:91}, {name:'6 Months', period:182}, {name:'1 Year', period:364}, {name:'2 Years', period:728} ]; qty = [ {qty:1}, {qty:3}, {qty:10}, {qty:20}, {qty:60}, ];