﻿if (typeof (jQuery) != "undefined") { $(document).ready(function() { var debug = false; if (window.location.search.toLowerCase().indexOf("debug=true") != -1) debug = true; function sleep(milliseconds) { var start = new Date().getTime(); while ((new Date().getTime() - start) < milliseconds) { } } function log(label, evt) { try { if (debug) { alert("Label = " + label); evt.preventDefault(); } else if (typeof GA_Event == "function") { GA_Event(label); sleep(100); } } catch (e) { } } function GaParams(id, label, endsWith) { this.id = id; this.label = label; this.endsWith = (typeof endsWith == "undefined" || endsWith == false) ? false : true; } var paramList = new Array(); paramList.push(new GaParams("slide_1_img", "HeroClick-1")); paramList.push(new GaParams("slide_2_img", "HeroClick-2")); paramList.push(new GaParams("slide_3_img", "HeroClick-3")); paramList.push(new GaParams("SlideshowControl-1", "Hero_Navigation1")); paramList.push(new GaParams("SlideshowControl-2", "Hero_Navigation2")); paramList.push(new GaParams("SlideshowControl-3", "Hero_Navigation3")); paramList.push(new GaParams("btn_left", "Carousel_Left")); paramList.push(new GaParams("btn_right", "Carousel_Right")); paramList.push(new GaParams("Auto", "Carousel_Auto")); paramList.push(new GaParams("Motorcycle", "Carousel_Motorcycle")); paramList.push(new GaParams("Boat", "Carousel_Boat")); paramList.push(new GaParams("RV", "Carousel_RV")); paramList.push(new GaParams("PCA", "Carousel_PCA")); paramList.push(new GaParams("Home", "Carousel_Homeowners")); paramList.push(new GaParams("Renters", "Carousel_Renters")); paramList.push(new GaParams("Condo", "Carousel_Condo")); paramList.push(new GaParams("Snowmobile", "Carousel_Snowmobile")); paramList.push(new GaParams("Health", "Carousel_Health")); paramList.push(new GaParams("Life", "Carousel_Life")); paramList.push(new GaParams("Pet", "Carousel_Pet")); paramList.push(new GaParams("CollectorCar", "Carousel_CollectorCar")); paramList.push(new GaParams("Umbrella", "Carousel_Umbrella")); paramList.push(new GaParams("logo", "Logo_Click")); $.each(paramList, function(index, value) { var gaParam = value; var elemId = gaParam.id; if (gaParam.endsWith == true) { elemId = "[id$='" + elemId + "']"; } else { elemId = "#" + elemId; } $(elemId).click(function(evt) { log(gaParam.label, evt); }); }); $(".productcontainer").click(function(evt) { try { var labelName = "Carousel_Copy_" + window.GetGaTrackingText($.trim($(this).text()).split(" ")[0].toLowerCase()); log(labelName, evt); } catch (e) { } }); window.GetGaTrackingText = function(productString) { productString = $.trim(productString); if (window.ProductTextMap[productString] == "undefined") return "Unknown"; return window.ProductTextMap[productString]; }; window.ProductTextMap = {}; window.ProductTextMap["auto"] = "Auto"; window.ProductTextMap["motorcycle"] = "Motorcycle"; window.ProductTextMap["boat"] = "Boat"; window.ProductTextMap["rv"] = "RV"; window.ProductTextMap["commercial"] = "PCA"; window.ProductTextMap["homeowners"] = "Homeowners"; window.ProductTextMap["renters"] = "Renters"; window.ProductTextMap["condo"] = "Condo"; window.ProductTextMap["snowmobile"] = "Snowmobile"; window.ProductTextMap["health"] = "Health"; window.ProductTextMap["life"] = "Life"; window.ProductTextMap["pet"] = "Pet"; window.ProductTextMap["collector"] = "CollectorCar"; window.ProductTextMap["umbrella"] = "Umbrella"; window.ProductCodeMap = {}; window.ProductCodeMap["AU"] = "Auto"; window.ProductCodeMap["MC"] = "Motorcycle"; window.ProductCodeMap["BT"] = "Boat"; window.ProductCodeMap["MT"] = "Motor_Home"; window.ProductCodeMap["TT"] = "Travel_Trailer"; window.ProductCodeMap["RV"] = "RV"; window.ProductCodeMap["CA"] = "PCA"; window.ProductCodeMap["H"] = "Homeowners"; window.ProductCodeMap["R"] = "Renters"; window.ProductCodeMap["C"] = "Condo"; window.ProductCodeMap["SM"] = "Snowmobile"; window.ProductCodeMap["MH"] = "Mobile_Home"; window.ProductCodeMap["AU+HO"] = "Auto_Homeowners"; window.ProductCodeMap["AU+RT"] = "Auto_Renters"; window.ProductCodeMap["AU+CO"] = "Auto_Condo"; window.GetGaTrackingTextFromCode = function(productCode) { if (window.ProductCodeMap[productCode] == "undefined") return "Unknown"; return window.ProductCodeMap[productCode]; }; $("input[id$='_btnOLSLogin']").click(function(evt) { if (!Page_IsValid) return; var labelName = "Login_OnPage"; if (this.id.search(/_header/i) > -1) { labelName = "Login_Header"; } else { var loc = window.location.href; if (loc.split('/')[2].indexOf("claims") != -1 || loc.split('/')[3].indexOf("claims") != -1) labelName = "Login_Claims"; } log(labelName, evt); }); $("input[id$='_btnRetrieveQuote']").click(function(evt) { TrackQuoteEvent("Retrieve", this.id, evt); }); $("input[id$='_btnQuoteStart']").click(function(evt) { TrackQuoteEvent("QuoteStart", this.id, evt); }); function TrackQuoteEvent(strType, btnId, evt) { if (typeof (Page_IsValid) != 'undefined' && Page_IsValid == false) return; if ($.trim(strType) == '' || $.trim(btnId) == '') return; var lbl = ""; var selects = $("select[id$='_ddlProduct']"); if (selects.length == 1) { var selProduct = selects.val(); selProduct = window.GetGaTrackingTextFromCode(selProduct); if (strType == "Retrieve") { if (hasClass(selects, "ByQuote")) { lbl = strType + "_ByQuote_" + selProduct; } else if (hasClass(selects, "ByEmail")) { lbl = strType + "_ByEmail_" + selProduct; } else { lbl = strType + "_ByZip_" + selProduct; } } else { lbl = strType + "_" + selProduct; } } else { var groupId = btnId.split("_")[btnId.split("_").length - 2]; $.each(selects, function(index, select) { var selGroupId = select.id.split("_")[select.id.split("_").length - 2]; if (selGroupId == groupId) { var selProduct = select.value; selProduct = window.GetGaTrackingTextFromCode(selProduct); if (strType == "Retrieve") { if (hasClass(select, "ByQuote")) { lbl = strType + "_ByQuote_" + selProduct; } else if (hasClass(select, "ByEmail")) { lbl = strType + "_ByEmail_" + selProduct; } else { lbl = strType + "_ByZip_" + selProduct; } } else { lbl = strType + "_" + selProduct; } } }); } log(lbl, evt); return false; } function hasClass(elem, className) { if (typeof (elem) == "undefined" || typeof (className) == "undefined") return false; if (typeof (elem.jquery) == "undefined") { elem = $(elem); } return elem.hasClass(className); } $("li>a.regular, li>a.close").click(function(evt) { var label = "Ticker_Open"; if ($("a.close").is(":visible")) { label = "Ticker_Close"; } log(label, evt); }); }); }
