var BASE_PATH = "https://leads.nsightlive.com/renderer/campaignView?accessCode=9dc8ac4e-6b4a-4469-963d-846583bfb722"; var appearanceDelayOverride = 30; appearanceDelayOverride = (45*1000); var reappearanceDelayOverride =120; reappearanceDelayOverride = (800 *1000);var newvalue = 0; var reappearanceDelayOverride2 =180; reappearanceDelayOverride2 = (800 *1000); var UrlSpecificappearanceDelayOverride = 30; UrlSpecificappearanceDelayOverride = (UrlSpecificappearanceDelayOverride*1000); var UrlSpecificreappearanceDelayOverride =120; UrlSpecificreappearanceDelayOverride = (UrlSpecificreappearanceDelayOverride *1000);var UrlSpecificreappearanceDelayOverride2 =180; UrlSpecificreappearanceDelayOverride2 = (UrlSpecificreappearanceDelayOverride2 *1000); var UrlSpecific2appearanceDelayOverride = 30; UrlSpecific2appearanceDelayOverride = (UrlSpecific2appearanceDelayOverride*1000); var UrlSpecific2reappearanceDelayOverride =120; UrlSpecific2reappearanceDelayOverride = (UrlSpecific2reappearanceDelayOverride *1000);var UrlSpecific2reappearanceDelayOverride2 =180; UrlSpecific2reappearanceDelayOverride2 = (UrlSpecific2reappearanceDelayOverride2 *1000); var PartialMessageTimer =25; PartialMessageTimer = (60 * 1000); var WebSitePath1 =""; var WebSitePath2 =""; var WebSitePathRedirect=""; var LeadSource1 = "LeadSurge"; var LeadSource2 = "LeadSurge"; var LeadSource3 = "LeadSurge"; var LeadSource4 = "LeadSurge"; var LeadSource5 = "LeadSurge"; var LeadSource =""; var CampaignId=""; var countForbell = 0; var DisplayForm1= "True"; var DisplayForm2= "True"; var DisplayForm3= "True"; var DisplayForm4= "True"; var DisplayForm5= "True"; var docCookies = { // see https://developer.mozilla.org/en-US/docs/Web/API/Document/cookie/Simple_document.cookie_framework getItem: function (sKey) { if (!sKey) { return null; } return decodeURIComponent(document.cookie.replace(new RegExp("(?:(?:^|.*;)\\s*" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=\\s*([^;]*).*$)|^.*$"), "$1")) || null; }, setItem: function (sKey, sValue, vEnd, sPath, sDomain, bSecure) { // if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; } var sExpires = ""; /* if (vEnd) { switch (vEnd.constructor) { case Number: sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; max-age=" + vEnd + ";Secure"; /* Note: Despite officially defined in RFC 6265, the use of `max-age` is not compatible with any version of Internet Explorer, Edge and some mobile browsers. Therefore passing a number to the end parameter might not work as expected. A possible solution might be to convert the the relative time to an absolute time. For instance, replacing the previous line with: */ //sExpires = vEnd === Infinity ? "; expires=Fri, 31 Dec 9999 23:59:59 GMT" : "; expires=" + (new Date(vEnd * 1e3 + Date.now())).toUTCString(); /* break; case String: sExpires = "; expires=" + vEnd + ";Secure"; break; case Date: sExpires = "; expires=" + vEnd.toUTCString() + ";Secure"; break; } }*/ //document.cookie = encodeURIComponent(sKey) + "=" + encodeURIComponent(sValue) + sExpires + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + (bSecure ? "; secure" : ""); setCookieNsight(encodeURIComponent(sKey), encodeURIComponent(sValue), 1); return true; }, removeItem: function (sKey, sPath, sDomain) { if (!this.hasItem(sKey)) { return false; } document.cookie = encodeURIComponent(sKey) + "=; expires=Thu, 01 Jan 1970 00:00:00 GMT" + (sDomain ? "; domain=" + sDomain : "") + (sPath ? "; path=" + sPath : "") + ";Secure"; return true; }, hasItem: function (sKey) { if (!sKey || /^(?:expires|max\-age|path|domain|secure)$/i.test(sKey)) { return false; } return (new RegExp("(?:^|;\\s*)" + encodeURIComponent(sKey).replace(/[\-\.\+\*]/g, "\\$&") + "\\s*\\=")).test(document.cookie); }, keys: function () { var aKeys = document.cookie.replace(/((?:^|\s*;)[^\=]+)(?=;|$)|^\s*|\s*(?:\=[^;]*)?(?:\1|$)/g, "").split(/\s*(?:\=[^;]*)?;\s*/); for (var nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) { aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]); } return aKeys; } }; //function openNewBackgroundTab() { // var a = document.getElementById("nextForm").href; // //document.getElementById('nsCloseBtn').onclick = function () { // //alert(a); // window.open(a, "_blank", "toolbar=yes,scrollbars=yes,resizable=yes,top=500,left=500,width=200,height=200"); // //}; //} function getAllCookieValues() { var cookies = document.cookie.split(';'); var cookieValues = {}; for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i].trim(); var cookieParts = cookie.split('='); var cookieName = cookieParts[0]; var cookieValue = decodeURIComponent(cookieParts[1]); cookieValues[cookieName] = cookieValue; } return cookieValues; } function getCookieExpirationDate(cookieName) { // Get the cookie string var cookies = document.cookie.split(';'); // Loop through each cookie to find the one with the given name for (var i = 0; i < cookies.length; i++) { var cookie = cookies[i].trim(); // Check if the cookie name matches if (cookie.substring(0, cookieName.length) === cookieName) { // Extract the expiration date from the cookie string var expirationString = cookie.substring(cookieName.length + 1); var expirationDate = new Date(expirationString); // Check if the expiration date is valid if (!isNaN(expirationDate.getTime())) { return expirationDate; } } } // If cookie not found or date parsing fails, return null return "none"; } function setCookieNsight(cookieName, cookieValue, expirationDays) { var expirationDate = new Date(); expirationDate.setDate(expirationDate.getDate() + expirationDays); var cookieString = cookieName + "=" + encodeURIComponent(cookieValue) + ";expires=" + expirationDate.toUTCString() + ";path=/"; document.cookie = cookieString; } // // var cookieString = "Pierre" + "=" + encodeURIComponent("pierre") + ";expires=" + expirationDate.toUTCString() + ";path=/"; //document.cookie = cookieString; function setAllCookiesExpiration(cookieName, cnewvalue) { if (docCookies.hasItem(cookieName) == "none") { //document.cookie = cookieName + '=' + cnewvalue;// + ';expires=' + expirationTime.toUTCString() + ';path=/'; // setCookieNsight(cookieName, cnewvalue, 1); var expirationDate = new Date(); expirationDate.setDate(expirationDate.getDate() + expirationDays); //(sKey, sValue, vEnd, sPath, sDomain, bSecure) docCookies.setItem(cookieName, cnewvalue, expirationDate.toUTCString(),"","",""); } else { // document.cookie = cookieName + "=" + cnewvalue; docCookies.setItem(cookieName, cnewvalue); } } function returnimage(value, value1, value2) { if (window.location.href.indexOf(value1) > -1 && value1.trim() != '') { //alert("this" + window.location.href.indexOf(value1)); return 3; } else if (window.location.href.indexOf(value2) > -1 && value2.trim() != '') { //alert("thissss" + window.location.href.indexOf(value2)); return 4; } else if (value > 2) { //alert("thissss222"); return 0; } else { //alert("thissss" + value); return value; } return value; } (function () { // appointmentFunction(); function loadContent() { var urlParams = new URLSearchParams(window.location.search); var clicked = urlParams.get('clicked'); if (clicked) { return; } var xhr = new XMLHttpRequest(); var closeModal = function () { document.getElementById('nsModal').style.display = 'none'; document.getElementById('nsReopen').style.display = 'block'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'none'; } } var openModal = function () { document.getElementById('nsModal').style.display = 'block'; document.getElementById('nsReopen').style.display = 'none'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'block'; } } function redirectURlModel(x, y, value) { if (window.getComputedStyle(x).display === "none" && window.getComputedStyle(y).display === "none" && value.trim() != '') { return true; } else { return false; } return false; } newvalue = parseInt(newvalue) || 0; newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); xhr.onreadystatechange = function (e) { if (xhr.readyState == 4 && xhr.status == 200) { function displayImageCase(newvalue) { switch (newvalue) { case 0: LeadSource = LeadSource1; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen1').style.display = 'block'; document.getElementById('closensModal1').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'block'; document.getElementById('FormImage1').style.display = 'block'; break; case 1: LeadSource = LeadSource2; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen2').style.display = 'block'; document.getElementById('closensModal2').style.display = 'block'; document.getElementById('FormText2').style.display = 'block'; document.getElementById('FormImage2').style.display = 'block'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 2: LeadSource = LeadSource3; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen3').style.display = 'block'; document.getElementById('closensModal3').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'block'; document.getElementById('FormImage3').style.display = 'block'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 3: LeadSource = LeadSource4; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen4').style.display = 'block'; document.getElementById('closensModal4').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'block'; document.getElementById('FormImage4').style.display = 'block'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 4: LeadSource = LeadSource5; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'block'; document.getElementById('closensModal5').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'block'; document.getElementById('FormImage5').style.display = 'block'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; } } var newDiv = document.createElement("div"); newDiv.innerHTML = xhr.responseText; document.body.insertBefore(newDiv, document.body.firstChild); document.getElementById('nsModalForm').style.display = 'none'; var bg = document.getElementsByClassName("ns-background"); for (var i = 0; i < bg.length; i++) { bg[i].onclick = function () { closeModal(); } } function validateEmail(email) { const re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; if (re.test(email.value)) { email.style.borderColor = "#ccc"; return true; } else { email.style.borderColor = "red"; return false; } return false; } function validate(valide) { const result = valide; const value = valide.value.trim(); if (value == '') { result.style.borderColor = "red"; return false; } else { result.style.borderColor = "#ccc"; return true; } return false; } function detectMobileDevice() { var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); var element = document.getElementById('text'); if (isMobile) { return true; // alert("You are using Mobile"); } else { // alert("You are using Desktop"); return false; } return false; } function logclickscount(ClickButton1Mobile , ClickOverlay1Mobile , ClickButton1Desktop , ClickOverlay1Desktop , ClickButton2Mobile , ClickOverlay2Mobile , ClickButton2Desktop , ClickOverlay2Desktop , ClickButton3Mobile , ClickOverlay3Mobile , ClickButton3Desktop , ClickOverlay3Desktop , ClickButton4Mobile , ClickOverlay4Mobile , ClickButton4Desktop , ClickOverlay4Desktop , ClickButton5Mobile , ClickOverlay5Mobile , ClickButton5Desktop , ClickOverlay5Desktop) { var campaignIds = document.querySelector('input[name=campaignId]').value; var posts1 = document.querySelector('input[name=LogUserClicks]').value; var formDatas = '{campaignId: "' + campaignIds + '",ClickButton1Desktop : ' + ClickButton1Desktop + ',ClickOverlay1Desktop : ' + ClickOverlay1Desktop + ',ClickButton2Desktop : ' + ClickButton2Desktop + ',ClickOverlay2Desktop : ' + ClickOverlay2Desktop + ',ClickButton3Desktop : ' + ClickButton3Desktop + ',ClickOverlay3Desktop : ' + ClickOverlay3Desktop + ',ClickButton4Desktop : ' + ClickButton4Desktop + ',ClickOverlay4Desktop : ' + ClickOverlay4Desktop + ',ClickButton5Desktop : ' + ClickButton5Desktop + ',ClickOverlay5Desktop : ' + ClickOverlay5Desktop + ',ClickButton1Mobile : ' + ClickButton1Mobile + ',ClickOverlay1Mobile : ' + ClickOverlay1Mobile + ',ClickButton2Mobile : ' + ClickButton2Mobile + ',ClickOverlay2Mobile : ' + ClickOverlay2Mobile + ',ClickButton3Mobile : ' + ClickButton3Mobile + ',ClickOverlay3Mobile : ' + ClickOverlay3Mobile + ',ClickButton4Mobile : ' + ClickButton4Mobile + ',ClickOverlay4Mobile : ' + ClickOverlay4Mobile + ',ClickButton5Mobile : ' + ClickButton5Mobile + ',ClickOverlay5Mobile : ' + ClickOverlay5Mobile + '}'; var ajax1 = new XMLHttpRequest(); ajax1.open('POST', posts1, true); ajax1.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); //ajax.setRequestHeader('Content-Length', formData.length; charset=utf-8); ajax1.send(formDatas); } displayImageCase(newvalue); var accessSource = document.querySelector('input[name=accessSource]').value; var campaignId = document.querySelector('input[name=campaignId]').value; var accessCode = document.querySelector('input[name=accessCode]').value; var sendlead = document.getElementById("nsModalSubmit"); sendlead.onclick = function () { if (validate(document.querySelector('input[name=firstName]')) == false || validate(document.querySelector('input[name=lastName]')) == false || validateEmail(document.querySelector('input[name=bestEmail]')) == false || validate(document.querySelector('input[name=bestPhone]')) == false) { //|| //validate(document.querySelector('input[name=make]')) == false || validate(document.querySelector('input[name=model]')) == false) { //alert(validateEmail(document.querySelector('input[name=bestEmail]')) + " " + validate(document.querySelector('input[name=bestPhone]'))); } else { if ((document.getElementById('AppointmentTimeForm').required == true && document.getElementById('AppoitmentdateForm').required == true) && (validate(document.getElementById("AppointmentTimeForm")) == false || validate(document.getElementById("AppoitmentdateForm")) == false)) { } else { var posts = document.querySelector('input[name=URL]').value; var lastName = document.querySelector('input[name=lastName]').value; var firstName = document.querySelector('input[name=firstName]').value; var bestEmail = document.querySelector('input[name=bestEmail]').value; var bestPhone = document.querySelector('input[name=bestPhone]').value; var makes = document.querySelector('input[name=make]').value; var model = document.querySelector('input[name=model]').value; var AppointmentTime = document.getElementById('AppointmentTimeForm').value; var Appoitmentdate = document.getElementById('AppoitmentdateForm').value; var comments = document.getElementById('comments').value; var formData = '{lastName: "' + lastName + '",firstName: "' + firstName + '",bestEmail: "' + bestEmail + '",bestPhone: "' + bestPhone + '",make: "' + makes + '", model: "' + model + '",accessSource: "' + accessSource + '",campaignId: "' + campaignId + '",accessCode: "' + accessCode + '",LeadSource: "' + LeadSource + '",Appoitmentdate: "' + Appoitmentdate + '",AppointmentTime: "' + AppointmentTime + '",comments: "' + comments + '"}'; var ajax = new XMLHttpRequest(); ajax.open('POST', posts, true); ajax.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); //ajax.setRequestHeader('Content-Length', formData.length; charset=utf-8); ajax.send(formData); document.getElementById('form_thanks').style.display = 'block'; document.getElementById('form_body').style.display = 'none'; } } }; var showoverlays = function () { var x = document.getElementById("myModal"); if (window.getComputedStyle(x).display === "none") { closeform(); } } var closeform = function () { document.getElementById('AgreementOverlay').style.display = 'none'; document.getElementById('form_thanks').style.display = 'none'; document.getElementById('form_body').style.display = 'block'; document.querySelector('input[name=lastName]').value = ''; document.querySelector('input[name=firstName]').value = ''; document.querySelector('input[name=bestEmail]').value = ''; document.querySelector('input[name=bestPhone]').value = ''; document.querySelector('input[name=make]').value = ''; document.querySelector('input[name=model]').value = ''; document.getElementById('hideoverlay').style.display = 'block'; document.getElementById('nsModalForm').style.display = 'none'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'none'; } }; var nsModalSubmitClose1 = document.getElementById("nsModalSubmitClose1"); nsModalSubmitClose1.onclick = function () { closeform(); closeThisModel(); }; var nsModalSubmitClose2 = document.getElementById("nsModalSubmitClose2"); nsModalSubmitClose2.onclick = function () { closeform(); }; var closensReopen = document.getElementById("closensReopen"); closensReopen.onclick = function () { var x = document.getElementById("Reopen4"); var y = document.getElementById("Reopen5"); var value = WebSitePathRedirect; if (redirectURlModel(x, y, value) === true) { location.href = value; } else { document.getElementById('hideoverlay').style.display = 'none'; document.getElementById('nsModalForm').style.display = 'block'; document.getElementById("nsModalForm").focus(); window.location = '#nsModalForm'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'block'; } } if (detectMobileDevice()) { switch (newvalue) { case 0: logclickscount(1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); break; case 1: logclickscount(0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); break; case 2: logclickscount(0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); break; case 3: logclickscount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0); break; case 4: logclickscount(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0); } } else { switch (newvalue) { case 0: logclickscount(0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); break; case 1: logclickscount(0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); break; case 2: logclickscount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0); break; case 3: logclickscount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0); break; case 4: logclickscount(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0); } } ReopenhideformShowMessageList(); }; var closensModal = document.getElementById("closensModal"); closensModal.onclick = function () { var x = document.getElementById("closensModal4"); var y = document.getElementById("closensModal5"); var value = WebSitePathRedirect; if (redirectURlModel(x, y, value) === true) { location.href = value; } else { document.getElementById('hideoverlay').style.display = 'none'; document.getElementById('nsModalForm').style.display = 'block'; document.getElementById("nsModalForm").focus(); window.location = '#nsModalForm'; //appointmentFunctionForm(); var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'block'; } } if (detectMobileDevice()) { switch (newvalue) { case 0: logclickscount(0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); break; case 1: logclickscount(0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); break; case 2: logclickscount(0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); break; case 3: logclickscount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0); break; case 4: logclickscount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0); } } else { switch (newvalue) { case 0: logclickscount(0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); break; case 1: logclickscount(0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); break; case 2: logclickscount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0); break; case 3: logclickscount(0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0); break; case 4: logclickscount(1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1); } } closensModalhideformShowMessageList(); //detectMobileDevice(); }; var ImagescookieName = 'image-state'; var close = document.getElementById("nsCloseBtn"); var Globaltimer = 'globaltimer'; //// url spesific2 /// var UrlSpecific2CookieName = 'ns-modal-stateUrlSpecific2'; //// url spesific /// var UrlSpecificCookieName = 'ns-modal-stateUrlSpecific'; var UrlSpecificTime = 'urlspecifictime'; var UrlSpecific2Time = 'urlspecific2time'; function closeThisModel() { newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); closeModal(); if (docCookies.hasItem("image-state")) { newvalue = parseInt(docCookies.getItem('image-state')) || 0; newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); newvalue = parseInt(newvalue) + 1; //document.cookie = "image-state=" + newvalue; setAllCookiesExpiration("image-state", newvalue); } else { newvalue = parseInt(newvalue) + 1; //document.cookie = "image-state=" + newvalue; setAllCookiesExpiration("image-state", newvalue); } newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); if (newvalue > 2) { if (newvalue == 3) { if (docCookies.hasItem(UrlSpecificCookieName)) { if (docCookies.hasItem(UrlSpecificTime)) { UrlSpecificappearanceDelayOverride = parseInt(docCookies.getItem(UrlSpecificTime)); } if (UrlSpecificappearanceDelayOverride == UrlSpecificreappearanceDelayOverride) { //document.cookie = UrlSpecificTime + "=" + UrlSpecificreappearanceDelayOverride2; setAllCookiesExpiration(UrlSpecificTime, UrlSpecificreappearanceDelayOverride2); UrlSpecificappearanceDelayOverride = parseInt(docCookies.getItem(UrlSpecificTime)); } else if (UrlSpecificappearanceDelayOverride == UrlSpecificreappearanceDelayOverride2) { } else { // document.cookie = UrlSpecificTime + "=" + UrlSpecificreappearanceDelayOverride ; setAllCookiesExpiration(UrlSpecificTime, UrlSpecificreappearanceDelayOverride); UrlSpecificappearanceDelayOverride = parseInt(docCookies.getItem(UrlSpecificTime)); } } else { } setTimeout(function () { var bg = document.getElementsByClassName("ns-background"); for (var i = 0; i < bg.length; i++) { document.getElementById('nsModal').style.display = 'block'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'block'; } var reOpen = document.getElementById("nsReopen"); reOpen.style.display = 'none'; } newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); displayImageCase(newvalue); }, UrlSpecificappearanceDelayOverride); } if (newvalue == 4) { if (docCookies.hasItem(UrlSpecific2CookieName)) { if (docCookies.hasItem(UrlSpecific2Time)) { UrlSpecificappearanceDelayOverride = parseInt(docCookies.getItem(UrlSpecific2Time)); } if (UrlSpecific2appearanceDelayOverride == UrlSpecific2reappearanceDelayOverride) { //document.cookie = UrlSpecific2Time + "=" + UrlSpecific2reappearanceDelayOverride2 ; setAllCookiesExpiration(UrlSpecific2Time, UrlSpecific2reappearanceDelayOverride2); UrlSpecific2appearanceDelayOverride = parseInt(docCookies.getItem(UrlSpecific2Time)); } else if (UrlSpecific2appearanceDelayOverride == UrlSpecific2reappearanceDelayOverride2) { } else { // document.cookie = UrlSpecific2Time + "=" + UrlSpecific2reappearanceDelayOverride; setAllCookiesExpiration(UrlSpecific2Time, UrlSpecific2reappearanceDelayOverride); UrlSpecific2appearanceDelayOverride = parseInt(docCookies.getItem(UrlSpecific2Time)); } } else { } setTimeout(function () { var bg = document.getElementsByClassName("ns-background"); for (var i = 0; i < bg.length; i++) { document.getElementById('nsModal').style.display = 'block'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'block'; } var reOpen = document.getElementById("nsReopen"); reOpen.style.display = 'none'; } newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); displayImageCase(newvalue); }, UrlSpecific2appearanceDelayOverride); } } else { //document.cookie = "image-state=" + newvalue + "; if (docCookies.hasItem("image-state")) { if (docCookies.hasItem(Globaltimer)) { appearanceDelayOverride = parseInt(docCookies.getItem('globaltimer')); } if (appearanceDelayOverride == reappearanceDelayOverride) { //document.cookie = "globaltimer=" + reappearanceDelayOverride2; setAllCookiesExpiration("globaltimer", reappearanceDelayOverride2); appearanceDelayOverride = parseInt(docCookies.getItem('globaltimer')); //setAllCookiesExpiration("globaltimer"); } else if (appearanceDelayOverride == reappearanceDelayOverride2) { } else { //document.cookie = "globaltimer=" + reappearanceDelayOverride; setAllCookiesExpiration("globaltimer", reappearanceDelayOverride); appearanceDelayOverride = parseInt(docCookies.getItem('globaltimer')); //setAllCookiesExpiration("globaltimer"); } } else { } setTimeout(function () { // create displayed cookie var bg = document.getElementsByClassName("ns-background"); for (var i = 0; i < bg.length; i++) { document.getElementById('nsModal').style.display = 'block'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'block'; } var reOpen = document.getElementById("nsReopen"); reOpen.style.display = 'none'; } newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); //alert(readCookie("image-state") + " " + newvalue); displayImageCase(newvalue); //if (docCookies.hasItem("image-state")) { // newvalue = parseInt(docCookies.getItem('image-state')) || 0; // newvalue = parseInt(newvalue) + 1; // document.cookie = "image-state=" + newvalue + ";Secure"; //} else { // newvalue = parseInt(newvalue) + 1; // document.cookie = "image-state=" + newvalue + ";Secure"; // } }, appearanceDelayOverride); //openNewBackgroundTab(); } }; close.onclick = closeThisModel; var launchLinks = document.getElementsByClassName("ns-launch-link"); var zChar = new Array(' ', '(', ')', '-', '.'); var maxphonelength = 14; var phonevalue1; var phonevalue2; var cursorposition; function ParseForNumber1(object) { phonevalue1 = ParseChar(object.value, zChar); } function ParseForNumber2(object) { phonevalue2 = ParseChar(object.value, zChar); } function backspacerUP(object, e) { if (e) { e = e } else { e = window.event } if (e.which) { var keycode = e.which } else { var keycode = e.keyCode } ParseForNumber1(object) if (keycode >= 48) { ValidatePhone(object) } } function backspacerDOWN(object, e) { if (e) { e = e } else { e = window.event } if (e.which) { var keycode = e.which } else { var keycode = e.keyCode } ParseForNumber2(object) } function GetCursorPosition() { var t1 = phonevalue1; var t2 = phonevalue2; var bool = false for (i = 0; i < t1.length; i++) { if (t1.substring(i, 1) != t2.substring(i, 1)) { if (!bool) { cursorposition = i bool = true } } } } function ValidatePhone(object) { var p = phonevalue1 p = p.replace(/[^\d]*/gi, "") if (p.length < 4) { object.value = p } else if (p.length == 4) { pp = p; d4 = p.indexOf('') d5 = p.indexOf('') if (d4 == -1) { pp = "" + pp; } if (d5 == -1) { pp = pp + ""; } object.value = pp; } else if (p.length > 5 && p.length < 9) { p = "(" + p; l30 = p.length; p30 = p.substring(0, 4); p30 = p30 + ") " p31 = p.substring(4, l30); pp = p30 + p31; object.value = pp; } else if (p.length >= 9) { p = "(" + p; l30 = p.length; p30 = p.substring(0, 4); p30 = p30 + ") " p31 = p.substring(4, l30); pp = p30 + p31; l40 = pp.length; p40 = pp.substring(0, 9); p40 = p40 + "-" p41 = pp.substring(9, l40); ppp = p40 + p41; object.value = ppp.substring(0, maxphonelength); } GetCursorPosition() if (cursorposition >= 0) { if (cursorposition == 0) { cursorposition = 2 } else if (cursorposition <= 2) { cursorposition = cursorposition + 1 } else if (cursorposition <= 5) { cursorposition = cursorposition + 2 } else if (cursorposition == 6) { cursorposition = cursorposition + 2 } else if (cursorposition == 7) { cursorposition = cursorposition + 4 e1 = object.value.indexOf(')') e2 = object.value.indexOf('-') if (e1 > -1 && e2 > -1) { if (e2 - e1 == 4) { cursorposition = cursorposition - 1 } } } else if (cursorposition < 11) { cursorposition = cursorposition + 3 } else if (cursorposition == 11) { cursorposition = cursorposition + 1 } else if (cursorposition >= 12) { cursorposition = cursorposition } var txtRange = object.createTextRange(); txtRange.moveStart("character", cursorposition); txtRange.moveEnd("character", cursorposition - object.value.length); txtRange.select(); } } function ParseChar(sStr, sChar) { if (sChar.length == null) { zChar = new Array(sChar); } else zChar = sChar; for (i = 0; i < zChar.length; i++) { sNewStr = ""; var iStart = 0; var iEnd = sStr.indexOf(sChar[i]); while (iEnd != -1) { sNewStr += sStr.substring(iStart, iEnd); iStart = iEnd + 1; iEnd = sStr.indexOf(sChar[i], iStart); } sNewStr += sStr.substring(sStr.lastIndexOf(sChar[i]) + 1, sStr.length); sStr = sNewStr; } return sNewStr; } document.querySelector('input[name=bestPhone]').onkeydown = function () { backspacerDOWN(this, event); }; document.querySelector('input[name=bestPhone]').onkeyup = function () { backspacerUP(this, event); }; //for (var i = 0; i < launchLinks.length; i++) { // launchLinks[i].addEventListener('click', function () { // try { // var params = new URLSearchParams(window.location.search); // params.append('clicked', true); // window.location.search = "?" + params.toString(); // } // catch{ // } // }); //} } } xhr.open("GET", BASE_PATH, true); xhr.setRequestHeader('Content-type', 'text/html'); xhr.send(); } if ( document.readyState === "complete" || (document.readyState !== "loading" && !document.documentElement.doScroll) ) { loadContent(); } else { document.addEventListener("DOMContentLoaded", loadContent); } var cookieName = 'ns-modal-state'; var ImagescookieName = 'image-state'; var Globaltimer = 'globaltimer'; var UrlSpecificTime = 'urlspecifictime'; var UrlSpecific2Time = 'urlspecific2time'; // check cookie, if exists, adjust the redisplay time if (docCookies.hasItem("image-state")) { appearanceDelayOverride = docCookies.getItem('globaltimer'); } //// url spesific /// var UrlSpecificCookieName = 'ns-modal-stateUrlSpecific'; // check cookie, if exists, adjust the redisplay time if (docCookies.hasItem(UrlSpecificCookieName)) { UrlSpecificappearanceDelayOverride = docCookies.getItem('urlspecifictime'); } ///// end of url spedific/// //// url spesific2 /// var UrlSpecific2CookieName = 'ns-modal-stateUrlSpecific2'; // check cookie, if exists, adjust the redisplay time if (docCookies.hasItem(UrlSpecific2CookieName)) { UrlSpecific2appearanceDelayOverride = docCookies.getItem('urlspecific2time'); } ///// end of url spedific2/// if (docCookies.hasItem('image-state')) { //alert(readCookie("image-state")); newvalue = parseInt(docCookies.getItem('image-state')) || 0; //parseInt(readCookie("image-state")); newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); } function addClass() { var buttonReopen = document.getElementById("nsReopen"); buttonReopen.className += "Movebutton"; } setTimeout(function () { addClass(); }, 7000); newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); if (newvalue > 2) { if (newvalue == 3) { if (docCookies.hasItem(UrlSpecificTime)) { UrlSpecificappearanceDelayOverride = parseInt(docCookies.getItem('urlspecifictime')); } else { //docCookies.setItem(cookieName, true); document.cookie = UrlSpecificTime + "=" + UrlSpecificappearanceDelayOverride; setAllCookiesExpiration(UrlSpecificTime, UrlSpecificappearanceDelayOverride); } if (docCookies.hasItem(UrlSpecificCookieName)) { } else { //docCookies.setItem(cookieName, true); //document.cookie = UrlSpecificCookieName + "=true"; setAllCookiesExpiration(UrlSpecificCookieName, "true"); } if (docCookies.hasItem("image-state")) { newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); //document.cookie = "image-state=" + newvalue; setAllCookiesExpiration("image-state", newvalue); } else { newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); //docCookies.setItem("image-state", newvalue); //document.cookie = "image-state=" + newvalue; setAllCookiesExpiration("image-state", newvalue); } setTimeout(function () { // create displayed cookie var bg = document.getElementsByClassName("ns-background"); for (var i = 0; i < bg.length; i++) { document.getElementById('nsModal').style.display = 'block'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'block'; } var reOpen = document.getElementById("nsReopen"); reOpen.style.display = 'none'; } switch (newvalue) { case 0: LeadSource = LeadSource1; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen1').style.display = 'block'; document.getElementById('closensModal1').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'block'; document.getElementById('FormImage1').style.display = 'block'; break; case 1: LeadSource = LeadSource2; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen2').style.display = 'block'; document.getElementById('closensModal2').style.display = 'block'; document.getElementById('FormText2').style.display = 'block'; document.getElementById('FormImage2').style.display = 'block'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 2: LeadSource = LeadSource3; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen3').style.display = 'block'; document.getElementById('closensModal3').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'block'; document.getElementById('FormImage3').style.display = 'block'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 3: LeadSource = LeadSource4; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen4').style.display = 'block'; document.getElementById('closensModal4').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'block'; document.getElementById('FormImage4').style.display = 'block'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 4: LeadSource = LeadSource5; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'block'; document.getElementById('closensModal5').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'block'; document.getElementById('FormImage5').style.display = 'block'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; } if (docCookies.hasItem("image-state")) { newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); //document.cookie = "image-state=" + newvalue + "; Secure"; setAllCookiesExpiration("image-state", newvalue); } }, UrlSpecificappearanceDelayOverride); } if (newvalue == 4) { // create displayed cookie if (docCookies.hasItem(UrlSpecific2Time)) { UrlSpecific2appearanceDelayOverride = parseInt(docCookies.getItem(UrlSpecific2Time)); } else { //docCookies.setItem(cookieName, true); // document.cookie = UrlSpecific2Time + "=" + UrlSpecific2appearanceDelayOverride; setAllCookiesExpiration(UrlSpecific2Time, UrlSpecific2appearanceDelayOverride); } if (docCookies.hasItem(UrlSpecific2CookieName)) { } else { //docCookies.setItem(cookieName, true); //document.cookie = UrlSpecific2CookieName + "=true"; setAllCookiesExpiration(UrlSpecific2CookieName, "true"); } if (docCookies.hasItem("image-state")) { newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); // document.cookie = "image-state=" + newvalue; setAllCookiesExpiration("image-state", newvalue); } else { newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); //docCookies.setItem("image-state", newvalue); //document.cookie = "image-state=" + newvalue; setAllCookiesExpiration("image-state", newvalue); } setTimeout(function () { var bg = document.getElementsByClassName("ns-background"); for (var i = 0; i < bg.length; i++) { document.getElementById('nsModal').style.display = 'block'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'block'; } var reOpen = document.getElementById("nsReopen"); reOpen.style.display = 'none'; } switch (newvalue) { case 0: LeadSource = LeadSource1; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen1').style.display = 'block'; document.getElementById('closensModal1').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'block'; document.getElementById('FormImage1').style.display = 'block'; break; case 1: LeadSource = LeadSource2; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen2').style.display = 'block'; document.getElementById('closensModal2').style.display = 'block'; document.getElementById('FormText2').style.display = 'block'; document.getElementById('FormImage2').style.display = 'block'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 2: LeadSource = LeadSource3; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen3').style.display = 'block'; document.getElementById('closensModal3').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'block'; document.getElementById('FormImage3').style.display = 'block'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 3: LeadSource = LeadSource4; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen4').style.display = 'block'; document.getElementById('closensModal4').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'block'; document.getElementById('FormImage4').style.display = 'block'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 4: LeadSource = LeadSource5; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'block'; document.getElementById('closensModal5').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'block'; document.getElementById('FormImage5').style.display = 'block'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; } if (docCookies.hasItem("image-state")) { newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); // document.cookie = "image-state=" + newvalue + "; Secure"; setAllCookiesExpiration("image-state", newvalue); } }, UrlSpecific2appearanceDelayOverride); } } else { if (docCookies.hasItem(Globaltimer)) { appearanceDelayOverride = parseInt(docCookies.getItem('globaltimer')); } else { //docCookies.setItem(cookieName, true); //document.cookie = "globaltimer=" + appearanceDelayOverride; setAllCookiesExpiration("globaltimer", appearanceDelayOverride); } if (docCookies.hasItem("image-state")) { newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); //document.cookie = "image-state=" + newvalue; setAllCookiesExpiration("image-state", newvalue); } else { newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); //docCookies.setItem("image-state", newvalue); // document.cookie = "image-state=" + newvalue; setAllCookiesExpiration("image-state", newvalue); } setTimeout(function () { // create displayed cookie var bg = document.getElementsByClassName("ns-background"); for (var i = 0; i < bg.length; i++) { document.getElementById('nsModal').style.display = 'block'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'block'; } var reOpen = document.getElementById("nsReopen"); reOpen.style.display = 'none'; } switch (newvalue) { case 0: LeadSource = LeadSource1; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen1').style.display = 'block'; document.getElementById('closensModal1').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'block'; document.getElementById('FormImage1').style.display = 'block'; break; case 1: LeadSource = LeadSource2; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen2').style.display = 'block'; document.getElementById('closensModal2').style.display = 'block'; document.getElementById('FormText2').style.display = 'block'; document.getElementById('FormImage2').style.display = 'block'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 2: LeadSource = LeadSource3; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen3').style.display = 'block'; document.getElementById('closensModal3').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'block'; document.getElementById('FormImage3').style.display = 'block'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 3: LeadSource = LeadSource4; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen4').style.display = 'block'; document.getElementById('closensModal4').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'block'; document.getElementById('FormImage4').style.display = 'block'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 4: LeadSource = LeadSource5; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'block'; document.getElementById('closensModal5').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'block'; document.getElementById('FormImage5').style.display = 'block'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; } if (docCookies.hasItem("image-state")) { newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); ///document.cookie = "image-state=" + newvalue + "; Secure"; setAllCookiesExpiration("image-state", newvalue); } }, appearanceDelayOverride); } })(); //Message Script; //message script // appointment script // appointment Form function ShowNsightMessageListWithTime() { var NotificationbellImage = document.getElementById("BellImg"); var NsightMessageDetail = document.getElementById("NsightMessageDetail"); if (NotificationbellImage.offsetParent!==null) { if (docCookies.hasItem("ns-PartialMessageTimer")) { } else { if (NsightMessageDetail.style.display === "block") { } else { var divsToHideMessageInfo = document.getElementsByClassName("MessageDisplayform"); for (var i = 0; i < divsToHideMessageInfo.length; i++) { divsToHideMessageInfo[i].style.display = "none"; } ShowNsightMessageList(); var postUrl = document.querySelector('input[name=PopUpURL]').value; var id = document.querySelector('input[name=PopUpCampaignID]').value; // alert(id + " , " + 0 + " , " + 1 + " , " + postUrl); NotificationBeLLClick(id, 0, 1, postUrl); } document.cookie = "ns-PartialMessageTimer=true"; } } } setTimeout(ShowNsightMessageListWithTime, PartialMessageTimer); // function ShowNsightMessageList() { var NsightMessageList = document.getElementById("NsightMessageList"); if (NsightMessageList.style.display === "none") { NsightMessageList.style.display = "block"; document.getElementById("NsightMessageDetail").style.display = "none"; } document.cookie = "ns-PartialMessageTimer=true"; } function ShowNsightFullMessage() { var NsightMessageList = document.getElementById("NsightMessageDetail"); if (NsightMessageList.style.display === "none") { NsightMessageList.style.display = "block"; document.getElementById("NsightAgreement").style.display = "none"; } var divsToHide = document.getElementsByClassName("agrements"); for (var i = 0; i < divsToHide.length; i++) { divsToHide[i].style.display = "none"; } } function ShowOrHideNsightMessageList() { var NsightMessageList = document.getElementById("NsightMessageList"); if (NsightMessageList.style.display === "none") { NsightMessageList.style.display = "block"; document.getElementById("NsightMessageDetail").style.display = "none"; } //agrements var agrements = document.getElementsByClassName("agrements"); for (var i = 0; i < agrements.length; i++) { agrements[i].style.display = "none"; } var NotificationFormModal = document.getElementsByClassName("NotificationFormModal"); for (var i = 0; i < NotificationFormModal.length; i++) { NotificationFormModal[i].style.display = "none"; } var FormthanksNotification = document.getElementsByClassName("FormthanksNotification"); for (var i = 0; i < FormthanksNotification.length; i++) { FormthanksNotification[i].style.display = "none"; } var divsToHideMessageInfo = document.getElementsByClassName("MessageDisplayform"); for (var i = 0; i < divsToHideMessageInfo.length; i++) { divsToHideMessageInfo[i].style.display = "none"; } document.cookie = "ns-PartialMessageTimer=true"; CloseNotificationFormModal(); closeTremsAndCondition(); } function ShowOrHideNsightMessageDetail() { var NsightMessageDetail = document.getElementById("NsightMessageDetail"); if (NsightMessageDetail.style.display === "none") { NsightMessageDetail.style.display = "block"; document.getElementById("NsightMessageList").style.display = "none"; } document.getElementsByClassName("NotificationFormModal").style.display = "none"; } function closeNsightMessageList() { var NsightMessageList = document.getElementById("NsightMessageList"); NsightMessageList.style.display = "none"; } function getidclick(elementId, marckerId) { var valueOfInput = document.getElementById(elementId); //var divsToHide = document.getElementsByClassName("MessageDisplay"); //for (var i = 0; i < divsToHide.length; i++) { // divsToHide[i].style.display = "none"; //} //document.getElementById(elementId).style.display = "block"; //var NsightMessageDetail = document.getElementById("NsightMessageDetail"); //if (NsightMessageDetail.style.display === "none") { // NsightMessageDetail.style.display = "block"; // document.getElementById("NsightMessageList").style.display = "none"; //} // pick up here for cookie var c = getCookieVisite(marckerId); if (c === marckerId) { document.getElementById(marckerId).style.display = "none"; } else { setCookieVisite(marckerId, marckerId, 1); document.getElementById(marckerId).style.display = "none"; } // checkForFirstTimeUserOrReturningUser(); closeNsightMessageList(); } function GetCountOfFirstTimeUser() { document.getElementById("bellMessagecountNew").innerHTML = document.querySelectorAll('#NsightMessageList .newUser .Teaser .NsighTLivedot:not([style*="display: none"]').length; document.getElementById("bellMessagecountNew").style.display = "block"; document.getElementById("bellMessagecountReturn").style.display = "none"; } function GetCountOfReturningUser() { document.getElementById("bellMessagecountReturn").innerHTML = document.querySelectorAll('#NsightMessageList .newUser .Teaser .NsighTLivedot:not([style*="display: none"]').length+ document.querySelectorAll('#NsightMessageList .ReturningUser .Teaser .NsighTLivedot:not([style*="display: none"]').length; document.getElementById("bellMessagecountReturn").style.display = "block"; document.getElementById("bellMessagecountNew").style.display = "none"; } function checkForFirstTimeUserOrReturningUser() { if (document.getElementById("bellMessagecountReturn").style.display === "block") { GetCountOfReturningUser(); } else { GetCountOfFirstTimeUser(); } } function setCookieVisite(c_name, value, exdays) { var exdate = new Date(); exdate.setDate(exdate.getDate() + exdays); var c_value = escape(value) + ((exdays == null) ? "" : "; expires=" + exdate.toUTCString()); document.cookie = c_name + "=" + c_value; } function getCookieVisite(c_name) { var c_value = document.cookie; var c_start = c_value.indexOf(" " + c_name + "="); if (c_start == -1) { c_start = c_value.indexOf(c_name + "="); } if (c_start == -1) { c_value = null; } else { c_start = c_value.indexOf("=", c_start) + 1; var c_end = c_value.indexOf(";", c_start); if (c_end == -1) { c_end = c_value.length; } c_value = unescape(c_value.substring(c_start, c_end)); } return c_value; } function checkSession() { var c = getCookieVisite("visited" + CampaignId); if (c === "yes") { // alert("Welcome back!"); GetCountOfReturningUser(); document.getElementById("ReturningUserMessages").style.display = "block"; document.getElementById("newUserMessages").style.display = "block"; } else { setCookieVisite("visited" + CampaignId, "yes", 1); // alert("Welcome new visitor!"); GetCountOfFirstTimeUser(); document.getElementById("newUserMessages").style.display = "block"; document.getElementById("ReturningUserMessages").style.display = "none"; } } function checkSessionHideNotification() { var divsToHide = document.getElementsByClassName("NsighTLivedot"); for (var i = 0; i < divsToHide.length; i++) { //alert(divsToHide[i].id); var c = getCookieVisite(divsToHide[i].id); //alert(c+" cookie"); if (c === divsToHide[i].id) { //alert(c + " yes " + divsToHide[i].id); document.getElementById(divsToHide[i].id).style.display = "none"; } } var divsToHideMessageInfo = document.getElementsByClassName("MessageDisplayform"); for (var i = 0; i < divsToHideMessageInfo.length; i++) { divsToHideMessageInfo[i].style.display = "none"; } checkSession(); } function ShowAgreement(Agreement, id) { document.getElementById("NsightMessageDetail").style.display = "none"; document.getElementById("NsightAgreement").style.display = "block"; //LeadSource,document.getElementById("NotificationLeadSource").value = LeadSource; document.getElementById(Agreement).style.display = "block"; //NoThankYou document.getElementById("NotificationFormModal" + id).style.display = "none"; document.getElementById("NoThankYou" + id).style.display = "block"; } function closeTremsAndCondition() { document.getElementById("NsightAgreement").style.display = "none"; var divsToHide = document.getElementsByClassName("agrements"); for (var i = 0; i < divsToHide.length; i++) { divsToHide[i].style.display = "none"; } } function closeTremsAndConditionOverlay() { document.getElementById("AgreementOverlay").style.display = "none"; } function ShowAgreementOverlay(id) { document.getElementById(id).style.display = "block"; } function closeTremsAndConditionToggle(id) { document.getElementById("NsightAgreement").style.display = "none"; document.getElementById("NotificationFormModal" + id).style.display = "block"; document.getElementById("NoThankYou" + id).style.display = "none"; var divsToHide = document.getElementsByClassName("agrements"); for (var i = 0; i < divsToHide.length; i++) { divsToHide[i].style.display = "none"; } } function ShowNotificationFormModal(LeadSource, ThankMessageS, MessageInfo, MessageInfo2,id) { var divsToHideMessageInfo = document.getElementsByClassName("MessageDisplayform"); for (var i = 0; i < divsToHideMessageInfo.length; i++) { divsToHideMessageInfo[i].style.display = "none"; } document.getElementById("FormbodyNotification" + id).style.display = "block"; document.getElementById("NotificationForm" + id).style.display = "block"; document.getElementById("NsightMessageDetail").style.display = "none"; document.getElementById("NotificationFormModal" + id).style.display = "block"; //document.getElementById("NotificationLeadSource" + id).value = document.getElementById(LeadSource).value; document.getElementById(ThankMessageS).style.display = "block"; document.getElementById("contentWellForm" + id).style.display = "block"; document.getElementById(MessageInfo2).style.display = "block"; document.getElementById("NotificationFormModal" + id).focus(); window.location = '#NotificationFormModal' + id; //appointmentFunction(); } function CloseNotificationFormModal() { document.getElementById("NsightMessageList").style.display = "block"; var FormthanksNotification = document.getElementsByClassName("FormthanksNotification"); for (var i = 0; i < FormthanksNotification.length; i++) { FormthanksNotification[i].style.display = "none"; } var NotificationFormModal = document.getElementsByClassName("NotificationFormModal"); for (var i = 0; i < NotificationFormModal.length; i++) { NotificationFormModal[i].style.display = "none"; } //document.getElementById('FormbodyNotification').style.display = 'block'; document.querySelector('input[name=lastNamen]').value = ''; document.querySelector('input[name=firstNamen]').value = ''; document.querySelector('input[name=bestEmailn]').value = ''; document.querySelector('input[name=bestPhonen]').value = ''; document.querySelector('input[name=maken]').value = ''; document.querySelector('input[name=modeln]').value = ''; document.querySelector('select[name=AppointmentTime]').value = ''; document.querySelector('input[name=Appoitmentdate]').value = ''; var divsToHide = document.getElementsByClassName("ThankMessageS"); for (var i = 0; i < divsToHide.length; i++) { divsToHide[i].style.display = "none"; } } function sendNotificationLead(id) { if (validates(document.getElementById("firstNamen" + id)) == false || validates(document.getElementById("lastNamen" + id)) == false || validateEmails(document.getElementById("bestEmailn" + id)) == false || validates(document.getElementById("bestPhonen" + id)) == false) { } else { if ((document.getElementById('AppointmentTime' + id).required == true && document.getElementById('Appoitmentdate' + id).required == true) && (validates(document.getElementById("AppointmentTime" + id)) == false || validates(document.getElementById("Appoitmentdate" + id)) == false)) { } else { var posts = document.getElementById("URLn" + id).value; var lastName = document.getElementById("lastNamen" + id).value; var firstName = document.getElementById("firstNamen" + id).value; var bestEmail = document.getElementById("bestEmailn" + id).value; var bestPhone = document.getElementById("bestPhonen" + id).value; var makes = document.getElementById("maken" + id).value; var model = document.getElementById("modeln" + id).value; var LeadSource = document.getElementById("NotificationLeadSource" + id).value; var accessSource = document.getElementById("accessSourcen" + id).value; var campaignId = document.getElementById("campaignIdn" + id).value; var accessCode = document.getElementById("accessCoden" + id).value; var comments = document.getElementById("comments" + id).value; var AppointmentTime = document.getElementById('AppointmentTime' + id).value; var Appoitmentdate = document.getElementById('Appoitmentdate' + id).value; var formData = '{lastName: "' + lastName + '",firstName: "' + firstName + '",bestEmail: "' + bestEmail + '",bestPhone: "' + bestPhone + '",make: "' + makes + '", model: "' + model + '",accessSource: "' + accessSource + '",campaignId: "' + campaignId + '",accessCode: "' + accessCode + '",LeadSource: "' + LeadSource + '",Appoitmentdate: "' + Appoitmentdate + '",AppointmentTime: "' + AppointmentTime + '",comments: "' + comments +'"}'; var ajax = new XMLHttpRequest(); ajax.open('POST', posts, true); ajax.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); //ajax.setRequestHeader('Content-Length', formData.length; charset=utf-8); ajax.send(formData); document.getElementById('FormthanksNotification' + id).style.display = 'block'; document.getElementById('FormbodyNotification' + id).style.display = 'none'; document.getElementById('AppointmentTime' + id).value=" "; document.getElementById('Appoitmentdate' + id).value = ""; document.getElementById("comments" + id).value = ""; document.getElementById("lastNamen" + id).value = ""; document.getElementById("firstNamen" + id).value = ""; document.getElementById("bestEmailn" + id).value = ""; document.getElementById("bestPhonen" + id).value = ""; document.getElementById("maken" + id).value = ""; document.getElementById("modeln" + id).value = ""; } } } var zChars = new Array(' ', '(', ')', '-', '.'); var maxphonelengths = 14; var phonevalue1s; var phonevalue2s; var cursorpositions; function ParseForNumber1s(object) { phonevalue1s = ParseChars(object.value, zChars); } function ParseForNumber2s(object) { phonevalue2s = ParseChars(object.value, zChars); } function backspacerUPs(object, e) { if (e) { e = e } else { e = window.event } if (e.which) { var keycode = e.which } else { var keycode = e.keyCode } ParseForNumber1s(object) if (keycode >= 48) { ValidatePhones(object) } } function backspacerDOWNs(object, e) { if (e) { e = e } else { e = window.event } if (e.which) { var keycode = e.which } else { var keycode = e.keyCode } ParseForNumber2s(object) } function GetCursorPositions() { var t1 = phonevalue1s; var t2 = phonevalue2s; var bool = false for (i = 0; i < t1.length; i++) { if (t1.substring(i, 1) != t2.substring(i, 1)) { if (!bool) { cursorpositions = i bool = true } } } } function ValidatePhones(object) { var p = phonevalue1s p = p.replace(/[^\d]*/gi, "") if (p.length < 4) { object.value = p } else if (p.length == 4) { pp = p; d4 = p.indexOf('') d5 = p.indexOf('') if (d4 == -1) { pp = "" + pp; } if (d5 == -1) { pp = pp + ""; } object.value = pp; } else if (p.length > 5 && p.length < 9) { p = "(" + p; l30 = p.length; p30 = p.substring(0, 4); p30 = p30 + ") " p31 = p.substring(4, l30); pp = p30 + p31; object.value = pp; } else if (p.length >= 9) { p = "(" + p; l30 = p.length; p30 = p.substring(0, 4); p30 = p30 + ") " p31 = p.substring(4, l30); pp = p30 + p31; l40 = pp.length; p40 = pp.substring(0, 9); p40 = p40 + "-" p41 = pp.substring(9, l40); ppp = p40 + p41; object.value = ppp.substring(0, maxphonelengths); } GetCursorPositions() if (cursorpositions >= 0) { if (cursorpositions == 0) { cursorpositions = 2 } else if (cursorpositions <= 2) { cursorpositions = cursorpositions + 1 } else if (cursorpositions <= 5) { cursorpositions = cursorpositions + 2 } else if (cursorpositions == 6) { cursorpositions = cursorpositions + 2 } else if (cursorpositions == 7) { cursorpositions = cursorpositions + 4 e1 = object.value.indexOf(')') e2 = object.value.indexOf('-') if (e1 > -1 && e2 > -1) { if (e2 - e1 == 4) { cursorpositions = cursorpositions - 1 } } } else if (cursorpositions < 11) { cursorpositions = cursorpositions + 3 } else if (cursorpositions == 11) { cursorpositions = cursorpositions + 1 } else if (cursorpositions >= 12) { cursorpositions = cursorpositions } var txtRange = object.createTextRange(); txtRange.moveStart("character", cursorpositions); txtRange.moveEnd("character", cursorpositions - object.value.length); txtRange.select(); } } function ParseChars(sStr, sChar) { if (sChar.length == null) { zChars = new Array(sChar); } else zChars = sChar; for (i = 0; i < zChars.length; i++) { sNewStr = ""; var iStart = 0; var iEnd = sStr.indexOf(sChar[i]); while (iEnd != -1) { sNewStr += sStr.substring(iStart, iEnd); iStart = iEnd + 1; iEnd = sStr.indexOf(sChar[i], iStart); } sNewStr += sStr.substring(sStr.lastIndexOf(sChar[i]) + 1, sStr.length); sStr = sNewStr; } return sNewStr; } function validateEmails(email) { const re = /^(([^<>()[\]\\.,;:\s@\"]+(\.[^<>()[\]\\.,;:\s@\"]+)*)|(\".+\"))@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\])|(([a-zA-Z\-0-9]+\.)+[a-zA-Z]{2,}))$/; if (re.test(email.value)) { email.style.borderColor = "#ccc"; return true; } else { email.style.borderColor = "red"; return false; } return false; } function validates(valide) { const result = valide; const value = valide.value.trim(); if (value == '') { result.style.borderColor = "red"; return false; } else { result.style.borderColor = "#ccc"; return true; } return false; } function CheckForMobileDevice() { var isMobile = /iPhone|iPad|iPod|Android/i.test(navigator.userAgent); if (isMobile) { return true; // alert("You are using Mobile"); } else { // alert("You are using Desktop"); return false; } return false; } function NotificationClick(id,partialMessage,fullMessage,postUrl) { var ClickParialMessageMobile = 0; var ClickParialMessageDesktop = 0; if (CheckForMobileDevice()) { ClickParialMessageMobile = partialMessage; } else { ClickParialMessageDesktop = partialMessage; } var formDatas = '{Id: "' + id + '",ClickParialMessageMobile : "' + ClickParialMessageMobile + '",ClickParialMessageDesktop : "' + ClickParialMessageDesktop + '"}'; var ajax1 = new XMLHttpRequest(); ajax1.open('POST', postUrl, true); ajax1.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); //ajax.setRequestHeader('Content-Length', formData.length; charset=utf-8); ajax1.send(formDatas); } function NotificationBeLLClick(id, click, popupclick, postUrl) { var ClickMobile = 0; var ClickDesktop = 0; var popupClickMobile = 0; var popupClickDesktop = 0; if (CheckForMobileDevice()) { ClickMobile = click; popupClickMobile = popupclick; } else { ClickDesktop = click; popupClickDesktop = popupclick; } //alert(id + " , " + 0 + " , " + 1 + " , " + postUrl); var formDatas = '{Id: "' + id + '",ClickNotificationBellMobile : "' + ClickMobile + '",ClickNotificationBellDesktop : "' + ClickDesktop + '",PopupFullMessageMobile : "' + popupClickMobile + '",PopupFullMessageDesktop : "' + popupClickDesktop + '"}'; //alert(formDatas); var ajax1 = new XMLHttpRequest(); ajax1.open('POST', postUrl, true); ajax1.setRequestHeader('Content-Type', 'application/json; charset=UTF-8'); //ajax.setRequestHeader('Content-Length', formData.length; charset=utf-8); ajax1.send(formDatas); } function Reopen1hideformShowMessageList() { //nsModalForm Reopen1 if (document.getElementById('Reopen1').style.display == 'block' && DisplayForm1=='True') { closeTheformForNotification(); ShowOrHideNsightMessageList(); } } function Reopen2hideformShowMessageList() { //nsModalForm Reopen1 if (document.getElementById('Reopen2').style.display == 'block' && DisplayForm2 == 'True') { closeTheformForNotification(); ShowOrHideNsightMessageList(); } } function Reopen3hideformShowMessageList() { //nsModalForm Reopen1 if (document.getElementById('Reopen3').style.display == 'block' && DisplayForm3 == 'True') { closeTheformForNotification(); ShowOrHideNsightMessageList(); } } function Reopen4hideformShowMessageList() { //nsModalForm Reopen1 if (document.getElementById('Reopen4').style.display == 'block' && DisplayForm4 == 'True') { closeTheformForNotification(); ShowOrHideNsightMessageList(); } } function Reopen5hideformShowMessageList() { //nsModalForm Reopen1 if (document.getElementById('Reopen5').style.display == 'block' && DisplayForm5 == 'True') { closeTheformForNotification(); ShowOrHideNsightMessageList(); } } function ReopenhideformShowMessageList() { Reopen1hideformShowMessageList(); Reopen2hideformShowMessageList(); Reopen3hideformShowMessageList(); Reopen4hideformShowMessageList(); Reopen5hideformShowMessageList(); } function closeTheformForNotification() { document.getElementById('form_thanks').style.display = 'none'; document.getElementById('form_body').style.display = 'block'; document.querySelector('input[name=lastName]').value = ''; document.querySelector('input[name=firstName]').value = ''; document.querySelector('input[name=bestEmail]').value = ''; document.querySelector('input[name=bestPhone]').value = ''; document.querySelector('input[name=make]').value = ''; document.querySelector('input[name=model]').value = ''; document.getElementById('hideoverlay').style.display = 'block'; document.getElementById('nsModalForm').style.display = 'none'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'none'; } } function closensModal1hideformShowMessageList() { //nsModalForm Reopen1 if (document.getElementById('closensModal1').style.display == 'block' && DisplayForm1 == 'True') { closeTheformForNotification(); ShowOrHideNsightMessageList(); closeThisModelForNotification(); } } function closensModal2hideformShowMessageList() { //nsModalForm Reopen1 if (document.getElementById('closensModal2').style.display == 'block' && DisplayForm2 == 'True') { closeTheformForNotification(); ShowOrHideNsightMessageList(); closeThisModelForNotification(); } } function closensModal3hideformShowMessageList() { //nsModalForm Reopen1 if (document.getElementById('closensModal3').style.display == 'block' && DisplayForm3 == 'True') { closeTheformForNotification(); ShowOrHideNsightMessageList(); closeThisModelForNotification(); } } function closensModal4hideformShowMessageList() { //nsModalForm Reopen1 if (document.getElementById('closensModal4').style.display == 'block' && DisplayForm4 == 'True') { closeTheformForNotification(); ShowOrHideNsightMessageList(); closeThisModelForNotification(); } } function closensModal5hideformShowMessageList() { //nsModalForm Reopen1 if (document.getElementById('closensModal5').style.display == 'block' && DisplayForm5 == 'True') { closeTheformForNotification(); ShowOrHideNsightMessageList(); closeThisModelForNotification(); } } function closensModalhideformShowMessageList() { closensModal1hideformShowMessageList(); closensModal2hideformShowMessageList(); closensModal3hideformShowMessageList(); closensModal4hideformShowMessageList(); closensModal5hideformShowMessageList(); } //closensModal1 function closeModelOverleyForNotification() { document.getElementById('nsModal').style.display = 'none'; document.getElementById('nsReopen').style.display = 'block'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'none'; } } function closeThisModelForNotification() { var cookieName = 'ns-modal-state'; var ImagescookieName = 'image-state'; var Globaltimer = 'globaltimer'; var UrlSpecificTime = 'urlspecifictime'; var UrlSpecific2Time = 'urlspecific2time'; newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); closeModelOverleyForNotification(); if (docCookies.hasItem("image-state")) { newvalue = parseInt(docCookies.getItem('image-state')) || 0; newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); newvalue = parseInt(newvalue) + 1; document.cookie = "image-state=" + newvalue; } else { newvalue = parseInt(newvalue) + 1; document.cookie = "image-state=" + newvalue; } newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); if (newvalue > 2) { if (newvalue == 3) { if (docCookies.hasItem(UrlSpecificCookieName)) { if (docCookies.hasItem(UrlSpecificTime)) { UrlSpecificappearanceDelayOverride = parseInt(docCookies.getItem(UrlSpecificTime)) } if (UrlSpecificappearanceDelayOverride == UrlSpecificreappearanceDelayOverride) { document.cookie = UrlSpecificTime + "=" + UrlSpecificreappearanceDelayOverride2; UrlSpecificappearanceDelayOverride = parseInt(docCookies.getItem(UrlSpecificTime)); } else if (UrlSpecificappearanceDelayOverride == UrlSpecificreappearanceDelayOverride2) { } else { document.cookie = UrlSpecificTime + "=" + UrlSpecificreappearanceDelayOverride; UrlSpecificappearanceDelayOverride = parseInt(docCookies.getItem(UrlSpecificTime)); } } else { } setTimeout(function () { var bg = document.getElementsByClassName("ns-background"); for (var i = 0; i < bg.length; i++) { document.getElementById('nsModal').style.display = 'block'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'block'; } var reOpen = document.getElementById("nsReopen"); reOpen.style.display = 'none'; } newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); displayImageCaseNotification(newvalue); }, UrlSpecificappearanceDelayOverride); } if (newvalue == 4) { if (docCookies.hasItem(UrlSpecific2CookieName)) { if (docCookies.hasItem(UrlSpecific2Time)) { UrlSpecificappearanceDelayOverride = parseInt(docCookies.getItem(UrlSpecific2Time)); } if (UrlSpecific2appearanceDelayOverride == UrlSpecific2reappearanceDelayOverride) { document.cookie = UrlSpecific2Time + "=" + UrlSpecific2reappearanceDelayOverride2; UrlSpecific2appearanceDelayOverride = parseInt(docCookies.getItem(UrlSpecific2Time)); } else if (UrlSpecific2appearanceDelayOverride == UrlSpecific2reappearanceDelayOverride2) { } else { document.cookie = UrlSpecific2Time + "=" + UrlSpecific2reappearanceDelayOverride; UrlSpecific2appearanceDelayOverride = parseInt(docCookies.getItem(UrlSpecific2Time)); } } else { } setTimeout(function () { var bg = document.getElementsByClassName("ns-background"); for (var i = 0; i < bg.length; i++) { document.getElementById('nsModal').style.display = 'block'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'block'; } var reOpen = document.getElementById("nsReopen"); reOpen.style.display = 'none'; } newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); displayImageCaseNotification(newvalue); }, UrlSpecific2appearanceDelayOverride); } } else { //document.cookie = "image-state=" + newvalue + "; if (docCookies.hasItem("image-state")) { if (docCookies.hasItem(Globaltimer)) { appearanceDelayOverride = parseInt(docCookies.getItem('globaltimer')); } if (appearanceDelayOverride == reappearanceDelayOverride) { document.cookie = "globaltimer=" + reappearanceDelayOverride2; appearanceDelayOverride = parseInt(docCookies.getItem('globaltimer')); } else if (appearanceDelayOverride == reappearanceDelayOverride2) { } else { document.cookie = "globaltimer=" + reappearanceDelayOverride; appearanceDelayOverride = parseInt(docCookies.getItem('globaltimer')); } } else { } setTimeout(function () { // create displayed cookie var bg = document.getElementsByClassName("ns-background"); for (var i = 0; i < bg.length; i++) { document.getElementById('nsModal').style.display = 'block'; var overlay = document.getElementsByClassName("ns-background"); for (var i = 0; i < overlay.length; i++) { overlay[i].style.display = 'block'; } var reOpen = document.getElementById("nsReopen"); reOpen.style.display = 'none'; } newvalue = parseInt(returnimage(newvalue, WebSitePath1, WebSitePath2)); displayImageCaseNotification(newvalue); }, appearanceDelayOverride); } }; function displayImageCaseNotification(newvalue) { switch (newvalue) { case 0: LeadSource = LeadSource1; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen1').style.display = 'block'; document.getElementById('closensModal1').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'block'; document.getElementById('FormImage1').style.display = 'block'; break; case 1: LeadSource = LeadSource2; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen2').style.display = 'block'; document.getElementById('closensModal2').style.display = 'block'; document.getElementById('FormText2').style.display = 'block'; document.getElementById('FormImage2').style.display = 'block'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 2: LeadSource = LeadSource3; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen3').style.display = 'block'; document.getElementById('closensModal3').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'block'; document.getElementById('FormImage3').style.display = 'block'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 3: LeadSource = LeadSource4; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen5').style.display = 'none'; document.getElementById('closensModal5').style.display = 'none'; document.getElementById('Reopen4').style.display = 'block'; document.getElementById('closensModal4').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'block'; document.getElementById('FormImage4').style.display = 'block'; document.getElementById('FormText5').style.display = 'none'; document.getElementById('FormImage5').style.display = 'none'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; break; case 4: LeadSource = LeadSource5; document.getElementById('Reopen1').style.display = 'none'; document.getElementById('closensModal1').style.display = 'none'; document.getElementById('Reopen2').style.display = 'none'; document.getElementById('closensModal2').style.display = 'none'; document.getElementById('Reopen3').style.display = 'none'; document.getElementById('closensModal3').style.display = 'none'; document.getElementById('Reopen4').style.display = 'none'; document.getElementById('closensModal4').style.display = 'none'; document.getElementById('Reopen5').style.display = 'block'; document.getElementById('closensModal5').style.display = 'block'; document.getElementById('FormText2').style.display = 'none'; document.getElementById('FormImage2').style.display = 'none'; document.getElementById('FormText3').style.display = 'none'; document.getElementById('FormImage3').style.display = 'none'; document.getElementById('FormText4').style.display = 'none'; document.getElementById('FormImage4').style.display = 'none'; document.getElementById('FormText5').style.display = 'block'; document.getElementById('FormImage5').style.display = 'block'; document.getElementById('FormText1').style.display = 'none'; document.getElementById('FormImage1').style.display = 'none'; } };