//============================================================================ var ifs_vals = []; var coupon = {}; //============================================================================ function ha_format_dollar_value(dollar_value, option = 'normal') { if (typeof dollar_value == 'string') dollar_value = parseFloat(dollar_value.replace('$','')); if (option == 'round_up') dollar_value = Math.ceil(dollar_value); return Intl.NumberFormat('en-US', { style: 'currency', currency: 'USD' }) .format(dollar_value).replace(".00",""); } //============================================================================ function get_access_level_string_from_radio() { if (typeof(pro_only_mode) != 'undefined' && pro_only_mode ) return 'Pro'; if (jQuery('#Access-Bronze').hasClass('Access-Selected')) return 'Bronze'; if (jQuery('#Access-Silver').hasClass('Access-Selected')) return 'Silver'; if (jQuery('#Access-Gold').hasClass('Access-Selected')) return 'Gold'; if (jQuery('#Access-Pro').hasClass('Access-Selected')) return 'Pro'; return 'unknown'; } //============================================================================ function get_payment_plan_string_from_radio() { if (jQuery('#Payment-Onepay').hasClass('Payment-Selected')) return 'Onepay'; if (jQuery('#Payment-Annual').hasClass('Payment-Selected')) return 'Annual'; if (jQuery('#Payment-Monthly').hasClass('Payment-Selected')) return 'Monthly'; if (jQuery('#Payment-3year').hasClass('Payment-Selected')) return '3year'; return 'unknown'; } //============================================================================ function get_market_level_string_from_radio() { if (jQuery('#Market-City').hasClass('Market-Selected')) return 'City'; if (jQuery('#Market-State').hasClass('Market-Selected')) return 'State'; if (jQuery('#Market-Region').hasClass('Market-Selected')) return 'Region'; if (jQuery('#Market-Nation').hasClass('Market-Selected')) return 'Nation'; return 'unknown'; } //============================================================================ function set_market_level(market_level) { jQuery("[id^='Market-']").removeClass('Market-Selected'); jQuery('#Market-' + market_level).addClass('Market-Selected'); clean_csrs(); // update_form_feields_and_prices(); // Called in clean_csrs } //============================================================================ function set_access_level(access_level) { jQuery("[id^='Access-']").removeClass('Access-Selected'); jQuery('#Access-' + access_level).addClass('Access-Selected'); update_form_feields_and_prices(); } //============================================================================ function set_payment_plan(payment_plan) { jQuery("[id^='Payment-']").removeClass('Payment-Selected'); jQuery('#Payment-' + payment_plan).addClass('Payment-Selected'); update_form_feields_and_prices(); } //============================================================================ function update_form_feields_and_prices() { if ( update_form_feields_and_prices.pause_update ) { console.log('uffap paused'); return 0; } console.log('uffap ok'); var market_type = get_market_level_string_from_radio(); if (market_type == 'unknown') { console.log('mu'); return 0; } var market_count = count_msas(); var access_level = get_access_level_string_from_radio(); var plan = get_payment_plan_string_from_radio(); if (plan == 'unknown') { console.log("Plan Unknown!"); return 0; } if ( plan == '3year' && ( access_level != 'Pro' || market_type != 'Nation' ) ) { console.log('resetting to Annual.'); set_payment_plan('Annual'); } document.getElementById('plan_option').value = plan; document.getElementById('market_type').value = market_type; document.getElementById('access_level').value = access_level; if (market_count > 0) { jQuery("#market_list_summary").html(''); } else { jQuery("#market_list_summary").html('(Please select at least 1 Market in Step #1 above)'); } if (market_type == 'Nation') { document.getElementById('loc1').value = 'msa_id_440'; document.getElementById('loc1name').value = 'USA'; } else { for (i = 1; i<=market_count; i++) { document.getElementById('loc' + i).value = document.getElementsByClassName('msa-list-row')[i-1].id; document.getElementById('loc' + i + 'name').value = document.getElementsByClassName('msa-list-name')[i-1].innerHTML; jQuery("#market_list_summary").html( jQuery("#market_list_summary").html() + document.getElementsByClassName('msa-list-name')[i-1].innerHTML + '
'); } } document.getElementById('market_count').value = market_count; update_visible_pricing(plan,market_type,market_count,access_level); jQuery(document.body).addClass('loading-complete'); } update_form_feields_and_prices.pause_update = false; //============================================================================ function pricing_update_wait_start() { $("#promo-code-apply-btn").hide(); $("#promo-code-apply-wait").css('display', 'inline-block'); jQuery("#top_banner_block").hide(); } jQuery(function() { jQuery('#have-gift-cert').click(function(){ jQuery('.gift-cert-row').toggle(); jQuery('.gift-check-row').toggle(); }); }); //============================================================================ function pricing_update_wait_stop() { $("#promo-code-apply-btn").show(); $("#promo-code-apply-wait").css('display', 'none'); setTimeout(function(){ jQuery("#top_banner_block").show(); }, 1000); } //============================================================================ function market_label_countable(market_type, market_count) { if ( market_type == 'Nation') return "Entire U.S.A."; if ( market_type == 'City' ) { if (market_count == 1) { return "City"; } else { return "Cities"; } } var s_ending = ""; if (market_count > 1) s_ending = "s"; return market_type + s_ending; } //============================================================================ function apply_pricing_data(pricing_data,plan,market_type,market_count,access_level) { // WORKAROUND: // Sometimes pricing tada is received multiple times in "random" order, And we can set "State" prices, when "USA" is selected. // To prevent this - make sure current selection matches the params if (plan != get_payment_plan_string_from_radio()) return 0; if (market_type != get_market_level_string_from_radio()) return 0; // if (market_count != count_msas()) return 0; //Fails when non-national level is selected, and no markets are selected yet if (access_level != get_access_level_string_from_radio()) return 0; // ======================================================================= var plans = { 1: 'Onepay', 2: 'Annual', 3: 'Monthly'}; var access_levels = { 1: 'Bronze', 2: 'Silver', 3: 'Gold', 4: 'Pro'}; var market_types = { 1: 'City', 2: 'State', 3: 'Region', 4: 'Nation'}; if (pro_only_mode) { plans = { 2: 'Annual', 3: 'Monthly'}; access_levels = { 4: 'Pro'}; } ifs_products = pricing_data.ifs_products; coupon = pricing_data.coupon; const lowest_level_available = pro_only_mode ? 'Pro' : 'Bronze'; for (var m in market_types) { if (typeof(ifs_products['Annual'][market_types[m]]) != 'undefined') { jQuery("#price_from_Annual_" + market_types[m]).html( ifs_products['Annual'][market_types[m]][1][lowest_level_available].price); jQuery("#price_from_Annual_Month_" + market_types[m]).html( ha_format_dollar_value(ifs_products['Annual'][market_types[m]][1][lowest_level_available].price_month, 'round_up')); if (ifs_products['Annual'][market_types[m]][1][lowest_level_available].price_month_before_discount != ifs_products['Annual'][market_types[m]][1][lowest_level_available].price_month) { jQuery("#price_from_Annual_Month_" + market_types[m] + "_before_discount").html( ha_format_dollar_value(ifs_products['Annual'][market_types[m]][1][lowest_level_available].price_month_before_discount, 'round_up')); jQuery("#price_from_Annual_Month_" + market_types[m] + "_before_discount").show(); } else { jQuery("#price_from_Annual_Month_" + market_types[m] + "_before_discount").html('^^^'); jQuery("#price_from_Annual_Month_" + market_types[m] + "_before_discount").hide(); } } if (typeof(ifs_products['Monthly'][market_types[m]]) != 'undefined') { jQuery("#price_from_Monthly_" + market_types[m]).html( ha_format_dollar_value(ifs_products['Monthly'][market_types[m]][1][lowest_level_available].price, 'round_up')); if (ifs_products['Monthly'][market_types[m]][1][lowest_level_available].price != ifs_products['Monthly'][market_types[m]][1][lowest_level_available].price_before_discount) { jQuery("#price_from_Monthly_" + market_types[m] + "_before_discount").html(ha_format_dollar_value(ifs_products['Monthly'][market_types[m]][1][lowest_level_available].price_before_discount, 'round_up')); jQuery("#price_from_Monthly_" + market_types[m] + "_before_discount").show(); } else { jQuery("#price_from_Monthly_" + market_types[m] + "_before_discount").html('^^^'); jQuery("#price_from_Monthly_" + market_types[m] + "_before_discount").hide(); } } } for (var l in access_levels) { for(var p in plans) { if ( typeof( ifs_products[plans[p]][market_type][market_count][access_levels[l]] ) != 'undefined' ) { jQuery("#price_" + access_levels[l] + "_" + plans[p]).html(ifs_products[plans[p]][market_type][market_count][access_levels[l]].price); if (ifs_products[plans[p]][market_type][market_count][access_levels[l]].price_before_discount != ifs_products[plans[p]][market_type][market_count][access_levels[l]].price) { jQuery("#price_" + access_levels[l] + "_" + plans[p] + "_before_discount").html(ha_format_dollar_value(ifs_products[plans[p]][market_type][market_count][access_levels[l]].price_before_discount, 'round_up')); jQuery("#price_" + access_levels[l] + "_" + plans[p] + "_before_discount").show(); } else { jQuery("#price_" + access_levels[l] + "_" + plans[p] + "_before_discount").html('^^^'); jQuery("#price_" + access_levels[l] + "_" + plans[p] + "_before_discount").hide(); } if (plans[p].indexOf('Annual') > -1) { //Calculate Annual Saving var price_annual = parseFloat(ifs_products[plans[p]][market_type][market_count][access_levels[l]].price.replace('$','').replace(',','')); var price_annual_month = parseFloat(ifs_products[plans[p]][market_type][market_count][access_levels[l]].price_month.replace('$','').replace(',','')); var price_month_before_discount = parseFloat(ifs_products[plans[p]][market_type][market_count][access_levels[l]].price_month_before_discount.replace('$','').replace(',','')); var price_monthly = parseFloat(ifs_products['Monthly'][market_type][market_count][access_levels[l]].price.replace('$','').replace(',','')); var annual_saving = Math.floor( price_monthly*12 - price_annual); jQuery("#price_" + access_levels[l] + "_" + plans[p] + "_Save").html('$' + Number(annual_saving).toLocaleString()); } if (typeof (ifs_products[plans[p]][market_type][market_count][access_level] ) != 'undefined') { jQuery("#price_" + plans[p]).html(ifs_products[plans[p]][market_type][market_count][access_level].price); if (ifs_products[plans[p]][market_type][market_count][access_level].price_before_discount != ifs_products[plans[p]][market_type][market_count][access_level].price) { jQuery("#price_" + plans[p] + "_before_discount").html(ifs_products[plans[p]][market_type][market_count][access_level].price_before_discount); jQuery("#price_" + plans[p] + "_before_discount").show(); } else { jQuery("#price_" + plans[p] + "_before_discount").html('^^^'); jQuery("#price_" + plans[p] + "_before_discount").hide(); } if (plans[p].indexOf('Annual') > -1) { var price_annual = parseFloat(ifs_products[plans[p]][market_type][market_count][access_level].price.replace('$','').replace(',','')); var price_annual_month = parseFloat(ifs_products[plans[p]][market_type][market_count][access_level].price_month.replace('$','').replace(',','')); var price_monthly = parseFloat(ifs_products['Monthly'][market_type][market_count][access_level].price.replace('$','').replace(',','')); var annual_saving = Math.floor( price_monthly*12 - price_annual); jQuery("#price_Annual_Save").html('$' + Number(annual_saving).toLocaleString()); jQuery("#price_Annual_Month").html(ha_format_dollar_value(price_annual_month)); if (price_month_before_discount != price_annual_month) { jQuery("#price_Annual_Month_before_discount").html(ha_format_dollar_value(price_month_before_discount, 'round_up')); jQuery("#price_Annual_Month_before_discount").show(); } else { jQuery("#price_Annual_Month_before_discount").html('^^^'); jQuery("#price_Annual_Month_before_discount").hide(); } } } jQuery("#Access-" + access_levels[l]).show(); } else { jQuery("#Access-" + access_levels[l]).hide(); } } } //3Yr Plan: if (typeof ( ifs_products['3year'] ) != 'undefined') { if (typeof ( ifs_products['3year']['Nation'][1]['Pro'] ) != 'undefined') { var price_monthly = parseFloat(ifs_products['Monthly']['Nation'][1]['Pro'].price.replace('$','').replace(',','')); var price_monthly_before_discount = parseFloat(ifs_products['Monthly']['Nation'][1]['Pro'].price_before_discount.replace('$','').replace(',','')); var price_3year = parseFloat(ifs_products['3year']['Nation'][1]['Pro'].price.replace('$','').replace(',','')); var price_3year_before_discount = parseFloat(ifs_products['3year']['Nation'][1]['Pro'].price_before_discount.replace('$','').replace(',','')); var rate_3year = parseFloat(ifs_products['3year']['Nation'][1]['Pro'].rate.replace('$','').replace(',','')); var rate_3year_before_discount = parseFloat(ifs_products['3year']['Nation'][1]['Pro'].rate_before_discount.replace('$','').replace(',','')); var saving_3year = Math.floor( price_monthly*36 - price_3year); var saving_3year_before_discount = Math.floor(price_monthly_before_discount * 36 - price_3year_before_discount); jQuery("#price_3year").html('$' + Number(price_3year).toFixed(2)); jQuery("#price_3year_Save").html('$' + Number(saving_3year).toFixed(2)); jQuery("#price_3year_Rate").html('$' + Number(rate_3year).toFixed(2)); jQuery(".package-paynow-rate").html(ha_format_dollar_value(price_3year)); jQuery(".package-paynow-rate-month").html(ha_format_dollar_value(price_3year/36)); if (price_3year_before_discount != price_3year) { jQuery(".package-paynow-rate-before-discount").html(ha_format_dollar_value(price_3year_before_discount)); jQuery(".package-paynow-rate-before-discount").show(); jQuery(".package-paynow-rate-month-before-discount").html(ha_format_dollar_value(price_3year_before_discount/36)); jQuery(".package-paynow-rate-month-before-discount").show(); } else { jQuery(".package-paynow-rate-before-discount").html('^^^'); jQuery(".package-paynow-rate-before-discount").hide(); jQuery(".package-paynow-rate-month-before-discount").html('^^^'); jQuery(".package-paynow-rate-month-before-discount").hide(); } jQuery(".package-savings-monthly").html(ha_format_dollar_value(saving_3year)); if (saving_3year_before_discount != saving_3year) { jQuery(".package-savings-monthly-before-discount").html(ha_format_dollar_value(saving_3year_before_discount)); jQuery(".package-savings-monthly-before-discount").show(); } else { jQuery(".package-savings-monthly-before-discount").html('^^^'); jQuery(".package-savings-monthly-before-discount").hide(); } jQuery(".package-subscription-rate").html(ha_format_dollar_value(rate_3year)); if (rate_3year_before_discount != rate_3year) { jQuery(".package-subscription-rate-before-discount").html(ha_format_dollar_value(rate_3year_before_discount)); jQuery(".package-subscription-rate-before-discount").show(); } else { jQuery(".package-subscription-rate-before-discount").html('^^^'); jQuery(".package-subscription-rate-before-discount").hide(); } console.log("3Y Price:" + price_3year); console.log("3Y Save:" + saving_3year); console.log("3Y Rate:" + rate_3year); } } /////////////////////////// if (typeof ( ifs_products[plan] ) != 'undefined') { if (typeof ( ifs_products[plan][market_type][market_count][access_level] ) != 'undefined') { jQuery(".price_current_product").html( ifs_products[plan][market_type][market_count][access_level].price ); // jQuery(".price_recurring_current_product").html( ifs_products[plan][market_type][market_count][access_level].price_recurring ); } } jQuery("#promo-code-frame").removeClass('Valid-Code'); jQuery("#promo-code-frame").removeClass('Invalid-Code'); jQuery("#promo-code-apply-btn-wrapper").removeClass('Valid-Code'); jQuery("#promo-code-apply-btn-wrapper").removeClass('Invalid-Code'); if (pricing_data.coupon.value != '') { if (pricing_data.coupon.valid) { jQuery("#promo-code-frame").addClass('Valid-Code'); jQuery("#promo-code-apply-btn-wrapper").addClass('Valid-Code'); } else { jQuery("#promo-code-frame").addClass('Invalid-Code'); jQuery("#promo-code-apply-btn-wrapper").addClass('Invalid-Code'); } } //jQuery("#plan_current_product").html( plan ); jQuery("#promo-banner-instructions-span").html(coupon.specialinstructions); } //============================================================================ function update_visible_pricing(plan,market_type,market_count,access_level) { // price_bronze market_count_bronze market_type_bronze price_bronze_onetime price_bronze_annual price_bronze_monthly if (market_count == 0) market_count = 1; jQuery("[id^='market_count_']").html(market_count); jQuery("[id^='market_type_']").html( market_label_countable( market_type, market_count) ); jQuery("[id^='access_level_div_']").show(); pricing_update_wait_start(); const promo_code_field_id = "#promoCode"; // promoCodeToPass" var promo_code = jQuery(promo_code_field_id).val(); if (!promo_code_applied) promo_code = ""; var form_options = ''; if (typeof(pro_only_mode) != 'undefined' && pro_only_mode ) { form_options += 'pro_only_mode,'; } var pricing_code = plan + '-' + access_level + '-' + market_type + '_' + promo_code; if (typeof(update_visible_pricing.data[pricing_code]) == 'undefined') { // console.log("REQUESTING PRICING..."); $.getJSON('https://www.housingalerts.com/add-markets/?plan_option=' + plan + '&access_level=' + access_level + '&market_type=' + market_type + '&promoCode=' + promo_code + '&get_pricing=1' + '&form_options=' + form_options, function(data) { // console.log("PRICING RECEIVED"); apply_pricing_data(data,plan,market_type,market_count,access_level); update_visible_pricing.data[pricing_code] = data; pricing_update_wait_stop(); }); } else { // console.log("PRICING FROM CACHE"); apply_pricing_data(update_visible_pricing.data[pricing_code],plan,market_type,market_count,access_level); pricing_update_wait_stop(); } return 0; //Temporary fix /* var price_current_product = product_info[plan_option][market_level][1][maps_option].ifs_data.ProductPrice; var price_maps_upgrade = product_info[plan_option][market_level][1]["with_maps"].ifs_data.ProductPrice - product_info[plan_option][market_level][1]["without_maps"].ifs_data.ProductPrice; var price_current_annual_subscription = product_info["annual_subscription"][market_level][1]["without_maps"].ifs_data.ProductPrice; var price_current_one_year = product_info["one_year"][market_level][1]["without_maps"].ifs_data.ProductPrice; var fake_price = Math.floor( price_current_product * 1.37 ); var message_under_green_button = ""; if ( plan_option == "annual_subscription" ) { message_under_green_button = "Join today - Only $" + fake_price + "/Year $" + price_current_product + "/Year
(annual subscription, cancel anytime)"; } else { message_under_green_button = "Join today - Only $" + fake_price + " $" + price_current_product + " (12 months, no subscription)"; } jQuery("#price_current_product").html( price_current_product ); jQuery("#price_maps_upgrade").html( price_maps_upgrade ); jQuery("#price_current_annual_subscription").html( price_current_annual_subscription ); jQuery("#price_current_one_year").html( price_current_one_year ); jQuery("#message_under_green_button").html( message_under_green_button ); */ } update_visible_pricing.data = {}; //============================================================================ jQuery(function() { jQuery("#orderform-step1").submit(function(){ result = false; if (get_market_level_string_from_radio() == 'Nation') { result = true; } else { if (count_msas() < 1) { alert("Please Select at least One Market"); goToAnchor('#Step2'); result = false; } else { result = true; } } if (result) { /* CLOSE FORM ON SUBMISSION */ jQuery("#order-frame").hide(); jQuery("#order-newtab-directions").show(); } return result; }); }); //============================================================================ function ha_httpGetRequest(url) { if (window.XMLHttpRequest) { // code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else { // code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } xmlhttp.onreadystatechange = function() { if (this.readyState == 4 && this.status == 200) { //alert(this.responseText); } }; xmlhttp.open("GET", url, true); xmlhttp.send(); } //============================================================================ function applyPromoCode() { /* Workaroing Apr 2020 - not sure how it worked w/o that... */ // jQuery("#promoCodeToPass").val( jQuery("#promoCode").val() ); /* ---------------------------------------------------------*/ promo_code_applied = true; update_form_feields_and_prices(); /* var promoCode = jQuery("#promoCode").val(); if (promoCode == '') { alert("Promo Code can't be blank"); return 0; } jQuery("#order-frame").hide(); jQuery("#apply-promocode-wait").show(); var url = location.protocol + '//' + location.host + location.pathname + "?promoCode=" + promoCode + "&plan_option=" + jQuery("#plan_option").val() + "&access_level=" + jQuery("#access_level").val(); window.location.href = url; */ } //============================================================================ function applyPromoCodeEmail() { var promoCodeEmail = jQuery("#promoCodeEmail").val(); if (promoCodeEmail == '') { alert("Email can't be blank"); return 0; } jQuery("#order-frame").hide(); jQuery("#apply-promocode-wait").show(); var url = location.protocol + '//' + location.host + location.pathname + "?promoCode=" + jQuery("#promoCode").val() + "&plan_option=" + jQuery("#plan_option").val() + "&access_level=" + jQuery("#access_level").val() + "&email=" + promoCodeEmail; window.location.href = url; } //============================================================================ function jump_to_anchor(h){ var url = location.href; //Save down the URL without hash. location.href = "#"+h; //Go to the target element. history.replaceState(null,null,url); //Don't like hashes. Changing it back. } //============================================================================ function captureEmail() { return 0; //Everything should now be captured by 'captureSelection()' Keep this function for compatibility with older forms where it is set as onChange handler } //=============================================================================== function captureSelection() { if ( is_ha_webinar && popinController.lastGoodPlaySecond <= 0) { return 0; } var email = document.getElementById("Email").value; if (email == "") { return; } else { var form_content = jQuery("#orderform-step1").serialize(); ha_httpGetRequest("https://www.housingalerts.com/o2/wp-content/themes/focusblog-housingalerts/savecontact-lite.php?" + form_content); } } //============================================================================ //============================================================================ //============================================================================ function add_market(id) { //Accepts pure numeric IDs MSAclick("MSA"+id); return 0; } //============================================================================ function MSAclick(msaid) { msaid = msaid.substr(3); if (msaid == '0') return 0; //USA //============================ if ( ok_to_add(msaid) ) { msa_name = globalMsaCaptions[msaid]; // remove "(MSAD)" msa_name = msa_name.replace(" (MSAD)",""); msa_name = msa_name.replace(" (MSAD)",""); msa_name = msa_name.replace(" (MSAD)",""); var message = "-----"; var current_count = count_msas(); message = "1) You have added \n-----------------\n" + msa_name + "\n-----------------\nto your order!\n \n"; //clean_csrs(); if (true || confirm(message)) { var max_name_length_mob = 23; jQuery("#msa_list").append("
" + msa_name + "
"); //jQuery('#msa_list').effect("bounce", { times:3 }, 300); } } update_msa_list(); } //============================================================================ function ok_to_add(id) { if (is_market_added(id)) { alert("This Market Is Already Selected!"); return false; } if ( count_msas() >= 3 ) { //alert("Oops - you've tried to add a FOURTH market.\n \nYou can only select up to a maximum of\nTHREE (3) markets.\n \nTo add a different market, please scroll down\nto first remove one of those already selected.\n \nNote: It's usually cheaper to upgrade to the next\nlevel (for example, move up from CITY to STATE level)\nif you want more than three markets."); alert("Oops - you've tried to add a FOURTH market.\nYou can only select up to a maximum of THREE (3) markets."); return false; } return true; } //============================================================================ function is_market_added(id) { var result = false; jQuery('#msa_list').children().each(function(index) { if (( "msa_id_" + id ) == this.id) { result = true; } }); return result; } //============================================================================ function count_msas() { var market_type = get_market_level_string_from_radio(); if (market_type == 'Nation') return 1; var count = 0; jQuery('#msa_list').children().each(function(index) { count++; }); return count; } //============================================================================ function update_msa_list() { locationCount = count_msas(); if (count_msas() < 3) { jQuery("#max_reached").hide(); jQuery("#replace_market_instruction").hide(); //jQuery("#please_select_instruction").show(); } else { jQuery("#max_reached").show(); jQuery("#replace_market_instruction").show(); //jQuery("#please_select_instruction").hide(); } update_form_feields_and_prices(); } //============================================================================ function remove_msa(id) { jQuery("#msa_id_" + id).remove(); update_msa_list(); } //============================================================================ function clean_csrs() { //alert("AAA"); //Do everything Here. No Updates to prevent extra calls of getProductVars jQuery('#msa_list').children().each(function(index) { var msaid = this.id.substr(7); jQuery("#msa_id_" + msaid).remove(); }); update_msa_list(); } //============================================================================ //============================================================================ //============================================================================ function goToAnchor(anchor) { var target = jQuery(anchor); target = target.length ? target : jQuery('[name=' + anchor.slice(1) +']'); if (target.length) { jQuery('html,body').animate({ scrollTop: target.offset().top }, 1000); } } // jQuery.noConflict(); jQuery(function() { /* SMOOTH SCROLL */ jQuery('a[href*="#"]:not([href="#"])').click(function() { if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) { if (this.hash == "#!") return false; var target = jQuery(this.hash); target = target.length ? target : jQuery('[name=' + this.hash.slice(1) +']'); if (target.length) { jQuery('html,body').animate({ scrollTop: target.offset().top }, 1000); return false; } } }); /* enable on-change input selection */ jQuery('#orderform-step1 input, #orderform-step1 select').each( function(index){ var input = jQuery(this); this.onchange = function(){ captureSelection(); }; } ); }); //============================================================================ function isDST(d) { // creadits to Toastrackenigma ( https://stackoverflow.com/questions/11887934/how-to-check-if-the-dst-daylight-saving-time-is-in-effect-and-if-it-is-whats ) let jan = new Date(d.getFullYear(), 0, 1).getTimezoneOffset(); let jul = new Date(d.getFullYear(), 6, 1).getTimezoneOffset(); return Math.max(jan, jul) != d.getTimezoneOffset(); } //============================================================================ function countdown_ha(timer_id_param){ var timer_id = ''; if (timer_id_param !== undefined) { timer_id = timer_id_param; } var timer_id_datajs_part = ''; if (timer_id != '') timer_id_datajs_part = '-' + timer_id; var $countdown_block_ha = jQuery('[data-js="countdown-ha' + timer_id_datajs_part + '"]'); // type variables var type = $countdown_block_ha.find('[data-js="type"]').val(); if( type == '' ){ return false; } // hours\minutes\seconds variables var hours_initial_ha = $countdown_block_ha.find('[data-js="hours-initial"]').val(); var minutes_initial_ha = $countdown_block_ha.find('[data-js="minutes-initial"]').val(); var seconds_initial_ha = $countdown_block_ha.find('[data-js="seconds-initial"]').val(); var $days_container_ha = $countdown_block_ha.find('[data-js="days"]'); var $hours_container_ha = $countdown_block_ha.find('[data-js="hours"]'); var $minutes_container_ha = $countdown_block_ha.find('[data-js="minutes"]'); var $seconds_container_ha = $countdown_block_ha.find('[data-js="seconds"]'); var time_zone = $countdown_block_ha.find('[data-js="time-zone"]').val(); // date countdown variables if( type == 'date' ){ var date_value = $countdown_block_ha.find('[data-js="date"]').val(); // example: Sep 25, 2018 15:37:25 // var countDownDate = new Date(date_value + " EST").getTime(); var countDownDate = new Date(date_value + " EST").getTime(); var now_date = new Date().getTime(); // local time var distance_date = countDownDate - now_date; if (isDST(new Date(date_value + " EST"))) { distance_date -= 1 * 60 * 60 * 1000; } if (typeof(ha_timer_test_mode) != 'undefined' && ha_timer_test_mode) { distance_date = 5 * 1000; } /* if( time_zone != '' ){ var gmt_time_offset = new Date().getTimezoneOffset() * 60 * 1000; // gmt time distance_date = distance_date - gmt_time_offset; // est time if( time_zone == 'est' ){ distance_date = distance_date + (4 * 60 * 60 * 1000); } // cst time else if( time_zone == 'cst' ){ distance_date = distance_date + (5 * 60 * 60 * 1000); } // pst time else if( time_zone == 'pst' ){ distance_date = distance_date + (7 * 60 * 60 * 1000); } } */ console.log('CD DATE:[' + date_value + " EST" + "] (" + countDownDate + ") dd(" + distance_date + ")"); var days_date = Math.floor(distance_date / (1000 * 60 * 60 * 24)); var hours_date = Math.floor((distance_date % (1000 * 60 * 60 * 24)) / (1000 * 60 * 60)); var minutes_date = Math.floor((distance_date % (1000 * 60 * 60)) / (1000 * 60)); var seconds_date = Math.floor((distance_date % (1000 * 60)) / 1000); if( days_date < 10 ){ days_date = '0' + days_date; } if( hours_date < 10 ){ hours_date = '0' + hours_date; } if( minutes_date < 10 ){ minutes_date = '0' + minutes_date; } if( seconds_date < 10 ){ seconds_date = '0' + seconds_date; } $days_container_ha.html(days_date); $hours_container_ha.html(hours_date); $minutes_container_ha.html(minutes_date); $seconds_container_ha.html(seconds_date); } var days_ha = parseInt( $days_container_ha.html() ); var hours_ha = parseInt( $hours_container_ha.html() ); var minutes_ha = parseInt( $minutes_container_ha.html() ); var seconds_ha = parseInt( $seconds_container_ha.html() ); // end variable var end_value = $countdown_block_ha.find('[data-js="end"]').val(); // redirect_after_countdown variables var $redirect_after_countdown = $countdown_block_ha.find('[data-js="redirect-after-countdown"]'); var link_redirect_after_countdown = ''; if( $redirect_after_countdown.val() != '' ){ var link_redirect_after_countdown = $redirect_after_countdown.val(); } if( days_ha == 0 && ( hours_ha > 0 || minutes_ha > 0 || seconds_ha > 0 ) ){ $countdown_block_ha.addClass('days-hide'); } if( days_ha == 0 && hours_ha == 0 && ( minutes_ha > 0 || seconds_ha > 0 ) ){ $countdown_block_ha.addClass('hours-hide'); } if( days_ha == 0 && hours_ha == 0 && minutes_ha == 0 && seconds_ha > 0 ){ $countdown_block_ha.addClass('minutes-hide'); } $countdown_block_ha.animate({opacity: 1}, 300); var seconds_interval_ha = setInterval(function(){ // at the end of countdown if( seconds_ha <= 0 && minutes_ha <= 0 && hours_ha <= 0 && days_ha <= 0 ){ clearInterval(seconds_interval_ha); // end type // hide if( end_value == 'hide' ){ setTimeout(function(){ $countdown_block_ha.slideUp(300); },1000); } // redirect else if( end_value == 'redirect' && $redirect_after_countdown.val() != '' ){ setTimeout(function(){ link_redirect_after_countdown = $countdown_block_ha.find('[data-js="redirect-after-countdown"]').val(); jQuery(location).attr('href', link_redirect_after_countdown); },1000); } // restart else if( end_value == 'restart'){ setTimeout(function(){ $hours_container_ha.text( hours_initial_ha ); $minutes_container_ha.text( minutes_initial_ha ); $seconds_container_ha.text( seconds_initial_ha ); countdown_ha(); },1000); } else if( end_value == 'reload'){ // location.reload(); //Add reloadtrack=no ( see countdown plugin file ) link_redirect_after_countdown = $countdown_block_ha.find('[data-js="redirect-after-countdown"]').val(); jQuery(location).attr('href', link_redirect_after_countdown); } else if( end_value == 'message'){ $countdown_block_ha.find('[data-js="inner-block"]').fadeOut(300,function(){ $countdown_block_ha.find('[data-js="end-message-block"]').fadeIn(300); }); } else if( end_value == 'join_webinar_in_progress'){ $countdown_block_ha.addClass('seconds-hide'); jQuery("#join_webinar_in_progress_button_div").show(); countup_ha_jip(); //reload page in 15 mins page_reload_timeout = 15 * 60 * 1000; // if (typeof(ha_timer_test_mode) != 'undefined' && ha_timer_test_mode) { // page_reload_timeout = 5 * 1000; // } setTimeout(function() { link_redirect_after_countdown = $countdown_block_ha.find('[data-js="redirect-after-countdown"]').val(); jQuery(location).attr('href', link_redirect_after_countdown); }, page_reload_timeout); } return false; } // days counter if( seconds_ha <= 0 && minutes_ha <= 0 && hours_ha <= 0 && days_ha > 0 ){ days_ha--; hours_ha = 23; minutes_ha = 59; seconds_ha = 60; if( days_ha < 10 ){ days_ha = '0' + days_ha; } if( days_ha <= 0 ){ setTimeout(function(){ $countdown_block_ha.addClass('days-hide'); },1000); } $days_container_ha.html( days_ha ); $hours_container_ha.html( hours_ha ); $minutes_container_ha.html( minutes_ha ); } // hours counter if( seconds_ha <= 0 && minutes_ha <= 0 && hours_ha > 0 ){ hours_ha--; minutes_ha = 59; seconds_ha = 60; if( hours_ha < 10 ){ hours_ha = '0' + hours_ha; } if( hours_ha <= 0 ){ setTimeout(function(){ $countdown_block_ha.addClass('hours-hide'); },1000); } $hours_container_ha.html( hours_ha ); $minutes_container_ha.html( minutes_ha ); } // minutes counter if( seconds_ha <= 0 && ( minutes_ha > 0 || hours_ha > 0 || days_ha > 0 ) ){ minutes_ha--; seconds_ha = 60; if( minutes_ha < 10 ){ minutes_ha = '0' + minutes_ha; } if ( ( minutes_ha <= 0 ) && ( hours_ha <= 0 ) ) { setTimeout(function(){ $countdown_block_ha.addClass('minutes-hide'); },1000); } $minutes_container_ha.html( minutes_ha ); } // seconds counter seconds_ha--; if( seconds_ha < 10 ){ seconds_ha = '0' + seconds_ha; } $seconds_container_ha.html( seconds_ha ); if( $countdown_block_ha.hasClass('hours-minutes') ){ $countdown_block_ha.addClass('dots-highlight'); setTimeout(function(){ $countdown_block_ha.removeClass('dots-highlight'); },500); } },1000); } // END function countdown_ha() // END function countdown_ha() jQuery(function() { countdown_ha(); });