", { html: "*Click your browser back button to cancel" }).appendTo(msg);
} else {
$("
", { class: "nextButton", html: "
" }).appendTo(msg);
}
$("#loading-div-background").show();
}
// sets display for Pet insurance tombstone
function setPetInsDisplay() {
$("#PetInsurance").hide();
if ($("#PetInsurance").attr("data-showLine").toLowerCase() === "true") {
$("#Animals").change(function () { setPetInsDisplay(); });
if ($("#Animals").val() !== "None") {
$("#PetInsurance").show();
}
}
}
// sets business insurance display
function setBusinessDisplay() {
$("#applicantBusiness").hide();
$("#applicantBusinessIns").hide();
if ($("#applicantBusiness").attr("data-showLine").toLowerCase() === "true") {
$("#applicantOccupationList").change(function () { setBusinessDisplay(); });
if (showApplicantBusiness($("#applicantOccupationList").val())) {
$("#applicantBusiness").show();
}
$("#ownerOperatorList").change(function () { setBusinessDisplay(); });
if ($("#ownerOperatorList").val() === "true") {
$("#applicantBusinessIns").show();
}
}
}
// don't show business insurance question(s) if occupation isn't selected, or if they aren't employed (homemaker, retired, unemployed, student)
function showApplicantBusiness(occupation) {
if (occupation === null || occupation === "" || occupation === "010" || occupation === "020" || occupation === "030" || occupation === "040")
return false;
return true;
}
// sets display for eq and windstorm ins questions
function setEqWindDisplay() {
$.ajax({
type: "GET",
url: _baseUrl + "/api/GetEqWindDisplay",
contentType: "application/json; charset=utf-8",
processData: false,
dataType: "json",
success: function (respData) {
var data = JSON.parse(respData);
$.each(data, function (i) {
if (data[i].IsVisible === false || $("#selHomeForm").val() === "4") {
$("#" + data[i].InputContainerName).hide();
}
else {
$("#" + data[i].InputContainerName).show();
if (data[i].IsRequired) {
$("#" + data[i].ControlName).prop("required", "true");
}
if (data[i].SelectedValue != null && data[i].SelectedValue.length > 0) {
$("#" + data[i].ControlName).val(data[i].SelectedValue);
}
else if (data[i].DefaultValue != null && data[i].DefaultValue.length > 0) {
$("#" + data[i].ControlName).val(data[i].DefaultValue);
}
}
});
},
error: function (resp) {
}
});
}
// sets visibility of priorInsurance fields
function setPriorAddressDisplay() {
$(".PriorAddressSection").hide();
if ($("#TimeAtResidence").is(":visible")) {
var priorDispSettings = $("#PriorAddressLbl").attr("data-priorBasis");
var timeAtRes = parseInt($("#TimeAtResidence").val());
// if they haven't selected anything don't display prior address unless agency settings are set to always display
if (timeAtRes === 0)
timeAtRes = 99;
switch (priorDispSettings) {
case "Yes":
$(".PriorAddressSection").show();
break;
case "SixMon":
if (timeAtRes < 6) {
$(".PriorAddressSection").show();
}
break;
case "OneYear":
if (timeAtRes < 12) {
$(".PriorAddressSection").show();
}
break;
case "TwoYear":
if (timeAtRes < 24) {
$(".PriorAddressSection").show();
}
break;
case "ThreeYear":
if (timeAtRes < 36) {
$(".PriorAddressSection").show();
}
break;
case "FourYear":
if (timeAtRes < 48) {
$(".PriorAddressSection").show();
}
break;
case "FiveYear":
if (timeAtRes < 60) {
$(".PriorAddressSection").show();
}
break;
}
}
}
function populateComparisonList(data) {
var isCombinedPolicy = ($("#IsCombinedPolicy").val() != "" && $("#IsCombinedPolicy").val().toLowerCase() === "true");
var md = new MobileDetect(window.navigator.userAgent);
var sort = "monthly";
$("#ComparisonSort").hide();
var rateResp = data;
if (!isCombinedPolicy && rateResp.Completed) {
if ($("#ComparisonSortList").val() === "PaymentAmount") {
sort = "monthly";
} else if ($("#ComparisonSortList").val() === "DownPayment") {
sort = "down";
} else if ($("#ComparisonSortList").val() === "TotalPremium") {
sort = "total";
}
if ($("#ComparisonSort").attr("data-showList") === "true") {
$("#ComparisonSort").show();
}
}
var customIWantIt = $("#OverrideIWantItButtons").val();
customIWantIt = customIWantIt.toLowerCase();
var isSpanish = $("#currentLanguage").val() == "Spanish";
var saves = isSpanish ? "Ahorra" : "Saves";
var monthly = isSpanish ? "Mensual" : "Monthly";
var perMonth = isSpanish ? "por Mes" : "Per Month";
var dueToday = isSpanish ? "Pago Hoy" : "Due Today";
var propCoverages = isSpanish ? "Coberturas de Propiedad" : "Property Coverages";
var dwellRep = isSpanish ? "Reemplazo de Vivienda" : "Dwelling Replacement";
var persProp = isSpanish ? "Propiedad Personal" : "Personal Property";
var otherStructLbl = isSpanish ? "Otras Estructuras" : "Other Structures";
var deductlbl = isSpanish ? "Deducible" : "Deductible";
var liabCoverages = isSpanish ? "Coberturas de Responsabilidad" : "Liability Coverages";
var personalLiab = isSpanish ? "Responsabilidad Personal" : "Personal Liability";
var medLbl = isSpanish ? "Pagos Médicos" : "Medical Payments";
var selectLbl = isSpanish ? "Seleccionar" : "Select";
var clickToCallTxt = isSpanish ? "Haga clic para llamar a nuestra agencia de seguros." : "Click to call our insurance agency.";
var resHtml = "";
var addlHtml = "";
if (rateResp.Success === true) {
var showClickToCall = md.mobile() && rateResp.ClickToCallPhoneNr != "";
var showCustomClickToCall = md.mobile() && rateResp.OverrideClickToCall != "";
$.each(rateResp.RateResponses,
function (i, rate) {
var dwell = 0;
var contents = 0;
var otherStruct = 0;
var liab = 0;
var med = 0;;
var deduct = "";
var rateTerm = isSpanish ? "Contrato de " + rate.Term + " meses" : rate.Term + " Month Term";
if (i < 3) {
for (var x = 0; x < rate.Coverages.length; x++) {
if (rate.Coverages[x].CoverageName === "Dwelling")
dwell = rate.Coverages[x].Limit;
else if (rate.Coverages[x].CoverageName === "Contents")
contents = rate.Coverages[x].Limit;
else if (rate.Coverages[x].CoverageName === "Med Pay")
med = rate.Coverages[x].Limit;
else if (rate.Coverages[x].CoverageName === "Other Structures")
otherStruct = rate.Coverages[x].Limit;
else if (rate.Coverages[x].CoverageName === "Liability")
liab = rate.Coverages[x].Limit;
}
deduct = rate.Deductibles[0].Value;
if (deduct === "N/A")
deduct = rate.Deductibles[1].Value;
var payAmt = rate.PayPlanPaymentAmount > 0 && (rate.PayPlanPaymentAmount * 2 < rate.TotalPremium)
? rate.PayPlanPaymentAmount
: rate.TotalPremium / rate.Term;
var downPmt = rate.PayPlanDownPayment > 0 ? rate.PayPlanDownPayment : rate.TotalPremium / rate.Term;
resHtml = resHtml + "
";
if (rateResp.PriorMonthlyPayment > 0) {
var diff = Math.round(rateResp.PriorMonthlyPayment - payAmt);
if (diff > 0)
resHtml = resHtml +
"
" +
saves +
" " +
diff.formatMoney(0) +
" " +
perMonth +
"
";
}
if (rate.CompanyID < 0) {
resHtml = resHtml +
"
";
} else {
var companyName = rate.LogoUrl.indexOf("real-estate.svg") > 0 ? "Carrier logo" : rate.CompanyName;
resHtml = resHtml + "
";
}
if (sort === "monthly") {
resHtml = resHtml +
"
" +
payAmt.formatMoney(2) +
"
" +
monthly +
"
" +
downPmt.formatMoney(2) +
" " +
dueToday +
"
";
} else if (sort === "down") {
resHtml = resHtml +
"
" +
downPmt.formatMoney(2) +
"
" +
dueToday +
"
" +
payAmt.formatMoney(2) +
" " +
perMonth +
"
";
} else {
resHtml = resHtml +
"
" +
rate.TotalPremium.formatMoney(2) +
"
" +
rateTerm +
"
";
}
resHtml = resHtml + "
" + propCoverages + "
";
resHtml = resHtml + "
";
if (rate.Form != "4") {
resHtml = resHtml + "- " + dwellRep + "";
resHtml = resHtml + " " + parseInt(dwell).formatMoney(0) + "
";
}
resHtml = resHtml + "- " + persProp + "";
resHtml = resHtml + " " + parseInt(contents).formatMoney(0) + "
";
if (rate.Form !== "4") {
resHtml = resHtml + "- " + otherStructLbl + "";
resHtml = resHtml +
" " +
parseInt(otherStruct).formatMoney(0) +
"
";
}
resHtml = resHtml + "- " + deductlbl + "";
var deductString = deduct < 50 ? deduct + "%" : parseInt(deduct).formatMoney(0);
resHtml = resHtml + " " + deductString + "
";
resHtml = resHtml + "
";
resHtml = resHtml + "
" + liabCoverages + "
";
resHtml = resHtml + "
";
resHtml = resHtml + "- " + personalLiab + "";
resHtml = resHtml + " " + parseInt(liab).formatMoney(0) + "
";
resHtml = resHtml + "- " + medLbl + "";
resHtml = resHtml + " " + parseInt(med).formatMoney(0) + "
";
resHtml = resHtml + "
";
resHtml = resHtml +
"
";
if (isCombinedPolicy && _hasAURates) {
resHtml = resHtml +
"
";
resHtml = resHtml + "
";
resHtml = resHtml +
"
";
} else {
resHtml = resHtml +
"
";
}
if (showClickToCall) {
resHtml = resHtml +
"

";
} else if (showCustomClickToCall) {
resHtml = resHtml + rateResp.OverrideClickToCall;
}
resHtml = resHtml + "
"; // close results panel
} else {
$("#addlOptions").show();
addlHtml = addlHtml +
"
";
var payAmt2 = rate.PayPlanPaymentAmount > 0 ? rate.PayPlanPaymentAmount : rate.TotalPremium / rate.Term;
if (sort === "monthly") {
addlHtml = addlHtml +
"
" +
payAmt2.formatMoney(2) +
"
" +
monthly +
"
";
} else if (sort === "down") {
var downPmt2 = rate.DownPayment > 0 ? rate.DownPayment : rate.TotalPremium / rate.Term;
addlHtml = addlHtml +
"
" +
downPmt2.formatMoney(2) +
"
" +
dueToday +
"
";
} else {
addlHtml = addlHtml +
"
" +
rate.TotalPremium.formatMoney(2) +
"
" +
rateTerm +
"
";
}
addlHtml = addlHtml +
"
";
if (isCombinedPolicy && _hasAURates) {
addlHtml = addlHtml +
"
";
addlHtml =
addlHtml + "
";
addlHtml = addlHtml +
"
";
} else
addlHtml = addlHtml +
"
";
if (showClickToCall) {
addlHtml = addlHtml +
"

";
} else if (showCustomClickToCall) {
addlHtml = addlHtml + rateResp.OverrideClickToCall;
}
addlHtml = addlHtml + "
"; // close results panel
}
});
if (isCombinedPolicy && _hasAURates) {
$("#top3hid").val(resHtml);
$("#addlHid").val(addlHtml);
} else {
$("#top3").html(resHtml);
$("#addRates").html(addlHtml);
$("#top3hid").val(resHtml);
$("#addlHid").val(addlHtml);
}
// custom sub-title
$("#CustomQuoteMsg").hide();
if ($("#CustomQuoteMsgHid").val() != "") {
$("#CustomQuoteMsg").show();
if (!$("#CustomQuoteMsg:contains(" + $("#CustomQuoteMsgHid").val() + ")")) {
$("#CustomQuoteMsg").html($("#CustomQuoteMsgHid").val());
}
}
// select I want this one
$(".carrierSelect").click(function (event) {
var compInfo = $("#CompanyInfo" + $(event.target).data("selcompany")).val().split("|");
$("#SelHOCompInfo").val($("#CompanyInfo" + $(event.target).data("selcompany")).val());
// piped values - rate.CompanyName + "|" + rate.TotalPremium + "|" + rate.PayPlanDownPayment + "|" + rate.PayPlanPaymentAmount + "|" + rate.PayPlanNumOfPayments
var selCompInfo = {
CompanyName: compInfo[0],
TotalPremium: compInfo[1],
DownPayment: compInfo[2],
PayPlanAmt: compInfo[3],
NumOfPayments: compInfo[4],
CompanyId: $(event.target).data("selcompany")
};
Itc.ConsumerRater.AnalyticsController.doGaEventView("Contact Me", compInfo[0], "Property Quote");
if ($("#ContactMeRedirect").val() == "true" && $("#ContactMeUrl").val() != "") {
if ($("#ContactMeNotify").val() == "true") {
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetContactByEmail/",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(selCompInfo),
processData: false,
dataType: "json",
success: function (conData) {
handleProposalResponse(conData);
}
,
error: function (conResp) {
//handle the error
}
});
}
var url = decodeURIComponent($("#ContactMeUrl").val());
window.location.href = url;
}
else {
var visited = $("#visitedPages").val();
$("#prevPage").val("pgResults");
$(".page").hide();
$("#visitedPages").val(visited + "|pgResults");
$("#selCompanyId").val($(event.target).data("selcompany"));
event.preventDefault();
$(".page").hide();
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetSelectedCarrier/",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(selCompInfo),
processData: false,
dataType: "json",
success: function (selData) {
if (selData.indexOf("ContactMethod") > -1) {
$("#pgContactMethod").show();
history.pushState("pgContactMethod", null, "/property/Home/ContactMethod");
doPageView("ContactMethod");
loadPageTitle("ContactMethod");
} else {
history.pushState("pgAddlLob", null, "/property/Home/AlsoInterested");
doPageView("AlsoInterested");
if (selData.length > 15) {
$("#pgAddlLob").attr("data-selLines", selData.substr(selData.indexOf("|") + 1));
}
$("#pgAddlLob").show();
}
$("#prevPage").val("pgResults");
visited = $("#visitedPages").val() + "|pgResults";
$("#visitedPages").val(visited);
},
error: function (resp) {
$(".page").hide();
$("#pgContactMethod").show();
history.pushState("pgContactMethod", null, "/property/Home/ContactMethod");
doPageView("ContactMethod");
loadPageTitle("ContactMethod");
}
});
scrollToTop();
}
});
// click to call button
$(".clickToCall").click(function () {
event.preventDefault();
var phoneNumber = $(this).data("numbertocall");
window.location.href = phoneNumber;
});
_returnedRates = true;
if (isCombinedPolicy && _hasAURates) {
showAURates();
if ($("#CustomQuoteMsg").is(":visible")) {
var msg = $("#CustomQuoteMsg").html();
msg = msg + "
Your auto quotes are shown below. Select the quote you are interested in to display your property quotes.";
$("#CustomQuoteMsg").html(msg);
}
}
else if (isCombinedPolicy && !_hasAURates) {
$("#CustomQuoteMsg").show();
}
} else { // rate.Success === false
if (isCombinedPolicy && _hasAURates && rateResp.Completed === true) {
var custMsg = $("#CustomQuoteMsgHid").val() !== "" ? $("#CustomQuoteMsgHid").val() + "
" : "";
$("#CustomQuoteMsg").html(custMsg + "We are unable to return home rates at this time.");
$("#CustomQuoteMsg").show();
showAURates();
}
else if (rateResp.Completed === true) {
showErrorThankYou();
}
}
}
// handles contact me response and redirects to proposal site if url is provided
function handleProposalResponse(data) {
if (data.indexOf("|") > 0) {
var dataValues = data.split("|");
if (dataValues[1].startsWith("https://")) {
top.location.href = dataValues[1].replace("\"", "");
} else {
showThankYou();
}
} else {
showThankYou();
}
}
// sets scroll position to top of page
function scrollToTop() {
if ('parentIFrame' in window) {
// page is iFramed w/ iframeResizer Library
parentIFrame.scrollTo(0, 0);
} else {
window.scrollTo(0, 0);
};
}
// checks to see if a string ends with a particular char
function DoesStringEndWith(myString, stringCheck) {
return (myString.lastIndexOf(stringCheck) === myString.length - stringCheck.length) > 0;
}
function iOS() {
var iDevices = [
'iPad Simulator',
'iPhone Simulator',
'iPod Simulator',
'iPad',
'iPhone',
'iPod'
];
if (!!navigator.platform) {
while (iDevices.length) {
if (navigator.platform === iDevices.pop()) { return true; }
}
}
return false;
}
// checks to see if we are in an iFrame
function isFramed() {
return window.self !== window.top;
}
// zero pads numbers
function zeroPad(str, count, left) {
var l;
for (l = str.length; l < count; l += 1) {
str = (left ? ("0" + str) : (str + "0"));
}
return str;
}
// money format prototype
Number.prototype.formatMoney = function (c, d, t) {
var n = this,
c = isNaN(c = Math.abs(c)) ? 2 : c,
d = d == undefined ? "." : d,
t = t == undefined ? "," : t,
s = n < 0 ? "-" : "",
i = String(parseInt(n = Math.abs(Number(n) || 0).toFixed(c))),
j = (j = i.length) > 3 ? j % 3 : 0;
return s + '$' + (j ? i.substr(0, j) + t : "") + i.substr(j).replace(/(\d{3})(?=\d)/g, "$1" + t) + (c ? d + Math.abs(n - i).toFixed(c).slice(2) : "");
};
// set a date a date string to be parsed for input control
Date.prototype.toDateInputValue = (function () {
var local = new Date(this);
local.setMinutes(this.getMinutes() - this.getTimezoneOffset());
return local.toJSON().slice(0, 10);
});
// gets formatted date string from a date input control
Date.prototype.fromDateInputValue = (function () {
try {
var local = new Date(this);
local.setMinutes(this.getMinutes() + this.getTimezoneOffset());
return local.toJSON().slice(0, 10);
}
catch (err) {
return this.getMonth() + 1 + "/" + this.getDate() + "/" + this.getFullYear();
}
});;
//Setup namespaces.
var Itc = Itc || {};
Itc.ConsumerRater = Itc.ConsumerRater || {};
// create controller
Itc.ConsumerRater.DatePicker = {
isAndroid: function () {
// checks to see if this is an android device
return /(android)/i.test(navigator.userAgent);
},
supportsDateInput: function () {
// checks to see if browser properly handles html5 date input
var input = document.createElement('input');
input.setAttribute('type', 'date');
var notADateValue = 'not-a-date';
input.setAttribute('value', notADateValue);
return (input.value !== notADateValue);
},
setDobDatePicker: function (controlId) {
// if this is an android device, set the date input to text so that we can overwrite the default date picker
if (this.isAndroid()) {
$(controlId).attr('type', 'text');
}
var today = new Date();
const yrRangeStr = (today.getFullYear() - 120).toString() + ":" + (today.getFullYear() - 14).toString();
$(controlId).datepicker({
dateFormat: "mm/dd/yy",
yearRange: yrRangeStr,
changeYear: true,
changeMonth: true,
defaultDate: "-35y"
});
const selDt = new Date($(controlId).val());
if (selDt.getFullYear() !== 1753 && !isNaN(selDt.getFullYear())) {
this.setSelectedDate(controlId, selDt);
}
},
setStandardDatePicker: function (controlId, minDate, maxDate) {
$(controlId).datepicker({
dateFormat: "mm/dd/yy",
minDate: minDate,
maxDate: maxDate,
changeYear: true
});
const selDt = new Date($(controlId).val());
if (selDt.getFullYear() !== 1753 && !isNaN(selDt.getFullYear())) {
this.setSelectedDate(controlId, selDt);
}
},
zeroPad: function (str, count, left) {
var l;
for (l = str.length; l < count; l += 1) {
str = (left ? ("0" + str) : (str + "0"));
}
return str;
},
setSelectedDate(controlId, selDt) {
selDt.setMinutes(selDt.getMinutes() + selDt.getTimezoneOffset());
const mon = zeroPad((selDt.getMonth() + 1).toString(), 2, true);
const dy = zeroPad(selDt.getDate().toString(), 2, true);
$(controlId).val(mon + "/" + dy + "/" + selDt.getFullYear().toString());
}
};;
//Setup namespaces.
var Itc = Itc || {};
Itc.ConsumerRater = Itc.ConsumerRater || {};
Itc.ConsumerRater.Utilities = {
clearForm: function() {
$('input[type=text]').val('');
$('input[type=email]').val('');
$('input[type=tel]').val('');
$('input[type=number]').val('');
$('select option').prop('selected', false);
$('input[type=radio]').prop("checked", false);
$('input[type=checkbox]').prop("checked", false);
},
toggleLanguage: function (value, baseUrl) {
this.showLoading();
$.ajax({
type: "POST",
url: baseUrl + "/auto/SetLanguage?language=" + value,
contentType: "application/json; charset=utf-8",
processData: false,
dataType: "json",
success: function(data) {
console.log('reloading');
location.reload(true);
},
error: function (resp) {
console.log('error: ' + resp.responseText);
this.hideLoading();
}
});
},
showLoading: function() {
$("#loading-div-background").show();
},
hideLoading: function() {
$("#loading-div-background").hide();
},
resetControls: function (controls) {
if (controls.length > 0) {
for (var x = 0; x < controls.length; x++) {
if (controls[x].value === "checked:true") {
$(controls[x].controlId).attr("checked", true);
} else {
$(controls[x].controlId).val(controls[x].value);
}
}
}
}
};;
//Setup namespaces.
var Itc = Itc || {};
Itc.ConsumerRater = Itc.ConsumerRater || {};
// create controller
Itc.ConsumerRater.AnalyticsController = {
doGaEventView: function (eventCategory, eventAction, eventLabel) {
if (typeof ga === "undefined")
return;
try {
if (ga.getByName('myTracker1') !== "undefined") {
ga('myTracker1.send', {
hitType: 'event',
eventCategory: eventCategory,
eventAction: eventAction,
eventLabel: eventLabel
});
}
ga('myTracker2.send', {
hitType: 'event',
eventCategory: eventCategory,
eventAction: eventAction,
eventLabel: eventLabel
});
} catch (err) {
}
},
doAdobePageView: function(baseUrl, pageTitle, url, previousPageName) {
if (typeof digitalData === "undefined") {
return;
}
try {
var refPageName = previousPageName.length === 0 ? "unknown" : previousPageName;
var refUrl = refPageName === "unknown" ? document.referrer : baseUrl + "/" + refPageName;
var queryString = url.indexOf("?") > 0 ? url.substr(url.indexOf("?") + 1) : "";
var subSections = url.replace(baseUrl + "/", "").split("/");
digitalData.push({
"event": "pageview",
"page": {
"cleanPagePath": url.replace(baseUrl + "/", "").replace(/\//g, ":"),
"pageTitle": pageTitle,
"fullUrl": url,
"queryString": queryString,
"referringUrl": refUrl.indexOf("?") > 0 ? refUrl.substr(0, refUrl.indexOf("?")) : refUrl,
"fullReferringUrl": refUrl,
"referringPageName": refPageName.replace("/", ":"),
"subSection1": subSections.length > 0 ? subSections[0] : "",
"subSection2": subSections.length > 1 ? subSections[1] : "",
"subSection3": subSections.length > 2 ? subSections[2] : "",
"subSection4": subSections.length > 3 ? subSections[3] : "",
"subSection5": subSections.length > 4 ? subSections[4] : "",
"subSection6": subSections.length > 5 ? subSections[5] : "",
"slug": subSections.length > 0 ? subSections[subSections.length - 1] : "Home",
"fullBreadcrumb": url.replace(baseUrl + "/", "").replace(/\//g, " > "),
"lastBreadcrumb": subSections.length > 0 ? subSections[subSections.length - 1] : "Home",
"pageTemplate": "",
"siteVersion": "enca",
"pageDate": ""
}
});
} catch (err) {
}
}
};;