var address = {};
var _stateCodes = ['AA', 'AE', 'AK', 'AL', 'AP', 'AR', 'AS', 'AZ', 'CA', 'CO', 'CT', 'DC', 'DE', 'FL', 'FM', 'GA', 'GU', 'HI', 'IA', 'ID', 'IL', 'IN', 'KS', 'KY', 'LA', 'MA', 'MD', 'ME', 'MH', 'MI', 'MN', 'MO', 'MP', 'MS', 'MT', 'NC', 'ND', 'NE', 'NH', 'NJ', 'NM', 'NV', 'NY', 'OH', 'OK', 'OR', 'PA', 'PR', 'PW', 'RI', 'SC', 'SD', 'TN', 'TX', 'UT', 'VA', 'VI', 'VT', 'WA', 'WI', 'WV', 'WY'];
var _returnedValuation = false;
var _numRetries = 0;
var _selState = "";
var _returnedRates = false;
var _hasAURates = false;
var _auLogo = "";
var _ssAddressStatus = "";
var _waiterRetries = 0;
var _waiterId;
var _geoId;
var _geoRetries = 0;
var _baseUrl = "";
var _auTerm = 6;
// IE Compatibiliity Mode
$(document).ready(function () {
SetupOnChangeEvents();
});
// Modern browsers
function postBackInit() {
SetupOnChangeEvents();
}
// page loaded set up
function SetupOnChangeEvents() {
if (window.addEventListener) {
window.addEventListener("message", onCookieCheckFromIFrameParent, false);
}
else if (window.attachEvent) {
window.attachEvent("onmessage", onCookieCheckFromIFrameParent, false);
}
if (isFramed()) {
window.parent.postMessage({ "cookieCheck": "checkCookies" }, "*");
}
$(".page").show();
$("#pgOwnership").hide();
$("#pgDetails").hide();
$("#pgCondition").hide();
$("#pgDiscounts").hide();
$("#pgContents").hide();
$("#pgContact").hide();
$("#pgResults").hide();
$("#pgContactMethod").hide();
$("#pgCallTiming").hide();
$("#pgCombinedChoice").hide();
$("#addressConfirmsection").hide();
$("#pgApplicant").hide();
$("#EQInsurancePan").hide();
$("#WindstormInsurancePan").hide();
$("#pgAddlLob").hide();
if ($("#hubAltair").val().toLowerCase() == "true") {
$(".AgencyMessageContainer").addClass("AgencyMessageContainerAltair").removeClass("AgencyMessageContainer");
}
_baseUrl = window.location.href;
_baseUrl = _baseUrl.substr(0, _baseUrl.indexOf("/prop"));
if (window.location.href === _baseUrl + "/property" || window.location.href === _baseUrl + "/property/" || window.location.href.indexOf("property?") > 0 || window.location.href.indexOf("property/?") > 0) {
doPageView("Name and Address");
}
if ($("#GreetingTxt").html() == "") {
$(".description").hide();
}
$(window).on('popstate', function (e) {
var state = e.originalEvent.state;
if (state !== null) {
var prevPg = $("#prevPage").val();
if (prevPg != "") {
$(".page").hide();
$("#" + prevPg).show();
var pgTitle = getPrevPgTitle(prevPg);
history.pushState(prevPg, null, pgTitle);
// now assign new prevPage value
var res = $("#visitedPages").val().split("|");
var foundIndex = -1;
for (var x = 0; x < res.length; x++) {
if (res[x] == prevPg) {
foundIndex = x;
break;
}
}
if (foundIndex > -1) {
if (foundIndex > 0)
foundIndex = foundIndex - 1;
$("#prevPage").val(res[foundIndex]);
}
else {
$("#prevPage").val("");
}
}
return false;
}
});
if (location.search.indexOf("clearsession") > 0) {
$("#RefreshPgToShow").val("step1");
$("#RefreshVisitedPages").val("");
$("#RefreshPrevPage").val("");
$("#RefreshScripts").text("Itc.ConsumerRater.Utilities.clearForm();");
}
if ($("#RefreshPgToShow").val() !== "") {
$("#loading-div-background").hide();
$("#disclaimerAbove").hide();
$(".page").hide();
$(".page").hide();
var showPg = "#" + $("#RefreshPgToShow").val();
$("#visistedPages").val($("#RefreshVisitedPages").val());
$("#RefreshVisitedPages").val("");
$("#prevPage").val($("#RefreshPrevPage").val());
$("#RefreshPrevPage").val("");
if ($("#RefreshScripts").text() !== "") {
var rs = $("#RefreshScripts").text();
eval(rs);
$("#RefreshScripts").text("");
}
$(showPg).show();
$("#RefreshPgToShow").val("");
scrollToTop();
}
if (location.search.indexOf("abpid") > 0) {
$("#loading-div-background").show();
$.ajax({
type: "GET",
url: _baseUrl + "/api/GetReturnToQuotePage",
contentType: "application/json; charset=utf-8",
processData: false,
dataType: "json",
success: function (data) {
if (JSON.stringify(data).length > 1) {
var pageInfo = JSON.parse(data);
if (pageInfo.FieldControls != null && pageInfo.FieldControls.length > 0) {
var controls = pageInfo.FieldControls;
$.each(controls, function (i) {
if (controls[i].IsVisible === false) {
$("#" + controls[i].InputContainerName).hide();
}
else {
if (controls[i].IsRequired) {
$("#" + controls[i].ControlName).prop("required", "true");
}
if (controls[i].FieldValues != null) {
$("#" + controls[i].ControlName + " option").remove();
for (var x = 0; x < controls[i].FieldValues.length; x++) {
$('', {
html: controls[i].FieldValues[x].Text,
value: controls[i].FieldValues[x].Value
}).appendTo($("#" + controls[i].ControlName));
}
}
if (controls[i].SelectedValue != null && controls[i].SelectedValue.length > 0) {
if ($("#" + controls[i].ControlName).prop("type") == "date")
$("#" + controls[i].ControlName).val(new Date(controls[i].SelectedValue).fromDateInputValue());
else
$("#" + controls[i].ControlName).val(controls[i].SelectedValue);
}
else if (controls[i].DefaultValue != null && controls[i].DefaultValue.length > 0) {
$("#" + controls[i].ControlName).val(controls[i].DefaultValue);
}
}
});
}
try {
if (pageInfo.LoadFunction != null && pageInfo.LoadFunction.length > 0) {
eval(pageInfo.LoadFunction);
}
}
catch (err) {
}
$(".page").hide();
$("#" + pageInfo.CurrentPage).show();
if (pageInfo.CurrentPage !== "step1") {
$(".description").hide();
}
history.pushState(pageInfo.CurrentPage, null, getPrevPgTitle(pageInfo.CurrentPage));
}
$("#loading-div-background").hide();
},
error: function (resp) {
//handle the error
$("#loading-div-background").hide();
}
});
}
$(".inputPanel input, .inputPanel select").focusin(function (event) {
$(".inputPanel").removeClass("inputHasFocus");
$(this).closest(".inputPanel").addClass("inputHasFocus");
});
$(".inputPanel input, .inputPanel select").focusout(function (event) {
$(".inputPanel").removeClass("inputHasFocus");
});
var showLeadSource = $("#leadsourceVisible").val() == "true";
var requireLeadSource = $("#leadsourceRequired").val() == "true";
$("#LeadSourceHOPan").hide();
$("#LeadSource").hide();
if (showLeadSource) {
$("#LeadSource").show();
$("#LeadSourceHOPan").show();
if (requireLeadSource) {
$("#LeadSource").prop("required", "true");
}
}
var showTimeAtRes = $("#TimeAtResidencePanel").attr("data-display") === "true";
var requireTimeAtRes = $("#TimeAtResidencePanel").attr("data-required") === "true";
$("#TimeAtResidencePanel").hide();
if (showTimeAtRes) {
$("#TimeAtResidencePanel").show();
if (requireTimeAtRes) {
$("#TimeAtResidence").prop("required", "true");
}
}
setPriorAddressDisplay();
$("#TimeAtResidence").change(function () {
setPriorAddressDisplay();
});
$("#verifyDisclosure").click(function () {
if ($("#verifyDisclosure").is(":checked")) {
$("#disclaimerBelow").show();
$("#disclaimerAbove").hide();
$("#disclaimerAbove").html("");
$(".agreement").removeClass("err");
}
});
$("#propAddressMsg").hide();
var useSingleLine = $("#UseSingleLineAddres").val() == "true";
if (useSingleLine) {
var la = jQuery.LiveAddress({
key: "170132855911969677",
waitForStreet: true,
autoVerify: true,
addresses: [{
id: 'residence',
freeform: '#propAddress'
}]
});
la.on("AddressAccepted", function (event, data, previousHandler) {
if (data.response.isMissingSecondary()) {
data.address.abort(event);
$("#propAddressMsg").show();
$("#propAddressMsg").html(" Don't forget your apartment number!");
$("#propAddress").focus();
var comma = $("#propAddress").val().indexOf(",");
// need dom element
document.getElementById("propAddress").setSelectionRange(comma, comma + 1);
logAddressLookup("Missing Apt Number", address.State, address.Zipcode);
}
else
previousHandler(event, data);
});
la.on("Completed", function (event, data, previousHandler) {
if (data.response.isValid()) {
address.Address1 = data.response.chosen.delivery_line_1;
address.Address2 = data.response.chosen.delivery_line_2;
address.City = data.response.chosen.components.city_name;
address.State = data.response.chosen.components.state_abbreviation;
address.Zipcode = data.response.chosen.components.zipcode;
address.Plus4Code = data.response.chosen.components.plus4_code;
address.Latitude = data.response.chosen.metadata.latitude;
address.Longitude = data.response.chosen.metadata.longitude;
address.County = data.response.chosen.metadata.county_name;
$('#beginPropRate').prop("disabled", false);
$('#beginPropRate').val("Let's Go!");
logAddressLookup("Success", address.State, address.Zipcode);
}
else
previousHandler(event, data);
});
// use as is functionality
la.on("OriginalInputSelected", function (event, data, previousHandler) {
// todo: log invalid address
var enteredAddr = $("#propAddress").val();
var splitAddrr = enteredAddr.split(",");
if (splitAddrr.length > 1 && (addrEndsWithStateCode(enteredAddr) || addrEndsWithZip(enteredAddr))) {
address.Address1 = splitAddrr[0];
address.City = splitAddrr[1].slice(0, splitAddrr[1].length - 3).trim();
address.State = _selState;
if (addrEndsWithZip(enteredAddr)) {
address.Zipcode = enteredAddr.slice(enteredAddr.length - 5);
address.City = splitAddrr[1].slice(0, splitAddrr[1].length - 9).trim();
var rightHalf = splitAddrr[1].replace(address.City, "");
rightHalf = rightHalf.replace(address.Zipcode, "");
address.State = rightHalf.trim();
beginPropRate();
logAddressLookup("Use as is", address.State, address.Zipcode);
}
else {
$("#MissingZip").show();
$("#popPropZIP").val("");
$("#popPropZIP").removeClass("inputErr");
logAddressLookup("Use as is - prompt for zip", address.State, "");
}
}
else {
$("#propAddressMsg").show();
$("#propAddressMsg").html(" Be sure to enter a complete address including city, state, and ZIP");
$("#propAddress").focus();
logAddressLookup("Use as is - not enough info", "", "");
}
});
}
$("#propZIP").mask('99999', { placeholder: '' }).focus(function () { this.select(); });
var overrideSS = false;
$("#propAddrRate").click(function (event) {
event.preventDefault();
if (overrideSS) {
if (standardAddressIsValid()) {
beginPropRate();
setName(true);
}
} else {
_ssAddressStatus = "";
var ok = (standardAddressIsValid());
if (ok === false) {
return;
} else {
doZipValidation().then(function () {
$("#ZipCodeErr").hide();
$("#loading-div-background").show();
doSmartyValidation().then(function () {
var done = _ssAddressStatus === "Success";
if (done) {
Itc.ConsumerRater.AnalyticsController.doGaEventView("Address Validation", "Validated", "Property Quote");
beginPropRate();
setName(true);
$("#loading-div-background").hide();
} else {
if (_ssAddressStatus === "Missing") {
$("#loading-div-background").hide();
return;
} else if (_ssAddressStatus === "confirm") {
$("#addresssection").hide();
$("#addressConfirmsection").show();
var enteredAddress = $("#propAddress1").val() + " " + $("#propAddress2").val() + " ";
enteredAddress += $("#propCity").val() + ", " + $("#propState").val() + " " + $("#propZIP").val();
$("#enteredAddress").html(enteredAddress);
address.Address2 = (address.Address2 == null || address.Address2 == undefined) ? "" : address.Address2;
var sugAddress = address.Address1 + " " + address.Address2 + " ";
sugAddress += address.City + ", " + address.State + " " + address.Zipcode + "-" + address.Plus4Code;
$("#suggestedAddress").html(sugAddress);
$("#suggestedAddressPan").show();
$("#addressConfirmTitle").hide();
$("#pg0Prev").hide();
$(".agreement").hide();
$("#disclaimerBelow").hide();
$("#propAddrRate").hide();
$("#loading-div-background").hide();
scrollToTop();
} else {
// do usps lookup
doCensusValidation().then(function () {
if (_ssAddressStatus === "Success") {
Itc.ConsumerRater.AnalyticsController.doGaEventView("Address Validation", "Validated", "Property Quote");
beginPropRate();
setName(true);
$("#loading-div-background").hide();
} else {
ShowAddressNotFound();
}
}).catch(function () {
ShowAddressNotFound();
});
}
}
}).catch(function () {
ShowAddressNotFound();
});
})
.catch(function (reject) {
$("#propZIP").addClass("inputErr");
$("#ZipPanel").addClass("err");
$("#propZIP").focus();
$("#ZipCodeErr").show();
$("#pgOwnership").hide();
$("#step1").show();
return;
});
}
}
});
$("#addressTryAgain").click(function (event) {
event.preventDefault();
Itc.ConsumerRater.AnalyticsController.doGaEventView('Address Validation', "Try again", "Property Quote");
$("#addresssection").show();
$("#addressConfirmsection").hide();
$("#propAddress1").focus();
$("#propAddrRate").show();
});
// address confirmation, use entered address
$("#useEnteredAddress").click(function (event) {
event.preventDefault();
Itc.ConsumerRater.AnalyticsController.doGaEventView('Address Validation', "Use entered address", "Property Quote");
address = {
Address1: $("#propAddress1").val(),
Address2: $("#propAddress2").val(),
City: $("#propCity").val(),
State: $("#propState").val(),
Zipcode: $("#propZIP").val()
};
beginPropRate();
setName(false);
});
$("#useSuggestedAddress").click(function (event) {
event.preventDefault();
Itc.ConsumerRater.AnalyticsController.doGaEventView('Address Validation', "Use suggested address", "Property Quote");
beginPropRate();
setName(true);
$("#propAddress1").val(address.Address1);
$("#propAddress2").val(address.Address2);
$("#propCity").val(address.City);
$("propZIP").val(address.Zipcode);
});
if ($("#IsCombinedPolicy").val().toLowerCase() == "true") {
var locAddress = $("#CombinedLocation").val();
address = JSON.parse(locAddress);
beginPropRate();
$("#pgOwnershipPrev").hide();
if ($("#ComboHomeForm").val() != "") {
$("#prevPage").val("pgOwnership");
$("#pgOwnership").hide();
$("#pgDetails").show();
history.pushState("pgDetails", null, "/property/Home/HomeDetails");
$("#prevPage").val("pgOwnership");
doPageView("Ownership");
if ($("#ComboHomeForm").val() === "HO4") {
showRentersQuestions()
}
else if ($("#ComboHomeForm").val() != "HO6") {
hideCondoQuestions();
}
else {
showCondoQuestions();
}
if (!_returnedValuation) {
$("#loading-div-background").show();
waitForValuation();
}
scrollToTop();
}
$("#NoRates").val("Thank you for the opportunity to quote your property and auto insurance.");
// check auto rate responses
$.ajax({
type: "GET",
url: _baseUrl + "/auto/PollGetRates/",
contentType: "application/json; charset=utf-8",
processData: false,
dataType: "json",
success: function (data) {
}
,
error: function (resp) {
}
});
}
$("#cancelZip").click(function (event) {
event.preventDefault();
$("#MissingZip").hide();
$("#propAddress").focus();
});
$("#popZipRate").click(function (event) {
event.preventDefault();
if ($("#popPropZIP").val().length > 4) {
address.Zipcode = $("#popPropZIP").val();
$("#MissingZip").hide();
beginPropRate();
}
else {
$("#popPropZIP").addClass("inputErr");
$("#popPropZIP").focus();
$("#MissingZip").show();
}
});
// swimming pool and pool type visibility
$("#panelSwimmingPoolType").hide();
$("#SwimmingPool").change(function () {
$("#panelSwimmingPoolType").hide();
if ($("#SwimmingPool").val() == "true")
$("#panelSwimmingPoolType").show();
});
setCurrentInsuranceDisplay();
if (document.querySelector('.AgencyMessageContainer') != null) {
var msg = window.getComputedStyle(document.querySelector('.AgencyMessageContainer'), ':after')
.getPropertyValue('content');
if (msg.indexOf("866-236-1961") != -1) {
$(".AgencyMessageContainer").on('click', function () { window.location.href = "tel:+18662361961"; });
$(".AgencyMessageContainer").css("cursor", "pointer");
}
}
else if (document.querySelector('.AgencyMessageContainerAltair') != null) {
var msg = window.getComputedStyle(document.querySelector('.AgencyMessageContainerAltair'), ':after')
.getPropertyValue('content');
if (msg.indexOf("877-871-7234") != -1) {
$(".AgencyMessageContainerAltair").on('click', function () { window.location.href = "tel:+18778717234"; });
$(".AgencyMessageContainerAltair").css("cursor", "pointer");
}
}
$("#beginPropRate").click(function (event) {
event.preventDefault();
beginPropRate();
return false;
});
// handle ownership logic
$("#pgOwnership > .innerPage > div > input[type=button]").click(function (event) {
event.preventDefault();
$(".page").hide();
var homeForm = "3";
$("#pgOwnership").find(".inputPanel").removeClass("selected");
$("#pgOwnership").find(".hoform").removeClass("selCov");
$("#pgOwnership").find(".hoform").prop("value", "Select");
$("#OwnershipType").val($(event.target).data("ownership"));
var confirm = $("#currentLanguage").val() === "Spanish" ? "Confirmar" : "Confirm";
$("#pgDetails").show();
loadPageTitle("pgDetails");
doPageView("PropertyDetails");
history.pushState("pgDetails", null, "/property/Home/HomeDetails");
if ($(event.target).data("ownership") === "rent") {
Itc.ConsumerRater.AnalyticsController.doGaEventView("HomeForm", "Renters", "Property Quote");
showRentersQuestions();
homeForm = "4";
$("#ComboHomeForm").val("HO4");
$("#RentersPanel").addClass("selected");
$("#curRent").addClass("selCov");
$("#curRent").prop("value", confirm);
scrollToTop();
}
else {
showHOCondoQuestions();
if ($(event.target).data("ownership") === "ownCondo") {
homeForm = "6";
Itc.ConsumerRater.AnalyticsController.doGaEventView("HomeForm", "CondoOwners", "Property Quote");
showCondoQuestions();
$("#ComboHomeForm").val("HO6");
$("#CondoPanel").addClass("selected");
$("#curOwnCondo").addClass("selCov");
$("#curOwnCondo").prop("value", confirm);
scrollToTop();
}
else {
hideCondoQuestions();
Itc.ConsumerRater.AnalyticsController.doGaEventView("HomeForm", "HomeOwners", "Property Quote");
$("#ComboHomeForm").val("HO3");
$("#HOPanel").addClass("selected");
$("#curOwn").addClass("selCov");
$("#curOwn").prop("value", confirm);
scrollToTop();
}
}
if (!_returnedValuation) {
$("#loading-div-background").show();
waitForValuation();
}
$(".GreetingText").hide();
scrollToTop();
// set policy home form
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetPropertyForm/" + homeForm,
contentType: "application/json; charset=utf-8",
processData: false,
dataType: "json",
success: function (data) {
$("#prevPage").val("pgOwnership");
$("#visitedPages").val("step1|pgOwnership");
scrollToTop();
}
,
error: function (resp) {
//handle the error
}
});
return false;
});
// handle dwelling info logic
$("#pg3submit").click(function (event) {
event.preventDefault();
if (pg3IsValid()) {
// for some reason $("#PetInsurance").val() just returns an empty string
var petInsurance = $("#PetInsurance").is(":visible") ? $("#PetInsurance option:selected").val() === "true" : false;
var earthquakeInsurance = $("#EQInsuranceList").is(":visible") ? $("#EQInsuranceList").val() : false;
var windstormInsurance = $("#WindstormInsuranceList").is(":visible") ? $("#WindstormInsuranceList").val() : false;
$(".page").hide();
$("#pgDetails").hide();
if ($("#selHomeForm").val() === "4") {
$("#pgDiscounts").show();
loadPageTitle("pgDiscounts");
history.pushState("pgDiscounts", null, "/property/Home/Discounts");
}
else {
history.pushState("pgCondition", null, "/property/Home/Condition");
$("#pgCondition").show();
loadPageTitle("pgCondition");
}
$("#visitedPages").val("step1|pgOwnership|pgDetails");
$("#prevPage").val("pgDetails");
var constType = $("#selHomeForm").val() == "3" ? "D" : $("#CondoBuildingType").val();
var familyCount = $("#selHomeForm").val() == "3" ? parseInt($("#NumberOfFamilies").val()) : parseInt($("#CondoNumberOfFamilies").val());
var storyType = $("#selHomeForm").val() == "3" ? $("#StoryType").val() : $("#CondoStoryType").val();
var info = {
NumberOfFamilies: familyCount,
StoryType: storyType,
YearOfConstruction: $("#YearOfConstruction").val(),
SquareFootage: $("#SquareFootage").val(),
Construction: $("#Construction").val(),
RoofComposition: $("#RoofComposition").val(),
RoofShape: $("#RoofShape").val(),
HailResistantRoof: $("#HailResistantRoof").val() == "true" ? true : false,
NumberOfFullBaths: $("#NumberOfFullBaths").val(),
NumberOfHalfBaths: $("#NumberOfHalfBaths").val(),
NumberOfThreeQuarterBaths: $("#NumberOfThreeQuarterBaths").val(),
PrimaryHeatingType: $("#PrimaryHeatingType").val(),
SwimmingPool: $("#SwimmingPool").val() == "true" ? true : false,
SwimmingPoolType: $("#SwimmingPoolType").val(),
TrampolineOnPremise: $("#TrampolineOnPremise").val() == "true" ? true : false,
Animals: $("#Animals").val(),
ConstructionType: constType,
PetInsurance: petInsurance,
EarthquakeInsurance: earthquakeInsurance,
WindstormInsurance: windstormInsurance
};
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetDwellingInfo/",
contentType: "application/json; charset=utf-8",
processData: false,
data: JSON.stringify(info),
dataType: "json",
success: function (data) {
},
error: function (resp) {
//handle the error
}
});
doPageView("Condition");
scrollToTop();
}
else {
$(".page").hide();
$("#pgDetails").show();
history.pushState("pgDetails", null, "/property/Home/HomeDetails");
loadPageTitle("pgDetails");
}
scrollToTop();
return false;
});
// handle condition logic
$("#pgCondition > .innerPage > div > input[type=button]").click(function (event) {
event.preventDefault();
$(".page").hide();
$("#pgDiscounts").show();
loadPageTitle("pgDiscounts");
history.pushState("pgDiscounts", null, "/property/Home/Discounts");
$("#visitedPages").val("step1|pgOwnership|pgDetails|pgCondition");
$("#prevPage").val("pgCondition");
doPageView("Discounts");
// update selected css for previous page functionality
$("#pgCondition").find(".inputPanel").removeClass("selected");
$("#pgCondition").find(".hoCondition").removeClass("selCov");
$("#pgCondition").find(".hoCondition").prop("value", "Select");
if ($(event.target).data("condition") == "okay") {
$("#condPanOk").addClass("selected");
$("#condOk").addClass("selCov");
$("#condOk").prop("value", "Confirm");
Itc.ConsumerRater.AnalyticsController.doGaEventView("Condition", "Needs Work", "Property Quote");
}
else if ($(event.target).data("condition") == "good") {
$("#condPanGood").addClass("selected");
$("#condGood").addClass("selCov");
$("#condGood").prop("value", "Confirm");
Itc.ConsumerRater.AnalyticsController.doGaEventView("Condition", "Good", "Property Quote");
}
else if ($(event.target).data("condition") == "excellent") {
$("#condPanEx").addClass("selected");
$("#condEx").addClass("selCov");
$("#condEx").prop("value", "Confirm");
Itc.ConsumerRater.AnalyticsController.doGaEventView("Condition", "Excellent", "Property Quote");
}
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetCondition/" + $(event.target).data("condition"),
contentType: "application/json; charset=utf-8",
processData: false,
dataType: "json",
success: function (data) {
},
error: function (resp) {
//handle the error
}
});
scrollToTop();
return false;
});
// handle discounts logic
$("#pg5submit").click(function (event) {
event.preventDefault();
var ok = true;
var focused = false;
$("#PriorCarrer").removeClass("inputErr");
$("#CurrentInsurerPanel").removeClass("err");
if ($("#InsuredDiscount").val() == "true") {
if ($("#PriorCarrer").val() == "") {
$("#PriorCarrer").addClass("inputErr");
$("#CurrentInsurerPanel").addClass("err");
ok = false;
$("#PriorCarrer").focus();
focused = true;
}
if ($("#PriorHOMonthlyPayment").is(":visible")) {
$("#PriorHOMonthlyPayment").removeClass("inputErr");
$("#PriorMonthlyPaymentPan").removeClass("err");
$("#paymentErr").html("");
if ($("#requireMonthlyPremium").val() == "true" || $("#PriorHOMonthlyPayment").val() != "") {
var payAmt = parseFloat($("#PriorHOMonthlyPayment").val());
if (isNaN(payAmt) || payAmt < 1 || payAmt > 9999.99) {
ok = false;
$("#PriorMonthlyPayment").addClass("inputErr");
$("#PriorMonthlyPaymentPan").addClass("err");
if (!focused) {
$("#PriorHOMonthlyPayment").focus();
focused = true;
}
$("#paymentErr").html("Please enter a payment between 1.00 and 9999.99");
}
}
}
}
if (!ok)
return;
history.pushState("pgContents", null, "/property/Home/Contents");
$(".page").hide();
$("#pgContents").show();
loadPageTitle("pgContents");
$("#visitedPages").val("step1|pgOwnership|pgDetails|pgCondition|pgDiscounts");
$("#prevPage").val("pgDiscounts");
doPageView("Contents");
var priorPayment = -1;
if ($("#InsuredDiscount").val() == "true") {
if ($("#showMonthlyPremium").val() == "true")
priorPayment = parseFloat($("#PriorHOMonthlyPayment").val()).toFixed(2);
}
var discInfo = {
CarDiscount: $("#AutoDiscount").val() == "true" ? true : false,
CurrentlyInsuredHome: $("#InsuredDiscount").val() == "true" ? true : false,
PriorCarrier: $("#InsuredDiscount").val() == "true" ? $("#PriorCarrer").val() : "",
GatedCommunity: $("#GatedCommunity").val(),
BurglarAlarm: $("#BurglarAlarm").val(),
FireAlarm: $("#FireAlarm ").val(),
PriorPayment: priorPayment
};
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetDiscounts/",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(discInfo),
processData: false,
dataType: "json",
success: function (data) {
},
error: function (resp) {
//handle the error
}
});
scrollToTop();
return false;
});
// applicant industry
$("#applicantIndustryList").change(setOccupation);
setBusinessDisplay();
// coApplicant fields
$("#coapplicantFirstName").change(function () { setUpCoApplicantNameFields(); });
// contents
$("#pg6submit").click(function (event) {
event.preventDefault();
history.pushState("pgApplicant", null, "/property/Home/Applicant");
$(".page").hide();
$("#loading-div-background").show();
doPageView("Applicant");
var visited = $("#visitedPages").val();
$("#prevPage").val("pgContents");
loadPageTitle("pgApplicant");
$("#visitedPages").val(visited + "|pgApplicant");
var conInfo = {
Jewelry: $("#Jewelry").val() == "true" ? true : false,
Computers: $("#Computers").val() == "true" ? true : false,
Electronics: $("#Electronics").val() == "true" ? true : false
};
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetContents/",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(conInfo),
processData: false,
dataType: "json",
success: function (dataString) {
// not sure why I need to parse the the json array, but it is throwing an exception in jquery js code if I don't
var data = JSON.parse(dataString);
$("#pgApplicant").show();
$.each(data, function (i) {
if (data[i].IsVisible == false) {
$("#" + data[i].InputContainerName).hide();
if (data[i].SelectedValue != null && data[i].SelectedValue.length > 0) {
if ($("#" + data[i].ControlName).prop("type") == "date")
$("#" + data[i].ControlName).val(new Date(data[i].SelectedValue).fromDateInputValue());
else {
$("#" + data[i].ControlName).val(data[i].SelectedValue);
}
}
}
else {
if (data[i].InputContainerName != "") {
$("#" + data[i].InputContainerName).show();
}
if (data[i].IsRequired) {
$("#" + data[i].ControlName).prop("required", "true");
}
if (data[i].FieldValues != null) {
$("#" + data[i].ControlName + " option").remove();
for (var x = 0; x < data[i].FieldValues.length; x++) {
$('', {
html: data[i].FieldValues[x].Text,
value: data[i].FieldValues[x].Value
}).appendTo($("#" + data[i].ControlName));
}
}
if (data[i].SelectedValue != null && data[i].SelectedValue.length > 0) {
if ($("#" + data[i].ControlName).prop("type") == "date")
$("#" + data[i].ControlName).val(new Date(data[i].SelectedValue).fromDateInputValue());
else {
$("#" + 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);
}
else {
$("#" + data[i].ControlName).val("");
}
}
});
if ($("#applicantOccupationPanel").is(":visible") && $("#applicantOccupationList option").length > 1) {
$("#applicantOccupationPanel").removeClass("hidden");
}
setBusinessDisplay();
if ($("#applicantDOBPan").is(":visible")) {
// set min/max dates
var today = new Date();
var min = today.getFullYear() - 120 + "-01-01";
var max = today.getFullYear() - 16 + "-01-01";
$("#applicantDOB").prop("min", min);
$("#applicantDOB").prop("max", max);
if (!Itc.ConsumerRater.DatePicker.supportsDateInput() || Itc.ConsumerRater.DatePicker.isAndroid()) {
Itc.ConsumerRater.DatePicker.setDobDatePicker("#applicantDOB");
}
}
if ($("#coapplicantDOBPan").is(":visible")) {
// set min/max dates
var today = new Date();
var min = today.getFullYear() - 120 + "-01-01";
var max = today.getFullYear() - 16 + "-01-01";
$("#coapplicantDOB").prop("min", min);
$("#coapplicantDOB").prop("max", max);
if (!Itc.ConsumerRater.DatePicker.supportsDateInput() || Itc.ConsumerRater.DatePicker.isAndroid()) {
Itc.ConsumerRater.DatePicker.setDobDatePicker("#coapplicantDOB");
}
}
$("#loading-div-background").hide();
},
error: function (resp) {
$("#pgApplicant").show();
$("#loading-div-background").hide();
}
});
setUpApplicantNameFields();
scrollToTop();
return false;
});
// applicant page
$("#pgApplicantSubmit").click(function (event) {
event.preventDefault();
if (validateApplicantPage()) {
var ownerOperator = $("#ownerOperatorList").is(":visible") ? $("#ownerOperatorList").val() === "true" : false;
var wantBusinessIns = $("#applicantBusinessList").is(":visible") ? $("#applicantBusinessList").val() === "true" : false;
history.pushState("pgResults", null, "/property/Home/QuoteResults");
$(".page").hide();
$("#prevPage").val("pgApplicant");
doPageView("ComparisonPage");
// save applicant - coapplicant info
var today = new Date();
var applicantDOB = new Date(today.getFullYear - 35, 0, 1).fromDateInputValue();
if ($("#applicantDOB").val() != null) {
applicantDOB = new Date($("#applicantDOB").val()).fromDateInputValue();
}
var coAppDOB = new Date(1753, 0, 1).fromDateInputValue(); // set to ITC invalid date
if ($("#applicantHasCoApplicant").val() === "true" && $("#coapplicantDOB").val() !== "") {
var coAppDOB = new Date($("#coapplicantDOB").val()).fromDateInputValue();
}
var applicant = {
DateOfBirth: applicantDOB,
Gender: $("#applicantGender").val(),
MaritalStatus: $("#applicantMarital").val(),
EducationLevel: $("#applicantEducation").val(),
Industry: $("#applicantIndustryList").val(),
Occupation: $("#applicantOccupationList").val(),
OwnerOperator: ownerOperator,
WantsBusinessInsurance: wantBusinessIns,
HasCoApplicant: $("#applicantHasCoApplicant").val() === "Yes" ? true : false
};
var coApplicant = {
FirstName: $("#coapplicantFirstName").val(),
LastName: $("#coapplicantLastName").val(),
Relation: $("#coapplicantRelation").val(),
DateOfBirth: coAppDOB,
Gender: $("#coapplicantGender").val(),
MaritalStatus: $("#coapplicantMarital").val()
};
var applicantInfo = new Array(applicant, coApplicant);
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetApplicantInfo/",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(applicantInfo),
processData: false,
dataType: "json",
success: function (data) {
$("#loading-div-background").show();
// may need to change this check at some point
if ($("#CustomWaitMsg").val() != "") {
var newHtm = "
" + $("#CustomWaitMsg").val() + "
";
$("#loading-div").html(newHtm);
}
if ($("#IsCombinedPolicy").val() != "" && $("#IsCombinedPolicy").val().toLowerCase() == "true") {
getAutoRates();
}
else
beginRating();
},
error: function (resp) {
$("#loading-div-background").show();
// may need to change this check at some point
if ($("#CustomWaitMsg").val() != "") {
var newHtm = "
" + $("#CustomWaitMsg").val() + "
";
$("#loading-div").html(newHtm);
}
if ($("#IsCombinedPolicy").val() != "" && $("#IsCombinedPolicy").val().toLowerCase() == "true") {
getAutoRates();
}
else
beginRating();
}
});
}
});
// sets dynamic descriptions of applicant fields
function setUpApplicantNameFields() {
var fName = $("#FirstName").val();
var fNameVal = "";
var fNameApostropheVal = "";
if (fName == "") {
fNameVal = $("#currentLanguage").val() == "Spanish" ? "este persona" : "this person";
fNameApostropheVal = $("#currentLanguage").val() == "Spanish" ? "de este persona" : "this person's";
}
else {
fNameVal = fName;
fNameApostropheVal = $("#currentLanguage").val() == "Spanish" ? fNameVal : (DoesStringEndWith(fNameVal, 's')) ? fNameVal + "'" : fNameVal + "'s";
}
var drvName = $("#applicantDOBDesc").val().replace("{0}", fNameApostropheVal);
$("#applicantDOBname").text(drvName);
var drvGender = $("#applicantGenderDesc").val().replace("{0}", fNameVal);
$("#applicantGendername").text(drvGender);
var drvMarital = $("#applicantMaritalDesc").val().replace("{0}", fNameApostropheVal);
$("#applicantMaritalname").text(drvMarital);
var drvIndus = $("#applicantIndusDesc").val().replace("{0}", fNameVal);
$("#applicantIndusName").text(drvIndus);
setUpCoApplicantNameFields();
}
// sets dynamic descriptions of coapplicant fields
function setUpCoApplicantNameFields() {
setCoApplicantDisplay();
$("#insdFirstName").text($("#FirstName").val());
cofName = $("#coapplicantFirstName").val();
if (cofName == "") {
cofNameVal = $("#currentLanguage").val() == "Spanish" ? "este persona" : "this person";
cofNameApostropheVal = $("#currentLanguage").val() == "Spanish" ? "de este persona" : "this person's";
}
else {
cofNameVal = cofName;
cofNameApostropheVal = $("#currentLanguage").val() == "Spanish" ? cofNameVal : (DoesStringEndWith(cofNameVal, 's')) ? cofNameVal + "'" : cofNameVal + "'s";
}
var coAppname = $("#coapplicantDOBDesc").val().replace("{0}", cofNameApostropheVal);
$("#coapplicantDOBname").text(coAppname);
var coAppGender = $("#coapplicantGenderDesc").val().replace("{0}", cofNameVal);
$("#coapplicantGendername").text(coAppGender);
var coAppMarital = $("#coapplicantMaritalDesc").val().replace("{0}", cofNameApostropheVal);
$("#coapplicantMaritalname").text(coAppMarital);
}
function setCoApplicantDisplay() {
$("#coApplicantInfo").hide();
$("#coApplicantFields").hide();
if ($("#applicantHasCoApplicant").val() === "true") {
$("#coApplicantInfo").show();
$("#coApplicantFields").show();
}
}
// populates occupation list based on the selected industry
function setOccupation() {
var selIndustry = $("#applicantIndustryList").val();
if (selIndustry == "") {
$("#applicantOccupationPanel").addClass("hidden");
}
else {
$("#applicantOccupationPanel").removeClass("hidden");
}
$.ajax({
type: "GET",
url: _baseUrl + "/auto/GetIndustryOccupations?industryType=" + selIndustry,
dataType: 'json',
success: function (data, status) {
$("#applicantOccupationList option").remove();
$.each(data, function (iO, option) {
// add to options
$('', {
html: option.Text,
value: option.Value
}).appendTo($("#applicantOccupationList"));
});
if ($("#applicantOccupationList option").length == 2 && $("#applicantOccupationList option").eq(0).val() == "")
$("#applicantOccupationList option")[1].selected = true;
setBusinessDisplay();
},
error: function () {
//handle the error
}
});
}
// handle contact via email
$("#contactEmail").click(function (event) {
event.preventDefault();
$("#loading-div-background").show();
Itc.ConsumerRater.AnalyticsController.doGaEventView("Contact Method", "Email", "Property Quote");
history.pushState("pgThankYou", null, "/property/Home/ThankYou");
if ($("#IsCombinedPolicy").val() == "false") {
var selCompId = $("#selCompanyId").val();
var selCompInfo = {};
if (selCompId != "") {
var compInfo = $("#CompanyInfo" + selCompId).val().split("|");
// piped values - rate.CompanyName + "|" + rate.TotalPremium + "|" + rate.PayPlanDownPayment + "|" + rate.PayPlanPaymentAmount + "|" + rate.PayPlanNumOfPayments
selCompInfo = {
CompanyName: compInfo[0],
TotalPremium: compInfo[1],
DownPayment: compInfo[2],
PayPlanAmt: compInfo[3],
NumOfPayments: compInfo[4]
};
}
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetContactByEmail/",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(selCompInfo),
processData: false,
dataType: "json",
success: function (data) {
handleProposalResponse(data);
}
,
error: function (resp) {
//handle the error
showThankYou();
}
});
scrollToTop();
}
else {
// combined policy
doComboContactMe();
scrollToTop();
}
});
// handle contact via phone
$("#contactPhone").click(function (event) {
$(".page").hide();
$("#pgCallTiming").show();
loadPageTitle("pgCallTiming");
var visited = $("#visitedPages").val();
$("#prevPage").val("pgContactMethod");
$("#visitedPages").val(visited + "|pgContactMethod");
history.pushState("pgCallTiming", null, "/property/Home/CallTiming");
doPageView('CallMe_Timing');
Itc.ConsumerRater.AnalyticsController.doGaEventView("Contact Method", "Phone", "Property Quote");
scrollToTop();
});
$("#callNow").click(function (event) {
event.preventDefault();
$("#loading-div-background").show();
Itc.ConsumerRater.AnalyticsController.doGaEventView("Contact Phone", "ASAP", "Property Quote");
history.pushState("pgThankYou", null, "/property/Home/ThankYou");
if ($("#IsCombinedPolicy").val() == "false") {
var selCompId = $("#selCompanyId").val();
selCompInfo = {};
if (selCompId != "") {
var compInfo = $("#CompanyInfo" + selCompId).val().split("|");
// piped values - rate.CompanyName + "|" + rate.TotalPremium + "|" + rate.PayPlanDownPayment + "|" + rate.PayPlanPaymentAmount + "|" + rate.PayPlanNumOfPayments
selCompInfo = {
CompanyName: compInfo[0],
TotalPremium: compInfo[1],
DownPayment: compInfo[2],
PayPlanAmt: compInfo[3],
NumOfPayments: compInfo[4]
};
}
Itc.ConsumerRater.AnalyticsController.doGaEventView("Contact Phone", "ASAP", "Property Quote");
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetContactByPhoneNow/",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(selCompInfo),
processData: false,
dataType: "json",
success: function (data) {
handleProposalResponse(data);
}
,
error: function (resp) {
//handle the error
showThankYou();
}
});
scrollToTop();
}
else {
// combined policy
var auComp = {};
var hoComp = {};
if (_hasAURates && $("#SelAUCompInfo").val() != "") {
var selAUCompInfo = $("#SelAUCompInfo").val().split("|");
auComp = {
CompanyName: selAUCompInfo[0],
TotalPremium: selAUCompInfo[1],
DownPayment: selAUCompInfo[2],
PayPlanAmt: selAUCompInfo[3],
NumOfPayments: selAUCompInfo[4],
CompanyId: selAUCompInfo[5]
};
}
else {
auComp = {
CompanyName: "",
TotalPremium: -1,
DownPayment: -1,
PayPlanAmt: -1,
NumOfPayments: -1
}
}
if (_returnedRates && $("#selCompanyId").val() != "") {
var compInfo = $("#SelHOCompInfo").val().split("|");
// piped values - rate.CompanyName + "|" + rate.TotalPremium + "|" + rate.PayPlanDownPayment + "|" + rate.PayPlanPaymentAmount + "|" + rate.PayPlanNumOfPayments
var hoComp = {
CompanyName: compInfo[0],
TotalPremium: compInfo[1],
DownPayment: compInfo[2],
PayPlanAmt: compInfo[3],
NumOfPayments: compInfo[4],
CompanyId: $("#selCompanyId").val()
};
}
else {
hoComp = {
CompanyName: "",
TotalPremium: -1,
DownPayment: -1,
PayPlanAmt: -1,
NumOfPayments: -1
}
}
var comboList = [];
comboList.push(auComp);
comboList.push(hoComp);
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetContactByPhoneNowCombined",
contentType: "application/json; charset=utf-8",
processData: false,
data: JSON.stringify(comboList),
dataType: "json",
success: function (data) {
handleProposalResponse(data);
}
,
error: function (resp) {
//handle the error
showThankYou();
}
});
}
scrollToTop();
});
// handle contact via phone schedule
$("#callSchedule").click(function (event) {
event.preventDefault();
$("#loading-div-background").show();
Itc.ConsumerRater.AnalyticsController.doGaEventView("Contact Phone", "Schedule", "Property Quote");
history.pushState("pgThankYou", null, "/property/Home/ThankYou");
if ($("#IsCombinedPolicy").val() == "false") {
var selCompId = $("#selCompanyId").val();
var selCompInfo = {};
if (selCompId != "") {
var compInfo = $("#CompanyInfo" + selCompId).val().split("|");
// piped values - rate.CompanyName + "|" + rate.TotalPremium + "|" + rate.PayPlanDownPayment + "|" + rate.PayPlanPaymentAmount + "|" + rate.PayPlanNumOfPayments
selCompInfo = {
CompanyName: compInfo[0],
TotalPremium: compInfo[1],
DownPayment: compInfo[2],
PayPlanAmt: compInfo[3],
NumOfPayments: compInfo[4],
CompanyId: $("#selCompanyId").val()
};
}
var conTime = {
DayOfWeek: $("#day").val(),
TimeOfDay: $("#time").val(),
CarrierInfo: selCompInfo
};
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetContactByPhoneSchedule/",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(conTime),
processData: false,
dataType: "json",
success: function (data) {
handleProposalResponse(data);
}
,
error: function (resp) {
//handle the error
showThankYou();
}
});
scrollToTop();
}
else {
// combined policy
var auComp = {};
var hoComp = {};
if (_hasAURates && $("#SelAUCompInfo").val() != "") {
var selAUCompInfo = $("#SelAUCompInfo").val().split("|");
auComp = {
CompanyName: selAUCompInfo[0],
TotalPremium: selAUCompInfo[1],
DownPayment: selAUCompInfo[2],
PayPlanAmt: selAUCompInfo[3],
NumOfPayments: selAUCompInfo[4],
CompanyId: selAUCompInfo[5]
};
}
else {
auComp = {
CompanyName: "",
TotalPremium: -1,
DownPayment: -1,
PayPlanAmt: -1,
NumOfPayments: -1
}
}
if (_returnedRates && $("#selCompanyId").val() != "") {
var compInfo = $("#SelHOCompInfo").val().split("|");
// piped values - rate.CompanyName + "|" + rate.TotalPremium + "|" + rate.PayPlanDownPayment + "|" + rate.PayPlanPaymentAmount + "|" + rate.PayPlanNumOfPayments
var hoComp = {
CompanyName: compInfo[0],
TotalPremium: compInfo[1],
DownPayment: compInfo[2],
PayPlanAmt: compInfo[3],
NumOfPayments: compInfo[4],
CompanyId: $("#selCompanyId").val()
};
}
else {
hoComp = {
CompanyName: "",
TotalPremium: -1,
DownPayment: -1,
PayPlanAmt: -1,
NumOfPayments: -1
}
}
var conTime = {
DayOfWeek: $("#day").val(),
TimeOfDay: $("#time").val(),
AUCarrierInfo: auComp,
HOCarrierInfo: hoComp
};
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetContactByPhoneScheduleCombined",
contentType: "application/json; charset=utf-8",
processData: false,
data: JSON.stringify(conTime),
dataType: "json",
success: function (data) {
handleProposalResponse(data);
}
,
error: function (resp) {
//handle the error
showThankYou();
}
});
}
scrollToTop();
});
// 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();
}
}
// previous button click
$(".previousPage").click(function (event) {
event.preventDefault();
var btnId = $(this).prop('id');
$("#loading-div-background").show();
$.ajax({
type: "GET",
url: _baseUrl + "/api/GetPreviousPage?buttonId=" + btnId,
contentType: "application/json; charset=utf-8",
processData: false,
dataType: "json",
success: function (data) {
$(".page").hide();
var previousPageInfo = JSON.parse(data);
history.pushState(previousPageInfo.PageId, null, previousPageInfo.RelativeUrlPath);
$("#" + previousPageInfo.PageId).show();
doPageView(previousPageInfo.PageTitle);
$("#loading-div-background").hide();
// now assign new prevPage value for browser back button
$("#prevPage").val("");
var res = $("#visitedPages").val().split("|");
var foundIndex = -1;
for (var x = 0; x < res.length; x++) {
if (res[x] == previousPageInfo.PageId) {
foundIndex = x;
break;
}
}
if (foundIndex > -1) {
if (foundIndex > 0)
foundIndex = foundIndex - 1;
$("#prevPage").val(res[foundIndex]);
}
scrollToTop();
},
error: function (resp) {
$("#loading-div-background").hide();
}
});
scrollToTop();
return false;
});
// roof shape help
$("#roofShapeHelp").click(function () {
$("#RoofTypeHelp").show();
$("#roofTop").focus();
});
$(".btnRoofShape").click(function (event) {
event.preventDefault();
var $this = $(this);
$("#RoofShape").find('option').attr("selected", false);
$("#RoofTypeHelp").hide();
$("#RoofShape").focus();
$("#RoofShape option[value='" + $this.attr("data-roof") + "']").prop('selected', true);
});
$("#getCombo").click(function () {
$(".page").hide();
history.pushState("pgCombinedChoice", null, "/property/Home/CombinedChoice");
Itc.ConsumerRater.AnalyticsController.doGaEventView("Combo Select", "Both", "Property Quote");
doPageView("Combined Auto and Home");
if ($("#ContactMeRedirect").val() == "true" && $("#ContactMeUrl").val() != "") {
if ($("#ContactMeNotify").val() == "true") {
doComboContactMe();
}
window.location.href = decodeURI($("#ContactMeUrl").val());
} else {
if ($("#pgCombinedChoice").attr("data-showAddlLob") === "true") {
$("#pgAddlLob").show();
} else {
$("#pgContactMethod").show();
}
}
});
// combined results - i like auto button click
$("#getAuto").click(function () {
$(".page").hide();
_returnedRates = false;
Itc.ConsumerRater.AnalyticsController.doGaEventView("Combo Select", "Auto", "Property Quote");
history.pushState("pgContactMethod", null, "/property/Home/ContactMethod");
doPageView("Combined Auto and Home");
if ($("#ContactMeRedirect").val() == "true" && $("#ContactMeUrl").val() != "") {
if ($("#ContactMeNotify").val() == "true") {
doComboContactMe();
}
window.location.href = decodeURI($("#ContactMeUrl").val());
}
else {
if ($("#pgCombinedChoice").attr("data-showAddlLob") === "true") {
$("#pgAddlLob").show();
} else {
$("#pgContactMethod").show();
}
}
});
// combined results - i like home click
$("#getHome").click(function () {
$("#SelAUCompInfo").val("");
$(".page").hide();
Itc.ConsumerRater.AnalyticsController.doGaEventView("Combo Select", "Property", "Property Quote");
history.pushState("pgContactMethod", null, "/property/Home/ContactMethod");
doPageView("Combined Auto and Home");
if ($("#ContactMeRedirect").val() == "true" && $("#ContactMeUrl").val() != "") {
if ($("#ContactMeNotify").val() == "true") {
doComboContactMe();
}
window.location.href = decodeURI($("#ContactMeUrl").val());
} else {
if ($("#pgCombinedChoice").attr("data-showAddlLob") === "true") {
$("#pgAddlLob").show();
} else {
$("#pgContactMethod").show();
}
}
});
$("#ComparisonSortList").change(function () {
$("#loading-div-background").show();
$.ajax({
type: "POST",
url: _baseUrl + "/api/ComparisonSort?sortVal=" + $("#ComparisonSortList").val(),
contentType: "application/json; charset=utf-8",
processData: false,
dataType: "json",
success: function (respData) {
var data = JSON.parse(respData);
data.Completed = true;
populateComparisonList(data);
$("#loading-div-background").hide();
},
error: function (resp) {
$("#loading-div-background").hide();
}
});
});
$("#applicantHasCoApplicant").change(function () {
setCoApplicantDisplay();
});
$("#LanguageToggle").click(function () {
var controls = [];
$("#residence input").each(function () {
if (this.value !== "" && this.id !== "") {
controls.push({
controlId: "#" + this.id,
value: this.value
});
}
});
$("#residence select").each(function () {
if (this.value !== "" && this.id !== "") {
controls.push({
controlId: "#" + this.id,
value: this.value
});
}
});
if ($("#verifyDisclosure").is(":checked")) {
controls.push({
controlId: "#verifyDisclosure",
value: "checked:true"
});
}
if (controls.length > 0) {
sessionStorage.setItem("reloading", "true");
sessionStorage.setItem("reloadControls", JSON.stringify(controls));
}
Itc.ConsumerRater.Utilities.toggleLanguage($("#LanguageToggle").attr("value"), _baseUrl);
});
var reloading = sessionStorage.getItem("reloading");
if (reloading) {
sessionStorage.removeItem("reloading");
var controls = JSON.parse(sessionStorage.getItem("reloadControls"));
if (controls.length > 0) {
setTimeout(Itc.ConsumerRater.Utilities.resetControls(controls), 500);
}
sessionStorage.removeItem("reloadControls");
}
}
// combo policy contact me
function doComboContactMe() {
// combined policy
var auComp = {};
var hoComp = {};
if (_hasAURates && $("#SelAUCompInfo").val() != "") {
var selAUCompInfo = $("#SelAUCompInfo").val().split("|");
auComp = {
CompanyName: selAUCompInfo[0],
TotalPremium: selAUCompInfo[1],
DownPayment: selAUCompInfo[2],
PayPlanAmt: selAUCompInfo[3],
NumOfPayments: selAUCompInfo[4],
CompanyId: selAUCompInfo[5]
};
}
else {
auComp = {
CompanyName: "",
TotalPremium: -1,
DownPayment: -1,
PayPlanAmt: -1,
NumOfPayments: -1
}
}
if (_returnedRates && $("#selCompanyId").val() != "") {
var compInfo = $("#SelHOCompInfo").val().split("|");
// piped values - rate.CompanyName + "|" + rate.TotalPremium + "|" + rate.PayPlanDownPayment + "|" + rate.PayPlanPaymentAmount + "|" + rate.PayPlanNumOfPayments
var hoComp = {
CompanyName: compInfo[0],
TotalPremium: compInfo[1],
DownPayment: compInfo[2],
PayPlanAmt: compInfo[3],
NumOfPayments: compInfo[4],
CompanyId: $("#selCompanyId").val()
};
}
else {
hoComp = {
CompanyName: "",
TotalPremium: -1,
DownPayment: -1,
PayPlanAmt: -1,
NumOfPayments: -1
}
}
var comboList = [];
comboList.push(auComp);
comboList.push(hoComp);
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetContactByEmailCombined",
contentType: "application/json; charset=utf-8",
processData: false,
data: JSON.stringify(comboList),
dataType: "json",
success: function (data) {
handleProposalResponse(data);
}
,
error: function (resp) {
//handle the error
showThankYou();
}
});
}
function standardAddressIsValid() {
var valid = true;
var focused = false;
// remove any current errors
$("#step1").find("*").removeClass("inputErr");
$("#step1").find("*").removeClass("err");
if ($("#NamePanel").is(":visible") == true) {
if ($("#FirstName").val() == "") {
valid = false;
$("#FirstName").focus();
focused = true;
$("#FirstName").addClass("inputErr");
$("#NamePanel").addClass("err");
}
if ($("#LastName").val().length < 2) {
valid = false;
if (!focused) {
$("#LastName").focus();
focused = true;
}
$("#LastName").addClass("inputErr");
$("#NamePanel").addClass("err");
}
}
if ($("#propAddress1").val() == "") {
valid = false;
$("#propAddress1").addClass("inputErr");
$("#AddressPanel").addClass("err");
if (!focused) {
$("#propAddress1").focus();
focused = true;
}
}
if ($("#propCity").val() == "") {
valid = false;
$("#propCity").addClass("inputErr");
$("#CityPanel").addClass("err");
if (!focused) {
$("#propCity").focus();
focused = true;
}
}
if ($("#propState").val() == "" || $("#propState").val() == "NoneSelected") {
valid = false;
$("#propState").addClass("inputErr");
$("#StatePanel").addClass("err");
if (!focused) {
$("#propState").focus();
focused = true;
}
}
$("#ZipCodeErr").hide();
if ($("#propZIP").val() === "" || $("#propZIP").val().length < 5) {
valid = false;
$("#propZIP").addClass("inputErr");
$("#ZipPanel").addClass("err");
if (!focused) {
$("#propZIP").focus();
focused = true;
}
}
if ($("#LeadSource").is(":visible") && $("#LeadSource").prop('required') && $("#LeadSource").val() == "") {
valid = false;
$("#LeadSourceHOPan").addClass("err");
$("#LeadSource").addClass("inputErr");
if (!focused) {
$("#LeadSource").focus();
focused = true;
}
}
var validator = $("#residence").validate();
if (!validator.element("#EmailAddress")) {
valid = false;
$("#EmailAddress").addClass("inputErr");
$("#EmailPanel").addClass("err");
if (!focused) {
focused = true;
$("#EmailAddress").focus();
}
}
if ($("#Phone").is(":visible")) {
$("#Phone").removeClass("inputErr");
if (!validator.element("#Phone") || !validatePhone($("#Phone").val())) {
valid = false;
if (!focused) {
$("#Phone").focus();
focused = true;
}
$("#Phone").addClass("inputErr");
$("#PhonePanel").addClass("err");
}
}
// for some reason smarty streets autocomplete can enable the continue button even if they haven't agreed yet
$("#verifyDisclosure").removeClass("inputErr");
$(".agreement").removeClass("err");
if (!$("#verifyDisclosure").is(":checked")) {
valid = false;
$("#verifyDisclosure").addClass("inputErr");
if (!focused) {
$("#verifyDisclosure").focus();
focused = true;
}
$(".agreement").addClass("err");
}
if ($("#TimeAtResidence").is(":visible") && $("#TimeAtResidence").prop("required") && $("#TimeAtResidence").val() === "0") {
$("#TimeAtResidencePanel").addClass("err");
$("#TimeAtResidence").addClass("inputErr");
valid = false;
if (!focused) {
$("#TimeAtResidence").focus();
focused = true;
}
}
var priorRequired = $("#PriorAddressLbl").attr("data-priorRequired") === "true";
if ($("#PriorAddress").is(":visible") && priorRequired && $("#PriorAddress").val() === "") {
$("#PriorAddressPanel").addClass("err");
$("#PriorAddress").addClass("inputErr");
valid = false;
if (!focused) {
$("#PriorAddress").focus();
focused = true;
}
}
if ($("#PriorCity").is(":visible") && priorRequired && $("#PriorCity").val() === "") {
$("#PriorCityPanel").addClass("err");
$("#PriorCity").addClass("inputErr");
valid = false;
if (!focused) {
$("#PriorCity").focus();
focused = true;
}
}
if ($("#PriorState").is(":visible") && priorRequired && ($("#PriorState").val() === "" || $("#PriorState").val() === "NoneSelected")) {
$("#PriorStatePanel").addClass("err");
$("#PriorState").addClass("inputErr");
valid = false;
if (!focused) {
$("#PriorState").focus();
focused = true;
}
}
if ($("#PriorZip").is(":visible") && priorRequired && $("#PriorZip").val() === "") {
$("#PriorZipPanel").addClass("err");
$("#PriorZip").addClass("inputErr");
valid = false;
if (!focused) {
$("#PriorZip").focus();
focused = true;
}
}
return valid;
}
function doZipValidation() {
return new Promise(function (resolve, reject) {
$.ajax({
type: "GET",
url: _baseUrl + "/api/ValidateZip?zip=" + $("#propZIP").val(),
contentType: "application/json; charset=utf-8",
processData: false,
dataType: "json",
success: function (data) {
if (data === "Failure") {
reject("Failure");
} else {
resolve("Success");
}
},
error: function (resp) {
reject("Failure");
}
});
});
}
// smarty streets valuation
function doSmartyValidation() {
return new Promise(function (resolve, reject) {
var validAddress = false;
var smartyStreetsURL = _baseUrl + "/auto/ValidateAddress?street=" +
encodeURIComponent($("#propAddress1").val()) +
'%20' +
encodeURIComponent($("#propAddress2").val()) +
"&city=" +
encodeURIComponent($("#propCity").val()) +
"&state=" +
$("#propState").val() +
"&zipcode=" +
encodeURIComponent($("#propZIP").val());
$.ajax({
type: "GET",
url: smartyStreetsURL,
contentType: "application/json",
dataType: "json",
success: function (data) {
if (data.length === 0) {
resolve(_ssAddressStatus = "Failure");
return;
}
resolve(handleSmartyData(data));
},
error: function (resp) {
reject(_ssAddressStatus = "Failure");
return false;
}
});
});
}
// handles smarty data
function handleSmartyData(data) {
$.each(data,
function (iO, retAddress) {
if (typeof retAddress.analysis.dpv_match_code !== 'undefined') {
if (retAddress.analysis.dpv_match_code == "Y") {
_ssAddressStatus = "Success";
address.Address1 = retAddress.delivery_line_1;
address.City = retAddress.components.city_name;
address.State = retAddress.components.state_abbreviation;
address.Zipcode = retAddress.components.zipcode;
address.Plus4Code = retAddress.components.plus4_code;
address.County = retAddress.metadata.county_name;
address.Latitude = retAddress.metadata.latitude;
address.Longitude = retAddress.metadata.longitude;
if (address.Address1 !== $("#propAddress1").val() ||
address.City !== $("#propCity").val() ||
address.Zipcode !== $("#propZIP").val()) {
_ssAddressStatus = "confirm";
}
}
else if (retAddress.analysis.dpv_match_code == "D") {
_ssAddressStatus = "Missing";
var missingErr = $("#currentLanguage").val() === "Spanish"
? "¿Apartamento perdido o suite?"
: "Missing apartment or suite?";
$("#ssErr").html(missingErr);
$("#ssErr").show();
$("#InsuredAddress2").addClass("inputErr");
$("#AddressPanel").addClass("err");
$("#InsuredAddress2").focus();
} else {
_ssAddressStatus = "Failure";
}
} else {
_ssAddressStatus = "Failure";
}
});
}
// back up address validation
function doCensusValidation() {
return new Promise(function (resolve, reject) {
var cenAddress = {
Address1: $("#propAddress1").val(),
Address2: $("#propAddress2").val(),
City: $("#propCity").val(),
State: $("#propState").val(),
Zipcode: $("#propZIP").val()
};
$.ajax({
type: "POST",
url: _baseUrl + "/auto/ValidateGeoAddress",
contentType: "application/json",
data: JSON.stringify(cenAddress),
dataType: "json",
success: function (data) {
if (data.length === 0 || data === "Failure") {
resolve(_ssAddressStatus = "Failure");
} else {
resolve(handleCensusData(data, cenAddress));
}
},
error: function (resp) {
reject(_ssAddressStatus = "Failure");
}
});
});
}
// handles census data
function handleCensusData(data, cenAddress) {
_ssAddressStatus = "Success";
address.Address1 = cenAddress.Address1;
address.Address2 = cenAddress.Address2;
address.City = cenAddress.City;
address.State = data; // returns state abbreviation
address.Zipcode = cenAddress.Zipcode;
address.Plus4Code = "";
address.County = "";
}
// show couldn't validate address
function ShowAddressNotFound() {
$("#addresssection").hide();
$("#addressConfirmsection").show();
$("#addressTryAgain").show();
$("#propAddrRate").hide();
$("#pg0Prev").hide();
$(".agreement").hide();
$("#disclaimerBelow").hide();
var enteredAddress = $("#propAddress1").val() + " " + $("#propAddress2").val() + " ";
enteredAddress += $("#propCity").val() + ", " + $("#propState").val() + " " + $("#propZIP").val();
$("#enteredAddress").html(enteredAddress);
$("#suggestedAddressPan").hide();
$("#addressConfirmTitle").show();
$("#loading-div-background").hide();
}
// sets current insurance display
function setCurrentInsuranceDisplay() {
// current insurance
$("#CurrentInsurerPanel").hide();
$("#PriorMonthlyPaymentPan").hide();
$("#InsuredDiscount").change(function () {
$("#CurrentInsurerPanel").hide();
if ($("#InsuredDiscount").val() == "true") {
$("#CurrentInsurerPanel").show();
if ($("#showMonthlyPremium").val() == "true") {
$("#PriorMonthlyPaymentPan").show();
}
}
});
if ($("#InsuredDiscount").val() == "true") {
$("#CurrentInsurerPanel").show();
if ($("#showMonthlyPremium").val() == "true") {
$("#PriorMonthlyPaymentPan").show();
}
}
}
// sets name info
function setName(addressValidated) {
hideiOSWarning();
var priorAddress = {
Address1: $("#PriorAddress").val(),
Address2: $("#PriorAddress2").val(),
City: $("#PriorCity").val(),
State: $("#PriorState").val() === "" ? "NoneSelected" : $("#PriorState").val(),
Zipcode: $("#PriorZip").val(),
Plus4Code: "",
County: ""
};
var person = {
FirstName: $("#FirstName").val(),
LastName: $("#LastName").val(),
LeadSource: $("#LeadSource").val(),
EmailAddress: $("#EmailAddress").val(),
Phone: $("#Phone").val(),
ZipCode: $("#propZIP").val(),
StateAbbrev: $("#propState").val(),
TimeAtResidence: parseInt($("#TimeAtResidence").val()),
PriorAddress: priorAddress,
AddressValidated: addressValidated
};
$.ajax({
type: "POST",
url: _baseUrl + "/api/SetName/",
contentType: "application/json; charset=utf-8",
data: JSON.stringify(person),
processData: false,
dataType: "json",
success: function (data) {
if (data == "Failure") {
if (iOS() && isFramed()) {
showiOSWarning();
}
}
},
error: function (resp) {
if (iOS() && isFramed()) {
showiOSWarning();
}
}
});
}
// hides iOS warning message
function hideiOSWarning() {
$("#iOSWarining").removeClass("iOSWarning");
$("#iOSWarining").addClass("iOSWarningHidden");
}
// shows iOS warning message
function showiOSWarning() {
$("#iOSWarining").removeClass("iOSWarningHidden");
$("#iOSWarining").addClass("iOSWarning");
$("#iOSWarining").focus();
}
// shows access control dialog
function showAccessControl() {
$("#getAccessControl").removeClass("modalBgHidden");
$("#getAccessControl").addClass("modalBg");
}
// hades access control dialog
function hideAccessControl() {
$("#getAccessControl").removeClass("modalBg");
$("#getAccessControl").addClass("modalBgHidden");
}
// validates page 3
function pg3IsValid() {
var valid = true;
var date = new Date();
// remove any current errors
$("#pgDetails").find("*").removeClass("inputErr");
$("#pgDetails").find("*").removeClass("err");
// year of const
if ($("#YearOfConstruction").is(":visible") && ($("#YearOfConstruction").val() < 1700 || $("#YearOfConstruction").val() > date.getFullYear())) {
valid = false;
$("#YearOfConstruction").addClass("inputErr");
$("#YearOfConstructionPan").addClass("err");
}
// sq ft
if ($("#SquareFootage").val() < 100 || $("#SquareFootage").val() > 100000) {
valid = false;
$("#SquareFootage").addClass("inputErr");
$("#SquareFootagePan").addClass("err");
}
// full baths
if ($("#NumberOfFullBaths").val() < 0 || $("#NumberOfFullBaths").val() > 9) {
valid = false;
$("#NumberOfFullBaths").addClass("inputErr");
$("#NumberOfFullBathsPan").addClass("err");
}
// half baths
if ($("#NumberOfHalfBaths").val() < 0 || $("#NumberOfHalfBaths").val() > 9) {
valid = false;
$("#NumberOfHalfBaths").addClass("inputErr");
$("#NumberOfHalfBathsPan").addClass("err");
}
// 3/4 baths
if ($("#NumberOfThreeQuarterBaths").val() < 0 || $("#NumberOfThreeQuarterBaths").val() > 9) {
valid = false;
$("#NumberOfThreeQuarterBaths").addClass("inputErr");
$("#NumberOfThreeQuarterBathsPan").addClass("err");
}
// swimming pool
if ($("#SwimmingPool").val() == "true" && $("#SwimmingPoolType").val() == "") {
valid = false;
$("#SwimmingPoolType").addClass("inputErr");
$("#SwimmingPoolTypePan").addClass("err");
$("#SwimmingPoolTypePan").show(); // make sure it is visible
}
// construction
if ($("#Construction").val() == "") {
valid = false;
$("#Construction").addClass("inputErr");
$("#ConstructionPan").addClass("err");
}
// roof composition
if ($("#RoofComposition").val() == "") {
valid = false;
$("#RoofComposition").addClass("inputErr");
$("#RoofCompositionPan").addClass("err");
}
// roof shape
if ($("#RoofShape").val() == "") {
valid = false;
$("#RoofShape").addClass("inputErr");
$("#RoofShapePan").addClass("err");
}
if (!valid) {
$("#pg3submit").addClass("err");
}
return valid;
}
// validates contact page
function contactPageValid() {
var valid = true;
// remove any current errors
$("#pgContact").find("*").removeClass("inputErr");
$("#pgContact").find("*").removeClass("err");
if ($("#FirstName").val() == "") {
valid = false;
$("#FirstName").addClass("inputErr");
}
if ($("#LastName").val() == "") {
valid = false;
$("#LastName").addClass("inputErr");
}
if ($("#ContactEmailAddress").val() == "" || !validateEmail($("#ContactEmailAddress").val())) {
valid = false;
$("#ContactEmailAddress").addClass("inputErr");
}
if (!validatePhone($("#ContactPhone").val())) {
valid = false;
$("#ContactPhone").addClass("inputErr");
}
if (!valid)
$("#pg7submit").addClass("err");
return valid;
}
// email validation function
function validateEmail(email) {
var 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,}))$/;
return re.test(email);
}
// phone validation function
function validatePhone(phone_number) {
phone_number = phone_number.replace(/\D/g, '');
return phone_number.length > 9 && phone_number.match(/^(1-?)?(\([2-9]\d{2}\)|[2-9]\d{2})-?[2-9]\d{2}-?\d{4}$/);
}
// gets rate results
function beginRating() {
$("#addlOptions").hide();
$(".description").hide();
$(".page").hide();
$("#pgResults").show();
$("#ComparisonSort").hide();
$.ajax({
type: "POST",
url: _baseUrl + "/api/GetRates/",
contentType: "application/json; charset=utf-8",
processData: false,
dataType: "json",
success: function (data) {
if (data === "Success") {
setTimeout(checkRateResults, 1000);
} else {
$("#loading-div-background").hide();
resetLoadingDivHtml();
if ($("#IsCombinedPolicy").val() != "" && $("#IsCombinedPolicy").val().toLowerCase() === "true") {
var rateResp = {};
rateResp.Success = false;
rateResp.Completed = true;
populateComparisonList(rateResp);
} else {
showErrorThankYou();
}
}
},
error: function (resp) {
//handle the error
$("#loading-div-background").hide();
resetLoadingDivHtml();
showErrorThankYou();
}
});
scrollToTop();
}
// see if rating is done and populate list with any rates returned
function checkRateResults() {
$.ajax({
type: "GET",
url: _baseUrl + "/api/CheckRates/",
contentType: "application/json; charset=utf-8",
processData: false,
dataType: "json",
success: function (data) {
var respData = JSON.parse(data);
populateComparisonList(respData);
if (!respData.Completed) {
setTimeout(checkRateResults, 2000);
} else {
$("#loading-div-background").hide();
resetLoadingDivHtml();
}
},
error: function (resp) {
//handle the error
$("#loading-div-background").hide();
resetLoadingDivHtml();
showErrorThankYou();
}
});
scrollToTop();
}
// removes rating messages from loading div
function resetLoadingDivHtml() {
$("#loading-div").html("
");
}
// gets auto rates
var _kickedOffRating = false;
function getAutoRates() {
var rateUrl = _kickedOffRating ? _baseUrl + "/auto/GetRates" : _baseUrl + "/auto/ComparisonSort?sortVal=" + $("#DefaultComparisonSort").val();
var noRates = $("#currentLanguage").val() === "Spanish" ? "No podemos devolver las tarifas automáticas en este momento." : "We are unable to return Auto rates at this time.";
$.ajax({
type: _kickedOffRating ? "GET" : "POST",
url: rateUrl,
processData: false,
dataType: "json",
success: function (data) {
var newData = JSON.stringify(data);
var rateResp = JSON.parse(newData);
if (rateResp.RatingStatus != 2) {
_kickedOffRating = true;
setTimeout(getAutoRates, 2000);
}
else { // done
$("#prevPage").val("pgApplicant");
if (rateResp.ComparisonCount == 0) {
var custMsg = $("#CustomQuoteMsgHid").val() != "" ? $("#CustomQuoteMsgHid").val() + " " : "";
$("#CustomQuoteMsg").html(custMsg + noRates);
$("#CustomQuoteMsg").show();
beginRating();
}
else {
_hasAURates = true;
setRateResponses(rateResp);
var custAuto = $("#currentLanguage").val() == "Spanish" ? "Sus Citas Automotrices Personalizadas" : "Your Customized Auto Quotes";
$("#ResultsTitle").html(custAuto);
beginRating();
}
}
},
error: function (resp) {
//handle the error
$("#loading-div-background").hide();
var custMsg = $("#CustomQuoteMsgHid").val() != "" ? $("#CustomQuoteMsgHid").val() + " " : "";
$("#CustomQuoteMsg").html(custMsg + noRates);
$("#CustomQuoteMsg").show();
beginRating();
}
});
}
function setRateResponses(rateResp) {
if (_returnedRates) {
$("#top3").html(rateResp.Top3Html);
$("#top3hidAU").val(rateResp.Top3Html)
$("#addlOptions").hide();
$("#addRates").html("");
if (rateResp.AddlRatesHtml != "") {
$("#addlOptions").show();
$("#addRates").html(rateResp.AddlRatesHtml);
$("#addlHidAU").val(rateResp.AddlRatesHtml);
}
$("#disclaimers").html(rateResp.AddlMsg);
history.pushState("pgResults", null, "/property/Home/QuoteResults");
$("#prevPage").val("pgResults");
var visited = $("#visitedPages").val() + "|pgResults";
$("#visitedPages").val(visited);
doPageView("Your Customized Auto Quotes");
}
else {
$("#top3hidAU").val(rateResp.Top3Html);
$("#addlHidAU").val(rateResp.AddlRatesHtml);
}
scrollToTop();
}
// for combined auto+home, select the auto carrier
function setSelCarrier(pipedValues) {
$("#SelAUCompInfo").val(pipedValues);
event.preventDefault();
var auInfo = pipedValues.split("|");
_auLogo = $("#auLogo_" + auInfo[5]).val();
if ($("#selTerm_" + auInfo[5]).length) {
_auTerm = parseInt($("#selTerm_" + auInfo[5]).val());
}
Itc.ConsumerRater.AnalyticsController.doGaEventView("Select Auto Carrier", auInfo[0], "Property Quote");
$(".page").hide();
if (_returnedRates) {
$("#top3").html($("#top3hid").val());
$("#addlOptions").hide();
$("#addRates").html("");
if ($("#addlHid").val() != "") {
$("#addlOptions").show();
$("#addRates").html($("#addlHid").val());
}
$("#ResultsTitle").html("Your Customized Home Quotes");
history.pushState("pgResults", null, "/property/Home/QuoteResults");
$("#prevPage").val("pgResultsAuto");
var visited = $("#visitedPages").val() + "|pgResultsAuto";
$("#visitedPages").val(visited);
doPageView("Your Customized Home Quotes");
$(".ComparisonSort").hide();
$("#pgResults").show();
if ($("#CustomQuoteMsg").is(":visible")) {
$("#CustomQuoteMsg").html($("#CustomQuoteMsgHid").val());
}
$.ajax({
type: "POST",
url: _baseUrl + "/auto/SetSelectedCarrier?values=" + pipedValues,
processData: false,
dataType: "json",
success: function (data) {
},
error: function (resp) {
}
});
scrollToTop();
}
else {
$("#pgContactMethod").show();
scrollToTop();
}
scrollToTop();
}
function beginPropRate() {
try {
window.history.replaceState(null, null, window.location.pathname); // removes any querystring values
} catch (err) {
// this may error if an agency adds 3rd party js files.
}
history.pushState("step1", null, "/property/Home/Ownership");
$("div.description").hide();
$(".smarty-ui").hide();
$(".page").hide();
$("#pgOwnership").show();
loadPageTitle("pgOwnership");
if ($("#ComboHomeForm").val() !== "") {
var confirm = $("#currentLanguage").val() === "Spanish" ? "Confirmar" : "Confirm";
if ($("#ComboHomeForm").val() == "HO4") {
$("#RentersPanel").addClass("selected");
$("#curRent").addClass("selCov");
$("#curRent").prop("value", confirm);
}
else if ($("#ComboHomeForm").val() == "HO3") {
$("#HOPanel").addClass("selected");
$("#curOwn").addClass("selCov");
$("#curOwn").prop("value", confirm);
}
else {
$("#CondoPanel").addClass("selected");
$("#curOwnCondo").addClass("selCov");
$("#curOwnCondo").prop("value", confirm);
}
}
$(".GreetingText").hide();
$(".map").hide();
$("#addressTitle").hide();
$("#prevPage").val("step1");
$("#visitedPages").val("step1");
doPageView("Ownership");
if ($(".map").is(':hidden')) {
$("#container").css("min-height", "calc(86vh)");
}
setPetInsDisplay();
scrollToTop();
$.ajax({
type: "POST",
url: _baseUrl + "/api/PropertyApi/",
contentType: "application/json; charset=utf-8",
processData: false,
data: JSON.stringify(address),
dataType: "json",
success: function (data) {
var sqFt = parseInt(data.SquareFootage) == 1 ? "" : data.SquareFootage;
$('#NumberOfFamilies option[value="' + data.NumberOfFamilies + '"]').prop('selected', true);
$('#StoryType option[value="' + data.StoryType + '"]').prop('selected', true);
$('#YearOfConstruction').val(data.YearOfConstruction);
$('.dwellingcoverage').html(data.DwellingAmt.formatMoney(0));
$('.propertycoverage').html((Math.round((data.DwellingAmt * 0.6) / 1000) * 1000).formatMoney(0));
$('.othercoverage').html((Math.round((data.DwellingAmt * 0.1) / 1000) * 1000).formatMoney(0));
$('.deductible').html("1% / " + (Math.round((data.DwellingAmt * 0.1) / 1000) * 1000).formatMoney(0));
$('#ReplacementCostValue').val(data.DwellingAmt);
$('#SquareFootage').val(sqFt);
$('#NumberOfFullBaths').val(data.NumberOfFullBaths);
$('#NumberOfHalfBaths').val(data.NumberOfHalfBaths);
$('#NumberOfThreeQuarterBaths').val(data.NumberOfThreeQuarterBaths);
$('#Construction option[value="' + data.Construction + '"]').prop('selected', true);
$('#RoofComposition option[value="' + data.RoofComposition + '"]').prop('selected', true);
$('#RoofShape option[value="' + data.RoofShape + '"]').prop('selected', true);
$('#PrimaryHeatingType option[value="' + data.PrimaryHeatingType + '"]').prop('selected', true);
$('#SwimmingPool option[value="' + data.SwimmingPool + '"]').prop('selected', true);
if (data.SwimmingPool) {
$('#SwimmingPoolType option:contains("' + data.SwimmingPoolType + '")').prop('selected', true);
$('#panelSwimmingPoolType').show();
}
_returnedValuation = true;
setEqWindDisplay();
scrollToTop();
}
,
error: function (resp) {
//handle the error
_returnedValuation = true;
}
});
}
// display auto rate results for combined quote
function showAURates() {
$("#top3").html($("#top3hidAU").val());
$("#addlOptions").hide();
$("#addRates").html("");
if ($("#addlHidAU").val() != "") {
$("#addlOptions").show();
$("#addRates").html($("#addlHidAU").val());
}
history.pushState("pgResults", null, "/property/Home/QuoteAutoResults");
$("#prevPage").val("pgContents");
var visited = $("#visitedPages").val() + "|pgResults";
$("#visitedPages").val(visited);
doPageView("Your Customized Auto Quotes");
$(".ComparsionPhoneMeLink").hide();
$(".buyNowAuto").hide();
scrollToTop();
}
// set selected HO company for combined quote
function setHOCarrier(compId) {
$("#selCompanyId").val(compId);
$(".page").hide();
$("#pgCombinedChoice").show();
history.pushState("pgCombinedChoice", null, "/property/Home/CombinedChoice");
// ho company
$("#SelHOCompInfo").val($("#CompanyInfo" + compId).val());
var compInfo = $("#CompanyInfo" + compId).val().split("|");
Itc.ConsumerRater.AnalyticsController.doGaEventView("Select Property Carrier", compInfo[0], "Property Quote");
// piped values - rate.CompanyName + "|" + rate.TotalPremium + "|" + rate.PayPlanDownPayment + "|" + rate.PayPlanPaymentAmount + "|" + rate.PayPlanNumOfPayments
// get auto payment
var auCompInfo = $("#SelAUCompInfo").val().split("|");
var auPayPlanAmt = parseFloat(auCompInfo[3]);
var auTotal = parseFloat(auCompInfo[1]);
if (_auTerm == 0)
_auTerm = 6;
var auPayment = (auPayPlanAmt > 0 && auPayPlanAmt * 2 < auTotal) ? auPayPlanAmt : (auTotal / _auTerm);
// get ho payment
var hoPayPlanAmt = parseFloat(compInfo[3]);
var hoTerm = $("#HOterm_" + compId).val();
var hoTotal = parseFloat(compInfo[1]);
var hoPayment = (hoPayPlanAmt > 0 && hoPayPlanAmt * 2 < hoTotal) ? hoPayPlanAmt : (hoTotal / parseInt(hoTerm));
var hoLogo = $("#HOlogo_" + compId).val();
var hoHtml = "