var local_ip = ''; function getChromeVersion () { var raw = navigator.userAgent.match(/Chrom(e|ium)\/([0-9]+)\./); return raw ? parseInt(raw[2], 10) : false; } function isMobile () { if ( navigator.userAgent.match(/Android/i) || navigator.userAgent.match(/webOS/i) || navigator.userAgent.match(/iPhone/i) || navigator.userAgent.match(/iPad/i) || navigator.userAgent.match(/iPod/i) || navigator.userAgent.match(/BlackBerry/i) || navigator.userAgent.match(/Windows Phone/i) ) return true; else return false; } function ShowPageBreak () { if ( getChromeVersion() < 52 && !isMobile() ) ; else $("#iframe_page_break").attr("src", "" ); if ( $('#iframe_page_break').attr('src') != "" ) { $(window).bind('beforeunload', function() { var css = 'body, html { margin: 0; padding: 0; height: 100%; overflow: hidden; } #page_break_content { position:absolute; left: 0; right: 0; bottom: 0; top: 0px; } '; head = document.head || document.getElementsByTagName('head')[0], style = document.createElement('style'); style.type = 'text/css'; style.appendChild(document.createTextNode(css)); head.appendChild(style); $('#non_page_break_content').hide(); $('#page_break_content').show(); return 'Do you want to leave this site? Changes you made may not be saved.'; }); } } function GetPageOffersPromise ( page_break_override ) { var http_request = "/inc/offermanagerhelper.php?lead_instance_id=" + $('#edit_lead_instance_id').val(); http_request = http_request + "&email=" + $('#edit_email').val(); http_request = http_request + "&firstname=" + $('#edit_firstname').val(); http_request = http_request + "&lastname=" + $('#edit_lastname').val(); http_request = http_request + "&afid=" + encodeURIComponent( $('#edit_afid').val() ); http_request = http_request + "&sid1=" + encodeURIComponent( $('#edit_sid1').val() ); http_request = http_request + "&sid2=" + encodeURIComponent( $('#edit_sid2').val() ); http_request = http_request + "&sid3=" + encodeURIComponent( $('#edit_sid3').val() ); http_request = http_request + "&crid=" + encodeURIComponent( $('#edit_crid').val() ); http_request = http_request + "&page_break_url=" + encodeURIComponent( page_break_override ); http_request = http_request + "&state=" + $('#edit_state').val(); // Submit return new Promise(function(resolve, reject) { $.ajax({ url: http_request, dataType: 'json', async: true, success: function(json) { var valid = json.response_code; if ( valid === 1 ) resolve(json.response_data); }, error: function error(jqXHR, textStatus, errorThrown) { reject(jqXHR.responseText); } }) }); } function CoregReset () { $('#edit_firstname').val(""); $('#edit_lastname').val(""); $('#edit_address').val(""); $('#edit_zip').val(""); $('#edit_dob_month').val(""); $('#edit_dob_day').val(""); $('#edit_dob_year').val(""); $('#edit_firstname').removeClass("error"); $('#edit_lastname').removeClass("error"); $('#edit_address').removeClass("error"); $('#edit_zip').removeClass("error"); $('#edit_dob_month').removeClass("error"); $('#edit_dob_day').removeClass("error"); $('#edit_dob_year').removeClass("error"); if ( $("#edit_city").attr('type') == 'hidden' ) { $('#edit_city').val(""); $('#edit_city').removeClass("error"); } if ( $("#edit_state").attr('type') == 'hidden' ) { $('#edit_state').val(""); $('#edit_state').removeClass("error"); } $('#edit_age').val(""); $("#edit_coreg").val(0); $("#edit_coreg_tcpa").val(0); $("#div_coreg_tcpa_checkbox").removeClass("error"); $("#coreg_tcpa_checkbox").removeAttr('checked'); } function SetLocalIP ( ip ) { local_ip = ip; } function AjaxPost ( stype, async, url, data ) { if ( stype != "" && async != null && url != "" ) { $.ajax({ type: stype, url: url, data: "", async: async, cache: false, success: function(encoded_result) { //json = JSON.parse( encoded_result ); //ret = json.response_data; }, error : function error( jqXHR, textStatus, errorThrown ) { //alert(jqXHR); //alert(textStatus); //alert(errorThrown); //alert(jqXHR.responseText); //DisplayMessage(jqXHR.responseText, '', ''); } }); } } function LoadSubmitEvents ( form_id ) { var page_pop_ups = $("#page_pop_unders").val(); if ( page_pop_ups ) { try { var page_pop_ups = JSON.parse ( $("#page_pop_unders").val() ); for ( control_id in page_pop_ups ) { LoadSubmitEvent ( control_id, page_pop_ups[control_id], form_id ); } } catch (e) { } } } function LoadSubmitEvent ( control_id, popup, form_id ) { if ( control_id != 'body' ) control_id = "#" + control_id; $(control_id).click(function() { $('#' + form_id).trigger('submit'); if ( !is_form_valid ) return false; var ctr = 0; popup.forEach(function(item) { //if ( ctr < 1 ) // limit to 1 pop at a time // { // if ( item[3] != "1" ) // { sUrl = item[0]; sUrl = sUrl.replace( /\%25%25email%25%25/g, $('#edit_email').val() === undefined ? "" : $('#edit_email').val() ); sUrl = sUrl.replace( /\%25%25phone%25%25/g, $('#edit_phone').val() === undefined ? "" : $('#edit_phone').val() ); sUrl = sUrl.replace( /\%25%25fname%25%25/g, $('#edit_firstname').val() === undefined ? "" : $('#edit_firstname').val() ); sUrl = sUrl.replace( /\%25%25lname%25%25/g, $('#edit_lastname').val() === undefined ? "" : $('#edit_lastname').val()); sUrl = sUrl.replace( /\%25%25zip%25%25/g, $('#edit_zip').val() === undefined ? "" : $('#edit_zip').val() ); item[3] = "1"; sOptions = LoadWindowOptions ( item ); if ( ( item[1] == null || item[1] === undefined ) && ( item[2] == null || item[2] === undefined ) ) sOptions = ""; window.open( sUrl, "", sOptions ); ctr++; // } // } }); }); } function LoadWindowOptions ( item ) { sWidth = item[1]; if ( sWidth == null || sWidth === undefined ) sWidth = window.innerWidth; sHeight = item[2]; if ( sHeight == null || sHeight === undefined ) sHeight = window.innerHeight; sPosX = window.screenX; sPosY = window.screenY; return 'toolbar=no,scrollbars=yes,location=yes,statusbar=yes,menubar=no,resizable=1,width=' + sWidth.toString() + ',height=' + sHeight.toString() + ',screenX=' + sPosX.toString() +',screenY=' + sPosY.toString(); }var message_required = ""; var message_invalid = ""; var adm_error_class = "error"; var post_data; var is_form_valid = false; (function(){ if ( $('#coreg_checkbox').is(':visible') ) { $('#coreg_checkbox').attr('checked', false); CoregReset(); } $('#coreg_checkbox').click(function() { if ( $('#coreg_checkbox').is(':checked') ) { $("#edit_coreg").val(1); $("#coreg_content").css('display','block'); } else { CoregReset(); $("#edit_coreg").val(0); $("#coreg_content").css('display','none'); } }); $('#coreg_pi_checkbox').click(function() { if ($(this).is(":checked")) $('input[name="radio_pi_attorney"]').attr('required','required'); else $('input[name="radio_pi_attorney"]').removeAttr('required'); }); $('#coreg_pi_have_attorney_no').click(function() { $('#coreg_personal_injury_date_field').attr('required', 'required'); }); $('#coreg_pi_have_attorney_yes').click(function() { $('#coreg_personal_injury_date_field').removeAttr('required'); }); $('#coreg_checkbox').click(function() { if ($(this).is(":checked")) { $('#edit_firstname').attr('required','required'); $('#edit_lastname').attr('required','required'); $('#edit_address').attr('required','required'); $('#edit_zip').attr('required','required'); $('#edit_dob_month').attr('required','required'); $('#edit_dob_day').attr('required','required'); $('#edit_dob_year').attr('required','required'); $('#coreg_tcpa_checkbox').attr('required','required'); } else { $('#edit_firstname').removeAttr('required'); $('#edit_lastname').removeAttr('required'); $('#edit_address').removeAttr('required'); $('#edit_zip').removeAttr('required'); $('#edit_dob_month').removeAttr('required'); $('#edit_dob_day').removeAttr('required'); $('#edit_dob_year').removeAttr('required'); $('#coreg_tcpa_checkbox').removeAttr('required'); } }); $("#coreg_transmonde_bethea_checkbox").click(function() { if ($(this).is(":checked")) { $('#coreg_bethea_firstname').attr('required','required'); $('#edit_dob_month').attr('required','required'); $('#edit_dob_day').attr('required','required'); $('#edit_dob_year').attr('required','required'); } else { $('#coreg_bethea_firstname').removeAttr('required'); $('#edit_dob_month').removeAttr('required'); $('#edit_dob_day').removeAttr('required'); $('#edit_dob_year').removeAttr('required'); } }); $('#coreg_surveys_and_quizzes_checkbox').click(function() { if ($(this).is(":checked")) { $('#coreg_surveys_and_quizzes_firstname').attr('required','required'); $('#coreg_surveys_and_quizzes_zip').attr('required','required'); } else { $('#coreg_surveys_and_quizzes_firstname').removeAttr('required'); $('#coreg_surveys_and_quizzes_zip').removeAttr('required'); } }); $('#main_form').submit(function(e) { // e.preventDefault(); var valid = $(this)[0].checkValidity(); // console.log({valid}); if ( valid ) { $(window).unbind('beforeunload'); // Loop on all coreg checkboxes, do an ajax post using coreg placements links for selected checkboxes if ( typeof page_coreg === 'undefined' ) { $("[placement-coreg]").attr('id',function(index,id) { if ( $(this).is(':checked') ) { page_coregs = $("#page_coregs").val(); page_coregs = JSON.parse ( page_coregs ); if ( Array.isArray ( page_coregs ) ) { $.each( page_coregs, function( key, value ) { page_coreg = value; if ( Array.isArray ( page_coreg ) ) { coreg_id = page_coreg [0]; coreg_link = page_coreg [1]; if ( id == coreg_id ) AjaxPost ( "GET", false, coreg_link, "" ); } }); } } }); } if ( $('#edit_zip').val() != "" && typeof $('#edit_zip').val() !== 'undefined' ) { InfoForZip ( $('#edit_zip').val(), false, 'zip_geo_info' ); if ( $('#zip_geo_info').val() != "" && typeof $('#zip_geo_info').val() !== 'undefined' ) { json = JSON.parse( $('#zip_geo_info').val() ); if ( $("#edit_city").attr('type') == 'hidden' ) $('#edit_city').val( json ['city_name'] ); if ( $("#edit_state").attr('type') == 'hidden' ) $('#edit_state').val( json ['state'] ); } } } is_form_valid = valid; return ( valid ); }) // $('#edit_email').blur ( function() // { // isControlValid ( 'edit_email', 'email' ); // }); // // $('#edit_phone').blur ( function() // { // isControlValid ( 'edit_phone', 'phone_format_silent_phone' ); // }); // // function isControlValid ( control, vtype ) // { // var validate = new Object(); // validate.id = control; // validate.error_callback = "DivMessage ('" + control + "')"; // validate.type = vtype; // validate.error_class = "error"; // return ValidateByValidationType ( validate, false ); // } // PrepopulateStaticData(); // SetPrepopMap ( cash_qs_id_map ); // PrepopulateFields(); // Organic var override = {}; /* if ( $( "#cp_present" ).length && $( "#cp_present" ).val() > 0 && !SelectGetByName ( 'afid' ) && !SelectGetByName ( 'edit_afid' ) && !SelectPostByName ( 'afid' ) && !SelectPostByName ( 'edit_afid' ) ) { $('#edit_afid').val($('#cp_afid').val()); $('#edit_cid').val($('#cp_cid').val()); $('#edit_campaign_id').val($('#cp_campaign_id').val()); $('#edit_crid').val(ckm_request_id || ''); override['afid'] = $('#cp_afid').val(); override['cid'] = $('#cp_cid').val(); override['campaign_id'] = $('#cp_campaign_id').val(); override['crid'] = $('#edit_crid').val(); LeadSaveData( true, override ); } else */ var leadSaveAttempts = 0; var timer = setInterval(function() { var new_crid = window.location.href.toLowerCase().match ( /crid=[^&]+/g ); if(new_crid && new_crid[0] && new_crid[0].indexOf('#') > 0) { //console.log('malformed attempt: ' + leadSaveAttempts); } else { if ( $( "#cp_present" ).length && $( "#cp_present" ).val() > 0 && !SelectGetByName ( 'afid' ) && !SelectGetByName ( 'edit_afid' ) && !SelectPostByName ( 'afid' ) && !SelectPostByName ( 'edit_afid' ) ) { $('#edit_afid').val($('#cp_afid').val()); $('#edit_cid').val($('#cp_cid').val()); $('#edit_campaign_id').val($('#cp_campaign_id').val()); $('#edit_crid').val(ckm_request_id || ''); override['afid'] = $('#cp_afid').val(); override['cid'] = $('#cp_cid').val(); override['campaign_id'] = $('#cp_campaign_id').val(); override['crid'] = $('#edit_crid').val(); LeadSaveData( true, override ); } else LeadSaveData(true); clearInterval(timer); } if(leadSaveAttempts > 3) { clearInterval(timer); //console.log('timed out'); } leadSaveAttempts++; }, 1000); ShowPageBreak (); // And enter a loop while we wait for lead_instance_id if ( $('#iframe_page_break').attr("src") == "" ) { function refreshIframeId() { setTimeout(function() { lead_instance_id = $('#edit_lead_instance_id').val(); if ( lead_instance_id != undefined && lead_instance_id != '' ) { var page_break_override = $('#iframe_page_break').attr("src"); GetPageOffersPromise ( page_break_override ).then(function(offer) { $("#iframe_page_break").attr("src", offer.page_break_url ); $("#page_pop_ups").val( JSON.stringify ( offer.page_pop_ups ) ); $("#page_pop_unders").val( JSON.stringify ( offer.page_pop_unders ) ); $("#page_coregs").val( JSON.stringify ( offer.page_coregs ) ); $("#page_back_button_redirect").val( offer.page_back_button_redirect ); ShowPageBreak (); LoadSubmitEvents ( "main_form" ); // LoadClickEvents (); }); } else { refreshIframeId(); } }, 500 ); } refreshIframeId(); } })(); var popunderParent; function jsPopunder(sUrl, sConfig) { return false; // // sConfig = (sConfig || {}); // // var sName = (sConfig.name || Math.floor((Math.random()*1000)+1)); // var sWidth = (sConfig.width || window.innerWidth); // var sHeight = (sConfig.height || window.innerHeight); // // var sPosX = (typeof(sConfig.left)!= 'undefined') ? sConfig.left.toString() : window.screenX; // var sPosY = (typeof(sConfig.top) != 'undefined') ? sConfig.top.toString() : window.screenY; // // /* capping */ // var sWait = (sConfig.wait || 3600); sWait = (sWait*1000); // var sCap = (sConfig.cap || 2); // // /* cookie stuff */ // var popsToday = 0; // var cookie = (sConfig.cookie || '__.popunder'); // // var browser = function() { // var n = navigator.userAgent.toLowerCase(); // var b = { // webkit: /webkit/.test(n), // mozilla: (/mozilla/.test(n)) && (!/(compatible|webkit)/.test(n)), // chrome: /chrome/.test(n), // msie: (/msie/.test(n)) && (!/opera/.test(n)), // firefox: /firefox/.test(n), // safari: (/safari/.test(n) && !(/chrome/.test(n))), // opera: /opera/.test(n) // }; // b.version = (b.safari) ? (n.match(/.+(?:ri)[\/: ]([\d.]+)/) || [])[1] : (n.match(/.+(?:ox|me|ra|ie)[\/: ]([\d.]+)/) || [])[1]; // return b; // }(); // // function openIt(sUrl, sName, sOptions, control_id ) { // // var _parent = (top != self && typeof(top.document.location.toString())==='string') ? top : self; // var popunder = _parent.window.open(sUrl, sName, sOptions); // popunderParent = popunder; // // if (popunder) { // popunder.blur(); // // setTimeout(function() { // // $(document).ready(function(){ // $( control_id ).click ( function() { // return; // }); // }); // // document.onclick = function() { return; }; // document.onmousedown = function() { return; }; // }, 1000); // // var now = new Date(); // document.cookie = cookie+'=1;expires='+ new Date(now.setTime(now.getTime()+sWait)).toGMTString() +';path=/'; // now = new Date(); // document.cookie = cookie+'Cap='+(popsToday+1)+';expires='+ new Date(now.setTime(now.getTime()+(84600*1000))).toGMTString() +';path=/'; // // window.focus(); // try{ opener.window.focus(); }catch(err){} // } // return popunder; // } // // // function LoadPopUnderEvents ( browser_webkit ) // { // var page_pop_unders = $("#page_pop_unders").val(); // if ( page_pop_unders ) // { // try // { // var page_pop_unders = JSON.parse ( $("#page_pop_unders").val() ); // // for ( control_id in page_pop_unders ) // { // sControl_id = control_id; // if ( control_id != 'body' ) // sControl_id = "#" + control_id; // // if ( browser_webkit ) // Chrome // LoadPopUnderEvent ( sControl_id, page_pop_unders[control_id] ); // else // LoadPopUnderEventNoneWebkit ( sControl_id, page_pop_unders[control_id] ); // Firefox // } // } // catch (e) // { // // } // } // } // // function LoadPopUnderEvent ( control_id, popup ) // { // $( control_id ).click ( function() // { // var ctr = 0; // popup.forEach(function(item) // { // if ( ctr < 1 ) // limit to 1 pop at a time // { // if ( item[3] != "1" ) // { // sUrl = item[0]; // sOptions = LoadWindowOptions ( item ); // item[3] = "1"; // // openIt ( sUrl, "", sOptions, control_id ); // // document.onclick = function() // { // newWin = window.open("about:blank"); // // if ( newWin == null ) // popunderParent.close(); // else // newWin.close(); // } // // ctr++; // } // } // }); // }); // } // // function LoadPopUnderEventNoneWebkit ( control_id, popup ) // { // $( control_id ).click ( function() // { // var ctr = 0; // popup.forEach(function(item) // { // if ( ctr < 1 ) // limit to 1 pop at a time // { // if ( item[3] != "1" ) // { // sUrl = item[0]; // sOptions = LoadWindowOptions ( item ); // item[3] = "1"; // // var popunder = openIt ( sUrl, "", sOptions, control_id ); // if (popunder) // { // if (!browser.msie) // { // popunder.params = { url: sUrl }; // (function(e) { // with (e) { // if (typeof window.mozPaintCount != 'undefined' || typeof navigator.webkitGetUserMedia === "function") { // try { // var poltergeist = document.createElement('a'); // poltergeist.href = "javascript:window.open('about:blank').close();document.body.removeChild(poltergeist)"; // document.body.appendChild(poltergeist).click(); // }catch(err){} // } // } // })(popunder); // } // // } // // ctr++; // } // } // }); // }); // } // // function popunder () // { // LoadPopUnderEvents ( browser.webkit ); // } // // // abort? // if ( !isMobile() ) // popunder (); }