function setDoorPrice(currentPrice, additionalCost) { var formDoorStr = document.getElementById('formDoorPrice').value; var formDoorPrice = parseInt(formDoorStr.replace(",", "")); if (currentPrice == 0) { currentPrice = formDoorPrice; } $('#doorPrice').val((currentPrice + additionalCost).toFixed(2)); $('#formDoorPrice').val((currentPrice + additionalCost).toFixed(2)); $("input[name='noloop']").val((currentPrice + additionalCost).toFixed(2)); $("input[name='looper']").val((currentPrice + additionalCost).toFixed(2)); } function setWindowPrice(windowType, windowPrice) { if (windowType == 'Solid' && windowCost > 0) { setDoorPrice(0, windowCost * -1); windowCost = 0; $("input[name='windowcost']").val('0.00'); return; } if (windowType != 'Solid' && windowCost == 0) { setDoorPrice(0, windowPrice); windowCost = windowPrice; $("input[name='windowcost']").val(windowPrice + '.00'); return; } if (windowType != 'Solid' && windowCost > 0) { setDoorPrice(0, windowCost * -1); setDoorPrice(0, windowPrice); windowCost = windowPrice; $("input[name='windowcost']").val(windowPrice + '.00'); return; } } function calcDoorSize() { doorWI = document.getElementById('widthInches').value; doorHI = document.getElementById('heightInches').value; doorSize = doorWI + " x " + doorHI ; $("#sumSize").text(doorSize) $("input[name='doorsize']").val(doorSize); } function doorColorBorder() { $(this).css("opacity", "0.5"); } function sumOpener(openerModel) { if (!openerModel) { openerModel = "No Opener"; } $('#sumOpener').text(openerModel); $("input[name='opener']").val(openerModel); } function showHeadRoom(headRoom) { if (headRoom == 1) { $('#sumHeadroom').css("display", "block"); $("input[name='kitselect']").val('Low Headroom Kit'); } else { $('#sumHeadroom').css("display", "none"); $("input[name='kitselect']").val('None'); } } function setDoorTrim() { if (document.getElementById("doorTrim").checked == true) { setDoorPrice(0,trimPrice); isTrim = 1; $('#sumTrim').text("Color Matched Trim"); $("input[name='doortrim']").val('Color Matched Trim'); $("input[name='trimprice']").val(trimPrice); } else { if (isTrim == 1) { setDoorPrice(0,(trimPrice * -1)); isTrim = 0; $('#sumTrim').text("No Trim"); $("input[name='doortrim']").val('No Trim'); $("input[name='trimprice']").val('0.00'); } } } function setDoorMaterial() { if (document.getElementById("doorMaterial").checked == true) { $("input[name='doormaterial']").val('Note: Door is being mounted to steel.'); } else { $("input[name='doormaterial']").val(''); } } function setDoorLock(lockStyle) { switch (lockStyle) { case 'inside': if (isLock == 1) { isLock = 0; setDoorPrice(0,-88); $('#sumLock').text('Inside') $("input[name='lockname']").val('Inside'); $("input[name='lockcost']").val('0'); } if (isLock == 0) { $('#sumLock').text('Inside') $("input[name='lockname']").val('Inside'); $("input[name='lockcost']").val('0'); } break; case 'outside': if (isLock == 0) { isLock = 1; setDoorPrice(0,88); $('#sumLock').text('Outside') $("input[name='lockname']").val('Outside'); $("input[name='lockcost']").val('88'); } break; case 'nolock': if (isLock == 1) { isLock = 0; setDoorPrice(0,-88); $('#sumLock').text('No Lock') $("input[name='lockname']").val('No Lock'); $("input[name='lockcost']").val('0'); } if (isLock == 0) { $('#sumLock').text('No Lock') $("input[name='lockname']").val('No Lock'); $("input[name='lockcost']").val('0'); } break; } } function setDoorOpener(openerModel, openerPrice) { if (!openerModel) { openerModel = "No Opener"; } $('#sumOpener').text(openerModel); $("input[name='opener']").val(openerModel); $("input[name='motorprice']").val(openerPrice + '.00'); if (isMotor == 0) { setDoorPrice(0, openerPrice); isMotor = 1; motorPrice = openerPrice; setDoorLock('nolock'); document.getElementById('lockselect').style.visibility = 'hidden'; } if (isMotor == 1 && openerModel != "No Opener") { setDoorPrice(0, (motorPrice * -1)); setDoorPrice(0, openerPrice); motorPrice = openerPrice; setDoorLock('nolock'); document.getElementById('lockselect').style.visibility = 'hidden'; } if (isMotor == 1 && openerModel == "No Opener") { setDoorPrice(0, (motorPrice * -1)); isMotor = 0; motorPrice = 0; setDoorLock('inside'); document.getElementById('lockselect').style.visibility = 'visible'; } } function getWindows(panelStyle) { if (!panelStyle) { panelStyle = document.getElementsByName('paneltype')[0].value}; if (window.XMLHttpRequest) { xmlhttp=new XMLHttpRequest(); } else { xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange=function(){ if (xmlhttp.readyState==4 && xmlhttp.status==200) { document.getElementById('windowBlock').innerHTML = xmlhttp.responseText; } } xmlhttp.open("GET", "windowchange.php?panelStyle=" + panelStyle, true); xmlhttp.send(); var sumPanelStyle; switch (panelStyle) { case 'raised': sumPanelStyle = 'Traditional Raised Panel'; doorModelFull = doorModel + "00"; break; case 'ranch': sumPanelStyle = 'Traditional Ranch Panel'; doorModelFull = doorModel + "03"; break; case 'flush': sumPanelStyle = 'Woodgrain Flush Panel'; doorModelFull = doorModel + "01"; break; } $("input[name='paneltype']").val(panelStyle); $('#sumPanel').text(sumPanelStyle); $('#sumModel').text(doorCollection + " " + doorModelFull); $("input[name='model']").val(doorCollection + " " + doorModelFull); $("input[name='doormodel']").val(doorCollection + " " + doorModelFull); checkGlass(); } function checkGlass() { if (windowStyle != 'Solid') { $('#sumWindowGlass').text(document.getElementById('formGlass').value); $("input[name='glasskind']").val(document.getElementById('formGlass').value); } else { $('#sumWindowGlass').text('No Window'); $("input[name='glasskind']").val('No Window'); } } function doorImage(doorColor, panelStyle, windowType) { if (!panelStyle) { panelStyle = document.getElementsByName('paneltype')[0].value}; if (!doorColor) { doorColor = document.getElementById('sumDoorColor').innerHTML }; if (!windowType) { windowType = document.getElementsByName('windowtype')[0].value}; var imgURL = "/garagedoors/doorimages/" + panelStyle.toLowerCase() + "-panel/" + doorColor.toLowerCase() + "/" + windowType.toLowerCase() + ".jpg"; $('#sumDoorImage').prop("src", imgURL); $('#sumDoorColor').text(doorColor); $('#formDoorColor').val(doorColor); $('#sumWindowStyle').text(windowType); $("input[name='windowtype']").val(windowType); $("input[name='color2']").val(doorColor); $("input[name='cartimage']").val(imgURL); if (doorColor == 'Medium' || doorColor == 'Cherry' || doorColor == 'Ultra-Grain Medium' || doorColor == 'Ultra-Grain Dark' || doorColor == 'Ultra-Grain Walnut') { document.getElementById('trim-price').innerHTML = '100'; trimPrice = 100; } else { document.getElementById('trim-price').innerHTML = '80'; trimPrice = 80; } windowStyle = windowType; } function checkHeadroom() { if (document.getElementById("formHeadroom").value == "LOW" && isHeadroom == 0) { isHeadroom = 1; $("#sumHeadroom").css("display", "block"); $("#headroomkit").css("display", "block"); $("input[name='kitselect']").val('Low Headroom Track'); $("input[name='kitcost']").val('260'); setDoorPrice(0,260); } if (document.getElementById("formHeadroom").value == "OK" && isHeadroom == 1) { isHeadroom = 0; $("#sumHeadroom").css("display", "none"); $("#headroomkit").css("display", "none"); $("input[name='kitselect']").val(''); $("input[name='kitcost']").val('0'); setDoorPrice(0,-260); } } function exactHeadroom() { $("input[name='exactroom']").val(document.getElementById('exactHR').value); } function checkWindcode() { if (document.getElementById("formWindcode").value == "Windcode") { $("#windcode").css("display", "block"); } else { $("#windcode").css("display", "none"); } } function colorPrice(colorprice) { colorprice = parseInt(colorprice.replace("$", "")); if (isWoodGrain == 0 && colorprice != 0) { isWoodGrain = 1; setDoorPrice(0, colorprice); } if (isWoodGrain == 1 && colorprice == 0) { isWoodGrain = 0; setDoorPrice(0, (woodGrainPrice * -1)); } } function setDoorAcc(accName, accPrice) { var accQuan = document.getElementById(accName).value; var currentPrice = document.getElementById('formDoorPrice').value; currentPrice = parseInt(currentPrice.replace(",", "")); var accTotal = accQuan * accPrice; accCost = accCost + accTotal; switch (accName) { case '893MAX': if (accQuan > acc4Count) { $('#sumAcc4').text(' ' + accQuan + ' ' + accName); $("input[name='accet4']").val(' ' + accQuan + ' ' + accName); setDoorPrice(currentPrice, accTotal); $("input[name='price2']").val(accCost + ".00"); acc4Count = accQuan; checkAccPrice(); return; } if (accQuan < acc4Count && accQuan != 0) { $('#sumAcc4').text(' ' + accQuan + ' ' + accName); $("input[name='accet4']").val(' ' + accQuan + ' ' + accName); currentPrice = currentPrice - (acc4Count * accPrice); setDoorPrice(currentPrice, accTotal); $("input[name='price2']").val(accCost + ".00"); acc4Count = accQuan; checkAccPrice(); return; } if (accQuan == 0 && acc4Count != 0) { $('#sumAcc4').text(' '); $("input[name='accet4']").val(' '); currentPrice = currentPrice - (acc4Count * accPrice); setDoorPrice(currentPrice, 0); $("input[name='price2']").val(accCost + ".00"); acc4Count = accQuan; checkAccPrice(); return; } break; case '895MAX': if (accQuan > acc2Count) { $('#sumAcc2').text(' ' + accQuan + ' ' + accName); $("input[name='accet2']").val(' ' + accQuan + ' ' + accName); setDoorPrice(currentPrice, accTotal); $("input[name='price2']").val(accCost + ".00"); acc2Count = accQuan; checkAccPrice(); return; } if (accQuan < acc2Count && accQuan != 0) { $('#sumAcc2').text(' ' + accQuan + ' ' + accName); $("input[name='accet2']").val(' ' + accQuan + ' ' + accName); currentPrice = currentPrice - (acc2Count * accPrice); setDoorPrice(currentPrice, accTotal); $("input[name='price2']").val(accCost + ".00"); acc2Count = accQuan; checkAccPrice(); return; } if (accQuan == 0 && acc2Count != 0) { $('#sumAcc2').text(' '); $("input[name='accet2']").val(' '); currentPrice = currentPrice - (acc2Count * accPrice); setDoorPrice(currentPrice, 0); $("input[name='price2']").val(accCost + ".00"); acc2Count = accQuan; checkAccPrice(); return; } break; case '877MAX': if (accQuan > acc3Count) { $('#sumAcc3').text(' ' + accQuan + ' ' + accName); $("input[name='accet3']").val(' ' + accQuan + ' ' + accName); setDoorPrice(currentPrice, accTotal); $("input[name='price2']").val(accCost + ".00"); acc3Count = accQuan; checkAccPrice(); return; } if (accQuan < acc3Count && accQuan != 0) { $('#sumAcc3').text(' ' + accQuan + ' ' + accName); $("input[name='accet3']").val(' ' + accQuan + ' ' + accName); currentPrice = currentPrice - (acc3Count * accPrice); setDoorPrice(currentPrice, accTotal); $("input[name='price2']").val(accCost + ".00"); acc3Count = accQuan; checkAccPrice(); return; } if (accQuan == 0 && acc3Count != 0) { $('#sumAcc3').text(' '); $("input[name='accet3']").val(' '); currentPrice = currentPrice - (acc3Count * accPrice); setDoorPrice(currentPrice, 0); $("input[name='price2']").val(accCost + ".00"); acc3Count = accQuan; checkAccPrice(); return; } break; case '828LM': if (accQuan > acc1Count) { $('#sumAcc1').text(' ' + accQuan + ' ' + accName); $("input[name='accet1']").val(' ' + accQuan + ' ' + accName); setDoorPrice(currentPrice, accTotal); $("input[name='price2']").val(accCost + ".00"); acc1Count = accQuan; checkAccPrice(); return; } if (accQuan < acc1Count && accQuan != 0) { $('#sumAcc1').text(' ' + accQuan + ' ' + accName); $("input[name='accet1']").val(' ' + accQuan + ' ' + accName); currentPrice = currentPrice - (acc1Count * accPrice); setDoorPrice(currentPrice, accTotal); $("input[name='price2']").val(accCost + ".00"); acc1Count = accQuan; checkAccPrice(); return; } if (accQuan == 0 && acc1Count != 0) { $('#sumAcc1').text(' '); $("input[name='accet1']").val(' '); currentPrice = currentPrice - (acc1Count * accPrice); setDoorPrice(currentPrice, 0); $("input[name='price2']").val(accCost + ".00"); acc1Count = accQuan; checkAccPrice(); return; } break; }; }; function checkAccPrice() { if (acc1Count == 0 && acc2Count == 0 && acc3Count == 0 && acc4Count == 0) { accCost = 0; $("input[name='price2']").val("0"); }; }; function angleIron(quantity) { if (angleCount == 0 && quantity == 0) { return; } if (angleCount == 0 && quantity > angleCount) { setDoorPrice(0, (quantity *50)); angleCount = quantity; if (quantity > 0) { $('#sumAngle').css("display", "block"); $('#sumAngleQty').text(quantity); $("input[name='punchedAngleQty']").val(quantity); } else { $('#sumAngle').css("display", "none"); $('#sumAngleQty').text(quantity); $("input[name='punchedAngleQty']").val(quantity); } } if (angleCount != 0) { anglePrice = angleCount * 50; setDoorPrice(0, (anglePrice * -1)); setDoorPrice(0, (quantity * 50)); angleCount = quantity; if (quantity > 0) { $('#sumAngle').css("display", "block"); $('#sumAngleQty').text(quantity); $("input[name='punchedAngleQty']").val(quantity); } else { $('#sumAngle').css("display", "none"); $('#sumAngleQty').text(quantity); $("input[name='punchedAngleQty']").val(quantity); } } } $(document).ready(function() { function setDefaults() { $("input[name='quantity']").val('1'); $("input[name='color2']").val('White'); $("input[name='paneltype']").val('raised'); $("input[name='windowtype']").val('Solid'); $("input[name='windowcost']").val('0'); $("input[name='glasskind']").val('No Window'); $("input[name='lockname']").val('Inside'); $("input[name='lockcost']").val('0'); $("input[name='opener']").val('No Opener'); $("input[name='motorprice']").val('0'); $("input[name='accet1']").val(''); $("input[name='accet2']").val(''); $("input[name='accet3']").val(''); $("input[name='price2']").val(''); $("input[name='price3']").val(''); $("input[name='price4']").val(''); $("input[name='kitselect']").val(''); $("input[name='kitcost']").val(''); $("input[name='looper']").val(''); $("input[name='noloop']").val(''); $("input[name='state']").val(''); }; doorImage(); getWindows(); calcDoorSize(); setDoorLock('inside'); setDoorPrice(0,0); $('#cartSum').scrollToFixed({marginTop: 10}); });