// JavaScript Document function formatCurrency(num) { num = num.toString().replace(/\$|\,/g, ''); if (isNaN(num)) num = "0"; sign = (num == (num = Math.abs(num))); num = Math.floor(num * 100 + 0.50000000001); cents = num % 100; num = Math.floor(num / 100).toString(); if (cents < 10) cents = "0" + cents; for (var i = 0; i < Math.floor((num.length - (1 + i)) / 3); i++) num = num.substring(0, num.length - (4 * i + 3)) + ',' + num.substring(num.length - (4 * i + 3)); return (((sign) ? '' : '-') + num + '.' + cents); } function validateCoupon() { var rawdoor = document.getElementById("rawdoorcost").value; var b = document.getElementById("multiprice2").value; var c = parseFloat(0.05).toFixed(2); var result = Math.ceil(parseInt(rawdoor) * c) ; var finalresult = parseInt(b) - result ; var bs = document.getElementById("novalsimple").value; var cs = parseFloat(0.05).toFixed(2); var secondresult = Math.ceil(parseInt(rawdoor) * cs) ; var finalsecondresult = parseInt(bs) - secondresult ; var doorseries = document.getElementById("doormodel").value; if (document.getElementById("couponcode").value == "5offgold" && doorseries.indexOf("Gold") != -1 ) { window.alert("Thank you, Coupon Code Accepted!") document.getElementById("discountbox").style.visibility = 'visible'; document.getElementById('ostias').value = 'Si'; document.getElementById('descuentos').value = "

Discount: Gold 5% Off

"; document.getElementById("total3").value = formatCurrency(finalresult); document.getElementById("noval").value = finalresult; document.getElementById("novalsimple").value = finalsecondresult; } if (document.getElementById("couponcode").value != "5offgold") { document.getElementById("discountbox").style.visibility = 'hidden'; window.alert("Sorry, The Coupon Code you entered is invalid. Please check and try again!") document.getElementById('ostias').value = 'No'; document.getElementById('descuentos').value = "

Discount: None

"; } if (document.getElementById("couponcode").value == "5offgold" && doorseries.indexOf("Gold") == -1 ) { document.getElementById("discountbox").style.visibility = 'hidden'; window.alert("Sorry, The Coupon you have entered is only valid with the Gold Garage Door Model") document.getElementById('ostias').value = 'No'; document.getElementById('descuentos').value = "

Discount: None

"; } }