LinkedIn Youtube Facebook Twitter Sales Rep Locator Document Search
 

$(document).ready(function(){ $( "#square-footage" ).prop( "disabled", true ); $( "#quantity" ).prop( "disabled", true ); // Custom Functions function addCommas(num) { var str = num.toString().split('.'); if (str[0].length >= 4) { //add comma every 3 digits befor decimal str[0] = str[0].replace(/(\d)(?=(\d{3})+$)/g, '$1,'); } /* Optional formating for decimal places if (str[1] && str[1].length >= 4) { //add space every 3 digits after decimal str[1] = str[1].replace(/(\d{3})/g, '$1 '); }*/ return str.join('.'); } function numberscrollAct() { $('.counter').each(function() { var $this = $(this), countTo = $this.attr('data-count'); faancy = addCommas(countTo); $({ countNum: $this.text()}).animate({ countNum: countTo }, { duration: 2500, easing:'linear', step: function() { $this.text(Math.floor(this.countNum)); }, complete: function() { $this.empty(); $this.append(faancy); $this.prepend('$'); $this.addClass('pop'); $('#pool-number').addClass('appear'); // $this.text(this.countNum); //alert('finished'); } }); }); } function calculatorGO() { // Calculations var squarefootage = $('#square-footage').val(); var sqftmath = $('#container.checked input').val(); var buildingNo = $('#quantity').val(); var equation = squarefootage * sqftmath * buildingNo; var fancynumber = addCommas(equation); if(equation > 100000) { $('.counter').addClass('small-numbers') } else { $('.counter').removeClass('small-numbers') } var numberSpin = $('#slide.savings h2'); var poolNumber = $('#pool-number, .pool-number'); var pools = ((squarefootage * 2)*0.334)/1100; var poolMath = Math.round(pools) * buildingNo; $('.counter').attr('data-count', equation) // Adding to DOM poolNumber.empty(); poolNumber.append(poolMath); numberSpin.empty(); numberSpin.append(fancynumber); numberSpin.prepend('$'); } // Form Validation $(function() { jQuery.validator.addMethod("zipcode", function(value, element) { return this.optional(element) || /^\d{5}(?:-\d{4})?$/.test(value); }, "Invalid zip"); $("form#email-signup").validate({ // Specify validation rules rules: { // The key name on the left side is the name attribute // of an input field. Validation rules are defined // on the right side fullname: { required: true }, address: { required: true }, email: { required: true, email: true }, city: { required: true }, state: { required: true }, zip: { required: true, zipcode: true } }, // Specify validation error messages messages: { fullname: "Please enter your full name", address: "Please enter your address", city: "Please enter your city", state: "Please enter your state", email: "Please enter a valid email address", zip: { required: "Missing zipcode" } }, errorPlacement: function(error, element) { error.insertBefore(element); }, // Make sure the form is submitted to the destination defined // in the "action" attribute of the form when valid submitHandler: function(form) { // form.submit(); $('button.more').hide(); $('p.success').removeClass('disappear'); } }); }); // Roof colors $('label#container').on('click tap', function() { $('body').find($('label#container')).removeClass('checked'); $(this).addClass('checked'); if($('#EPDM').is(':checked')) { $('.roof-img').removeClass('light'); $('body').removeClass('MB TPO'); $('body').addClass('EPDM roof-selected'); $( "#square-footage" ).prop( "disabled", false ); } else if($('#MB').is(':checked')) { $('.roof-img').removeClass('light'); $('body').removeClass('EPDM TPO'); $('body').addClass('MB roof-selected'); $( "#square-footage" ).prop( "disabled", false ); } else if($('#TPO').is(':checked')) { $('.roof-img').addClass('light'); $('body').removeClass('MB EPDM'); $('body').addClass('TPO roof-selected'); $( "#square-footage" ).prop( "disabled", false ); } // Tool-tips $('.tool-tip.one').addClass('disappear'); setTimeout(function() { $('.tool-tip.two').addClass('appear'); }, 400); setTimeout(function() { $('.slider-box').removeClass('faded'); }, 400); }); // Range Slider $('.range-slider').on('input', function() { var addDiv = $('.range-value'); var currentSpot = $(this).val(); var realSpot = addCommas(currentSpot); addDiv.empty(); addDiv.append(realSpot + ' sf'); }); $('.range-slider').on('click change tap', function() { var addDiv = $('.range-value'); var currentSpot = $(this).val(); var realSpot = addCommas(currentSpot); addDiv.empty(); addDiv.append(realSpot + ' sf'); $('.tool-tip.one').addClass('disappear'); $('.tool-tip.two').addClass('disappear'); setTimeout(function() { $('.tool-tip.three').addClass('appear'); }, 400); setTimeout(function() { $('.description, #quantity').removeClass('faded'); $('.description, #quantity').addClass('appear'); // $('#quantity').focus(); }, 400); setTimeout(function() { $('#btnbuilding').removeClass('faded'); }, 1300); $('#btnbuilding').addClass('ready'); $('body').addClass('sqf-selected'); $( "#quantity" ).prop( "disabled", false ); setTimeout(function() { $('#btnbuilding').addClass('sparkly'); }, 1500); }); $('#quantity').on('click tap', function() { $('.tool-tip.three').removeClass('appear'); }); // Building Form - Input Animations $('#btnbuilding').on('click tap change', function() { if ($(this).hasClass('ready')) { $('.tool-tip.three').removeClass('appear'); $('#calculator-form').addClass('no-tips completed'); $('#calculator').addClass('completed'); $(this).addClass('disappear'); $('.start').addClass('hide'); calculatorGO(); $('.savings').addClass('show'); $('#small-print p').removeClass('disappear'); $(this).hide(); $(this).data('clicked', true); $('.paint-left, .paint-right').addClass('start'); numberscrollAct(); setTimeout(function() { $('div#extras').addClass('activate'); setTimeout(function() { $('div#coin').addClass('is-flipped'); }, 1000); setTimeout(function() { $('#sign-up').addClass('show'); }, 1500); setTimeout(function() { $('.sign-up-container').addClass('show'); }, 1900); setTimeout(function() { $('.wave-container').addClass('rise'); }, 1000); }, 2200); } else { // Alert fields aren't finished } }); // Reload Calculator $("#form-section input").on("change paste keyup", function() { if ($('#calculator-form').hasClass('completed')) { calculatorGO(); } }); // Menu toggle $('#menu-toggle').on('click tap', function() { $(this).toggleClass('close'); $('#calculator-form').toggleClass('show'); }); // Mobile Form Toggle $('#free-estimate, #close-form').on('click tap', function() { $('#contact-form').toggleClass('show'); }); });