jQuery(document).ready(function ($) { //$(".content-area").addClass('span12').removeClass('span8'); // $('.hth-river .hth-quote-box-container').html($('.hth-main-banner .hth-quote-box-container').html()); // $('.mboxDefault').after(''); if (typeof(fitVids) == 'function'){ $(".hth-river-video").fitVids(); } $('.hth-quote-box-trigger').on('click', function(e){ var quoteForm = $(this).parent().parent().find('.hth-quote-form'); quoteForm.find('.hth-quote-form-validation-error').hide(); quoteForm.find('.hth-quote-postal-code-input').val(''); if ($(this).hasClass('hth-quote-box-trigger-auto')){ if (quoteForm.hasClass('open')){ if (quoteForm.hasClass('hth-quote-form-auto')){ quoteForm.slideUp(500); quoteForm.removeClass('open'); } else { quoteForm.removeClass('hth-quote-form-home').addClass('hth-quote-form-auto'); } } else { quoteForm.removeClass('hth-quote-form-home').addClass('hth-quote-form-auto open'); quoteForm.slideDown(800); } } else { if (quoteForm.hasClass('open')){ if (quoteForm.hasClass('hth-quote-form-home')){ quoteForm.slideUp(300); quoteForm.removeClass('open'); } else { quoteForm.removeClass('hth-quote-form-auto').addClass('hth-quote-form-home'); } } else { quoteForm.removeClass('hth-quote-form-auto').addClass('hth-quote-form-home open'); quoteForm.slideDown(300); } } }); $('.hth-quote-form-button').on('click', function(e){ var quoteForm = $(this).parentsUntil('.hth-quotebox-row').find('.hth-quote-form'); var postalCode = quoteForm.find('.hth-quote-postal-code-input').val(); var validationAlert = quoteForm.find('.hth-quote-form-validation-error'); postalCode = postalCode.replace(/\s/g, ''); // trim spaces from postal code before submitting var pattern = new RegExp(/^[A-Za-z]{1}\d[A-Za-z]{1}\d[A-Za-z]{1}\d/); if (!pattern.test(postalCode)){ validationAlert.show(); } else { validationAlert.hide(); var appType = ''; if (quoteForm.hasClass('hth-quote-form-auto')){ appType = 'auto'; } else if (quoteForm.hasClass('hth-quote-form-home')){ appType = 'home'; } //window.alert('Ready to submit: ' + postalCode + ' ' + appType); window.location.href='https://www1.johnson.ca/j_jiequote/app/equote-flow?appType=' + appType + '&retrieveQuote=false&postalCode=' + postalCode + '&lang=en'; } }); });