/* Minification failed. Returning unminified contents.
(7175,110-111): run-time error JS1100: Expected ',': =
(7175,120-121): run-time error JS1002: Syntax error: ,
(7175,128-129): run-time error JS1100: Expected ',': =
(8221,169-170): run-time error JS1100: Expected ',': =
(8221,173-174): run-time error JS1002: Syntax error: ,
(8221,187-188): run-time error JS1100: Expected ',': =
(8221,190-191): run-time error JS1002: Syntax error: ,
(8221,206-207): run-time error JS1100: Expected ',': =
(8221,213-214): run-time error JS1002: Syntax error: ,
(8221,225-226): run-time error JS1100: Expected ',': =
(8221,228-229): run-time error JS1002: Syntax error: ,
(8221,239-240): run-time error JS1100: Expected ',': =
(8221,246-247): run-time error JS1002: Syntax error: ,
(8221,262-263): run-time error JS1100: Expected ',': =
(8221,269-270): run-time error JS1002: Syntax error: ,
(8221,283-284): run-time error JS1100: Expected ',': =
(8221,289-290): run-time error JS1002: Syntax error: ,
(8221,299-300): run-time error JS1100: Expected ',': =
(8350,162-163): run-time error JS1100: Expected ',': =
(8350,169-170): run-time error JS1002: Syntax error: ,
(8350,182-183): run-time error JS1100: Expected ',': =
(8350,186-187): run-time error JS1002: Syntax error: ,
(8350,200-201): run-time error JS1100: Expected ',': =
(8350,203-204): run-time error JS1002: Syntax error: ,
(8350,219-220): run-time error JS1100: Expected ',': =
(8350,226-227): run-time error JS1002: Syntax error: ,
(8350,238-239): run-time error JS1100: Expected ',': =
(8350,241-242): run-time error JS1002: Syntax error: ,
(8350,257-258): run-time error JS1100: Expected ',': =
(8350,264-265): run-time error JS1002: Syntax error: ,
(8350,274-275): run-time error JS1100: Expected ',': =
(8366,93-94): run-time error JS1195: Expected expression: >
(8366,107-108): run-time error JS1004: Expected ';': )
(8371,46-47): run-time error JS1002: Syntax error: }
(8376,72-81): run-time error JS1197: Too many errors. The file might not be a JavaScript file: 'item_id'
 */
// Needed globals
var currentCompare = "";
var timeoutTopMenuSub;
var itemprice = 0;
var adVehicleImpressions = [];
var addOnLayer;
var frequentlyBoughtLayer;
var bundleOptionsLayer;
var productsLayer;
var configuratorLayer;
var openboxLayer;
var sentProducts = false;
var sentAdOns = false;
var sentBundles = false;
var sentfrequentlybought = false;
var sentconfigurator = false;
var sentopenbox = false;
var geotargetcomplete = false;
var productclicked = false;
var hideIT = "";
var returnToIT = "";
var sentopenbox = false;
var closeStoreSelector = false;
var keyisdown = false;
var usingGA4 = false;
var usingGA3 = false;
var usingBloomreach = false;

var usingA1 = false;
var processedlists = [];
var processedbloomreachlists = [];
var processedPromolists = [];
var hasTouch = true;
var currentCategory = "";
var PDPCat = "";
var currentCats = "";
var listname;
var bloomreachloadTime;
var bloomreachscrollpercent;
var bloomreach_identified;
var bloomreachh1;
var bloomreach2;
var bloomreachTitle;
var bloomreachDescription;
var bloomreachimage;
var bloomreachh1;
var bloomreachh2;
var bloomreachcartItems;
var boomreachcartIds;
var bloomreachcartTotal;
var bloomreachcartTotalItems;

var bloomreachlistItems;
var bloomreachlistIds;
var bloomreachlistTotal;
var bloomreachlistTotalItems;

var list;
var pv;
var cnt = 0;


var isLogin = "" + localStorage.getItem("login");
localStorage.setItem("login", "");

var pvc = 1;
$(".lazy-item").hide();
if ("" + localStorage.getItem("pvc") != "" && !isNaN("" + localStorage.getItem("pvc"))) {
    pvc = parseInt("" + localStorage.getItem("pvc"));
    pvc += 1;

    if ("" + localStorage.getItem("pvcDate") != "")
    {
        var pvcDate = new Date(localStorage.getItem("pvcDate"));
        var diff = new Date().valueOf() - pvcDate.valueOf();
        var diffInHours = diff / 1000 / 60 / 60;
        if (diffInHours > 24)
        {
            pvc = 1;
        }


    }
    localStorage.setItem("pvc", pvc);
}
else
{
    localStorage.setItem("pvc", pvc);
    localStorage.setItem("pvcDate", new Date());

}



function DisplayAll() {
    $('.BundleWrapper').css('display', 'block');
    $('[id*="collapse"]').css('display', 'inline');
    $('[id*="expand"]').css('display', 'none');
 
}
function HideAll() {
    $('.BundleWrapper').css('display', 'none');
    $('[id*="collapse"]').css('display', 'none');
    $('[id*="expand"]').css('display', 'inline');
   
}


function toggleBundle(BundleProdId) {
    var BundleDisplayValue = $('#BundleWrapper' + BundleProdId).css('display');
    if (BundleDisplayValue == 'none') {
        $('#BundleWrapper' + BundleProdId).css('display', 'block');
        $('#tab-specs .productHead i#expand' + BundleProdId).css('display', 'none');
        $('#tab-specs .productHead i#collapse' + BundleProdId).css('display', 'inline');
    }
    if (BundleDisplayValue == 'block') {
        $('#BundleWrapper' + BundleProdId).css('display', 'none');
        $('#tab-specs .productHead i#expand' + BundleProdId).css('display', 'inline');
        $('#tab-specs .productHead i#collapse' + BundleProdId).css('display', 'none');
    }
}
function isInViewport(element) {
    var rect = element.getBoundingClientRect();

    if ($(element).hasClass("slick-slide")) {

        rect = $(element).parent()[0].getBoundingClientRect();

        //if ($(element).data('list') == "Homepage PowerSpec Banner Ad") {
        //    console.log($(element).parent()[0].getBoundingClientRect());
        //}

        return (
            rect.top > 0 &&

            rect.top <= (window.innerHeight || document.documentElement.clientHeight)

         

        );

    }

    else {

       

        return (
            rect.top > 0 &&

            rect.bottom <= (window.innerHeight || document.documentElement.clientHeight)

        );
    }
}



function ImgError(source) {
    var test = source.src;
    var newSRC = "/assets/images/noimage.gif";
    if (source.src.length > 0) {
        var list2 = test.split("/");
        if (list2.length == 4) {
            var graphic = list2[3].split(".");
            if (graphic.length == 2) {
                var pimg = graphic[0].split("_");
                if (pimg.length == 2) {
                    if (!isNaN(pimg[0]) && !isNaN(pimg[1])) {
                        newSRC = "/assets/images/noimageproduct.gif";
                    }
                }
            }
        }

    }
    source.src = newSRC;
    source.onerror = "";
    return true;
}


function getParameterByName(name, url) {
    if (!url) url = window.location.href;
    name = name.replace(/[\[\]]/g, '\\$&');
    var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)'),
        results = regex.exec(url);
    if (!results) return null;
    if (!results[2]) return '';
    return decodeURIComponent(results[2].replace(/\+/g, ' '));
}

function handleOnKeyDown(e, itm) {

    if (event.key == "Enter") {
        event.preventDefault();
        event.target.click();
    }

    //if (e.keyCode == 13 && itm.prop('tagName') != "A" && itm.prop('tagName') != "BUTTON" && itm.prop('tagName') != "INPUT") {
    //    itm.click();
    //}

}
function validatePhoneNumber(elementValue) {
    var phoneNumberPattern = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
    return phoneNumberPattern.test(elementValue);
}


function isEmail(email) {
    var regex = /^([a-zA-Z0-9_.+-])+\@(([a-zA-Z0-9-])+\.)+([a-zA-Z0-9]{2,4})+$/;
    return regex.test(email);
}

function loadLazy() {


    $(".lazy-img").each(function () {
        if ($(this).attr("src") != $(this).data("full") && $(this).data("full") != "") {
            $(this).attr("src", $(this).data("full"));
        }
    });

}
//********  LoginModalItems
function setServiceButton() {

    // remm out whole function first...
    // before finding, lets see if the user is already logged in and if so, lets alter the a tag to the after login data value...
    //if ($("body").hasClass("isLoggedIn")) {
    //    // switch the links
    //    $(".serviceBtn a").each(function () {

    //        if (typeof $(this).data("after") !== "undefined")
    //        {
    //            $(this).attr("href", $(this).data("after"));



    //        }

    //    });

    //}

    // DO NOT USE ANY BELOW

    ////try {
    ////    $(".serviceBtn a").fancybox({
    ////        'width': 600,
    ////        'height': '95%',
    ////        'autoScale': false,
    ////        'transitionIn': 'elastic',
    ////        'transitionOut': 'fade',
    ////        'type': 'iframe',
    ////        'idleTime': false,
    ////        'baseClass': 'fbModalLogin'

    ////    });

    ////} catch (app) {

    ////}




    ////$(".serviceBtn a").click(function () {

    ////    var afterLogin = "";
    ////    if (typeof $(this).data("after") !== "undefined") {
    ////        afterLogin = $(this).data("after");
    ////    }

    ////    //console.log("adding Listener");
    ////    var mliframe = $($(".fbModalLogin .fancybox-iframe").contents()[0], window);
    ////    // var mliframe = $(".fbModalLogin .fancybox-iframe").contents();
    ////    window.addEventListener("message", function (event) {

    ////        if (event.origin !== "https://devaccount.microcenter.com") {

    ////            return;
    ////        }
    ////        else if (event.data.loginSuccess === true) {

    ////            if (afterLogin != "") {
    ////                $(".fbModalLogin .fancybox-iframe").attr("src", afterLogin);
    ////            }
    ////            else
    ////            {
    ////                localStorage.setItem("login", "true");
    ////                location.reload(true);
    ////            }
    ////            // Close modal window/redirect/reload page
    ////        }
    ////    }, false);



    ////});


}


function getUrlParameter(url, sParam) {



    var sPageURL = url.split('?')[0];

    var sURLVariables = url.split('?')[1].split('&');



    for (i = 0; i < sURLVariables.length; i++) {
        sParameterName = sURLVariables[i].split('=');

        if (sParameterName[0].toLowerCase() === sParam.toLowerCase()) {
            return typeof sParameterName[1] === undefined ? "" : decodeURIComponent(sParameterName[1]);
        }
    }

    return "";
}

function setModalLogin() {

    return;
    // rem out whole thing for now.
    // before finding, lets see if the user is already logged in and if so, lets alter the a tag to the after login data value...
    if ($("body").hasClass("isLoggedIn")) {
        // switch the links
        $(".login-modal").each(function () {

            if (typeof $(this).data("after") !== "undefined") {
                $(this).attr("href", $(this).data("after"));



            }

        });

    }


    try {
        $(".login-modal").fancybox({
            'width': 600,
            'height': '95%',
            'autoScale': false,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'type': 'iframe',
            'idleTime': false,
            'baseClass': 'fbModalLogin',
            'afterShow': function () { $('.fancybox-button--close').focus(); }

        });

    } catch (app) {

    }



    $(".login-modal").click(function () {


        try {
            $('#mainMenu').panel('close');
        }
        catch (ex) {

        }
        //console.log("adding Listener");
        var mliframe = $($(".fbModalLogin .fancybox-iframe").contents()[0], window);
        // var mliframe = $(".fbModalLogin .fancybox-iframe").contents();
        window.addEventListener("message", function (event) {

            if (event.origin.toLowerCase().indexOf(".microcenter.com") <= 0) {

                return;
            }
            else if (event.data.loginSuccess === true) {
                localStorage.setItem("login", "true");
                location.reload(true);
                // Close modal window/redirect/reload page
            }
        }, false);



    });
}

function resetLoading() {
    $(".body-loading").css("display", "none");
    $(".body-loading").css("background-color", "transparent");
}


//***********  share functions for Product Page

function copyFuncProduct() {

    if (usingGA4) {
        gtag('event', 'Configure Your PC', {
            'event_type': 'share',
            'event_action': 'copy_url'
        });
    }
    if (usingGA3) {
        ga('mc.send', 'event', 'Configure Your PC', 'share', 'copy_url');
    }

    var copyText = document.getElementById("shareURL");
    copyText.select();
    copyText.setSelectionRange(0, 99999);
    document.execCommand("copy");
    var tooltip = document.getElementById("myTooltip");
    tooltip.innerHTML = "Copied";

    $(".desktopShare .dropdown-menu").addClass("show");
    $(".desktopShare .dropdown").addClass("show");






    setTimeout(function () { tooltip.innerHTML = "<i class=\"fa fa-copy\"></i>Copy"; }, 3000);

    setTimeout(function () {
        $(".desktopShare .dropdown-menu").addClass("show");
        $(".desktopShare .dropdown").addClass("show");
    }, 100);

    $("#Actiontooltip").innerHTML = "<i class=\"fa fa-copy\"></i>Copy";

}
function outFuncProduct() {
    var tooltip = document.getElementById("myTooltip");

    if (tooltip.innerHTML != "Copied") {
        tooltip.innerHTML = "<i class=\"fa fa-copy\"></i>Copy";

    }
    $("#Actiontooltip").innerHTML = "<i class=\"fa fa-copy\"></i>Copy";

}


var currentFormList = "";
var currentFormRecommendationID = "";
function bindSubmit() {
    $(".crtfrm").unbind('submit');

    $(".crtfrm").submit(function (e) {

        currentFormList = "";
        currentFormRecommendationID = "";

        var carttype = "instore";
        thisForm = $(this);
        var isAjax = false;
        var thisAjax = $(this).find("input[name='ajax']");
        var actionType = $(this).find("input[name='cartType']");
        var na = $(this).find("input[name='na']");
        var noaddons = (na == null || na.val() == "" || na.val() == "true" );
        if (actionType.length) {
            carttype = actionType.val();
        }

        if (thisAjax.length && thisAjax.val() == "true") {




            isAjax = true;
            e.preventDefault();


        }



        var productIDs = "";
        var count = 0;
        var rulecount = 0;
        var rules = new Array();
        var rf = "";
        var existingCartIDs;

        var serviceplan;



        if ($(".crtfrm input[name='rf']").val() != null) {
            if ($(this).find("input[name='rf']").val().indexOf(",") < 0) {
                rf = $(this).find("input[name='rf']").val();
            }
        }



        if (rf == "Frequently Bought Together") {

            $("#FrequentyPurchasedTogether input[name='productIDsFB']:checked").each(function () {

                if (count > 0) {
                    productIDs += ",";
                }
                productIDs += $(this).val();


                count++;
                var myID = $(this).val();


            });
            $(this).find("input[name='productIDs']").val(productIDs);
        }

        else if (!noaddons) {

            try {
               

               // adding in the bundle form additions

                $("#bundleAddOnfrm input[name='productIDs']:checked").each(function () {



                    if (count > 0) {
                        productIDs += ",";
                    }
                    productIDs += $(this).val();



                    count++;
                    var myID = $(this).val();


                    var rulename = $("#productRule_" + myID).val();

                    if (rulename != null) {

                        if (rf.length > 0) {
                            rf = rf + ",";
                        }
                        rf = rf + rulename;
                    }
                    var masterSku = $("input[name = 'sku']").val();
                    // here we need to do the gaq push

                    if ($("#sku_" + myID).val() != null) {

                        // window.alert("Pushing: " + $("#source_" + myID).val() + " - " + $("#advehicle_" + myID).val() + "," + $("#sku_" + myID).val() + "," + 'from:' + masterSku + "," + $("#price_" + myID).val());

                        //   _gaq.push(['_trackEvent', $("#source_" + myID).val() + ' - ' + $("#advehicle_" + myID).val(), $("#sku_" + myID).val(), 'from:' + masterSku], $("#price_" + myID).val());

                    }


                });



                $("#interstitialfrm input[name='productIDs']:checked").each(function () {


                    
                    if (count > 0) {
                        productIDs += ",";
                    }
                    productIDs += $(this).val();

             

                    count++;
                    var myID = $(this).val();


                    var rulename = $("#productRule_" + myID).val();

                    if (rulename != null) {

                        if (rf.length > 0) {
                            rf = rf + ",";
                        }
                        rf = rf + rulename;
                    }
                    var masterSku = $("input[name = 'sku']").val();
                    // here we need to do the gaq push

                    if ($("#sku_" + myID).val() != null) {

                        // window.alert("Pushing: " + $("#source_" + myID).val() + " - " + $("#advehicle_" + myID).val() + "," + $("#sku_" + myID).val() + "," + 'from:' + masterSku + "," + $("#price_" + myID).val());

                        //   _gaq.push(['_trackEvent', $("#source_" + myID).val() + ' - ' + $("#advehicle_" + myID).val(), $("#sku_" + myID).val(), 'from:' + masterSku], $("#price_" + myID).val());

                    }


                });

                $("#serviceSkufrm input[name='productIDs']:checked").each(function () {

                    if (count > 0) {
                        productIDs += ",";
                    }
                    productIDs += $(this).val();



                    count++;
                    var myID = $(this).val();


                    var rulename = $("#productRule_" + myID).val();

                    if (rulename != null) {

                        if (rf.length > 0) {
                            rf = rf + ",";
                        }
                        rf = rf + rulename;
                    }
                    var masterSku = $("input[name = 'sku']").val();
                    // here we need to do the gaq push

                    if ($("#sku_" + myID).val() != null) {

                        // window.alert("Pushing: " + $("#source_" + myID).val() + " - " + $("#advehicle_" + myID).val() + "," + $("#sku_" + myID).val() + "," + 'from:' + masterSku + "," + $("#price_" + myID).val());

                        //   _gaq.push(['_trackEvent', $("#source_" + myID).val() + ' - ' + $("#advehicle_" + myID).val(), $("#sku_" + myID).val(), 'from:' + masterSku], $("#price_" + myID).val());

                    }


                });

                $("#interstitialfrm .productIDsRadio:checked").each(function () {

                    if (count > 0) {
                        productIDs += ",";
                    }
                    productIDs += $(this).val();
                    count++;
                    var myID = $(this).val();


                    var rulename = $("#productRule_" + myID).val();

                    if (rulename != null) {

                        if (rf.length > 0) {
                            rf = rf + ",";
                        }
                        rf = rf + rulename;
                    }
                    var masterSku = $("input[name = 'sku']").val();
                    // here we need to do the gaq push

                    if ($("#sku_" + myID).val() != null) {

                        // window.alert("Pushing2: " + $("#source_" + myID).val() + " - " + $("#advehicle_" + myID).val() + "," + $("#sku_" + myID).val() + "," + 'from:' + masterSku + "," + $("#price_" + myID).val());

                        //   _gaq.push(['_trackEvent', $("#source_" + myID).val() + ' - ' + $("#advehicle_" + myID).val(), $("#sku_" + myID).val(), 'from:' + masterSku], $("#price_" + myID).val());

                    }


                });
                $("#serviceSkufrm .productIDsRadio:checked").each(function () {

                    if (count > 0) {
                        productIDs += ",";
                    }
                    productIDs += $(this).val();
                    count++;
                    var myID = $(this).val();


                    var rulename = $("#productRule_" + myID).val();

                    if (rulename != null) {

                        if (rf.length > 0) {
                            rf = rf + ",";
                        }
                        rf = rf + rulename;
                    }
                    var masterSku = $("input[name = 'sku']").val();
                    // here we need to do the gaq push

                    if ($("#sku_" + myID).val() != null) {

                        // window.alert("Pushing2: " + $("#source_" + myID).val() + " - " + $("#advehicle_" + myID).val() + "," + $("#sku_" + myID).val() + "," + 'from:' + masterSku + "," + $("#price_" + myID).val());

                        //   _gaq.push(['_trackEvent', $("#source_" + myID).val() + ' - ' + $("#advehicle_" + myID).val(), $("#sku_" + myID).val(), 'from:' + masterSku], $("#price_" + myID).val());

                    }


                });


                $("#interstitialfrm1 input[name='productIDs']:checked").each(function () {

                    if (count > 0) {
                        productIDs += ",";
                    }
                    productIDs += $(this).val();
                    count++;
                    var myID = $(this).val();


                    var rulename = $("#productRule_" + myID).val();

                    if (rulename != null) {

                        if (rf.length > 0) {
                            rf = rf + ",";
                        }
                        rf = rf + rulename;
                    }
                    var masterSku = $("input[name = 'sku']").val();
                    // here we need to do the gaq push

                    if ($("#sku_" + myID).val() != null) {

                        // window.alert("Pushing3: " + $("#source_" + myID).val() + " - " + $("#advehicle_" + myID).val() + "," + $("#sku_" + myID).val() + "," + 'from:' + masterSku + "," + $("#price_" + myID).val());

                        //  _gaq.push(['_trackEvent', $("#source_" + myID).val() + ' - ' + $("#advehicle_" + myID).val(), $("#sku_" + myID).val(), 'from:' + masterSku], $("#price_" + myID).val());

                    }


                });



                $(this).find("input[name='productIDs']").val(productIDs);
                $(this).find("input[name='rf']").val(rf);



            } catch (err) {

            }

            try {


                $("#interstitialfrm1 input[name='productIDs']:checked").each(function () {

                    if (count > 0) {
                        productIDs += ",";
                    }
                    productIDs += $(this).val();
                    count++;


                });


                $(this).find("input[name='productIDs']").val(productIDs);


            } catch (err) {

            }



        }

        // now lets look for service plan


        try {

            if (!noaddons) {
                 serviceplan = $("#serviceplanfrm input[name='serviceplan']:checked").val();


                $(this).find("input[name='serviceplan']").val(serviceplan);
                if (count > 0) {
                    productIDs += ",";
                }
                productIDs += serviceplan;
                count++;
            }

        } catch (err) {

        }

       
       

        var prodID = $(this).find("input[name='productID']").val();
        rf = $(this).find("input[name='rf']").val();
        var activeVal = $(document.activeElement).val();


        var recommendationID = $(this).find("input[name='recommendation_id']").val();

        if (recommendationID) {
            currentFormRecommendationID = $(this).find("input[name='recommendation_id']").val();
        }


        var list = $(this).find("input[name='list_id']").val();
  
        if (list) {
            currentFormList = $(this).find("input[name='list_id']").val();
        }
        else {
           
            try {
                if (prodID != null) {
                    var submitButton = $(e.originalEvent.submitter);
                    var locator = '[data-id="' + prodID + '"]';

                    var productItemContainer = submitButton.closest('.product-item');

                    if (productItemContainer === null)
                    {
                        productItemContainer = submitButton.closest('.detail_wrapper')
               
                    }
                    var closestElement = productItemContainer.find(locator);

                    //console.log(closestElement);

                    if (closestElement != null && closestElement.length && closestElement.data('list') != null) {

                        currentFormList = closestElement.data('list');
                    }
                }
            } catch (e) { }
        }
        var isMini = $(this).hasClass("miniAjax");
        if (isAjax) {


            $("#Aria-Announcements").html("Adding Item To Cart Please Wait");
            window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 1000);
            $(".body-loading").css("display", "block");
            if (!isMini) {
                $(".body-loading").css("background-color", "#ffffff");
            }
            var btnpushed = $(this).find(".btn-add");
            if (!isMini) {
                $("#cartModal").html("");
            }
            $.ajax({
                url: "/store/add_productAjax.aspx?ismini=" + isMini,
                type: 'POST',
                async: true,
                data: thisForm.serialize(),
                success: function (op, textStatus, xhr) {

                    if (!isMini) {
                       

                        $("#cartModal").html(op);
                        //$("#cartModal").show();
                        $('#cartModal').modal('show');
                        // $("#cartModal .close-button").focus();
                        // $("body").addClass("fancybox-is-open");
                        // $(".fancybox-bg").show();
                        //setFancyboxHeight();
                        Header.setCartQty($(".cartAjaxQty").html());

                        bindSubmit();

                        bindClickItemV2();

                        bindListClick();



                        $("#cartModal .modal-interstitial-tabs").productTabs({
                            "speed": 200
                        });

                        $(".body-loading").css("display", "none");
                        $(".body-loading").css("background-color", "transparent");
                        $(".crtfrm .big.STBTN").css("display", "block");


                    }
                    else {
                        productIDs = "";
                        var currentCartQty = parseInt($(".cartQTY").html()) + 1;
                        Header.setCartQty(currentCartQty);
                        $(".body-loading").css("display", "none");
                        $(".body-loading").css("background-color", "transparent");


                        btnpushed.addClass("addedToCart");
                        btnpushed.html(btnpushed.html().replace("ADD TO CART", "ITEM ADDED"));
                        btnpushed.html(btnpushed.html().replace("Add To List", "ITEM ADDED"));

                        //  $("#Aria-Announcements").html(btnpushed.html());
                        //  window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
                        //setTimeout(function () {
                        //    btnpushed.html(btnpushed.html().replace("ITEM ADDED", "ADD TO CART"));

                        //    btnpushed.removeClass("addedToCart");
                        //}, 3000);
                    }

                    if (usingBloomreach) {
                        setTimeout(function () {
                            $.when(addBloomreachEvent(prodID, productIDs, rf, activeVal, serviceplan, carttype, "Add On", isMini))
                                .then(function () {
                                    return;
                                });
                        }, 500);
                        
                    }
                },
                error: function (xhr, textStatus, errorThrown) {
                  //  alert("An error occurred.");
                    $(".body-loading").css("display", "none");
                    $(".body-loading").css("background-color", "transparent");
                    $(".crtfrm .big.STBTN").css("display", "block");
                }
            });


        }
        else {
            if (usingBloomreach) {

                $.when(addBloomreachEvent(prodID, productIDs, rf, activeVal, serviceplan, carttype, "Add On", isMini))
                    .then(function () {
                        return;
                    });
            }

        }

      
            addToCartClick(prodID, productIDs, rf, activeVal, 0, carttype);

        if (usingA1) {
            $.when(addA1Event(prodID, productIDs, rf, activeVal, serviceplan, carttype))
                .then(function () {
                    return;
                });
        }

        

    });

    
    $(".ajaxServicePlan").off("click");
 
    $(".ajaxServicePlan").click(function (e) {

        
        var spid = $(this).data("spid");
        var productid = $(this).data("productid");
        var serviceproductid = $(this).data("serviceproductid");
        var plandescription = $(this).data("plandescription");
       
        if (typeof $(this).data("spid") !== 'undefined' && typeof $(this).data("spid") !== 'undefined')
        {
           // ga('mc.send', 'event', 'AddServicePlanFromModal', plandescription, productid);
            
            $(".ajaxServicePlan").addClass("off");
            $(".ajaxServicePlan").removeClass("on");
            $(this).removeClass("off");
            $(this).addClass("on");
            $(".body-loading").css("display", "block");
            // now we need to add the service plan...
            $.ajax({
                type: "POST",
                url: "/store/add_protectionPlanAjax.aspx",
                data: { spid: spid, productid: productid, serviceproductid: serviceproductid, plandescription: plandescription },
                success: function (msg) {
                    if (msg.length > 2) {
                 
                    

                       // $(".protectionPlanTitle").html("Protect and Support " + msg);
                        $("#servicePlanInfo").html($("#planDetails" + serviceproductid).html());
                        bindClickItemV2();
                    }
                    $(".body-loading").css("display", "none");
                    $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Protection Plan Added</div>');
                    window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
                }
            });

        }

       
    });
}





function bindClickItemBR() {

    $(".productClickItemBR").off("click");

  

  

    
    $('.productClickItemBR').click(function (e) {

        // e.preventDefault();

        if (typeof $(this).data('id') !== 'undefined') {
            productclicked = true;



            var thislist = "Unknown";
            if (typeof $(this).data('list') !== 'undefined') {
                thislist = $(this).data('list');
            }



            if (usingGA4) {
                if (typeof (gtag) != 'undefined') {
                    gtag('event', 'select_item', {
                        'item_list_id': (String($(this).data('list') || '')).replace("\\\"", " "),
                        'item_list_name': (String($(this).data('list') || '')).replace("\\\"", " "),
                        'is_personalized': $(this).data('personalized'),
                        items: [
                            {
                                item_id: $(this).data('id'),
                                item_name: (String($(this).data('name') || '')).replace("\\\"", " "),
                                currency: "USD",
                                index: $(this).data('position'),
                                item_brand: (String($(this).data('brand') || '')).replace("\\\"", " "),
                                item_category: (String($(this).data('category') || '')).replace("\\\"", " "),
                                item_coord: (String($(this).data('coord') || '')).replace("\\\"", " "),
                                item_core: (String($(this).data('core') || '')).replace("\\\"", " "),
                                item_list_id: (String($(this).data('list') || '')).replace("\\\"", " "),
                                item_list_name: (String($(this).data('list') || '')).replace("\\\"", " "),

                                price: $(this).data('price'),

                                quantity: 1
                            }
                        ]
                    });
                }
            }
            if (usingGA3) {
                if (typeof (ga) != 'undefined') {
                    ga('mc.ec:addProduct', {                              // Provide product details in a productFieldObject.
                        'id': $(this).data('id'),                   // Product ID (string).
                        'name': $(this).data('name'),               // Product name (string).
                        'category': $(this).data('category'),       // Product category (string).
                        'brand': $(this).data('brand'),             // Product brand (string).
                        'price': $(this).data('price'),
                        'position': $(this).data('position'),
                        'list': thislist

                    });

                    ga('mc.ec:setAction', 'click', { 'list': thislist });

                    ga('mc.send', 'event', 'eCommerce', 'click', thislist, {
                        'hitCallback': function () {
                            try {
                                if (!evt.ctrlKey) {

                                    //if ($(this).attr('href') != null) {
                                    //    document.location = $(this).attr('href');
                                    //} else if ($(this).data('href') != null) {
                                    //    document.location = $(this).data('href');
                                    //}
                                }
                            } catch (e) { }
                        }
                    });
                }
            }

            var recommendation_id = (String($(this).data('recommendationid') || '')).replace("\\\"", " ")
            if (usingBloomreach) {
                // we need to fire a bloomreach click event.
                var source = "Microcenter";

                if (recommendation_id != '') {
                    source = "Bloomreach";
                }
                var brlist = (String($(this).data('list') || ''));
                if (brlist != 'Search Results') {
                    exponea.track("recommendation", {
                        action: "click",
                        item_id: $(this).data('id'),
                        source: source,
                        recommendation_id: recommendation_id,
                        list_name: (String($(this).data('list') || '')).replace("\\\"", " "),
                        index: $(this).data('position')

                        // other properties: placement, ...
                    });
                }
            }
        }

    });



  

}





function bindClickItemV2() {
  
  //  $(".productClickItemV2").off("click");
   // $(".ajaxServicePlan").off("click");
   // $('.eventClick').unbind();
   // $('.promoClickItem').unbind();

   // $(".optionsContainer").off("click");
    bindOptionsContainer();

    // new bundle pdp section

    $('.PDPBundleButton').click(function () {

        if ($(this).hasClass("BtnOff")) {
            $(this).removeClass('BtnOff').addClass('BtnOn');
            $('.PDPBundleButton .addRemove').html('<i class="fa-regular fa-square-minus"></i>REMOVE</span>');
            $('.PDPBundleItem').prop('checked', true);
            // lets record the event



        }
        else {
            $(this).removeClass("BtnOn").addClass("BtnOff");
            $('.PDPBundleButton .addRemove').html('<i class="fa-regular fa-square-plus"></i>ADD</span>');
            $('.PDPBundleItem').prop('checked', false);


        }


    });
    $('.productClickItemV2').click(function (e) {
      
        // e.preventDefault();
   
        if (typeof $(this).data('id') !== 'undefined' ) {
            productclicked = true;

          

            var thislist = "Unknown";
            if (typeof $(this).data('list') !== 'undefined') {
                thislist = $(this).data('list');
            }



            if (usingGA4) {
                if (typeof (gtag) != 'undefined') {
                    gtag('event', 'select_item', {
                        'item_list_id': (String($(this).data('list') || '')).replace("\\\"", " "),
                        'item_list_name': (String($(this).data('list') || '')).replace("\\\"", " "),
                        'is_personalized': $(this).data('personalized'),
                        items: [
                            {
                                item_id: $(this).data('id'),
                                item_name: (String($(this).data('name') || '')).replace("\\\"", " "),
                                currency: "USD",
                                index: $(this).data('position'),
                                item_brand: (String($(this).data('brand') || '')).replace("\\\"", " "),
                                item_category: (String($(this).data('category') || '')).replace("\\\"", " "),
                                item_coord: (String($(this).data('coord') || '')).replace("\\\"", " "),
                                item_core: (String($(this).data('core') || '')).replace("\\\"", " "),
                                item_list_id: (String($(this).data('list') || '')).replace("\\\"", " "),
                                item_list_name: (String($(this).data('list') || '')).replace("\\\"", " "),

                                price: $(this).data('price'),
                               
                                quantity: 1
                            }
                        ]
                    });
                }
            }
            if (usingGA3) {
                if (typeof (ga) != 'undefined') {
                    ga('mc.ec:addProduct', {                              // Provide product details in a productFieldObject.
                        'id': $(this).data('id'),                   // Product ID (string).
                        'name': $(this).data('name'),               // Product name (string).
                        'category': $(this).data('category'),       // Product category (string).
                        'brand': $(this).data('brand'),             // Product brand (string).
                        'price': $(this).data('price'),
                        'position': $(this).data('position'),
                        'list': thislist

                    });

                    ga('mc.ec:setAction', 'click', { 'list': thislist });

                    ga('mc.send', 'event', 'eCommerce', 'click', thislist, {
                        'hitCallback': function () {
                            try {
                                if (!evt.ctrlKey) {

                                    //if ($(this).attr('href') != null) {
                                    //    document.location = $(this).attr('href');
                                    //} else if ($(this).data('href') != null) {
                                    //    document.location = $(this).data('href');
                                    //}
                                }
                            } catch (e) { }
                        }
                    });
                }
            }

            var recommendation_id = (String($(this).data('recommendationid') || '')).replace("\\\"", " ")
            if (usingBloomreach ) {
                // we need to fire a bloomreach click event.
                var source = "Microcenter";

                if (recommendation_id != '')
                {
                    source = "Bloomreach";
                }
                var brlist = (String($(this).data('list') || ''));
                if (brlist != 'Search Results') {
                    exponea.track("recommendation", {
                        action: "click",
                        item_id: $(this).data('id'),
                        source: source,
                        recommendation_id: recommendation_id,
                        list_name: (String($(this).data('list') || '')).replace("\\\"", " "),
                        index: $(this).data('position')

                        // other properties: placement, ...
                    });
                }
            }
        }

    });



    $(".ajaxServicePlan").click(function (e) {

        
        var spid = $(this).data("spid");
        var productid = $(this).data("productid");
        var serviceproductid = $(this).data("serviceproductid");
        var plandescription = $(this).data("plandescription");

        if (typeof $(this).data("spid") !== 'undefined' && typeof $(this).data("spid") !== 'undefined') {
            // ga('mc.send', 'event', 'AddServicePlanFromModal', plandescription, productid);

            $(".ajaxServicePlan").addClass("off");
            $(".ajaxServicePlan").removeClass("on");
            $(this).removeClass("off");
            $(this).addClass("on");
            $(".body-loading").css("display", "block");
            // now we need to add the service plan...
            $.ajax({
                type: "POST",
                url: "/store/add_protectionPlanAjax.aspx",
                data: { spid: spid, productid: productid, serviceproductid: serviceproductid, plandescription: plandescription },
                success: function (msg) {
                    if (msg.length > 2) {



                        // $(".protectionPlanTitle").html("Protect and Support " + msg);
                        $("#servicePlanInfo").html($("#planDetails" + serviceproductid).html());
                        bindClickItemV2();
                    }
                    $(".body-loading").css("display", "none");
                    $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Protection Plan Added</div>');
                    window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
                }
            });

        }


    });


   

    $('.eventClick').unbind();
    $('.eventClick').click(function (e) {


        var eventcategory = $(this).data("eventcategory");
        var eventaction = $(this).data("eventaction");
        var eventlabel = $(this).data("eventlabel");
        var eventvalue = $(this).data("eventvalue");
        var eventtype = $(this).data("eventname");
        if (eventvalue == null)
        {
            eventvalue = 1;
        }

 

        if (eventtype != null && eventcategory != null) {
        
            if (usingGA4) {
                gtag('event', eventtype, {

                    'event_category': eventcategory,
                    'event_action': eventaction,
                    'event_label': eventlabel,
                    'event_value': eventvalue
                });
            }

            if (usingGA3 && $(this).attr("onClick") === undefined)
            {
                if (typeof (ga) != 'undefined') {
                    
                    ga('mc.send', { 'hitType': 'event', 'eventCategory': eventcategory, 'eventAction': eventaction, 'eventLabel': eventlabel, 'eventValue': eventvalue });

                }
            }

        }

        // e.preventDefault();

    

    });

    
    $('.promoClickItem').click(function (e) {

        // e.preventDefault();
   
        if ($(this).data('list') != null) {
            productclicked = true;

            var thislist = "Unknown";
            if ($(this).data('list') != null) {
                thislist = $(this).data('list');
            }

          
          

            if (usingGA4) {
                if (typeof (gtag) != 'undefined') {
                    var list = "[";
                   if ($(this).data('name') && $(this).data('brand') && $(this).data('category')) {
                   {
                    list += "{";

                    list += 'item_id: "' + $(this).data('id') + '",';
                           list += 'item_name: "' + (String($(this).data('name') || '')).replace('"', '\\\"') + '",';

                           list += 'index: ' + $(this).data('position') + ',';
                           list += ' item_brand: "' + (String($(this).data('brand') || '')).replace('"', '\\\"') + '",';
                           list += 'item_category: "' + (String($(this).data('category') || '')).replace('"', '\\\"') + '",';
                           list += 'item_coord: "' + (String($(this).data('coord') || '')).replace('"', '\\\"') + '",';
                           list += 'item_core: "' + (String($(this).data('core') || '')).replace('"', '\\\"') + '",';

                    list += 'currency: "USD",';

                           list += 'price:' + $(this).data('price') + ',';
                  
                    list += ' quantity: 1';





                    list += '}';
                   }
                }
             list += "]";
                    gtag('event', 'select_promotion', {
                        'promotion_id': (String($(this).data('list') || '')).replace("\\\"", " "),
                        'promotion_name': (String($(this).data('list') || '')).replace("\\\"", " "),
                        items: eval(list)
                    });
                }
            }
            if (usingGA3) {
                if (typeof (ga) != 'undefined') {

                    if ($(this).data('name') && $(this).data('brand') && $(this).data('category')) {
                        ga('mc.ec:addProduct', {                              // Provide product details in a productFieldObject.
                            'id': $(this).data('id'),                   // Product ID (string).
                            'name': $(this).data('name'),               // Product name (string).
                            'category': $(this).data('category'),       // Product category (string).
                            'brand': $(this).data('brand'),             // Product brand (string).
                            'price': $(this).data('price'),
                            'currency': 'USD',
                            'position': $(this).data('position'),
                            'list': thislist

                        });
                    }

                    ga('mc.ec:setAction', 'promoClick', { 'list': thislist });

                    ga('mc.send', 'event', 'eCommerce', 'promoClick', thislist, {
                        'hitCallback': function () {
                            try {
                                if (!evt.ctrlKey) {

                                    //if ($(this).attr('href') != null) {
                                    //    document.location = $(this).attr('href');
                                    //} else if ($(this).data('href') != null) {
                                    //    document.location = $(this).data('href');
                                    //}
                                }
                            } catch (e) { }
                        }
                    });
                }
            }


        }

    });

}


function bindListClick() {

    listView("Service Plan Add To Cart Modal");
    listView("Add Cart Ajax Key Add Ons");
    $(".listclick").off("click");
    $(".listclick").click(function (e) {

        // e.preventDefault();
        listname = $(this).data('list');
        var cnt = 0;
        if (usingGA4) {
            if (typeof (gtag) != 'undefined' && $('#cartModal .productViewItem').length) {

                var list = "[";
                var pv = $('#cartModal .productViewItem');
                
         
                var ispersonalized = "";

         
                $('#cartModal .productViewItem').each(function () {
                    
                    if ($(this).data('list') == listname)
                    {
         

                        if (cnt > 0) { list += ','; }

                        if (typeof $(this).data('name') !== 'undefined' && typeof $(this).data('brand') !== 'undefined' && typeof $(this).data('category') !== 'undefined') {
                            list += "{";

                            list += 'item_id: "' + $(this).data('id') + '",';
                            list += 'item_name: "' + (String($(this).data('name') || '')).replace('"', '\\\"') + '",';

                            list += 'index: ' + $(this).data('position') + ',';
                            list += ' item_brand: "' + (String($(this).data('brand') || '')).replace('"', '\\\"') + '",';
                            list += 'item_category: "' + (String($(this).data('category') || '')).replace('"', '\\\"') + '",';
                            list += 'item_coord: "' + (String($(this).data('coord') || '')).replace('"', '\\\"') + '",';
                            list += 'item_core: "' + (String($(this).data('core') || '')).replace('"', '\\\"') + '",';

                            list += 'item_list_id: "' + $(this).data('list') + '",';
                            list += 'item_list_name: "' + $(this).data('list') + '",';

                            list += 'price:' + $(this).data('price') + ',';
                            list += 'currency: "USD",';
                            list += ' quantity: 1';





                            list += '}';


                            cnt += 1;
                        }
                    }
                });

                list += ']';
         
                if (list != '[]') {
                    gtag("event", "view_item_list", {
                        'item_list_id': (String(listname || '')).replace('"', '\\\"'),
                        'item_list_name': (String(listname || '')).replace('"', '\\\"'),
                        items: eval(list)

                    });
                }





            }
        }

        if (usingGA3) {


            if (typeof ga != "undefined") {

    
                $('#cartModal .productViewItem').each(function () {

                    if (listname == $(this).data('list')) {

                        ga('mc.ec:addImpression', {                     // Provide product details in a productFieldObject.
                            'id': $(this).data('id'),                   // Product ID (string).
                            'name': $(this).data('name'),               // Product name (string).
                            'category': $(this).data('category'),       // Product category (string).
                            'brand': $(this).data('brand'),             // Product brand (string).
                            'price': $(this).data('price'),
                            'position': $(this).data('position'),
                            'list': listname

                        });

                    }



                });
                if (listname != "") {

                    ga('mc.ec:setAction', 'detail');
                    ga('mc.send', 'event', 'eCommerce', listname, { nonInteraction: true });
                }

            }
        }

    });

    if ($('.listclick')) {
        $('.listclick').first().trigger('click');
    }

}


if (!("ontouchstart" in document.documentElement)) {
    hasTouch = false;
}


if (!("ontouchstart" in document.documentElement)) {
    hasTouch = false;
}

function serviceBVCheck() {
    $(".serviceReviews").hide();
    $(".serviceQA").hide();

    var refreshId = setInterval(function () {


        if ($(".serviceReviews #BVRRDisplayContentBodyID").length) {
            $(".serviceReviews").show();

        }

        if ($(".serviceReviews #BVRRDisplayContentID").length) {
            clearInterval(refreshId);
        }
    }, 1000);

    var refreshId2 = setInterval(function () {

        if ($(".serviceQA .BVQAQuestions").length) {
            $(".serviceQA").show();
        }

        if ($(".serviceQA #BVQAQuestionAndAnswerCountID").length) {

            clearInterval(refreshId2);
        }


    }, 1000);




}


function getScrollPercent() {


    var scrollTop = $(window).scrollTop(); // Current vertical scroll position
    var windowHeight = $(window).height(); // Height of the viewport
    var documentHeight = $(document).height(); // Total height of the document

    // Calculate the scroll percentage
    var scrollPercent = (scrollTop / (documentHeight - windowHeight)) * 100;

    return scrollPercent;
}

function getLoadTime() {
  
    var lt = 0;
    if (window.performance && window.performance.getEntriesByType) {
        var entries = window.performance.getEntriesByType("navigation");
        if (entries.length > 0) {
            var navTiming = entries[0];
            var pageLoadTime = navTiming.loadEventEnd - navTiming.startTime;
            lt = Math.round(((pageLoadTime / 1000) + Number.EPSILON) * 100) / 100;
        }
    }

    return lt;

  
}


function bindOptionsContainer() {

    // Add in buying options functions...

  
    $(".optionsContainer").click(function () {

        var optionID = $(this).attr("class");
        var isButton = $(this).is("button");
        $("#cartModal").hide();
        $("#cartModal").html('');


        if (isButton) {
            $(".optionsContainer").removeClass("Selected");
            $(this).addClass("Selected");

            $("Button.optionsContainer").attr("aria-pressed", "false");
            $(this).attr("aria-pressed", "true");

            if (optionID.indexOf("pickupOption") >= 0 && isButton) {
                $(".cartType").val("instore");
                $(".pickupOption").addClass("Selected");
                $(".crtfrm .big.STBTN").val("Add To Cart");
                $(".crtfrm .big.STBTN").html("Add To Cart");
                $(".crtfrm .big.BUY-NOW").html("Buy Now");
                $(".crtfrm").first().find(".big.BUY-NOW").parent().show();
                $(".mm-t007-sticky-bar .crtfrm .big.BUY-NOW").parent().show();
                $(".fixed-footer .crtfrm .big.BUY-NOW").parent().show();

            } else if (optionID.indexOf("shippingOption") >= 0 && isButton) {
                $(".cartType").val("shipout");

                $(".shippingOption").addClass("Selected");
                $(".crtfrm .big.STBTN").val("Add To Cart");
                $(".crtfrm .big.STBTN").html("Add To Cart");
                $(".crtfrm .big.BUY-NOW").html("Buy Now");
                $(".crtfrm").first().find(".big.BUY-NOW").parent().show();
                $(".mm-t007-sticky-bar .crtfrm .big.BUY-NOW").parent().show();
                $(".fixed-footer .crtfrm .big.BUY-NOW").parent().show();
            } else if (optionID.indexOf("listOption") >= 0 && isButton) {

                $(".listOption").addClass("Selected");
                $(".cartType").val("list");
                $(".crtfrm .big.STBTN").val("Add To List");
                $(".crtfrm .big.STBTN").html("Add To List");
                $(".crtfrm").first().find(".big.BUY-NOW").parent().hide();
                $(".mm-t007-sticky-bar .crtfrm .big.BUY-NOW").parent().hide();
                $(".fixed-footer .crtfrm .big.BUY-NOW").parent().hide();
            }
        }

        return false;
    });

}

$(document).ready(function () {
  
    bindOptionsContainer();

    var firstH1 = $('h1').first();
    if (firstH1.length) {
        bloomreachh1 = firstH1.text();
    }
    var firstH2 = $('h2').first();


    if (firstH2.length) {
        bloomreachh2 = firstH2.text();
    }

   
    bloomreachTitle = document.title;


   bloomreachDescription = $('meta[name="description"]').attr('content');
   bloomreachimage = $('meta[property="og:image"]').attr('content');;




    $(".lazy-item").show();
    $(".showAllAuthors").click(function () {
        $(".authorList .hide").show();
        $(".showAllAuthors").hide();
    });

    $(".seeAllCategories").click(function () {
        $(".allCategories").show();
        $(".seeAllCategories").hide();
    });

    $("#blogsearchbutton").click(function () {

        $("#blogsearchform").submit();
    });

    $('.singleEventClick').click(function (e) {


        var eventcategory = $(this).data("eventcategory");
        var eventaction = $(this).data("eventaction");
        var eventlabel = $(this).data("eventlabel");
        var eventvalue = $(this).data("eventvalue");
        var eventtype = $(this).data("eventname");
        if (eventvalue == null) {
            eventvalue = 1;
        }



        if (eventtype != null && eventcategory != null) {

            if (usingGA4) {
                gtag('event', eventtype, {

                    'event_category': eventcategory,
                    'event_action': eventaction,
                    'event_label': eventlabel,
                    'event_value': eventvalue
                });
            }

            if (usingGA3 && $(this).attr("onClick") === undefined) {
                if (typeof (ga) != 'undefined') {

                    ga('mc.send', { 'hitType': 'event', 'eventCategory': eventcategory, 'eventAction': eventaction, 'eventLabel': eventlabel, 'eventValue': eventvalue });

                }
            }

        }

        // e.preventDefault();



    });

    
   





    $('.bvinine_rating').click(function (event) {

        $('html, body').animate({
            scrollTop: $("#tab-reviews-bm").offset().top
        }, 100);
        
    });





    setTimeout(function () {
       
        checkCharlotte();
        checkMiami();
        checkSantaClara();

    },100);





    loadLazy();


    // add validation flag fixes.
    if ($('.needsValidation').length)
    {
        var validationInteraction = false;
        var validationcookie = readCookie("Mvalidation");

        if (typeof (validationcookie) != 'undefined' && validationcookie != null && validationcookie != "") {
            $(".needsValidation").hide();
        }
        $(".needsValidation").hover(function () {
            validationInteraction = true;
        });

        $(".closevalidation").click(function () {
            $(".needsValidation").hide();
            createCookie("Mvalidation", "closed", 1);
        });

        setTimeout(function () {
            if (!validationInteraction) {
                $(".needsValidation").hide();
            }

        }, 15000);
    }

    // add login flag fixes.

    if ($('.needsLogin').length) {



        var loginInteraction = false;
        var logincookie = readCookie("Mlogin");

        if (pvc < 3)
        {
            $(".needsLogin").hide();
        }
        else if (typeof (logincookie) != 'undefined' && logincookie != null && logincookie != "" && pvc >= 3) {
            $(".needsLogin").hide();

        }
        else {

            if (($('.needsCharlotte') == null || !$('.needsCharlotte').is(":visible")) && ($('.needsSantaClara') == null || !$('.needsSantaClara').is(":visible")) && ($('.needsSantaClara') == null || !$('.needsSantaClara').is(":visible"))) {

                $(".needsLogin").show();
                $(".closeloginrequest").focus();
                createCookie("Mlogin", "closed", 1);
                $(window).scroll(function () {
                    var MobileSignIn = $('.MobileFramework .needsLogin'),
                        scroll = $(window).scrollTop();
                    var headerTop = $('.MobileFramework .hdrRow4').offset().top;

                    if (scroll >= headerTop) {
                        MobileSignIn.addClass('stickySignIn');
                    }
                    else {
                        MobileSignIn.removeClass('stickySignIn');
                    }
                });


            }
        }

        $(".needsLogin").hover(function () {
            loginInteraction = true;
        });


        $(".closeloginrequest").click(function () {
            $(".needsLogin").hide();
            createCookie("Mlogin", "closed", 1);
        });

        setTimeout(function () {
            if (!loginInteraction && $('.needsLogin').is(":visible")) {
                $(".needsLogin").hide();
                createCookie("Mlogin", "closed", 1);
            }

        }, 30000);
    }

    else
    {
        createCookie("Mlogin", "closed", 1);
    }


  

   
   
    if ($('.needsCharlotte').length && pvc >=2) {
        $("#storeInfo").removeClass("forceopen");
        var charlotteInteraction = false;
        var charlottecookie = readCookie("Mcharlotte");

        if (typeof (charlottecookie) != 'undefined' && charlottecookie != null && charlottecookie != "") {
            $(".needsCharlotte").hide();

        }
        else {
            $(".needsCharlotte").show();
            $(".closecharlotterequest").focus();
        }

        $(".needsCharlotte").hover(function () {
            charlotteInteraction = true;
        });


        $(".closecharlotterequest").click(function () {
            $(".needsCharlotte").hide();
            createCookie("Mcharlotte", "closed", 365);
        });

        $(".needsCharlotte .learnMoreButton").click(function () {
            $(".needsCharlotte").hide();
            createCookie("Mcharlotte", "closed", 365);
        });


        setTimeout(function () {
            if (!charlotteInteraction) {
                $(".needsCharlotte").hide();
                createCookie("Mcharlotte", "closed", 365);
            }

        }, 30000);
    }

    if ($('.needsMiami').length && pvc >= 2) {
        $("#storeInfo").removeClass("forceopen");
        var miamiInteraction = false;
        var miamicookie = readCookie("Mmiami");

        if (typeof (miamicookie) != 'undefined' && miamicookie != null && miamicookie != "") {
            $(".needsMiami").hide();

        }
        else {
            $(".needsMiami").show();
            $(".closemiamirequest").focus();
        }

        $(".needsMiami").hover(function () {
            miamiInteraction = true;
        });


        $(".closemiamirequest").click(function () {
            $(".needsMiami").hide();
            createCookie("Mmiami", "closed", 365);
        });

        $(".needsMiami .learnMoreButton").click(function () {
            $(".needsMiami").hide();
            createCookie("Mmiami", "closed", 365);
        });


        setTimeout(function () {
            if (!miamiInteraction) {
                $(".needsMiami").hide();
                createCookie("Mmiami", "closed", 365);
            }

        }, 30000);
    }

    if ($('.needsSantaClara').length && pvc >= 2) {
        $("#storeInfo").removeClass("forceopen");
        var santaclaraInteraction = false;
        var santaclaracookie = readCookie("Msantaclara");

        if (typeof (santaclaracookie) != 'undefined' && santaclaracookie != null && santaclaracookie != "") {
            $(".needsSantaClara").hide();

        }
        else {
            $(".needsSantaClara").show();
            $(".closesataclararequest").focus();
        }

        $(".needsSantaClara").hover(function () {
            santaclaraInteraction = true;
        });


        $(".closesantaclararequest").click(function () {
            $(".needsSantaClara").hide();
            createCookie("Msantaclara", "closed", 365);
        });

        $(".needsSantaClara .learnMoreButton").click(function () {
            $(".needsSantaClara").hide();
            createCookie("Msantaclara", "closed", 365);
        });


        setTimeout(function () {
            if (!santaclaraInteraction) {
                $(".needsSantaClara").hide();
                createCookie("Msantaclara", "closed", 365);
            }

        }, 30000);
    }


    productView();

    $(".shuffle").click(function () {

        var el = $(this).data("elements");

        $("." + el).shuffle();
        var max = Number($(this).data("max"));
        var cnt = 0;
        $("." + el + " hr").removeClass("hide-text");
        $("." + el).addClass("border-md-right");
        $("." + el).each(function () {
            cnt += 1;
            if (cnt == 1) {

                $(this).find("hr").addClass("hide-text");
            }
            if (cnt >= max) {


                $(this).removeClass("border-md-right");
            }
            if (cnt > max) {

                $(this).find("hr").addClass("hide-text");

            }


            if (cnt <= max) {
                $(this).show();
            }
            else {
                $(this).hide();
            }

        });


    });

    $(".seemore").click(function () {

        var el = $(this).data("elements");

        var totalcnt = 0;
        var cnt = 0;
        $("." + el).each(function () {
           
            if (!$(this).is(":visible") && cnt < 3) {
                $(this).show();
                if (!$(this).find("hr").is(":visible")) {
                    $(this).addClass("pt-50");
                }
                cnt += 1;
                totalcnt += 1;
            }
            if (cnt == 0) {
                totalcnt += 1;
            }
        });
        var max = Number($(this).data("max"));

       
        if (totalcnt >= $("." + el).length)
        {
            $(".seemore-" + el).hide();
        }
        cnt = 0;
        $("." + el + " hr").removeClass("hide-text");
        $("." + el).addClass("border-md-right");
        $("." + el).each(function () {
            cnt += 1;
            if (cnt == 1) {

                $(this).find("hr").addClass("hide-text");
            }
            if (cnt % 3 == 0) {


                $(this).removeClass("border-md-right");
            }
            if (cnt % 3 == 0) {

                // $(this).find("hr").addClass("hide-text");

            }


            //if (cnt <= max) {
            //    $(this).show();
            //}
            //else {
            //    $(this).hide();
            //}

        });


    });


   
    if (usingGA4) {
        // lets add listener for any a tag, div, button click with event sending
        $('a').click(function (e) {

          
            // e.preventDefault();

            if ($(this).data('eventname') != null && $(this).data('eventaction') != null && $(this).data('eventcategory') != null) {


             
                if (typeof (gtag) != 'undefined') {
                    gtag('event', $(this).data('eventname'), {
                        
                        'event_category': $(this).data('eventcategory'),
                        'event_action': $(this).data('eventaction'),
                        'event_label': $(this).data('eventlabel'),
                        'event_value': $(this).data('eventvalue')
                    });

                }
                   
                      
                    
               


            }

        });
    }


    if (navigator.share && $("body").hasClass("MobileFramework")) {
        $(".mobileShare").show();
        $(".desktopShare").hide();
        $(".mobileShareButton").click(function () {
            navigator.share({
                title: $(document).attr('title'),
                url: $(location).attr('href')


            });

        });

    }
    else {

        $(".mobileShare").hide();
        $(".desktopShare").show();
    }

    $(".clearAsus").click(function () {

        $(".asusCheckbox").prop('checked', false);

        $(".productIDsRadio").removeClass("isselectedItem");
        $(".productIDsRadio").prop('checked', false);

        setsummarytotal();
        return false;
    });

    // fix usabila and bizaar voice




    // add play buttons to sliders

    setTimeout(function () {
        $(".slick-dots").append("<li role='presentation' class='play'><a href='#' class='slick-play'><img src='https://60a99bedadae98078522-a9b6cded92292ef3bace063619038eb1.ssl.cf2.rackcdn.com/play-16.png' alt='play'><span class='hide-text'>Next</span></a></li><li role='presentation' class='pause'><a href='#' class='slick-pause' ><img src='https://60a99bedadae98078522-a9b6cded92292ef3bace063619038eb1.ssl.cf2.rackcdn.com/pause-16.png' alt='pause'><span class='hide-text'>pause</span></a></li>");
        // Play/Pause button
        $(".slick-play").click(function () {
            $(".slick-slider").slick('slickPlay');
            $(this).hide();
            $('.slick-pause').show();
            return false;
        });
        $(".slick-pause").click(function () {
            $(".slick-slider").slick('slickPause');
            $(this).hide();
            $('.slick-play').show();
            return false;
        });
    }, 500);



    // flip on async styles...

    $(".asyncStyle").each(function () {
        $(this).attr("media", "all");

    });

    // turn off reviews and Q and A in service pages if page has no
    if ($(".serviceReviews").length) {
        serviceBVCheck();
    }






    if (isLogin === "true") {

        resetLoading();

    }


    // lets prevent search unless there is content.

    $(".siteSearchForm").submit(function () {

        if (!$("#search-query").val()) {
            $("#search-query").focus();
            return false;
        }

    });



    function getQuerystringParameter() {
        var getUrlParameter = function getUrlParameter(sParam) {
            var sPageURL = window.location.search.substring(1),
                sURLVariables = sPageURL.split('&'),
                sParameterName,
                i;

            for (i = 0; i < sURLVariables.length; i++) {
                sParameterName = sURLVariables[i].split('=');

                if (sParameterName[0] === sParam) {
                    return typeof sParameterName[1] === undefined ? true : decodeURIComponent(sParameterName[1]);
                }
            }
            return false;
        };

        var searchValue = getUrlParameter('vkw');
        // console.log('searchValue = ' + searchValue);
    }




    $(".productSearch").click(function () {
        var searchValue = getQuerystringParameter();

        if (usingGA4) {
            gtag('event', 'searchChoices', {
                'event_type': 'ProductsSearch',
                'event_action': searchValue
            });
        }
        if (usingGA3) {

            ga("mc.send", "event", "searchChoices", "ProductsSearch", searchValue);
        }
        //  console.log("Handler for productSearch .click() called.");
    });

    $(".contentSearch").click(function () {
        var searchValue = getQuerystringParameter();
        if (usingGA4) {
            gtag('event', 'searchChoices', {
                'event_type': 'ContentSearch',
                'event_action': searchValue
            });
        }
        if (usingGA3) {

            ga("mc.send", "event", "searchChoices", "ContentSearch", searchValue);
        }
        //   console.log("Handler for contentSearch .click() called.");
    });

    $(".st-ui-result.__swiftype_result").click(function () {
        var linkValue = $(this).find(".resultType").text() + " - " + ($(this).find(".st-ui-type-heading").text());
        if (usingGA4) {
            gtag('event', 'contentResults', {
                'event_type': 'contentResultsLink',
                'event_action': linkValue
            });
        }
        if (usingGA3) {
            ga("mc.send", "event", "contentResults", "contentResultsLink", linkValue);
        }
        //  console.log("Handler for contentResultsLink .click() called.");
    });

    $("#hotdeals .hotdealItem .clickable.fade a").click(function () {
        var clickHotDeals = $(this).text();
        var index = clickHotDeals.indexOf(' ', clickHotDeals.indexOf(' ') + 1);
        var hotDealsCategory = clickHotDeals.substr(index + 1);


            if (usingGA4) {
                gtag('event', 'hmpg', {
                    'event_type': 'categories',
                    'event_action': hotDealsCategory
                });
            }
            if (usingGA3) {


                ga("mc.send", "event", "hmpg", "categories", hotDealsCategory);
            }
        
        //   console.log('hotDealsCategory = ' + hotDealsCategory);
    });

    $(".SearchDropdown .dropdown-item").click(function (e) {

        e.preventDefault();

        var nValue = $(this).data("n");
        var fieldname = $(this).data("fieldname");
        var target = $(this).data("target");
        var cat = $(this).data("cat");
        var url = $(this).attr("href");
        var title = $(this).html();

        if (fieldname == "keyword") {
            $("#swiftypeSearch").css("display", "flex");
            $("#standardSearch").hide();
            $("#site-search-query").focus();
        }
        else {
            $("#swiftypeSearch").css("display", "none");
            $("#standardSearch").show();
            $("#search-query").focus();

        }

        $(".siteSearchForm").attr("target", target);
        $(".siteSearchForm").attr("action", url);

        $(".siteSearchForm #search-nValue").val(nValue);
        $(".siteSearchForm #search-cat").val(cat);
        $(".siteSearchForm #search-query").attr("name", fieldname);

        $(".SearchDropdown #searchTitle").html(title);

        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Search changed to:' + title + ' Begin typing to start search.</div>');
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);

        $(".SearchDropdown .dropdown-menu").hide();





    });


    // lets do the new store selected button.


    $("#storeselectorHref").click(function () {


        if (!keyisdown) {
            if ($("#boosted .dropdown-menu").is(":visible")) {
                $("#boosted .dropdown-menu").hide();
                closeStoreSelector = false;
            }
            else {
                $("#boosted .dropdown-menu").show();
                closeStoreSelector = true;
                $("#boosted .dropdown-menu").focus();
            }
        }
    });

    $("#boosted #storeselectorHref").keydown(function (e) {
        keyisdown = true;
    });
    $("#boosted #storeselectorHref").keyup(function (e) {

        keyisdown = false;
        e.preventDefault();

        if (e.which === 13 || e.which === 40) {
            if ($("#boosted .dropdown-menu").is(":visible")) {
                $("#boosted .dropdown-menu").hide();
                closeStoreSelector = false;
            }
            else {
                $("#boosted .dropdown-menu").show();
                closeStoreSelector = true;
                $("#boosted .dropdown-menu").find("a").first().focus();
            }
        }


    });


    $("#boosted .dropdown-menu li a").keyup(function (e) {
        e.preventDefault();
        var focusElement = $(document.activeElement);
        var currentLI = focusElement.parent();
        if (e.which === 40) {


            if (currentLI != $("#boosted .dropdown-menu").find("li").last()) {
                currentLI.next().find("a").first().focus();
            }

        }


        if (e.which === 38) {

            if (currentLI != $("#boosted .dropdown-menu").find("li").first()) {
                currentLI.prev().find("a").first().focus();
            }
            else {
                $("#boosted .dropdown-menu").hide();
                closeStoreSelector = false;
                $("#storeselectorHref").focus();
            }

        }


        //38 up
        //40 down
    }
    );












    window.onclick = function (event) {


        try {

            if (!event.target.matches('#boosted') && !event.target.matches('#storeselectorHref')) {
                $("#boosted .dropdown-menu").hide();
                closeStoreSelector = false;
            }
        } catch (err) {

        }
    };



    $("#storeselector").change(function () {

        if ($("#storeselector option:selected").index() > 0) {
            $("#getstoreselectorButton").show();
        }
        else {
            $("#getstoreselectorButton").hide();
        }

    });

    if ($("#storeselector option:selected").index() > 0) {
        $("#getstoreselectorButton").show();
    }

    $('.mm14-products-viewed-wrapper').each(function () {

        try {
            addSliderEvent($(this));

        } catch (err) {

        }

    });

    //if ($('.mm14-products-viewed-wrapper').length > 0) 
    //{ 
    //    addSliderEvent();
    //}


    $("#skip-main-content").click(function (evt) {

        var thisID = $(this).attr('href');



        if ($(thisID + " h1").first().length) {


            $(thisID + " h1").first().attr('id', 'main-content-h1');
            $(thisID + " h1").first().attr('tabindex', '0');

            $(thisID + " h1").first().focus();
            return false;
        }



    });














    var ismobile = (jQuery.browser.mobile == true);

    // new type ahead custom roll below *************************************

    var typeAheadInput;
    var typeAheadTimeOut;
    var closeTypeAhead = true;




    // add the click events for search results
    $('.productClickItem').click(function (e) {
        e.preventDefault();
        productClick(this);

    });

    $('.inBundle-title a').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });

    $('.inBundle-image img').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });


    $('.products .image').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });


    $('.avProductClick').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });


    $('.addOnProductClick').click(function (evt) {

        addOnClick(this, evt);


    });




    $('.pDescription h2 a').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });

    $('.SearchBannerProduct').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });

    $('.RightBannerProduct').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });

    $('.featureProduct').click(function (evt) {
        evt.preventDefault();
        productClick(this, evt);
    });

    

    $('.SearchTower').click(function (evt) {
        promoClick(this, evt);
    });

    $('.SearchBanner').click(function (evt) {
        promoClick(this, evt);
    });


    // handle each of the tab click impressions...


    $("#tabClearance").click(function (evt) {
        sendOpenBoxImpression();
    });

    $('#tabInterstitial').click(function (evt) {


        sendaddOnImpression();


    });


    $('#frequentlyBoughtLabel').click(function (evt) {


        sendfrequentlyboughtImpression();


    });


    $('#ConfiguratorLabel').click(function (evt) {


        sendconfiguratorImpression();


    });


    $('#BundleLabel').click(function (evt) {


        sendBundleImpression();

    });



    $("#byProd2").click(function () {
        if (!$("#mainMenu").hasClass("ui-panel-open")) {
           // console.log($("#byProd"));

            window.setTimeout(function () { $("#byProd").focus(); }, 500);

        }

    });

    // add a handler for click within typeahead box
    $(".typeAheadAjax").hover(function () { closeTypeAhead = false; }, function () { closeTypeAhead = true; });

    // handle arrow down to access type ahead...

    $(document).on("keydown", function (e) {
        if (e.keyCode == 40 && $(".typeAheadAjax").is(":visible")) {
            e.preventDefault();

            $(".typeAheadResults li").first().find('a').first().focus();
        }

    });




    // add touch start handler to close typeahead on mobile device
    $('.typeAheadAjax').on('touchstart', function () {
        closeTypeAhead = false;
    });

    $('.typeAheadAjax').on('touchmove', function () {
        closeTypeAhead = false;
    });

    $('.typeAheadAjax').on('touchend', function () {
        window.setTimeout(function () {
            closeTypeAhead = true;
        }, 1000);

    });

    $('.typeAheadAjax').on('touchleave', function () {
        window.setTimeout(function () {
            closeTypeAhead = true;
        }, 1000);

    });

    // add a handler for the input with typing delay

    $("#search-query").keyup(function (e) {

        if (e.keyCode != 40) {
            window.clearTimeout(typeAheadTimeOut);
            $(".typeAheadAjax").hide();

            typeAheadInput = this.value;
            $("#search-query").removeClass('loading');
            typeAheadTimeOut = window.setTimeout(function () { loadTypeAhead(); }, 50);
        }
    });

    // add a handler for a click to close type ahead
    $(document).mousedown(function () {
        if (closeTypeAhead) {
            window.clearTimeout(typeAheadTimeOut);
            $(".typeAheadAjax").hide();
            $("#search-query").removeClass('loading');
        }


    });




    // add touch start handler to close typeahead on mobile device
    $(document).on('touchstart', function () {
        if (closeTypeAhead) {
            window.setTimeout(function () {
                window.clearTimeout(typeAheadTimeOut);
                $(".typeAheadAjax").hide();
                $("#search-query").removeClass('loading');
            }, 1000);
        }



    });



    // function for loading type ahead
    function loadTypeAhead() {

        var fieldName = $("#search-query").attr("name");

        if (fieldName.toLowerCase() == "ntt") {
            // we have a change
            if (typeAheadInput.length >= 2) {

                // we need to the loading graphic



                var nvalue = $("#search-nValue").val();
                // we need to call the ajax and fill the content
                $("#search-query").addClass("loading");

                $.ajax({
                    type: "POST",
                    url: "/assets/ajax/autosuggest.aspx",
                    data: "term=" + typeAheadInput + "&N=" + nvalue,
                    success: function (msg) {

                        if (msg.length >= 6 && msg.indexOf("0 suggestions found, 0 categories found, 0 brands found.") <= 0) {





                            $(".typeAheadAjax").html("<div class='typeAheadArrow'></div>" + msg);
                            $(".typeAheadAjax").show();

                            $("#Aria-Announcements").html('<div aria-live="polite" role="alert">' + $("#typeaheadanouncement").html() + ' Press down arrow to access suggestions.</div>');
                            window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);

                            returnToIT = "#search-query";
                            hideIT = ".typeAheadAjax";
                            // close loading graphic
                            $("#search-query").removeClass("loading");

                            // set click events on more buttons
                            $("#TA-articles .TA-more").click(function () { $("#TA-articles li").removeClass("TA-hide"); $(this).addClass("TA-hide"); });
                            $("#TA-suggestions .TA-more").click(function () { $("#TA-suggestions li").removeClass("TA-hide"); $(this).addClass("TA-hide"); });
                            $("#TA-categories .TA-more").click(function () { $("#TA-categories li").removeClass("TA-hide"); $(this).addClass("TA-hide"); });
                            $("#TA-brands .TA-more").click(function () { $("#TA-brands li").removeClass("TA-hide"); $(this).addClass("TA-hide"); });

                            $(".TA-Scroll").mCustomScrollbar({
                                mouseWheel: true,
                                advanced: {
                                    autoScrollOnFocus: false,
                                    updateOnContentResize: true,
                                    updateOnBrowserResize: false,
                                    contentTouchScroll: true
                                }
                            });

                            window.setTimeout(function () { $(".TA-Scroll").mCustomScrollbar("update"); }, 1500);


                        } else {
                            $("#search-query").removeClass("loading");
                        }



                    }
                });

                // close loading graphic



            }
            else {

                $(".typeAheadAjax").hide();


            }
        }
    }


    setCompareFeatures();



    setGridView();

    // need to set the base settings









    // More less on side nav

    bindMore();







    //$("#primary ul li.main").click(function () {
    // clearTimeout();
    //   try {
    //       $.next("ul").show();
    //       return false;
    //   }
    //   catch (err) {

    //   }
    // }
    //	);



    try {

        $("#configuratorTabs.tabs").productTabs({
            "speed": 200

        });

        $(".configurator .nav-link").click(function () {

            $(".configurator .nav-link").removeClass("active");


            $("." + $(this).attr("class").replace(" ", ".")).not("#" + $(this).attr("id")).addClass("active");

            if ($(this).parent().parent().attr("id") == "configuratorTabs2") {
                $('.ActionButtons').addClass("cnfSticky");
                $('.ActionButtonsContainer').addClass("cnfSticky");

                $('html,body').animate({ scrollTop: $("#configuratorWrapper").offset().top }, 'fast');

                $('.ActionButtons').removeClass("cnfSticky");
                $('.ActionButtonsContainer').removeClass("cnfSticky");
            }
        });


        $("#product.DesktopFramework .tabs").productTabs({
            "speed": 200

        });



        if (location.hash != null && location.hash.indexOf("tab") >= 0) {


            var thistab = "";

            if (location.hash == "#tab-specs") { thistab = "#tabSpecs"; }
            if (location.hash == "#tab-protectionplans") { thistab = "#tabProtectionplans"; }
            if (location.hash == "#tab-interstitial") { thistab = "#tabInterstitial"; }
            if (location.hash == "#tab-reviews") { thistab = "#tabReviews"; }
            if (location.hash == "#tab-qa") { thistab = "#tabQa"; }
            if (location.hash == "#tab-info") { thistab = "#tabInfo"; }
            if (location.hash == "#tab-support") { thistab = "#tabSupport"; }
            if (location.hash == "#tab-clearance") { thistab = "#tabClearance"; }
            if (location.hash == "#tab-rebate") { thistab = "#tabRebate"; }




            if (thistab != "") {

                $("#product.DesktopFramework #product-details .accTab a").removeClass("current");


                $("#product.DesktopFramework #product-details .accTab a").attr("aria-selected", "false");

                $("#product.DesktopFramework " + thistab).addClass("current");
                $("#product.DesktopFramework " + thistab).attr("aria-selected", "true");


                $("#product.DesktopFramework #product-details article").css("display", "none");
                $("#product.DesktopFramework #product-details article").attr("aria-hidden", "true");



                $(location.hash).css("display", "block");
                $(location.hash).attr("aria-hidden", "false");


            }
        }

        // set active product tab


    }
    catch (err) {

    }

    try {
        $("#quickview-content .tabs").productTabs({
            "speed": 200
        });

    }
    catch (err) {

    }

    try {


        var testProductStation = $("#product.productStation.MobileFramework .tabs");



        if (testProductStation.length <= 0) {

            $("#product.MobileFramework .tabs").accordion({ header: ".tabLink", active: false, collapsible: true, heightStyle: "content", change: function (event, ui) { $("#product.MobileFramework .tabs").show()[0].scrollIntoView(true); } });
        }
        else {

            $("#product.MobileFramework .tabs").productTabs({
                "speed": 200

            });
        }

    }
    catch (err) {

    }


    try {

        $(".DesktopFramework.techcenter .tabs").productTabs({
            "speed": 200
        });
    }
    catch (err) {

    }


    try {

        $(".MobileFramework.techcenter  .tabs").accordion({ header: ".tabLink", active: false, collapsible: true, heightStyle: "content", change: function (event, ui) { $(".techcenter .tabs").show()[0].scrollIntoView(true); } });

    }
    catch (err) {

    }

    try {
        $("#careproduct .tabs").organicTabs({
            "speed": 200
        });

    }
    catch (err) {

    }


    $("article.tabs section div").hide();
    $("article.tabs section:first article").show();
    $("article.tabs section:first").addClass("active");




    // INTERSTITIAL

    $("#intersticialTabs #isserviceplans").click(function () {

        activateServicePlans();

    });

    $("#intersticialTabs #zone1tab").click(function () {

        activateZone1();

    });

    $("#intersticialTabs #zone2tab").click(function () {
        activateZone2();

    });

    $("#intersticialContent input").each(function () {
        $(this).attr("checked", false);
    });


    // clear the rf value if regular form gets clicked
    $(".RWO-RESERVE").click(function () {

        $(".crtfrm input[name='IsQuick']").val("True");


    });

    $(".crtQty").change(function () {


        if (isNaN($(this).val())) {
            $(this).val(1);
        }

        if ($(this).val() > $(this).data("max")) {
            $(this).val($(this).data("max"));
        }
        if ($(this).val() < 0) {
            $(this).val(1);
        }

        $(".crtQty").val($(this).val());

    });

    // clear the rf value if regular form gets clicked
    $(".btn-add").click(function () {

        if ($(".crtfrm input[name='rf']").val() != "Interstitial Add Ons") {
            //  $(".crtfrm input[name='rf']").val("Add To Cart Form");
        }


    });

    // Add to cart submit button - bind interstial form selections
    $("#intersticialBtn").click(function () {

        $(".crtfrm input[name='rf']").val("Add Ons");
        $(".crtfrm").first().submit();
        return false;

    });

    // Add to cart submit button - bind frequently purchased

    $("#FrequentyPurchasedTogetherButton").click(function () {

        $("#cartModal").html('');
        $(".crtfrm input[name='rf']").val("Frequently Bought Together");
        $(".crtfrm").first().submit();

    });












    $(".crtfrm .big.STBTN").click(function (e) {



        $(".body-loading").each(function () {

            $(this).attr("style", "display:block !important; background-color:rgb(255,255,255); opacity:.8;");


        });


        $(".crtfrm .big.STBTN").css("display", "none");


        $(".RWOQuantity").val('');
        $("#cartModal").html('');
        var ajx = $(".crtfrm.ajaxForm").first().find("input[name='ajax']");
        if (ajx.length) {


            ajx.val("true");
            $(".crtfrm.ajaxForm").first().find("input[name='buyItNow']").val("false");

        }

        ajx = $(".crtfrm.ajaxForm").last().find("input[name='ajax']");
        if (ajx.length) {


            ajx.val("true");
            $(".crtfrm.ajaxForm").last().find("input[name='buyItNow']").val("false");

        }



    });
    $(".crtfrm .big.BUY-NOW").click(function (e) {

        $("#cartModal").html('');
        var ajx = $(".crtfrm.ajaxForm").first().find("input[name='ajax']");

        if (ajx.length) {

            ajx.val("false");
            $(".crtfrm.ajaxForm").first().find("input[name='buyItNow']").val("true");

        }

        ajx = $(".crtfrm.ajaxForm").last().find("input[name='ajax']");

        if (ajx.length) {

            ajx.val("false");
            $(".crtfrm.ajaxForm").last().find("input[name='buyItNow']").val("true");

        }

        $(".crtfrm.ajaxForm").first().submit();


    });

   
    $(".ChangeCartType").click(function () {

        $(this).parent().parent().parent().find(".cartType").val($(this).data("carttype"));

    });

    $("#opAddToCart").click(function () {

        //alert('click add to cart');

        $("#cart-options.BuyingOptions input.btn-add").removeClass("opDisabled");

        $("#cart-options.BuyingOptions input.btn-add.grey.big.opPickupAtStore").addClass("opDisabled");

    });

    $("#opPickupRadio").click(function () {

        //alert('pick up at store')

        $("#cart-options.BuyingOptions input.btn-add").addClass("opDisabled");

        $("#cart-options.BuyingOptions input.btn-add.opPickupAtStore").removeClass("opDisabled");

    });



    $(".opDeliveryTypeRadio").click(function () {

        var storeID = 29;
        if ($(this).data("storeid") != null) {
            storeID = parseInt($(this).data("storeid"));
        }
        // set the store
        $(".crtfrm input[name='store_id']").val(storeID);

        $(".crtfrm").first().attr("action", "/store/add_product.aspx?storeid=" + storeID);

        if (storeID != 29) {
            // we need to turn on the button.

            $("#opPickupAtStore").removeClass("opDisabled");
            $("#opPickupAtStore").addClass("opEnabled");
            $("#opPickupAtStore").unbind();
            $("#opPickupAtStore").click(function () {

                $(".crtfrm").first().submit();
            });
        }
        else {
            $("#opPickupAtStore").addClass("opDisabled");
            $("#opPickupAtStore").removeClass("opEnabled");
            $("#opPickupAtStore").unbind();
            $("#opPickupAtStore").click(function () {
                return;
            });
        }

        // rebind the click...






    });


    // need to bind the subit to the buying options button.

    $('#topserviceplan input').attr('checked', false);
    $('#serviceplanfrm input').attr('checked', false);

    $("#topserviceplan input[name='topserviceplan']").click(function () {

        $("#serviceplanfrm input[name='serviceplan'][value='" + this.value + "']").attr("checked", "checked");

    });

    $('#moreprotectionplans').click(function () {


        $('#topserviceplan li').removeClass("hideitem");
        $('#moreprotectionplans').addClass("hideitem");
    });


    $("#serviceplanfrm input[name='serviceplan']").click(function () {

        $('#topserviceplan input').attr('checked', false);
        $("#topserviceplan input[name='topserviceplan'][value='" + this.value + "']").attr("checked", "checked");

    });

    // lets handle add ons radio buttons...

    $(".productIDsRadio").click(function () {


        var thisFormName = $(this).attr("name");


        var thisRemoveItem = $("input[name = '" + thisFormName + "'][value = '']");

        if (thisRemoveItem != null && thisRemoveItem.parent() != null) {
            thisRemoveItem.parent().show();
        }

        if ($(this).val() == '') {

            $(this).parent().hide();
        }



    });



    $(".startBuild").click(function () {


        var buildID = $(this).data('buildid');
        var buildName = $(this).data('buildname');
        var storeSelected = $(this).data('storeselected');
        var rulecount = 0;


        //ga('mc.ec:addProduct', {
        //    'id': $('.ProductLink_' + productId).data('id'),
        //    'name': $('.ProductLink_' + productId).data('name'),
        //    'category': $('.ProductLink_' + productId).data('category'),
        //    'brand': $('.ProductLink_' + productId).data('brand'),
        //    'price': price,
        //    'quantity': 1
        //});


        if (usingGA4) {
            gtag('event', 'start_build', {
                'event_type': 'start_build',
                'event_action': 'store:' + storeSelected,
                'build_id': '' + buildID
            });
        }
        if (usingGA3) {


            ga('mc.send', 'event', 'start_build', 'start_build', storeSelected);
        }


        $('.sku').each(function () {
            var bsku = $(this).html().replace('SKU: ', '');
            if (bsku == '583526' || bsku == '583559' || bsku == '583575' || bsku == '583609' || bsku == '583617' || bsku == '583757' || bsku == '583864' || bsku == '583872' || bsku == '583922' || bsku == '583955' || bsku == '584094' || bsku == '584110' || bsku == '584250' || bsku == '584318' ){
                $(this).parent().find('.stock').html('Special Order');
        }

        });


    });


    $(".openboxfrm").submit(function () {


        var productIDs = "";
        var count = 0;
        var rulecount = 0;
        var rules = new Array();

        var price = $(this).parent().parent().data('price');

        var productId = $(this).find("input[name='productID']").val();



        if (usingGA4) {
            gtag("event", "add_to_cart", {
                currency: "USD",
                value: price,
               
                items: [
                    {
                        item_id: $('.ProductLink_' + productId).data('id'),
                        item_name: (String($('.ProductLink_' + productId).data('name') || '')).replace("\\\"", " "),


                        index: 0,
                        item_brand: (String($('.ProductLink_' + productId).data('brand') || '')).replace("\\\"", " "),
                        item_category: (String($('.ProductLink_' + productId).data('category') || '')).replace("\\\"", " "),
                        item_coord: (String($('.ProductLink_' + productId).data('coord') || '')).replace("\\\"", " "),
                        item_core: (String($('.ProductLink_' + productId).data('core') || '')).replace("\\\"", " "),
                        item_list_id: "Add To Cart Click - Single Product Clearance",
                        item_list_name: "Add To Cart Click - Single Product Clearance",
                        is_personalized: $('.ProductLink_' + productId).data('personalized'),
                        price: price,
                        currency: "USD",
                        quantity: 1
                    }
                ]
            });
        }
        if (usingGA3) {


            ga('mc.ec:addProduct', {
                'id': $('.ProductLink_' + productId).data('id'),
                'name': $('.ProductLink_' + productId).data('name'),
                'category': $('.ProductLink_' + productId).data('category'),
                'brand': $('.ProductLink_' + productId).data('brand'),
                'price': price,
                'quantity': 1,
                'list': 'Add To Cart Click - Single Product Clearance'
            });




            ga('mc.ec:setAction', 'add', { list: 'Add To Cart Click - Single Product Clearance' });

        }



    });



    bindSubmit();
    bindClickItemV2();

    $(".proceedtocart").click(function () {

        $(".crtfrm").submit();

    });
    $(".proceedAjaxModal").click(function () {
        $("#crtfrmAjaxItems").submit();

    });



    // lets handle the Frequently purchased pricing updates and image removal


    $(".fbBundleProductCheckbox").click(function () {

        var addedTotal = 0;

        $("#FrequentyPurchasedTogether input[name='ProductID']").each(function () {
            addedTotal = parseFloat($(this).data("price"));

        });

        $("#FrequentyPurchasedTogether input[name='productIDsFB']:checked").each(function () {


            addedTotal = addedTotal + parseFloat($(this).data("price"));


        });


        var displayTotal = addedTotal.toFixed(2).toString();

        $(".BundledPrice").html("$" + displayTotal);

        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Bundled Price Updated to $' + displayTotal + '</div>');
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);



        // now lets toggle displays
        if ($(this).is(':checked')) {
            //$(".recentImageItem" + $(this).data("id")).fadeIn(400);
            $(".recentImageItem" + $(this).data("id")).css("opacity", "1");
        }
        else {
            //$(".recentImageItem" + $(this).data("id")).fadeOut(400);
            $(".recentImageItem" + $(this).data("id")).css("opacity", ".6");
        }



    });








    $(".opClose").click(function () {

        $(".opClose").hide();
        $("#open_box_modal").hide();
        $("#openBox").show();
        $(".fbSmallButton").css("opacity", "1");
        $("input.btn-add.grey.big.STBTN").css("opacity", "1");
        $("input.btn-add.grey.big.RWO-ON").css("opacity", "1");
        $('#opReduceAttention').removeClass('btn-add grey big STBTN opReduceAttention').addClass('btn-add grey big STBTN');
        $('#opReduceAttention').removeClass('btn-add grey big opReduceAttention').addClass('btn-add grey big');
    }),

        $(".opChoose").click(function () {
            $(".RWO-RESERVE").prop("type", "button");
            $("#open_box_modal_container .btn-add").css("display", "none");
            $(this).parent().parent().find(".btn-add").css("display", "block");
            $(".opBuyNowArea").text('BUY NOW');
        }),

        $("#openBox").click(function () {
            return $("#product-details article").removeClass("active"),
                $("#openBox").hide(),
                $(".opClose").show(),
                $("#product-details article").hide(),
                $("#tab-clearance").fadeIn("fast"),
                $("#product-details ul.nav li a").removeClass("current"),
                $("#tabClearance").addClass("current"),
                $(".fbSmallButton").css("opacity", ".4"),
                $("input.btn-add.grey.big.STBTN").css("opacity", ".4"),
                $("input.btn-add.grey.big.BUY-NOW").css("opacity", ".4"),
                $("input.btn-add.grey.big.RWO-ON").css("opacity", ".4"),
                $("#open_box_modal").is(":visible") ? $("#open_box_modal").hide() : ($("#open_box_modal").show(),
                    $('#opReduceAttention').removeClass('btn-add grey big STBTN').addClass('btn-add grey big STBTN opReduceAttention'),
                    $('#opReduceAttention').removeClass('btn-add grey big').addClass('btn-add grey big opReduceAttention')
                ),
                sendOpenBoxImpression();
            //$.cookie( $(this).parents("article").attr('id'), $(this).html());
            return false;
        });

    if ($("#open_box_modal").not(":visible") && window.location.href.indexOf("ob=1") == -1) {


        //sendOpenBoxImpression();

        $("#open_box_modal").mCustomScrollbar({
            mouseWheel: true,
            advanced: {
                autoScrollOnFocus: false,
                updateOnContentResize: true,
                updateOnBrowserResize: false,
                contentTouchScroll: true
            }
        });
    }

    $("#afterRebate").click(function () {



        $("#product-details article").removeClass("active");
        $("#product-details article").hide();
        $("#tab-rebate").fadeIn("fast");


        $("#product-details ul.nav li a").removeClass("current");
        $("#tabRebate").addClass("current");


        //$.cookie( $(this).parents("article").attr('id'), $(this).html());
        return false;



    });

    try {


        $("article.tabs section h1").click(function () {
            $("article.tabs section").removeClass("active");
            $(this).parent("section").addClass("active");
            $("article.tabs section:not('.active') article").hide();
            $("section.active article").fadeIn("fast");
            //$.cookie( $(this).parents("article").attr('id'), $(this).html());
            return false;
        });
    } catch (app) {

    }


    // turning of the old method...


    $('div.summary .slides-container').slick({
        slidesToShow: 1,
        slidesToScroll: 1,
        dots: false,
        arrows: false,
        infinite: false,
        autoplay: false,
        fade: true

    });

    $('div.summary #thumbnails .image-slide:first-child').addClass('current');

    $('div.summary .slides-container').on('beforeChange', function (event, slick, currentSlide, nextSlide) {
        $('div.summary #thumbnails .image-slide').removeClass('current');

        $('div.summary #thumbnails .image-slide[data-slide-index="' + nextSlide + '"]').addClass('current');

    });

    $('div.summary #thumbnails .image-slide').click(function () {

        var index = $(this).data('slide-index');
        $('div.summary .slides-container').slick("slickGoTo", index);

    });



    //$('#product div.summary .photos #thumbnails').slick({
    //    slidesToShow: 8,
    //    slidesToScroll: 0,
    //    dots: false,
    //    arrows: false,
    //    infinite: true,
    //    autoplay: false,
    //    focusOnSelect: true,
    //    asNavFor: '#product div.summary .photos .slides-container'

    //})



    //try {
    //    // PRODUCT PHOTO GALLERY
    //    $('#product div.summary').slides({
    //        preload: true,
    //        preloadImage: '/assets/images/loading.gif',
    //        effect: 'fade',
    //        crossfade: true,
    //        slideSpeed: 350,
    //        fadeSpeed: 300,
    //        generateNextPrev: false,
    //        generatePagination: false
    //    });
    //} catch (app) {

    //}


    // lets fire up the zip code search


    $("#findStoreZip").change(function (e) {
        e.preventDefault();
        var zip = $("#findStoreZip").val();

        if (zip.length >= 3) {
            // we should fire the ajax...
            $.ajax({
                type: "POST",
                url: "/assets/ajax/storeZipCode.aspx",
                data: { zip: zip, url: window.location.href },
                success: function (msg) {
                    if (msg.length > 60) {
                        createCookie("searchZip", zip, 30);
                    }
                    $("#storeList").html(msg);
                    $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Located store lists opened</div>');
                    window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
                }
            });


        }
        else {
            eraseCookie("searchZip");
        }

    });

    $("#findStoreButton").click(function (e) {
        e.preventDefault();
        var zip = $("#findStoreZip").val();

        if (zip.length >= 3) {
            // we should fire the ajax...
            $.ajax({
                type: "POST",
                url: "/assets/ajax/storeZipCode.aspx",
                data: { zip: zip, url: window.location.href },
                success: function (msg) {
                    if (msg.length > 60) {
                        createCookie("searchZip", zip, 30);
                    }
                    $("#storeList").html(msg);
                    $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Located store lists opened</div>');
                    window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
                }
            });


        }
        else {
            // eraseCookie("searchZip");
        }

    });

    $(".zipCodeLookup form").submit(
        function (e) {
            e.preventDefault();
            var zip = $("#findStoreZip").val();

            if (zip.length >= 3) {
                // we should fire the ajax...
                $.ajax({
                    type: "POST",
                    url: "/assets/ajax/storeZipCode.aspx",
                    data: { zip: zip, url: window.location.href },
                    success: function (msg) {
                        if (msg.length > 60) {
                            createCookie("searchZip", zip, 30);
                        }
                        $("#storeList").html(msg);
                        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Located store lists opened</div>');
                        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
                    }
                });


            }

        }
    );




    // STORE LOCATION MODAL
    //$(".myStore .info").click(function (e) {

    //    e.preventDefault();
    //    $("#storeInfo").show();
    //    $("#storeInfo").addClass("show");
    //    $("#Aria-Announcements").html('<div aria-live="polite" role="alert">My store info dialog opening.</div>');
    //    window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
    //    $("#storeInfo .closeModal").focus();

    //});
    $("#My-Store").click(function (e) {

        e.preventDefault();
        $("#storeInfo").show();
        $("#storeInfo .dropdown-menu ").hide();
        //   $("#storeInfo").addClass("show");
        escapeTarget = $("#My-Store");
        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">My store info dialog opening.</div>');
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
        $("#storeInfo .closeModal").focus();


    });

    $("#storeInfo .closeModal").click(function () {
        $("#storeInfo").removeClass("show");
        $("#storeInfo").removeClass("forceopen");
        $("#storeInfo").hide();
        $("#storeInfo .dropdown-menu ").hide();
        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Store info closed.</div>');
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
        return false;
    });



    $("#hypSignInWrapper").click(function (e) {
        $("#storeInfo").hide();
        $("#storeInfo").removeClass("show");
        $("#storeInfo").removeClass("forceopen");
        e.preventDefault();
        $("#accountOptions").show();
        //$("#accountOptions").removeClass("hide");
        //$("#accountOptions").addClass("show");
        escapeTarget = $(document.activeElement);
        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">My account info dialog opening.</div>');
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
        $("#accountOptions .closeModal").focus();


    });

    $("#hypMyAccount").click(function (e) {

        e.preventDefault();
        //    $("#accountOptions").removeClass("hide");
        //    $("#accountOptions").addClass("show");
        $("#accountOptions").show();
        escapeTarget = $(document.activeElement);
        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">My account info dialog opening.</div>');
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
        $("#accountOptions .closeModal").focus();


    });



    $("#accountOptions .closeModal").click(function () {
        //$("#accountOptions").addClass("hide");
        // $("#accountOptions").removeClass("show");
        $("#accountOptions").hide();
        $("#Aria-Announcements").html('<div aria-live="polite" role="alert">My account info dialog closed.</div>');
        window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
        return false;
    });


    if (!hasTouch && !window.navigator.msPointerEnabled) {
        // SHOW 'ZOOM' TEXT
        $("#product div.slides-container a .productImageZoom").hover(
            function () {
                $(this).parent().append($("<p class='icons zoom replace'>Zoom</p>"));
            },
            function () {
                $(this).parent().find("p.zoom").remove();
            }
        );

        $(".hypMyAccountModal").hoverIntent({
            over: function () {
                $("#storeInfo").hide();
                $("#storeInfo").removeClass("show");
                $("#storeInfo").removeClass("forceopen");
                $("#accountOptions").show();
                // $("#accountOptions").removeClass("hide");
            },
            out: function () {

                //  $("#accountOptions").addClass("hide");
                $("#accountOptions").hide();
            },
            timeout: 300
        });



        $(".myStore").hoverIntent({
            over: function () {

                $("#storeInfo").show();
                //  $("#storeInfo").addClass("show");
            },
            out: function () {
                $("#storeInfo").hide();
                $("#storeInfo .dropdown-menu ").hide();
                //   $("#storeInfo").remove("show");
            },
            timeout: 300
        });





        //$(".hypMyAccountModal").hover(
        //    function () {
        //        $("#accountOptions").removeClass("hide");
        //    },
        //    function () {
        //        $("#accountOptions").addClass("hide");
        //    }
        //);

    }

    try {


        $('#careproduct div.summary').slides({
            preload: true,
            preloadImage: '/assets/images/loading.gif',
            effect: 'fade',
            crossfade: true,
            slideSpeed: 350,
            fadeSpeed: 300,
            generateNextPrev: false,
            generatePagination: false
        });
    } catch (app) {

    }

    // SHOW 'ZOOM' TEXT
    $("#careproduct div.slides-container a").hover(
        function () {
            $(this).append($("<p class='icons zoom replace'>Zoom</p>"));
        },
        function () {
            $(this).find("p.zoom").remove();
        }
    );


    $('#fader').fadeIn("fast");


    try {
        $('#fader').orbit({


            animation: 'fade',                  // fade, horizontal-slide, vertical-slide, horizontal-push
            animationSpeed: 1000,                // how fast animtions are
            timer: true, 			 // true or false to have the timer
            advanceSpeed: 5000, 		 // if timer is enabled, time between transitions 
            pauseOnHover: true, 		 // if you hover pauses the slider
            startClockOnMouseOut: true, 	 // if clock should start on MouseOut
            startClockOnMouseOutAfter: 100, 	 // how long after MouseOut should the timer start again
            directionalNav: false, 		 // manual advancing directional navs
            captions: false, 			 // do you want captions?
            captionAnimation: 'fade', 		 // fade, slideOpen, none
            captionAnimationSpeed: 800, 	 // if so how quickly should they animate in
            bullets: false, 		 // true or false to activate the bullet navigation
            bulletThumbs: false, 	 // thumbnails for the bullets
            bulletThumbLocation: '', 	 // location from this file where thumbs will be
            afterSlideChange: function () { }



        });

    } catch (app) {

    }


    try {

        $(".specialOptions").fancybox({
            baseClass: 'fancyOptions',
            width: 800,
            height: 640,
            idleTime: false,
            transitionIn: "elastic",
            transitionOut: "fade",
            type: "iframe",

            buttons: ["close"],
            'afterShow': function () { $('.fancybox-button--close').focus(); }

        });
    } catch (app) {

    }

    try {
        $(".fancyPhotos").fancybox({
            'opacity': true,
            'overlayShow': false,
            'hideOnContentClick': false,
            'transitionIn': 'fade',
            'transitionOut': 'fade',
            'scrolling': 'no',
            'padding': 20,
            'width': 500,
            'min-width': 320,
            'height': 500,
            'min-height': 320,
            'overlayColor': '#F0F0F0',
            'titleShow': false,
            'type': 'iframe',
            'idleTime': false,
            'iframe': { scrolling: 'no', preload: false },
            'aspectRatio': true,
            'afterLoad': function (instance, slide) {
                // console.log(instance);
                // console.log(slide);
                $('.fancybox-button--close').focus();
                if (slide.src.indexOf('youtube.com') > 0) {

                    slide.$slide.addClass('fancybox-slide--video');
                }
            }

        });
    } catch (app) {

    }


    try {



        $(".fancyVideo").fancybox({
            'opacity': true,
            'overlayShow': false,
            'hideOnContentClick': false,
            'transitionIn': 'fade',
            'transitionOut': 'fade',
            'scrolling': 'no',
            'padding': 20,
            'width': 1000,
            'min-width': 320,
            'height': 1000,
            'min-height': 320,
            'arrows': false,
            'infobar': false,
            'overlayColor': '#F0F0F0',
            'titleShow': false,
            'idleTime': false,


            'aspectRatio': true,
            'afterShow': function () { $('.fancybox-button--close').focus(); }

        });
    } catch (app) {

    }





    try {
        $(".fancyPhotosMobile").fancybox({
            'opacity': true,
            'overlayShow': false,
            'hideOnContentClick': false,
            'transitionIn': 'fade',
            'transitionOut': 'fade',
            'scrolling': 'no',
            'padding': 20,
            'width': 500,
            'min-width': 320,
            'height': 500,
            'min-height': 320,
            'overlayColor': '#F0F0F0',
            'titleShow': false,
            'idleTime': false,

            'aspectRatio': true,
            'afterLoad': function (instance, slide) {

                $('.fancybox-button--close').focus();
                //console.log(instance);
                //console.log(slide);
                if (slide.src.indexOf('youtube.com') > 0) {

                    slide.$slide.addClass('fancybox-slide--video');
                }
            }
        });
    } catch (app) {

    }
    $(".productImageZoom").click(function () {
        $(".zm-viewer.followViewerConfig").css("display", "none");
    });








    $("#tech a").attr('target', '_blank');

    try {
        $(".bio-modal").fancybox({
            'width': 830,
            'height': '95%',
            'autoScale': false,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'type': 'iframe',
            'idleTime': false,
            'baseClass': 'fbModalBio',
            'afterShow': function () { $('.fancybox-button--close').focus(); }

        });

    } catch (app) {

    }




    setModalLogin();
    setServiceButton();





    try {
        $(".pop-modal").fancybox({
            'width': 830,
            'height': '95%',
            'autoScale': false,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'type': 'iframe',
            'idleTime': false,
            'afterShow': function () { $('.fancybox-button--close').focus(); }

        });

    } catch (app) {

    }

    try {
        $(".pop-modal16x9").fancybox({
            'width': '95%',
            'fitToView': true,
            'height': '53%',
            'autoScale': false,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'type': 'iframe',
            'idleTime': false,
            'baseClass': 'modal16X9',
            'caption': '<a href="/site/customer-support/terms-conditions-site.aspx#tours" class="virtualDisclaimer">Product prices shown on the virtual tour are subject to change and may not be the current product price. </a>',

            'afterShow': function () {
                $('.fancybox-button--close').focus();

            }

        });

    } catch (app) {

    }

    try {
        $(".sms-modal").fancybox({

            'maxWidth': 440,
            'maxHeight': 560,
            'fitToView': false,
            'width': '88%',
            'height': 560,
            'autoSize': false,
            'closeClick': false,
            'openEffect': 'none',
            'closeEffect': 'none',
            'controls': 0,
            'showinfo': 0,
            'autoDimensions': false,
            'scrolling': 'no',
            'padding': 0,
            'type': 'iframe',
            'arrows': false,
            'infobar': false,
            'buttons': ["close"],
            'idleTime': false,

            'iframe': { scrolling: 'no', preload: true },
            'afterShow': function () { $('.fancybox-button--close').focus(); }


        });

    } catch (app) {

    }

    try {
        $("a.PlanDetailsLink").fancybox({
            'width': '620px',
            'height': '95%',
            'autoScale': false,
            'titleShow': false,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'idleTime': false,
            'afterShow': function () {

                $('.fancybox-button--close').focus();

                $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Protection Plan Information Opened</div>');
                window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);

            }
        });

    } catch (app) {

    }







    try {
        function openModal(name, skuIDs) {
            $.fancybox(
                {

                    'autoDimensions': false,
                    'width': 1000,
                    'height': '95%',
                    'autoScale': false,
                    'transitionIn': 'elastic',
                    'transitionOut': 'fade',
                    'type': 'iframe',
                    'idleTime': false,
                    'href': '/endeca/compare.aspx?skuIDs=' + skuIDs,
                    'afterShow': function () { $('.fancybox-button--close').focus(); }
                }
            );
        }

    } catch (app) {

    }


    ADAUpdates();


    // end ready

});



function setModalLoginFavorite() {



    // before finding, lets see if the user is already logged in and if so, lets alter the a tag to the after login data value...
    if ($("body").hasClass("isLoggedIn")) {
        // switch the links
        $(".login-modalFav").each(function () {

            if (typeof $(this).data("after") !== "undefined") {
                $(this).attr("href", $(this).data("after"));



            }

        });

    }


    //try {

    //    $(".login-modalFav").fancybox({
    //        'width': 600,
    //        'height': '95%',
    //        'autoScale': false,
    //        'transitionIn': 'elastic',
    //        'transitionOut': 'fade',
    //        'type': 'iframe',
    //        'idleTime': false,
    //        'baseClass': 'fbModalLogin',
    //        'afterShow': function () { $('.fancybox-button--close').focus(); }

    //    });

    //} catch (app) {

    //}



    //$(".login-modalFav").click(function () {


    //    var productID = $(this).data("productid");

    //    try {
    //        $('#mainMenu').panel('close');
    //    }
    //    catch (ex) {

    //    }
    //    //console.log("adding Listener");
    //    var mliframe = $($(".fbModalLogin .fancybox-iframe").contents()[0], window);
    //    // var mliframe = $(".fbModalLogin .fancybox-iframe").contents();
    //    window.addEventListener("message", function (event) {

    //        if (event.origin.toLowerCase().indexOf(".microcenter.com") <= 0) {

    //            return;
    //        }
    //        else if (event.data.loginSuccess === true) {
    //            localStorage.setItem("login", "true");

    //            window.location.href = "https://" + window.location.host + window.location.pathname + "?favID=" + productID;


    //            //location.reload(true);
    //            // Close modal window/redirect/reload page
    //        }
    //    }, false);



    //});
}

function sendOpenBoxImpression() {


    if (usingGA4) {
        if (typeof (OpenBoxLayer) != 'undefined' && !sentopenbox && typeof (gtag) != 'undefined') {

            var list = "[";
            for (cnt = 0; cnt < OpenBoxLayer.length; ++cnt) {

                if (cnt > 0) { list += ","; }
                list += "{";
                list += "item_id: " + (String(OpenBoxLayer[cnt].name || '')).replace("\\\"", " ") + ",";
                list += "item_name: " + OpenBoxLayer[cnt].id + ",";
                list += "index: " + OpenBoxLayer[cnt].position + ",";
                list += "item_brand: " + (String(OpenBoxLayer[cnt].brand || '')).replace("\\\"", " ") + ",";
                list += "item_category: " + (String(OpenBoxLayer[cnt].category || '')).replace("\\\"", " ") + ",";
                list += "item_coord: " + (String(OpenBoxLayer[cnt].coord || '')).replace("\\\"", " ") + ",";
                list += "item_core: " + (String(OpenBoxLayer[cnt].core || '')).replace("\\\"", " ") + ",";

                list += "item_list_id: " + (String(OpenBoxLayer[cnt].list || '')).replace("\\\"", " ") + ",";
                list += "item_list_name: " + (String(OpenBoxLayer[cnt].list || '')).replace("\\\"", " ") + ",";
               
                list += "price: " + OpenBoxLayer[cnt].price + ",";
                
                list += "currency: 'USD',";
                list += "quantity: " + 1 ;




                list += "}";



            }
            list += "]";

            gtag("event", "view_item_list", {
                item_list_id: "Single Product Clearance",
                item_list_name: "Single Product Clearance",
                items: eval(list)

            });


            sentopenbox = true;

        }
    }
    if (usingGA3) {


        if (typeof (OpenBoxLayer) != 'undefined' && !sentopenbox && typeof (ga) != 'undefined') {

            // ga('mc.ec:addImpression', addOnLayer);
            for (cnt = 0; cnt < OpenBoxLayer.length; ++cnt) {
                ga('mc.ec:addImpression', OpenBoxLayer[cnt]);
            }

            sentopenbox = true;
            ga('mc.ec:setAction', 'detail');
            ga('mc.send', 'event', 'eCommerce', 'Single Product Clearance', { nonInteraction: true });


        }

    }
}

function sendfrequentlyboughtImpression() {

    if (usingGA4) {
        if (typeof (frequentlyBoughtLayer) != 'undefined' && !sentfrequentlybought && typeof (gtag) != 'undefined') {

            var list = "[";
            for (cnt = 0; cnt < frequentlyBoughtLayer.length; ++cnt) {
                if (typeof (frequentlyBoughtLayer[cnt].name) != 'undefined' && typeof (frequentlyBoughtLayer[cnt].brand) != 'undefined' &&  typeof (frequentlyBoughtLayer[cnt].list) != 'undefined') {
                    if (cnt > 0) { list += ","; }
                    list += "{";
                    list += "item_id: '" + frequentlyBoughtLayer[cnt].id + "',";
                    list += "item_name: '" + (String(frequentlyBoughtLayer[cnt].name || '')).replace("\\\"", " ")  + "',";
                    list += "index: " + frequentlyBoughtLayer[cnt].position + ",";
                    list += "item_brand: '" + (String(frequentlyBoughtLayer[cnt].brand || '')).replace("\\\"", " ") + "',";

                    list += "item_category: '" + (String(frequentlyBoughtLayer[cnt].category || '')).replace("\\\"", " ") + "',";
                    list += "item_coord: '" + (String(frequentlyBoughtLayer[cnt].coord || '')).replace("\\\"", " ") + "',";
                    list += "item_core: '" + (String(frequentlyBoughtLayer[cnt].core || '')).replace("\\\"", " ") + "',";
                   
                    list += "item_list_id: '" + (String(frequentlyBoughtLayer[cnt].list || '')).replace("\\\"", " ") + "',";
                    list += "item_list_name: '" + (String( frequentlyBoughtLayer[cnt].list || '')).replace("\\\"", " ") + "',";
                    list += "price: " + frequentlyBoughtLayer[cnt].price + ",";
                    list += "currency: 'USD',";
                    list += "quantity: " + 1 + ",";




                    list += "}";
                }


            }
            list += "]";

            //gtag("event", "view_item_list", {
            //    item_list_id: "Frequently Bought Together",
            //    item_list_name: "Frequently Bought Together",
            //    items: eval(list)

            //});

            sentfrequentlybought = true;

        }
    }
    if (usingGA3) {
        if (typeof (frequentlyBoughtLayer) != 'undefined' && !sentfrequentlybought && typeof (ga) != 'undefined') {
            var listName = "Frequently Bought Together";
            // ga('mc.ec:addImpression', addOnLayer);
            for (cnt = 0; cnt < frequentlyBoughtLayer.length; ++cnt) {
                ga('mc.ec:addImpression', frequentlyBoughtLayer[cnt]);
                listName = frequentlyBoughtLayer[cnt].list;
            }

            sentfrequentlybought = true;
            ga('mc.ec:setAction', 'detail');
            ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });


        }
    }

}

function sendconfiguratorImpression() {


    if (usingGA4) {
        if (typeof (configuratorLayer) != 'undefined' && !sentconfigurator && typeof (gtag) != 'undefined') {

            var list = "[";
            for (cnt = 0; cnt < configuratorLayer.length; ++cnt) {

                if (cnt > 0) { list += ","; }
                list += "{";
                list += "item_id: " + (String(configuratorLayer[cnt].name || '')).replace("\\\"", " ") + ",";
                list += "item_name: " + configuratorLayer[cnt].id + ",";
                list += "index: " + (String(configuratorLayer[cnt].position || '')).replace("\\\"", " ") + ",";
                list += "item_brand: " + (String(configuratorLayer[cnt].brand || '')).replace("\\\"", " ") + ",";
                list += "item_category: " + (String(configuratorLayer[cnt].category || '')).replace("\\\"", " ") + ",";
                list += "item_coord: " + (String(configuratorLayer[cnt].coord || '')).replace("\\\"", " ") + ",";
                list += "item_core: " + (String(configuratorLayer[cnt].core || '')).replace("\\\"", " ") + ",";
                list += "item_list_id: " + (String(configuratorLayer[cnt].list || '')).replace("\\\"", " ") + ",";
                list += "item_list_name: " + (String(configuratorLayer[cnt].list || '')).replace("\\\"", " ") + ",";
                list += "price: " + configuratorLayer[cnt].price + ",";
                list += "currency: 'USD',";
                list += "quantity: " + 1 + ",";




                list += "}";



            }
            list += "]";

            gtag("event", "view_item_list", {
                item_list_id: "Recommended Items",
                item_list_name: "Recommended Items",
                items: eval(list)

            });

            sentconfigurator = true;

        }
    }
    if (usingGA3) {


        if (typeof (sentconfigurator) != 'undefined' && !sentconfigurator && typeof (ga) != 'undefined') {


             listName = "Recommended Items";
            // ga('mc.ec:addImpression', addOnLayer);
            for (cnt = 0; cnt < configuratorLayer.length; ++cnt) {
                ga('mc.ec:addImpression', configuratorLayer[cnt]);
                listName = configuratorLayer[cnt].list;
            }

            sentconfigurator = true;
            ga('mc.ec:setAction', 'detail');
            ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });


        }
    }

}

function sendBundleImpression() {



    if (usingGA4) {
        if (typeof (bundleOptionsLayer) != 'undefined' && !sentBundles && typeof (gtag) != 'undefined') {

            var list = "[";
            for (cnt = 0; cnt < bundleOptionsLayer.length; ++cnt) {

                if (cnt > 0) { list += ","; }
                list += "{";
                list += "item_id: " + (String(bundleOptionsLayer[cnt].name || '')).replace("\\\"", " ") + ",";
                list += "item_name: " + bundleOptionsLayer[cnt].id + ",";
                list += "index: " + bundleOptionsLayer[cnt].position + ",";
                list += "item_brand: " + (String(bundleOptionsLayer[cnt].brand || '')).replace("\\\"", " ") + ",";
                list += "item_category: " + (String(bundleOptionsLayer[cnt].category || '')).replace("\\\"", " ") + ",";
                list += "item_coord: " + (String(bundleOptionsLayer[cnt].coord || '')).replace("\\\"", " ") + ",";
                list += "item_core: " + (String(bundleOptionsLayer[cnt].core || '')).replace("\\\"", " ") + ",";

                list += "item_list_id: " + (String(bundleOptionsLayer[cnt].list || '')).replace("\\\"", " ") + ",";
                list += "item_list_name: " + (String(bundleOptionsLayer[cnt].list || '')).replace("\\\"", " ") + ",";
                list += "price: " + bundleOptionsLayer[cnt].price + ",";
                list += "currency: 'USD',";
                list += "quantity: " + 1 + ",";




                list += "}";



            }
            list += "]";

            gtag("event", "view_item_list", {
                item_list_id: "Bundle Product Option",
                item_list_name: "Bundle Product Option",
                items: eval(list)

            });

            sentBundles = true;

        }
    }
    if (usingGA3) {


        if (typeof (bundleOptionsLayer) != 'undefined' && !sentBundles && typeof (ga) != 'undefined') {

             listName = "Bundle Product Option";
            // ga('mc.ec:addImpression', addOnLayer);
            for (cnt = 0; cnt < bundleOptionsLayer.length; ++cnt) {
                ga('mc.ec:addImpression', bundleOptionsLayer[cnt]);
                listName = bundleOptionsLayer[cnt].list;
            }

            sentBundles = true;
            ga('mc.ec:setAction', 'detail');
            ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });


        }
    }

}

function sendaddOnImpression() {

    if (usingGA4) {
        if (typeof (addOnLayer) != 'undefined' && !sentAdOns && typeof (gtag) != 'undefined') {

            var list = "[";
            for (cnt = 0; cnt < addOnLayer.length; ++cnt) {

                if (cnt > 0) { list += ","; }
                list += "{";
                list += "item_id: " + (String(addOnLayer[cnt].name || '')).replace("\\\"", " ") + ",";
                list += "item_name: " + addOnLayer[cnt].id + ",";
                list += "index: " + addOnLayer[cnt].position + ",";
                list += "item_brand: " + (String(addOnLayer[cnt].brand || '')).replace("\\\"", " ") + ",";
                list += "item_category: " + (String(addOnLayer[cnt].category || '')).replace("\\\"", " ") + ",";
                list += "item_coord: " + (String(addOnLayer[cnt].coord || '')).replace("\\\"", " ") + ",";
                list += "item_core: " + (String(addOnLayer[cnt].core || '')).replace("\\\"", " ") + ",";

                list += "item_list_id: " + (String(addOnLayer[cnt].list || '')).replace("\\\"", " ") + ",";
                list += "item_list_name: " + (String(addOnLayer[cnt].list || '')).replace("\\\"", " ") + ",";
                list += "price: " + addOnLayer[cnt].price + ",";
                list += "currency: 'USD',";
                list += "quantity: " + 1;




                list += "}";



            }
            list += "]";

            gtag("event", "view_item_list", {
                item_list_id: "Bundle Product Option",
                item_list_name: "Bundle Product Option",
                items: eval(list)

            });

            sentAdOns = true;

        }
    }
    else {

        if (typeof (addOnLayer) != 'undefined' && !sentAdOns && typeof (ga) != 'undefined') {
             listName = "Ad Ons";
            // ga('mc.ec:addImpression', addOnLayer);
            for (cnt = 0; cnt < addOnLayer.length; ++cnt) {
                ga('mc.ec:addImpression', addOnLayer[cnt]);
                listName = addOnLayer[cnt].list;
            }

            sentAdOns = true;
            ga('mc.ec:setAction', 'detail');
            ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });


        }

    }



}


function sendproductImpression() {



    if (usingGA4) {
        if (typeof (productsLayer) != 'undefined' && !sentProducts && typeof (gtag) != 'undefined') {

            var list = "[";
            for (cnt = 0; cnt < productsLayer.length; ++cnt) {

                if (productsLayer[cnt].list != null && productsLayer[cnt].brand != null && productsLayer[cnt].name != null) {
                    if (cnt > 0) { list += ","; }
                    list += "{";
                    list += "item_id: " + (String(productsLayer[cnt].name || '')).replace("\\\"", " ") + ",";
                    list += "item_name: " + productsLayer[cnt].id + ",";
                    list += "index: " + productsLayer[cnt].position + ",";
                    list += "item_brand: " + (String(productsLayer[cnt].brand || '')).replace("\\\"", " ") + ",";
                    list += "item_category: " + (String(productsLayer[cnt].category || '')).replace("\\\"", " ") + ",";
                    list += "item_coord: " + (String(productsLayer[cnt].coord || '')).replace("\\\"", " ") + ",";
                    list += "item_core: " + (String(productsLayer[cnt].core || '')).replace("\\\"", " ") + ",";

                    list += "item_list_id: " + (String(productsLayer[cnt].list || '')).replace("\\\"", " ") + ",";
                    list += "item_list_name: " + (String(productsLayer[cnt].list || '')).replace("\\\"", " ") + ",";
                    list += "price: " + addOnLayer[cnt].price + ",";
                    list += "currency: 'USD',";
                    list += "quantity: " + 1;




                    list += "}";

                }

            }
            list += "]";

            gtag("event", "view_item_list", {
                item_list_id: "Bundle Product Option",
                item_list_name: "Bundle Product Option",
                items: eval(list)

            });

            sentProducts = true;

        }
    }
    else {





        if (typeof (productsLayer) != 'undefined' && !sentProducts && typeof (ga) != 'undefined') {

            // ga('mc.ec:addImpression', addOnLayer);
            for (cnt = 0; cnt < productsLayer.length; ++cnt) {
                if (productsLayer.length == 1) {
                    ga('mc.ec:addProduct', productsLayer[cnt]);
                }
                else {
                    ga('mc.ec:addImpression', productsLayer[cnt]);
                }

            }

            sentProducts = true;
            ga('mc.ec:setAction', 'detail');
            if (productsLayer.length > 1) {
                ga('mc.send', 'event', 'eCommerce', 'Products', { nonInteraction: true });
            }


        }
    }


}




function createCookie(name, value, days) {
    var expires;
    if (days) {
        var date = new Date();
        date.setTime(date.getTime() + (days * 24 * 60 * 60 * 1000));
        expires = "; expires=" + date.toGMTString();
    }
    else
    {
        expires = "";
    }
    if (window.location.hostname == "localhost") {
        document.cookie = name + "=" + value + expires + ";path=/;domain=localhost;";

    }
    else {
        document.cookie = name + "=" + value + expires + "; path=/;secure;domain=.microcenter.com;";
    }



}

function readCookie(name) {
    var nameEQ = name + "=";
    var ca = document.cookie.split(';');
    for (var i = 0; i < ca.length; i++) {
        var c = ca[i];
        while (c.charAt(0) == ' ') c = c.substring(1, c.length);
        if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length, c.length);
    }
    return null;
}

function eraseCookie(name) {
    createCookie(name, "", -1);

}

// **************************************************************
// Compare Functions
// *************************************************************
function setCompareFeatures() {

    // **********************************************************************





    // *************************************************************************
    // compare methods
    // *************************************************************************

    var skucheck = readCookie('compare');
    if (typeof (skucheck) != 'undefined' && skucheck != null && skucheck != "") {
        currentCompare = skucheck;
    }
    else {
        skucheck = currentCompare;
    }


    var foundsku = "";


    $('#compare-remove').click(function (e) {
        currentCompare = "";
        e.preventDefault();
        eraseCookie("compare");


        $('.inline-compare-text').css("display", "inline");
        $('.inline-compare-button').css("display", "none");
        $('.checkbox').prop('checked', false);
        $('.inline-compare-text').html('Select 2 to compare');
        set_compare_section('', '');
        return false;
    });

    $('.compare2023').click(function (e) {

        e.preventDefault();

        $("#compareSubmit").submit();

        //        var allIds = new Array();
        //        var productIDs = '0';
        //        productIDs = readCookie('compare');
        //        openModal('compare', productIDs);
    });

    $('.compare').click(function (e) {

        e.preventDefault();

        $("#compareSubmit").submit();

        //        var allIds = new Array();
        //        var productIDs = '0';
        //        productIDs = readCookie('compare');
        //        openModal('compare', productIDs);
    });

    $('#compare-over-alert a').click(function (e) {
        e.preventDefault();
        $('#compare-over-alert').hide();

    });




    if (typeof (skucheck) != 'undefined' && skucheck != null && skucheck != "") {
        var allskus = new Array();

        allskus = skucheck.split('|');

        set_compare_section('', '');

        if (allskus.length > 1) {
            $('.inline-compare-text').html('Add to compare');
        }
        else {
            $('.inline-compare-text').html('Select 2 to compare');
        }

        for (var a in allskus) {
            foundsku = "";
            foundsku = allskus[a].split(':')[0];
            var foundproductID = allskus[a].split(':')[1];

            if (!isNaN(foundproductID)) {



                $('#button_productIDcheck' + foundproductID).css("display", "inline");

                if (window.location.pathname.toLowerCase().indexOf("/product") < 0) {


                    $('#text_productIDcheck' + foundproductID).css("display", "none");
                }
                else {

                    $('#text_productIDcheck' + foundproductID).html('Compare');
                }
                //$('.inline-compare-text').html('Add to compare');
                $('#productIDcheck' + foundproductID).prop('checked', true);



            }

        }


    }
    else {
        $('.inline-compare-text').html('Select 2 to compare');
    }






    /* lest set the featured item slider */


    try {
        $("div.featuredList").carousel({ dispItems: 1 });
    } catch (e) {

    }

    try {
        $("div.featuredItems").css('display', 'block');
    } catch (e) {

    }


}







function set_compare_section(sku_id, producttitle) {
    var thisSku;
    var thisProductId;
    var cookie = readCookie('compare');

    if (typeof (cookie) != 'undefined' && cookie != null && cookie != "") {
        currentCompare = cookie;
    }
    else {
        cookie = currentCompare;
    }

    var compareON = false;

    if (cookie && cookie.search('c26ba48acbfa28c59f170514c27aea07') != -1) {
        cookie = cookie.replace(/%7C/, '|');
        var allskus = new Array();
        allskus = cookie.split('|');



        for (var skuCount = 1; skuCount < 5; skuCount++) {


            if (allskus.length > skuCount) {
                compareON = true;
                thisSku = Right('000000' + allskus[skuCount].split(":")[0], 6);

                thisProductId = Right('0000000' + allskus[skuCount].split(":")[1], 7);


                var compareHtml = '<img src="https://90a1c75758623581b3f8-5c119c3de181c9857fcb2784776b17ef.ssl.cf2.rackcdn.com/' + thisProductId + '_' + thisSku + '.jpg" alt="' + producttitle + '">';
                compareHtml = compareHtml + '<div><a href="#" onclick="removeCompare(\'' + allskus[skuCount].split(":")[0] + ':' + allskus[skuCount].split(":")[1] + '\');return false;">X<span class="hide-text"> Remove Compare Item - ' + producttitle + '</span></a></div>';
                $('#compare-item' + skuCount).html(compareHtml);


            }
            else {
                $('#compare-item' + skuCount).html('');

            }


        }

        if (sku_id != "") {

            // lets animate the picture...


             thisSku = Right('000000' + sku_id.split(":")[0], 6);

             thisProductId = Right('0000000' + sku_id.split(":")[1], 7);

            $('.compare-section').show();
            var compareAnimationImg = '<img id=\"compareAnimationImg\" src="https://90a1c75758623581b3f8-5c119c3de181c9857fcb2784776b17ef.ssl.cf2.rackcdn.com/' + thisProductId + '_' + Right('0000000' + thisSku, 6) + '.jpg">';


            var compareAnimationPosition = $('#text_productIDcheck' + sku_id.split(":")[1]).parent().parent().parent().parent().position();
           // console.log(compareAnimationPosition.top + " " + compareAnimationPosition.left);

            var compareDestinationPosition = $('#compare-item' + (allskus.length - 1)).position();




            $('#compareAnimation').css("top", (compareAnimationPosition.top + 30) + 'px');
            $('#compareAnimation').css("left", (compareAnimationPosition.left + 20) + 'px');
            $('#compareAnimation').css("width", '120px');
            $('#compareAnimation').css("height", '120px');
            $('#compareAnimation').html(compareAnimationImg);
            $('#compareAnimation').show();

            $('#compare-item' + (allskus.length - 1) + ' img').hide();
            $('#compareAnimation').animate({ width: '36px', height: '36px', top: '-44px', left: compareDestinationPosition.left + 'px' }, 1000);


            setTimeout(function () { $('.compare-section #compare-item' + (allskus.length - 1) + ' img').show(); $('#compareAnimation').hide(); }, 1000);

            $("#Aria-Announcements").html('<div aria-live="polite" role="alert">Compare item added or changed ' + producttitle + '.  Tab then press enter to load compare page in new window.</div>');
            window.setTimeout(function () { $("#Aria-Announcements").html(''); }, 5000);
        }

    } else {
        $('.compare-item').html('');
        $("#productGridAnnouncement").focus();
    }

    if (compareON) {
        $('.compare-section').show();
    } else {
        $('.inline-compare-text').css("display", "inline");
        $('.inline-compare-button').css("display", "none");
        $('.checkbox').prop('checked', false);
        $('.compare-section').hide();


    }

}

function removeCompare(sku_id) {

    var cookie = readCookie('compare');
    if (typeof (cookie) != 'undefined' && cookie != null && cookie != "") {
        currentCompare = cookie;
    }
    else {
        cookie = currentCompare;
    }
    var newCookie = "c26ba48acbfa28c59f170514c27aea07";

    if (cookie && cookie.search('c26ba48acbfa28c59f170514c27aea07') != -1) {
        cookie = cookie.replace(/%7C/, '|');
        var allskus = new Array();
        allskus = cookie.split('|');
        for (var skuCount = 1; skuCount < allskus.length; skuCount++) {

            if (allskus[skuCount] != sku_id) {

                newCookie = newCookie + "|" + allskus[skuCount];
            }

        }




        var foundsku = parseInt(sku_id.split(':')[0]);
        var foundproductID = sku_id.split(':')[1];
        $('#button_productIDcheck' + foundproductID).css("display", "none");
        $('#text_productIDcheck' + foundproductID).css("display", "inline");
        //$('.inline-compare-text').html('Add to compare');


        $('#productIDcheck' + foundproductID).prop('checked', false);


        if (allskus.length > 2) {
            $('.inline-compare-text').html('Add to compare');
        }
        else {


            $('.inline-compare-text').html('Select 2 to compare');
        }

        createCookie('compare', newCookie, 7);

        var et = "Compare Item Removed";

        ga('mc.send', 'event', et, sku_id, 'X selected');

        set_compare_section('', '');

    }



}


function set_compare_items(thisForm, sku_id, producttitle, searchResult, productPage ) {

    if (searchResult == null)
    {
        searchResult = true;
    }

    if (productPage == null) {
        productPage = false;
    }


    $('#compare-over-alert').hide();

    var cookie = readCookie('compare');

    if (typeof (cookie) != 'undefined' && cookie != null && cookie != "") {
        currentCompare = cookie;
    }
    else {
        cookie = currentCompare;
    }
    var allskus = new Array();


    if (cookie == '' && currentCompare == '') {

        var date = new Date();
        var minutes = -1;
        date.setTime(date.getTime() - 1);
        $.cookie(name, null, { domain: window.location.hostname, expires: date });
        $.cookie(name, null, { domain: '.microcenter.com', expires: date });


    }


    if (cookie && cookie.search('c26ba48acbfa28c59f170514c27aea07') != -1) {
        cookie = cookie.replace(/%7C/, '|');

        allskus = cookie.split('|');

        if (allskus.length > 4 && thisForm.elements[0].checked) {
            var thisPosition = $('#text_productIDcheck' + sku_id.split(":")[1]).parent().parent().parent().parent().position();

            $('#compare-over-alert').css("top", (thisPosition.top + 30) + 'px');
            $('#compare-over-alert').css("left", (thisPosition.left + 30) + 'px');

            $('#compare-over-alert').show();
            thisForm.elements[0].checked = false;
            return;
        }
    }

    var foundsku = sku_id.split(':')[0];
    var foundproductID = sku_id.split(':')[1];

    if (cookie) {
        cookie = cookie.replace(/%7C/, '|');

        if (cookie.search('c26ba48acbfa28c59f170514c27aea07') != -1) {
            if (thisForm.elements[0].checked) {

                // checkbox was checked
                if (cookie.search(sku_id) == -1) {
                    // if cookie does not contain product_id
                    createCookie('compare', cookie + '|' + sku_id, 7);
                } else {
                    // cookie already contains product_id
                }


                $('#button_productIDcheck' + foundproductID).css("display", "inline");
                if (!productPage) {
                    $('#text_productIDcheck' + foundproductID).css("display", "none");
                    $('.inline-compare-text').html('Add to compare');
                }
                else {
                    $('#text_productIDcheck' + foundproductID).css("display", "inline");
                    $('.inline-compare-text').html('Compare');
                }
            } else {
                // checkbox was un-checked
                $('#button_productIDcheck' + foundproductID).css("display", "none");
                $('#text_productIDcheck' + foundproductID).css("display", "inline");
                new_cookie = cookie.replace("|" + sku_id, '');
                createCookie('compare', new_cookie, 7);
                 allskus = new Array();
                sku_id = '';
                allskus = new_cookie.split('|');
                if (productPage) {
                    $('.inline-compare-text').html('Add To Compare');
                }
                if (allskus.length < 2) {
                    if (productPage) {
                        $('.inline-compare-text').html('Add To Compare');
                    }
                    else {
                        $('.inline-compare-text').html('Select 2 to compare');
                    }

                }
            }

        } else {
            createCookie('compare', 'c26ba48acbfa28c59f170514c27aea07|' + sku_id, 7);
            $('#button_productIDcheck' + foundproductID).css("display", "inline");
            $('#text_productIDcheck' + foundproductID).css("display", "none");
            $('.inline-compare-text').html('Add to compare');
        }


    } else {
        createCookie('compare', 'c26ba48acbfa28c59f170514c27aea07|' + sku_id, 7);

        $('#button_productIDcheck' + foundproductID).css("display", "inline");
        $('#text_productIDcheck' + foundproductID).css("display", "none");
        $('.inline-compare-text').html('Add to compare');
    }

    // send ping to analytics
    var et = "Compare Item Removed";
    if (thisForm.elements[0].checked) {
        et = "Compare Item Added";
    }
    ga('mc.send', 'event', et, sku_id, producttitle);

    if (searchResult) {
        set_compare_section(sku_id, producttitle);
    }


}



// END ON READY


var serviceplantotal = 0;
var addonstotal = 0;
var servicestotal = 0;


function checkCharlotte() {


    if (readCookie("charlotteDistance") == null || readCookie("charlotteDistance") == "" || readCookie("charlotteDistance") == "0") {


        $.ajax({
            url: "/assets/ajax/StoreDistanceCheck.aspx",
            type: "GET",
            data: {
                slat: "35.174430", slong: "-80.877650"
            }
        }).done(function (msg) {



            createCookie("charlotteDistance", msg);

            if (!isNaN(msg)) {

                if (Number(msg) <= 175) {
                    $("body").addClass("isCharlotte");
                }
            }



        });

    }

    if (readCookie("charlotteDistance") != null && !isNaN(readCookie("charlotteDistance"))) {

        if (Number(readCookie("charlotteDistance")) <= 175) {
            $("body").addClass("isCharlotte");
            $(".needsLogin").hide();
        }

    }

}

function checkMiami() {


    if (readCookie("miamiDistance") == null || readCookie("miamiDistance") == "" || readCookie("miamiDistance") == "0") {



        $.ajax({
            url: "/assets/ajax/StoreDistanceCheck.aspx",
            type: "GET",
            data: {
                slat: "25.773740", slong: "-80.322460"
            }
        }).done(function (msg) {



            createCookie("miamiDistance", msg);

            if (!isNaN(msg)) {

                if (Number(msg) <= 200) {
                    $("body").addClass("isMiami");
                }
            }



        });

    }

    if (readCookie("miamiDistance") != null && !isNaN(readCookie("miamiDistance"))) {

        if (Number(readCookie("miamiDistance")) <= 200) {
            $("body").addClass("isMiami");
            $(".needsLogin").hide();
        }

    }

}

function checkSantaClara() {


    if (readCookie("santaclaraDistance") == null || readCookie("santaclaraDistance") == "" || readCookie("santaclaraDistance") == "0") {



        $.ajax({
            url: "/assets/ajax/StoreDistanceCheck.aspx",
            type: "GET",
            data: {
                slat: "37.354107", slong: "-121.955238"
            }
        }).done(function (msg) {



            createCookie("santaclaraDistance", msg);

            if (!isNaN(msg)) {

                if (Number(msg) <= 200) {
                    $("body").addClass("isSantaClara");
                }
            }



        });

    }

    if (readCookie("santaclaraDistance") != null && !isNaN(readCookie("santaclaraDistance"))) {

        if (Number(readCookie("santaclaraDistance")) <= 200) {
            $("body").addClass("isSantaClara");
            $(".needsLogin").hide();
        }

    }

}


function SelectServicePlan(serviceplan, price) {
    var currentServicePlanValue = parseFloat($('input[name="servicePlanValue"]').val());
    var currentServicePaanId = parseFloat($('input[name="servicePlanId"]').val());


    $("#summaryserviceplans .summaryserviceplans").hide();
    $("#summaryserviceplans #plan" + serviceplan).show();
    serviceplantotal = price;
    if (serviceplantotal > 0) {

        $("#interstitialSummary #serviceplanprice").html('<a href="#" onclick="SummaryToggle(\'summaryserviceplans\'); return false;">+ Protection Plan:</a> $' + price);
        $("#interstitialSummary #serviceplanprice").show();
    }
    else {
        $("#interstitialSummary #serviceplanprice").hide();
    }


    // now lets set the prices with adjustments
    $('.spHolder').each(function (index) {

        var thisId = $(this).val();
        var thisPrice = 0;
        if (thisId > 0) {
            thisPrice = $('input[name="spPrice_' + thisId + '"]').val();

            var displayPrice = "";
            var correctedSPPrice = parseFloat((parseFloat(thisPrice) - parseFloat(price))).toFixed(2);

            if (correctedSPPrice >= 0) {
                displayPrice = "(+$" + correctedSPPrice + ")";
            }
            else {
                displayPrice = "(-$" + Math.abs(correctedSPPrice).toFixed(2) + ")";

            }
            // lets record the price
            $('#servicePlanCalculatedPrice_' + thisId).html(displayPrice);

            if (price > 0) {
                $('#servicePlanCalculatedPrice_' + thisId).show();
                $('#servicePlanPrice_' + thisId).hide();

            }
            else {

                $('#servicePlanCalculatedPrice_' + thisId).hide();
                $('#servicePlanPrice_' + thisId).show();

            }

            if (thisId == serviceplan) {
                $('#servicePlanCalculatedPrice_' + thisId).hide();
                $('#servicePlanPrice_' + thisId).hide();
            }
        }

    });




    $('input[name="servicePlanValue"]').val(price);
    $('input[name="servicePlanId"]').val(serviceplan);


    setsummarytotal();

}

var newwindow;
function popBargainBinWindow(url) {
    newwindow = window.open(url, 'name', 'height=300,width=300,left=100,top=100,resizable=yes,scrollbars=yes');
    if (window.focus) {
        newwindow.focus();
    }
}

function printFancybox() {
    $("#fancybox-frame").get(0).contentWindow.print();
}




function SelectProduct(productid, price, ischecked, isservice) {

    isservice = (typeof isservice !== 'undefined') ? isservice : false;




    if (ischecked) {

        if (!isservice) {
            addonstotal += price;
            addonstotal = (Math.round(addonstotal * 100)) / 100;
            $("#interstitialSummary #addonsprice").html('<a href="#" onclick="SummaryToggle(\'summarypricing\'); return false;">+ Add Ons:</a> $' + addonstotal);
            $("#interstitialSummary #addonsprice").show();
            $("#summarypricing #product" + productid).first().show();
        }
        else {
            servicestotal += price;
            servicestotal = (Math.round(servicestotal * 100)) / 100;
            $("#interstitialSummary #serviceprice").html('<a href="#" onclick="SummaryToggle(\'serviceprice\'); return false;">+ Services:</a> $' + servicestotal);
            $("#interstitialSummary #serviceprice").show();
            $("#servicepricing #product" + productid).first().show();

        }


    }

    else {



        if (!isservice) {
            $("#summarypricing #product" + productid).first().hide();
            addonstotal = addonstotal - price;
            addonstotal = (Math.round(addonstotal * 100)) / 100;

            if (addonstotal > 0) {
                $("#interstitialSummary #addonsprice").html('<a href="#" onclick="SummaryToggle(\'summarypricing\'); return false;">+ Add Ons:</a> $' + addonstotal);
                $("#interstitialSummary #addonsprice").show();
            }
            else {
                $("#interstitialSummary #addonsprice").hide();
            }
        }
        else {
            $("#servicepricing #product" + productid).first().hide();
            servicestotal = servicestotal - price;
            servicestotal = (Math.round(servicestotal * 100)) / 100;

            if (servicestotal > 0) {
                $("#interstitialSummary #serviceprice").html('<a href="#" onclick="SummaryToggle(\'serviceprice\'); return false;">+ Services:</a> $' + servicestotal);
                $("#interstitialSummary #serviceprice").show();
            }
            else {
                $("#interstitialSummary #serviceprice").hide();
            }
        }
    }

    // addonstotal = addonstotal.toFixed(2);
    // servicestotal = (Math.round(servicestotal * 100)) / 100;

    setsummarytotal();
}



function SelectProductRadio(productid, price, ischecked, radioCount, isservice) {


    var isAsus = false;
    if ($('#interstitialSummary .price strong').length)         // use this if you are using id to check
    {
        thisprice = $("#interstitialSummary .price strong").html();
    }
    else {
        isAsus = true;
        thisprice = "$" + $("#summaryprice").data("buildprice");
    }

    isservice = (typeof isservice !== 'undefined') ? isservice : false;
    // first we need to reduce the total
    var currentValue = 0;
    var currentProductID = 0;
    if (parseFloat($("#radioGroup_" + radioCount + "_CP").val()) > 0) {
        currentValue = parseFloat($("#radioGroup_" + radioCount + "_CP").val());
    }

    if (parseFloat($("#radioGroup_" + radioCount + "_CPID").val()) > 0) {
        currentProductID = parseFloat($("#radioGroup_" + radioCount + "_CPID").val());
    }

    if (isAsus) {


        if ($("#checkID_" + productid).hasClass("isselectedItem")) {

            $("#checkID_" + productid).removeClass("isselectedItem");
            $("#checkID_" + productid).prop('checked', false);
            $("#radioGroup_" + radioCount + "_CP").val(0);
            $("#radioGroup_" + radioCount + "_CPID").val(0);


        }
        else {
            // need to turn off all of the others in this group.


            $("input[type='radio'][name='productIDs_R" + radioCount + "']").removeClass("isselectedItem");
            $("#checkID_" + productid).addClass("isselectedItem");
            $("#radioGroup_" + radioCount + "_CP").val(price);
            $("#radioGroup_" + radioCount + "_CPID").val(productid);
        }

    }


    if (!isservice) {
        // reduce the tot
        addonstotal = addonstotal - currentValue;
    }
    else {
        // reduce the total
        servicestotal = servicestotal - currentValue;
    }

    if (!isservice) {

        $("#summarypricing #product" + currentProductID).first().hide();

    }
    else {
        $("#servicepricing #product" + currentProductID).first().hide();

    }



    if (!isservice) {
        addonstotal = addonstotal + price;
        addonstotal = addonstotal.toFixed(2);


        $("#interstitialSummary #addonsprice").html('<a href="#" onclick="SummaryToggle(\'summarypricing\'); return false;">+ Add Ons:</a> $' + addonstotal);
        $("#interstitialSummary #addonsprice").show();


    }
    else {
        servicestotal = servicestotal + price;
        servicestotal = servicestotal.toFixed(2);


        $("#interstitialSummary #serviceprice").html('<a href="#" onclick="SummaryToggle(\'serviceprice\'); return false;">+ Services:</a> $' + servicestotal);
        $("#interstitialSummary #serviceprice").show();
    }

    if (!isservice) {
        $("#summarypricing #product" + productid).first().show();
    }
    else {
        $("#servicepricing #product" + productid).first().show();
    }


    $("#radioGroup_" + radioCount + "_CPID").val(productid);
    $("#radioGroup_" + radioCount + "_CP").val(price);



    // now lets set the prices with adjustments
    $('input[name="productIDs_R' + radioCount + '"]').each(function (index) {

        var thisId = $(this).val();
        var thisPrice = 0;
        if (thisId > 0) {
            thisPrice = $('input[name="productPrice_' + thisId + '"]').val();

            var displayPrice = "";
            var correctedPrice = (thisPrice - price).toFixed(2);

            if (correctedPrice >= 0) {
                displayPrice = "(+$" + correctedPrice + ")";
            }
            else {
                displayPrice = "(-$" + Math.abs(correctedPrice).toFixed(2) + ")";

            }
            // lets record the price
            $('#CalculatedPrice_' + thisId).html(displayPrice);

            if (price > 0) {
                $('#CalculatedPrice_' + thisId).show();
                $('#Price_' + thisId).hide();

            }
            else {


                $('#CalculatedPrice_' + thisId).hide();
                $('#Price_' + thisId).show();


            }

            if (thisId == productid) {
                $('#CalculatedPrice_' + thisId).hide();
                $('#Price_' + thisId).hide();
            }
        }

    });

    if (!isAsus) {
        if (price > 0) {
            // we need to turn on the calculated prices and removal checkbox
            $('#noItem_R' + radioCount).show();

        } else {
            $('#noItem_R' + radioCount).hide();
        }
    }
    setsummarytotal();
}


function SummaryToggle(myToggle) {

    if (myToggle == "summarypricing") {
        $('#summaryserviceplans').hide();
        $('#servicepricing').hide();
        if ($('#summarypricing').is(':visible')) {
            $('#summarypricing').hide();
        } else {
            $('#summarypricing').show();
        }

    }

    if (myToggle == "serviceprice") {
        $('#summaryserviceplans').hide();
        $('#summarypricing').hide();

        if ($('#servicepricing').is(':visible')) {
            $('#servicepricing').hide();
        } else {
            $('#servicepricing').show();
        }

    }


    if (myToggle == "summaryserviceplans") {
        $('#summarypricing').hide();
        $('#servicepricing').hide();

        if ($('#summaryserviceplans').is(':visible')) {
            $('#summaryserviceplans').hide();
        } else {
            $('#summaryserviceplans').show();
        }

    }

    $('.closeItem').show();



}

function SummaryClose() {


    $('#summaryserviceplans').hide();
    $('#summarypricing').hide();
    $('#servicepricing').hide();



}


function setsummarytotal() {




    try {

        var thisprice = "";
        var isAsus = false;
        if ($('#interstitialSummary .price strong').length)         // use this if you are using id to check
        {
            thisprice = $("#interstitialSummary .price strong").html();
        }
        else {
            isAsus = true;
            thisprice = "$" + $("#summaryprice").data("buildprice");
        }



        if (thisprice.indexOf('$') >= 0) {
            itemprice = parseFloat(thisprice.replace('$', '').replace(',', '')).toFixed(2);
        }

        var totalprice = 0;
        var totalItems = 0;
        servicestotal = 0;
        addonstotal = 0;
        $(".productIDsRadio").each(function () {
            if ($(this).is(':checked')) {
                if (isAsus) {
                    $(this).parent().parent().parent().addClass("isSelected");

                }
                totalItems += 1;
                if ($(this).data("service") == "yes") {
                    servicestotal = servicestotal + parseFloat($('input[name="productPrice_' + $(this).val() + '"]').first().val());

                }
                else {
                    addonstotal = addonstotal + parseFloat($('input[name="productPrice_' + $(this).val() + '"]').first().val());
                }

            }
            else {
                if (isAsus) {
                    $(this).parent().parent().parent().removeClass("isSelected");
                }
            }

        });



        $("input[name=productIDs]:checked").each(function () {
            if (isAsus) {
                $(this).parent().parent().parent().addClass("isSelected");

            }
            totalItems += 1;
            if ($(this).data("service") == "yes") {

                servicestotal = servicestotal + parseFloat($('#ProductPrice_' + $(this).val()).first().val().replace('$', '').replace(',', ''));
            }
            else {

                addonstotal = addonstotal + parseFloat($('#ProductPrice_' + $(this).val()).first().val().replace('$', '').replace(',', ''));

            }

        });

        if (isAsus) {
            $("input[name=productIDs]:not(:checked)").each(function () {
                $(this).parent().parent().parent().removeClass("isSelected");
            });
        }

        addonstotal = addonstotal.toFixed(2);
        servicestotal = servicestotal.toFixed(2);


        $("#totalSelected").html(totalItems);

        $("#interstitialSummary #addonsprice").html('<a href="#" onclick="SummaryToggle(\'summarypricing\'); return false;">+ Add Ons:</a> $' + addonstotal);
        if (addonstotal > 0) {
            $("#interstitialSummary #addonsprice").show();
        }
        else {
            $("#interstitialSummary #addonsprice").hide();
        }

        $("#interstitialSummary #serviceprice").html('<a href="#" onclick="SummaryToggle(\'serviceprice\'); return false;">+ Services:</a> $' + servicestotal);
        if (servicestotal > 0) {
            $("#interstitialSummary #serviceprice").show();
        }
        else {
            $("#interstitialSummary #serviceprice").hide();
        }

        totalprice = parseFloat(parseFloat(itemprice) + parseFloat(addonstotal) + parseFloat(servicestotal) + parseFloat(serviceplantotal)).toFixed(2);
        //alert(itemprice + "+" + addonstotal + "+" + serviceplantotal + " = " + totalprice);

        if (totalprice >= parseFloat(itemprice) && parseFloat(itemprice) > 0) {
            if (!isAsus) {
                $("#summaryprice").html('Total With Add Ons: $' + totalprice);
                $("#summaryprice").show();
            }
            else {
                $("#summaryprice").html('$' + totalprice);
                $("#summaryprice").show();
            }

        } else {
            if (!isAsus) {
                $("#summaryprice").hide();
            }
        }

        if (parseFloat(addonstotal) <= 0) {
            $("#addonsprice").hide();
        }

    }
    catch (e) {



    }
}
function Right(str, n) {
    if (n <= 0)
        return "";
    else if (n > String(str).length)
        return str;
    else {
        var iLen = String(str).length;
        return String(str).substring(iLen, iLen - n);
    }
}




function addSliderEvent(thisSlider) {


    var position;
    var STEP_SIZE_X;
    var $root;
    var PRODUCT_COUNTS;
    function toDecimal(x) {
        return (x).toFixed(2) * 1;
    }

    function getViewSizeByPercent() {

        //    alert(thisSlider.width() + " " + thisSlider.find('.mm14-products-viewed').width() * 100 + " " + STEP_SIZE_X);
        //    alert(toDecimal(thisSlider.width() / thisSlider.find('.mm14-products-viewed').width() * 100 / STEP_SIZE_X));
        return toDecimal(thisSlider.width() / thisSlider.find('.mm14-products-viewed').width() * 100 / STEP_SIZE_X);
    }



    function move(step) {
        var viewingProducts = getViewSizeByPercent();

        //var viewingProducts = 4;
        var x;
        position += viewingProducts * step;
        if (position >= PRODUCT_COUNTS) {
            position = PRODUCT_COUNTS;
        } else if (position < 0) {
            position = 0;
        }

        // Hide / Show - swipe elements
        thisSlider.parent().find('.mm14-carousel-next').show();
        thisSlider.parent().find('.mm14-carousel-prev').show();



        if (position + viewingProducts >= PRODUCT_COUNTS) {
            thisSlider.parent().find('.mm14-carousel-next').addClass('disable');
        } else {
            thisSlider.parent().find('.mm14-carousel-next').removeClass('disable');
        }

        if (position - viewingProducts < 0) {
            thisSlider.parent().find('.mm14-carousel-prev').addClass('disable');
        } else {
            thisSlider.parent().find('.mm14-carousel-prev').removeClass('disable');
        }
        if (viewingProducts >= PRODUCT_COUNTS) {
            thisSlider.parent().find('.mm14-carousel-prev').hide();
            thisSlider.parent().find('.mm14-carousel-next').hide();
        }

        if (step === 1) {
            if (position + viewingProducts > PRODUCT_COUNTS) {
                position = PRODUCT_COUNTS - viewingProducts;
            }
        } else if (step === -1) {
            if (position - viewingProducts < 0) {
                position = 0;
            }
        }


        x = toDecimal(STEP_SIZE_X * position);


        thisSlider.find('.mm14-products-viewed').css('transform', 'translateX(' + -x + '%)');
    }

    function init() {


        position = 0;

        var itemsPerPage = Math.floor(thisSlider.width() / thisSlider.find('.recent-item').first().width());


        STEP_SIZE_X = 100 / itemsPerPage;



        $root = thisSlider.find('.mm14-products-viewed');
        PRODUCT_COUNTS = thisSlider.find('.recent-item').length;

        //
        $root.css('transform', 'translateX(0%)');
        thisSlider.parent().find('.mm14-carousel-next').show();
        thisSlider.parent().find('.mm14-carousel-prev').show();
        move(0);
    }

    init();

    thisSlider.parent().find('.mm14-carousel-prev').click(function () {
        move(-1);
    });

    thisSlider.parent().find('.mm14-carousel-next').click(function () {
        move(1);
    });

    $(window).resize(function () {
        init();
    });
}


function categoryRender() {
    if ($('.recentlyViewed').length === 0) {
        $('.DesktopFramework #ads')
            .prepend(getTemplate('category', {
                products: campaign.scope.productsViewed,
            }));
    }
}

setTimeout(function () {
    if ($("#home").length != 0) {
        $('#pnlMainAds h2#tcb002').prependTo('#hotdeals');

        //$('.recentlyViewed .recent-item .recent-item-link').each(function () {
        //    var linkTextHome = $(this).html();
        //    var linkLengthHome = $(this).html().length;

        //    if (linkLengthHome > 40) {
        //        $(this).html(linkTextHome.substring(0, 40) + '...');
        //    }
        //});




        $('.mm14-products-viewed-wrapper').each(function () {


            addSliderEvent($(this));
        });
    }
    else if ($("#product").length != 0) {
        $('.recently-viewed-title').html('You recently viewed');


        //$('.recent-item .recent-item-link').each(function () {
        //    var linkText = $(this).html();
        //    var linkLength = $(this).html().length;
        //    if (linkLength > 32) {
        //        $(this).html(linkText.substring(0, 32) + '...');
        //    }
        //});

        //  $('.DesktopFramework #recentlyViewed').appendTo('#product-details-control .summary');
    }

}, 1000);


function setGridView() {
    // list and grid view

    $(".grView").click(function () {
        $(".grView").addClass("on");
        $(".lsView").removeClass("on");
        $("#productGrid").removeClass("col1");
        $("#productGrid").addClass("col3");



        eraseCookie('viewtype');
        createCookie('viewtype', 'grid', 1);


        // need to write the cookie

    });


    $(".lsView").click(function () {
        $(".lsView").addClass("on");
        $(".grView").removeClass("on");
        $("#productGrid").removeClass("col3");
        $("#productGrid").addClass("col1");

        eraseCookie('viewtype');
        createCookie('viewtype', 'list', 1);




        // need to write the cookie

    });

    try {






        var viewtype = readCookie('viewtype');



        if (viewtype == null) {

            var im = readCookie('isMobile');

            if ((im != null && im == "true") || ($("body").hasClass("MobileFramework"))) {
                viewtype = "list";
                createCookie('viewtype', 'list', 1);
            }
            else {
                viewtype = "grid";
                createCookie('viewtype', 'grid', 1);
            }

        }




        if (viewtype == 'list') {

            $("#productGrid").removeClass("col3");
            $("#productGrid").addClass("col1");
            $(".lsView").addClass("on");
            $(".grView").removeClass("on");

        } else {
            $("#productGrid").removeClass("col1");
            $("#productGrid").addClass("col3");
            $(".lsView").removeClass("on");
            $(".grView").addClass("on");
        }

        $("#productGrid.eset").removeClass("col1");
        $("#productGrid.eset").addClass("col3");


    } catch (e) {



    }
}

function productClick(productObj, evt) {

    // console.log(productObj);

    if ($(productObj).data('id') != null && !productclicked) {
        productclicked = true;

        var thislist = "Search Results";
        if ($(productObj).data('list') != null) {
            thislist = $(productObj).data('list');
        }

        if (usingGA4) {
            if (typeof (gtag) != 'undefined') {

                gtag("event", "view_item", {
                    currency: "USD",
                    value: $(productObj).data('price'),
                    items: [
                        {
                            item_id: $(productObj).data('id'),
                            item_name: $(productObj).data('name'),


                            index: $(productObj).data('position'),
                            item_brand: $(productObj).data('brand'),
                            item_category: $(productObj).data('category'),

                            item_list_id: thislist,
                            item_list_name: thislist,

                            price: $(productObj).data('price'),
                            currency: "USD",
                            quantity: 1
                        }
                    ]

                });
            }
            try {




                if ($(productObj).attr('href') != null) {
                    document.location = $(productObj).attr('href');
                } else if ($(productObj).data('href') != null) {
                    document.location = $(productObj).data('href');
                }

            } catch (e) { }
        }
        if (usingGA3) {
            if (typeof (ga) != 'undefined') {
                ga('mc.ec:addProduct', {                              // Provide product details in a productFieldObject.
                    'id': $(productObj).data('id'),                   // Product ID (string).
                    'name': $(productObj).data('name'),               // Product name (string).
                    'category': $(productObj).data('category'),       // Product category (string).
                    'brand': $(productObj).data('brand'),             // Product brand (string).
                    'price': $(productObj).data('price'),
                    'position': $(productObj).data('position'),
                    'list': thislist

                });

                ga('mc.ec:setAction', 'click', { 'list': thislist });

                ga('mc.send', 'event', 'eCommerce', 'click', thislist, {
                    'hitCallback': function () {
                        try {




                            if ($(productObj).attr('href') != null) {
                                document.location = $(productObj).attr('href');
                            } else if ($(productObj).data('href') != null) {
                                document.location = $(productObj).data('href');
                            }

                        } catch (e) { }
                    }
                });
            }
        }


        //        dataLayer.push({
        //            'event': 'productClick',
        //            'ecommerce': {
        //                'click': {
        //                    'actionField': { 'list': 'Search Results' },      // Optional list property.
        //                    'products': [{
        //                        'name': $(productObj).data('name'),                      // Name or ID is required.
        //                        'id': $(productObj).data('id'),
        //                        'price': $(productObj).data('price'),
        //                        'brand': $(productObj).data('brand'),
        //                        'category': $(productObj).data('category')
        //                    }]
        //                }
        //            },
        //            'eventCallback': function () {
        //                if ($(productObj).attr('href') != null) {
        //                    document.location = $(productObj).attr('href');
        //                } else if ($(productObj).data('href') != null) {
        //                    document.location = $(productObj).data('href');
        //                }
        //            }
        //        });
    }
    


}

function listView(list_id) {


    var eventlist = [];

    //$('.productViewItem').each(function () {
    //    eventlist.push([$(this).data('list'), $(this).data('id'), $(this).data('name'), $(this).data('position'), $(this).data('brand'), $(this).data('category'), $(this).data('price')]);
    //});

    //console.log(eventlist);
    // lets do the product list 

    if (usingGA4) {
        if (typeof (gtag) != 'undefined' && $('.productViewItem').length) {

            var list = "[";
            var pv = $('.productViewItem');
            var cnt = 0;
             listname = list_id;
            var ispersonalized = "";


            $('.productViewItem').each(function () {

                if ($(this).data('list') == list_id)
                {





                    if (cnt > 0) { list += ','; }

                    if (typeof $(this).data('name') !== 'undefined' && typeof $(this).data('brand') !== 'undefined' && typeof $(this).data('category') !== 'undefined') {
                        list += "{";

                        list += 'item_id: "' + $(this).data('id') + '",';
                        list += 'item_name: "' + (String($(this).data('name') || '')).replace('"', '\\\"') + '",';

                        list += 'index: ' + $(this).data('position') + ',';
                        list += ' item_brand: "' + (String($(this).data('brand') || '')).replace('"', '\\\"') + '",';
                        list += 'item_category: "' + (String($(this).data('category') || '')).replace('"', '\\\"') + '",';
                        list += 'item_coord: "' + (String($(this).data('coord') || '')).replace('"', '\\\"') + '",';
                        list += 'item_core: "' + (String($(this).data('core') || '')).replace('"', '\\\"') + '",';
                        list += 'item_list_id: "' + $(this).data('list') + '",';
                        list += 'item_list_name: "' + $(this).data('list') + '",';

                        list += 'price:' + $(this).data('price') + ',';
                        list += 'currency: "USD",';
                        list += ' quantity: 1';





                        list += '}';


                        cnt += 1;
                    }
                }
            });
              
            list += ']';

            if (list != '[]') {
                gtag("event", "view_item_list", {
                    'item_list_id': (String(listname || '')).replace('"', '\\\"'),
                    'item_list_name': (String(listname || '')).replace('"', '\\\"'),
                    items: eval(list)

                });
            }


          


        }
    }

    if (usingGA3) {


        if (typeof ga != "undefined") {

             listName = "";
            $('.productViewItem').each(function () {

                if (listName != $(this).data('list') && listName != "") {

                    ga('mc.ec:setAction', 'detail');
                    ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });
                }

                ga('mc.ec:addImpression', {                     // Provide product details in a productFieldObject.
                    'id': $(this).data('id'),                   // Product ID (string).
                    'name': $(this).data('name'),               // Product name (string).
                    'category': $(this).data('category'),       // Product category (string).
                    'brand': $(this).data('brand'),             // Product brand (string).
                    'price': $(this).data('price'),
                    'position': $(this).data('position'),
                    'list': $(this).data('list')

                });

                listName = $(this).data('list');



            });
            if (listName != "") {

                ga('mc.ec:setAction', 'detail');
                ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });
            }

        }
    }

    //lets do the promo list


    if (usingGA4) {

        if (typeof (gtag) != 'undefined' && $('.promoViewItem').length) {

             list = "[";
             pv = $('.promoViewItem');
             cnt = 0;
             listname = "";


            $('.promoViewItem').each(function () {

                try {

               

                if (listname != $(this).data('list') && listname != "" && (list_id == "" || list_id == listname)) {

                  //  console.log(list);

                    // we need to push the list
                    list += ']';
                    gtag("event", "view_promotion", {
                        'promotion_name': (String(listname || '')).replace('"', '\\\"'),
                        'promotion_id': (String(listname || '')).replace('"', '\\\"'),
                        items: eval(list)

                    });
                    cnt = 0;
                    list = '[';
                }
                listname = $(this).data('list');

                if (cnt > 0) { list += ','; }

                    if ($(this).data('name') && $(this).data('brand') && $(this).data('category') ) {
                    list += "{";

                    list += 'item_id: "' + $(this).data('id') + '",';
                        list += 'item_name: "' + (String($(this).data('name') || '')).replace('"', '\\\"') + '",';

                    list += 'index: ' + $(this).data('position') + ',';
                        list += ' item_brand: "' + (String($(this).data('brand') || '')).replace('"', '\\\"') + '",';
                        list += 'item_category: "' + (String($(this).data('category') || '')).replace('"', '\\\"') + '",';
                        list += 'item_coord: "' + (String($(this).data('coord') || '')).replace('"', '\\\"') + '",';
                        list += 'item_core: "' + (String($(this).data('core') || '')).replace('"', '\\\"') + '",';


                    list += 'price:' + $(this).data('price') + ',';
                    list += 'currency: "USD",';
                    list += ' quantity: 1';





                    list += '}';

                    cnt += 1;
                }
                }
                catch (e) { }
            });

            list += ']';

            if (list != '[]' && (list_id == "" || list_id == listname)) {

                try {
                gtag("event", "view_promotion", {
                    'promotion_name': (String(listname || '')).replace('"', '\\\"'),
                    'promotion_id': (String(listname || '')).replace('"', '\\\"'),
                    items: eval(list)

                });
                }
                catch (e) { }
            }





        }
    }

    if (usingGA3) {


        if (typeof ga != "undefined") {

             listName = "";
            $('.promoViewItem').each(function () {

                if (listName != $(this).data('list') && listName != "") {

                    ga('mc.ec:setAction', 'detail');
                    ga('mc.send', 'event', 'PromoView', listName, { nonInteraction: true });
                }

                if ($(this).data('name') && $(this).data('brand') && $(this).data('category')) {
                    ga('mc.ec:addImpression', {                     // Provide product details in a productFieldObject.
                        'id': $(this).data('id'),                   // Product ID (string).
                        'name': $(this).data('name'),               // Product name (string).
                        'category': $(this).data('category'),       // Product category (string).
                        'brand': $(this).data('brand'),             // Product brand (string).
                        'price': $(this).data('price'),
                        'position': $(this).data('position'),
                        'list': $(this).data('list')

                    });
                }
                listName = $(this).data('list');



            });
            if (listName != "") {

                ga('mc.ec:setAction', 'detail');
                ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });
            }

        }
    }

}
// this function will send all product lists on page that are in view.
function sendGA4ViewList() {


    if (usingGA4) {
        if (typeof (gtag) != 'undefined' && $('.productViewItem').length) {
            
            var list = "[";
            var pv = $('.productViewItem');
            var cnt = 0;
             listname = "";
            var ispersonalized = "";

            var visiblelists = [];

            $('.productViewItem').each(function () {
                
                if (isInViewport(this) && visiblelists.indexOf($(this).data('list')) < 0 && processedlists.indexOf($(this).data('list')) < 0)
                {
                    visiblelists.push($(this).data('list'));

          
                  
                }
            });



            $('.productViewItem').each(function () {

        
          
                if (visiblelists.indexOf($(this).data('list')) >= 0)
                {
                    processedlists.push($(this).data('list'));

                    if (listname != $(this).data('list') && listname != "") {

                        $(this).data('processed', 'true');
                        //  console.log(list);
                        // we need to push the list
                        list += ']';

                       

                        gtag("event", "view_item_list", {
                            'item_list_id': listname,
                            'item_list_name': listname,
                            'is_personalized': $(this).data('personalized'),
                            items: eval(list)

                        });
                        cnt = 0;
                        list = '[';
                    }
                    listname = $(this).data('list');

                    if (cnt > 0) { list += ','; }

                    if (typeof $(this).data('name') !== 'undefined' && typeof $(this).data('brand') !== 'undefined' && typeof $(this).data('category') !== 'undefined') {
                        list += "{";

                        list += 'item_id: "' + $(this).data('id') + '",';
                        list += 'item_name: "' + (String($(this).data('name') || '')).replace('"', '\\\"') + '",';

                        list += 'index: ' + $(this).data('position') + ',';
                        list += ' item_brand: "' + (String($(this).data('brand') || '')).replace('"', '\\\"') + '",';
                        list += 'item_category: "' + (String($(this).data('category') || '')).replace('"', '\\\"') + '",';
                        list += 'item_coord: "' + (String($(this).data('coord') || '')).replace('"', '\\\"') + '",';
                        list += 'item_core: "' + (String($(this).data('core') || '')).replace('"', '\\\"') + '",';
                        list += 'item_list_id: "' + $(this).data('list') + '",';
                        list += 'item_list_name: "' + $(this).data('list') + '",';

                        list += 'price:' + $(this).data('price') + ',';
                        list += 'currency: "USD",';
                        list += ' quantity: 1';





                        list += '}';


                        cnt += 1;
                    }
                }
            });

            list += ']';
      
            if (list != '[]') {

               
         
               
                gtag("event", "view_item_list", {
                    'item_list_id': (String(listname || '')).replace('"', '\\\"'),
                    'item_list_name': (String(listname || '')).replace('"', '\\\"'),
                    items: eval(list)

                });

            }





        }
    }

    if (usingBloomreach) {
        if ($('.productViewItem').length) {

            var list = [];
            var pv = $('.productViewItem');
            var cnt = 0;
            listname = "";
            var recommendationID = "";
            var ispersonalized = "";
            var source = "Microcenter"
            var visiblelists = [];



            $('.productViewItem').each(function () {

                if (isInViewport(this) && visiblelists.indexOf($(this).data('list')) < 0 && processedbloomreachlists.indexOf($(this).data('list')) < 0) {
                    visiblelists.push($(this).data('list'));



                }
            });


            $('.productViewItem').each(function () {



                if (visiblelists.indexOf($(this).data('list')) >= 0) {
                    processedbloomreachlists.push($(this).data('list'));

                    if (listname != $(this).data('list') && listname != "") {

                        $(this).data('processed', 'true');
                        //  console.log(list);
                        // we need to push the list
                        //list += ']';


                        exponea.track("recommendation", {
                            action: "show",
                            source: source,
                            item_ids: list,
                            list_name: listname,
                            recommendation_id: recommendationID
                        });

                        cnt = 0;
                        list = [];
                    }
                    listname = $(this).data('list');
                    recommendationID = (String($(this).data('recommendationid') || ''));
                    if (recommendationID != '') {
                        source = "Bloomreach";
                    }
                    else {
                        source = "Microcenter";
                    }
                  

                    if (typeof $(this).data('name') !== 'undefined' && typeof $(this).data('brand') !== 'undefined' && typeof $(this).data('category') !== 'undefined') {
                        list.push($(this).data('id'));



                        cnt += 1;
                    }
                }
            });

            // list += ']';

            if (list.length > 0) {




                exponea.track("recommendation", {
                    action: "show",
                    source: source,
                    item_ids: list,
                    list_name: listname,
                    recommendation_id: recommendationID
                });

            }





        }
    }

}


// this function will send all promo lists on page that are in view
function sendGA4PromoViewList() {

    if (usingGA4) {

        if (typeof (gtag) != 'undefined' && $('.promoViewItem').length) {

            var list = "[";
            var pv = $('.promoViewItem');
            var cnt = 0;
             listname = "";

            var visiblepromos = [];
            $('.promoViewItem').each(function () {

                if (isInViewport(this) && visiblepromos.indexOf($(this).data('list')) < 0 && processedPromolists.indexOf($(this).data('list')) < 0) {
          
                    visiblepromos.push($(this).data('list'));
                }
            });

            $('.promoViewItem').each(function () {
                if (visiblepromos.indexOf($(this).data('list')) >= 0) {
                    processedPromolists.push($(this).data('list'));
                if (listname != $(this).data('list') && listname != "") {

                    //  console.log(list);

                    // we need to push the list
                    list += ']';
                    gtag("event", "view_promotion", {
                        'promotion_name': (String(listname || '')).replace('"', '\\\"'),
                        'promotion_id': (String(listname || '')).replace('"', '\\\"'),
                        items: eval(list)

                    });
                    cnt = 0;
                    list = '[';
                }
                listname = $(this).data('list');

                    if (cnt > 0) { list += ','; }

                    if ($(this).data('name') && $(this).data('brand') && $(this).data('category')) {
                        list += "{";

                        if ($(this).data('id')) {
                            list += 'item_id: "' + $(this).data('id') + '",';
                        }
                        if ($(this).data('name')) {
                            list += 'item_name: "' + (String($(this).data('name') || '')).replace('"', '\\\"') + '",';
                        }
                        if ($(this).data('position')) {
                            list += 'index: ' + $(this).data('position') + ',';
                        }
                        if ($(this).data('brand')) {
                            list += ' item_brand: "' + (String($(this).data('brand') || '')).replace('"', '\\\"') + '",';
                        }
                        if ($(this).data('category')) {
                            list += 'item_category: "' + (String($(this).data('category') || '')).replace('"', '\\\"') + '",';
                        }

                        list += 'item_coord: "' + (String($(this).data('coord') || '')).replace('"', '\\\"') + '",';
                        list += 'item_core: "' + (String($(this).data('core') || '')).replace('"', '\\\"') + '",';

                        if ($(this).data('price')) {
                            list += 'price:' + ('' + (String($(this).data('price')) || '')).replace('$', '') + ',';
                            list += 'currency: "USD",';
                        }
                        list += ' quantity: 1';





                        list += '}';

                        cnt += 1;
                    }
                }

            });

            list += ']';


            try {
                if (list != '[]') {
                    gtag("event", "view_promotion", {
                        'promotion_name': (String(listname || '')).replace('"', '\\\"'),
                        'promotion_id': (String(listname || '')).replace('"', '\\\"'),
                        items: eval(list)

                    });
                }
            }
            catch (ex) { }




        }
    }
}

function productView() {

   
    var eventlist = [];

    //$('.productViewItem').each(function () {
    //    eventlist.push([$(this).data('list'), $(this).data('id'), $(this).data('name'), $(this).data('position'), $(this).data('brand'), $(this).data('category'), $(this).data('price')]);
    //});

    //console.log(eventlist);
    // lets do the product list 


    sendGA4ViewList();


    sendGA4PromoViewList();


    $(window).on("resize scroll", function (e) {
        sendGA4ViewList();
        sendGA4PromoViewList();
    });
    

    if (usingGA3) {


        if (typeof ga != "undefined") {

             listName = "";
            $('.productViewItem').each(function () {

                if (listName != $(this).data('list') && listName != "") {

                    ga('mc.ec:setAction', 'detail');
                    ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });
                }

                ga('mc.ec:addImpression', {                     // Provide product details in a productFieldObject.
                    'id': $(this).data('id'),                   // Product ID (string).
                    'name': $(this).data('name'),               // Product name (string).
                    'category': $(this).data('category'),       // Product category (string).
                    'brand': $(this).data('brand'),             // Product brand (string).
                    'price': $(this).data('price'),
                    'position': $(this).data('position'),
                    'list': $(this).data('list')

                });

                listName = $(this).data('list');



            });
            if (listName != "") {

                ga('mc.ec:setAction', 'detail');
                ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });
            }

        }
    }

    //lets do the promo list

   

    if (usingGA3 ) {


        if (typeof ga != "undefined" ) {

            listName = "";
            $('.promoViewItem').each(function () {

                if (listName != $(this).data('list') && listName != "") {
                    
                    ga('mc.ec:setAction', 'detail');
                    ga('mc.send', 'event', 'PromoView', listName, { nonInteraction: true });
                }

                if ($(this).data('name') && $(this).data('brand') && $(this).data('category')) {
                    ga('mc.ec:addImpression', {                     // Provide product details in a productFieldObject.
                        'id': $(this).data('id'),                   // Product ID (string).
                        'name': $(this).data('name'),               // Product name (string).
                        'category': $(this).data('category'),       // Product category (string).
                        'brand': $(this).data('brand'),             // Product brand (string).
                        'price': $(this).data('price'),
                        'position': $(this).data('position'),
                        'list': $(this).data('list')

                    });
                }
                listName = $(this).data('list');



            });
            if (listName != "") {

                ga('mc.ec:setAction', 'detail');
                ga('mc.send', 'event', 'eCommerce', listName, { nonInteraction: true });
            }

        }
    }

}

function addOnClick(productObj, evt) {



    if ($(productObj).data('id') != null && !productclicked) {
        productclicked = true;


        if (usingGA4) {
            if (typeof (gtag) != 'undefined') {
                gtag('event', 'select_item', {
                    'item_list_id': $(productObj).data('list'),
                    'item_list_name': $(productObj).data('list'),
                    items: eval([
                        {
                            item_id: $(productObj).data('id'),
                            item_name: $(productObj).data('name'),

                            index: $(productObj).data('position'),
                            item_brand: $(productObj).data('brand'),
                            item_category: $(productObj).data('category'),

                            item_list_id: $(productObj).data('list'),
                            item_list_name: $(productObj).data('list'),

                            price: $(productObj).data('price'),
                            currency: "USD",
                            quantity: 1
                        }
                    ])
                });
            }
        }
        if (usingGA3) {


            dataLayer.push({
                'event': 'productClick',
                'ecommerce': {
                    'click': {
                        'actionField': { 'list': $(productObj).data('list') },      // Optional list property.
                        'products': [{
                            'name': $(productObj).data('name'),                      // Name or ID is required.
                            'id': $(productObj).data('id'),
                            'price': $(productObj).data('price'),
                            'brand': $(productObj).data('brand'),
                            'category': $(productObj).data('category'),
                            'position': $(productObj).data('position')
                        }]
                    }
                },
                'eventCallback': function () {

                    if (!evt.ctrlKey) {
                        if ($(productObj).attr('href') != null) {
                            document.location = $(productObj).attr('href');
                        } else if ($(productObj).data('href') != null) {
                            document.location = $(productObj).data('href');
                        }
                    }
                }
            });
        }
    }



}

function promoClick(promoObj, evt) {

    if (usingGA4) {
        if (typeof (gtag) != 'undefined') {

            gtag("event", "select_promotion", {
                creative_name: $(promoObj).data('creative'),
                creative_slot: $(promoObj).data('position'),
                promotion_id: $(promoObj).data('id'),
                promotion_name: $(promoObj).data('name')

            });
        }
    }
    if (usingGA3) {


        ga('mc.ec:addPromo', [{
            'id': $(promoObj).data('id'),
            'name': $(promoObj).data('name'),
            'creative': $(promoObj).data('creative'),
            'position': $(promoObj).data('position')
        }]);

        ga('mc.ec:setAction', 'promo_click');

        ga('mc.send', 'event', 'Internal Promotions', 'click', $(promoObj).data('name'), {
            'hitCallback': function () {

                if (!evt.ctrlKey) {
                    document.location = $(promoObj).attr('href');
                }
            }
        });
    }
    //    dataLayer.push({
    //        'event': 'promotionClick',
    //        'ecommerce': {
    //            'promoClick': {
    //                'promotions': [{
    //                    'id': $(promoObj).data('id'),
    //                    'name': $(promoObj).data('name'),
    //                    'creative': $(promoObj).data('creative'),
    //                    'position': $(promoObj).data('position')
    //                }]
    //            }
    //        },
    //        'eventCallback': function () {
    //            document.location = $(promoObj).attr('href');
    //        }
    //    });



}

function addA1Event(productId, productIds, analyticslist, isQuick, serviceplan, carttype) {

    if (carttype == null) {
        carttype = "instore";
    }
    var ct = "cartUpdated";

    if (carttype == "list") {
        ct = "listUpdated";
    }

    if (carttype == "favorite") {
        ct = "favoriteUpdated";
    }


    var dfd = $.Deferred();
    setTimeout(function () {
        if (usingA1 && typeof $A1 != 'undefined') {


            if (typeof isQuick == 'undefined' || isQuick.toLowerCase().indexOf("pickup") <= 0) {



                $.ajax({
                    type: "Get",
                    url: "/store/getcartproducts.aspx?carttype=" + carttype,
                    async: false,
                    success: function (msg) {
                        existingCartIDs = msg;
                        var productList = [];
                        var listcount = 0;
                        if (productId != null && analyticslist.indexOf("Interstitial Add Ons") < 0) {
                            // add the main id to the list
                            productList[listcount] = $A1.Target({ SourceProductNumber: String(productId) });
                            listcount += 1;
                            //  alert(analyticslist + " sending main productID");
                        }


                        if (serviceplan != null) {

                            var planID = serviceplan.split(':');

                            if (planID.length == 2) {
                                productList[listcount] = $A1.Target({ SourceProductNumber: String(planID[1]) });
                                listcount += 1;
                            }
                        }


                        if (productIds != null) {
                            // add the product Ids
                            var splitIds = productIds.split(",");
                            splitIds.forEach(function (pid) {
                                if (pid != "" && pid != productId) {
                                    productList[listcount] = $A1.Target({ SourceProductNumber: String(pid) });
                                    listcount += 1;
                                }

                            });
                        }


                        if (existingCartIDs != null) {
                            // add the product Ids

                            existingCartIDs.forEach(function (pid) {
                                productList[listcount] = $A1.Target({ SourceProductNumber: String(pid) });
                                listcount += 1;
                            });
                        }



                        //console.log(productList[1]);
                        productList[listcount] = $A1.Target({
                            subType: "",
                            c_clientId: a1clientId
                        });

                       // console.log("Pushing: " + productId + " and selected items " + productIds + " and existing cart items " + existingCartIDs + " for " + ct);

                        ga(function () {
                            myEvent = $A1.Event({
                                type: ct,
                                customer: currentVisitor,
                                targets: productList
                            }).send();
                        });


                        dfd.resolve();

                    }
                });
                // now lets work on our a1 push
            } else {
                dfd.resolve();
            }
        }
    });
    return dfd.promise();
}


function addBloomreachEvent(productId, productIds, analyticslist, isQuick, serviceplan, carttype, actiontype = "Add On", isMini=false) {

    
    var bloomreachType = "cart"
    if (carttype == null) {
        carttype = "instore";
    }
    var ct = "cartUpdated";

    if (carttype == "list") {
        ct = "listUpdated";
        bloomreachType = "list"
    }

    if (carttype == "favorite") {
        ct = "favoriteUpdated";
        bloomreachType = "favorite"
    }
    if (actiontype == "Configurator") {
        bloomreachType = "configurator";
    }
    if (isMini)
    {
        bloomreachType = bloomreachType + "_interstitial";
    }
 

    
    var listAction = "";
   // alert(currentFormList);
    if (currentFormList != "" )
    {
        listAction = currentFormList;
    }
    else
    {
        var itemDetail = $('[data-id=' + productId + ']').first();


        if (productId != null && itemDetail != null) {

            if (itemDetail.data('list') != null) {
                listAction = itemDetail.data('list');
            }
        }
    }

    var dfd = $.Deferred();
    setTimeout(function () {
        if (usingBloomreach) {

      

            if (isQuick === null || typeof isQuick === 'undefined' || typeof isQuick !== 'string' || isQuick.toLowerCase().indexOf("pickup") <= 0) {


          
                if (productId != null && analyticslist.indexOf("Interstitial Add Ons") < 0) {
                    // add the main id to the list
                  
                    var productdata = {
                        type: bloomreachType,
                        action: 'add',
                        page_type: 'website',
                        action_type: 'Product',
                        list_id: listAction,
                        recommendation_id: currentFormRecommendationID,
                        product_id: productId
                        
                    };

         

                    var cartTotals = {
                        "product_list": bloomreachcartItems,
                        "product_ids": bloomreachcartIds,
                        "total_quantity": bloomreachcartTotalItems,
                        "total_price": bloomreachcartTotal,
                        "cart_type": carttype

                    }
                    var listTotals = {
                        "product_list": bloomreachlistItems,
                        "product_ids": bloomreachlistIds,
                        "total_quantity": bloomreachlistTotalItems,
                        "total_price": bloomreachlistTotal,
                        "cart_type": carttype

                    }

                   // console.log(bloomreachType);
         
                    $.ajax({
                        url: '/assets/ajax/getProductAttributes.aspx',
                        type: 'POST',
                        data: productdata,
                        cache: false,
                        dataType: 'json', 
                        success: function (response) {
                            
                            var updatedResponse = Object.assign({}, response, bloomreachData);
                            if (bloomreachType == "cart" || bloomreachType == "cart_interstitial")
                            {
                                updatedResponse = Object.assign({}, updatedResponse, cartTotals);
                            }
                            if (bloomreachType == "list" || bloomreachType == "list_interstitial") {
                                updatedResponse = Object.assign({}, updatedResponse, listTotals);
                            }
                          
                           // console.log(updatedResponse);

                            exponea.track("update", updatedResponse);
                        },
                        error: function (response) {
                         
                        }

                    });

                  

                }


                if (serviceplan != null) {

                    var planID = serviceplan.split(':');

                    if (planID.length == 2) {
                        
                        var productdata = {
                            action: 'add',
                            page_type: 'website',
                            action_type: 'Service Plan',
                            type: bloomreachType,
                            product_id: planID[1]
                            
                        };

                        $.ajax({
                            url: '/assets/ajax/getProductAttributes.aspx',
                            type: 'POST',
                            cache: false,
                            data: productdata,
                            dataType: 'json',
                            success: function (response) {
                                var updatedResponse = Object.assign({}, response, bloomreachData);
                                exponea.track("update", updatedResponse);
                            }
                        });


                  
                    }
                }


                if (productIds != null) {
                    // add the product Ids
                    var splitIds = productIds.split(",");
                
                    splitIds.forEach(function (pid) {
                        
                   
                        if (typeof pid !== 'undefined' && pid.trim() !== "" && pid != productId && !isNaN(pid)) {
                           

                            var productdata = {
                                action: 'add',
                                page_type: 'website',
                                action_type: actiontype,
                                type: bloomreachType,
                                product_id: pid
                                
                            };

                            $.ajax({
                                url: '/assets/ajax/getProductAttributes.aspx',
                                type: 'POST',
                                cache: false,
                                data: productdata,
                                dataType: 'json',
                                success: function (response) {
                                    var updatedResponse = Object.assign({}, response, bloomreachData);
                                    exponea.track("update", updatedResponse);
                                }
                            });

                          
                        }

                    });
                }









                // console.log("Pushing: " + productId + " and selected items " + productIds + " and existing cart items " + existingCartIDs + " for " + ct);





                dfd.resolve();

            }

            // now lets work on our a1 push
        } else {
            dfd.resolve();
        }
    
    });
    return dfd.promise();
}



function addToCartClick(productId, productIds, analyticslist, isQuick, totalValue, carttype) {

    var primarylist;
    var isConfigurator = false;

    setTimeout(function () {
        if (carttype == null) {
            carttype = "instore";
        }
        var ct = "add to cart";
        var ga4Action = "add_to_cart";

        var islist = false;


        if (carttype == "list") {
            ct = "add to list";
            islist = true;
            //  ga4Action = "add_to_wishlist";
        }


        if (totalValue === undefined) {
            totalValue = 0;
        }
        doPush = false;

        //alert("Asdfasdf" + analyticslist);

        var listAction = analyticslist;

        if (listAction == "") {
            listAction = "Add To Cart Click";
        }

        if (isQuick.toLowerCase().indexOf("pickup") > 0) {
            //   listAction = "Quick Pickup Click";
        }



        var itemDetail = $('.ProductLink_' + productId);

        if (!(itemDetail != null && itemDetail.data('id') != null)) {

            itemDetail = $(".productViewItem[data-id='" + productId + "']").first();


        }
        if (usingGA4) {
            itemDetail = $('[data-id=' + productId + ']').first();
        }



      


        if (productId != null || productIds != null) {
        
            if (productIds != null  || itemDetail != null && itemDetail.data('id') != null && (typeof (ga) != 'undefined' || usingGA4 || usingGA3)) {
                doPush = true;
                // lets push the data
                if (usingGA4) {
                    var list = "";
                    if (productId != null && itemDetail != null) {


                        if (currentFormList != "") {
                            listAction = currentFormList;
                        }
                        else {
                            if (itemDetail.data('list') != null) {
                                listAction = itemDetail.data('list');
                            }
                        }
                        var indx = 0;
                        if (itemDetail.data('position') != null) {
                            indx = itemDetail.data('position');
                        }


                        list += "{";

                        list += 'item_id: "' + itemDetail.data('id') + '",';
                        list += 'item_name: "' + (String(itemDetail.data('name') || '')).replace('"', '\\\"') + '",';

                        list += 'index: ' + itemDetail.data('position') + ',';
                        list += ' item_brand: "' + (String(itemDetail.data('brand') || '')).replace('"', '\\\"') + '",';
                        list += 'item_category: "' + (String(itemDetail.data('category') || '')).replace('"', '\\\"') + '",';
                        list += 'item_coord: "' + (String(itemDetail.data('coord') || '')).replace('"', '\\\"') + '",';
                        list += 'item_core: "' + (String(itemDetail.data('core') || '')).replace('"', '\\\"') + '",';

                        list += 'item_list_id: "' + itemDetail.data('list') + '",';
                        list += 'item_list_name: "' + itemDetail.data('list') + '",';
                        if (islist) {
                            list += 'is_list: "' + islist + '",';
                        }
                        list += 'price:' + itemDetail.data('price') + ',';
                        list += ' quantity: 1';
                        list += '}';
                    }

                    if (productIds != null && productIds != "") {
                        SplitIds = productIds.split(',');
                  
                        for (cnt = 0; cnt < SplitIds.length; ++cnt) {
                            

                            var classkey = SplitIds[cnt];
                          
                            if (classkey != "" && !isNaN(classkey)) {
                                
                                if (classkey.indexOf(":") > 0) {
                                    classkey = classkey.split(':')[1];

                                }

                                itemDetail = $('[data-id=' + classkey + ']').first();

                                if (itemDetail != null && itemDetail.data('id') != null) {

                                    if (list != "") {
                                        list += ",";
                                    }

                                    list += "{";

                                    list += 'item_id: "' + itemDetail.data('id') + '",';
                                    list += 'item_name: "' + (String(itemDetail.data('name') || '')).replace('"', '\\\"') + '",';

                                    list += 'index: ' + itemDetail.data('position') + ',';
                                    if (itemDetail.data('brand')) {
                                        list += ' item_brand: "' + (String(itemDetail.data('brand') || '')).replace('"', '\\\"') + '",';
                                    }
                                    if (itemDetail.data('category')) {
                                        list += 'item_category: "' + (String(itemDetail.data('category') || '')).replace('"', '\\\"') + '",';
                                    }
                                    list += 'item_coord: "' + (String(itemDetail.data('coord') || '')).replace('"', '\\\"') + '",';
                                    list += 'item_core: "' + (String(itemDetail.data('core') || '')).replace('"', '\\\"') + '",';

                                    list += 'item_list_id: "' + itemDetail.data('list') + '",';
                                    list += 'item_list_name: "' + itemDetail.data('list') + '",';
                                    if (islist) {
                                        list += 'is_list: "' + islist + '",';
                                    }
                                    list += 'price:' + itemDetail.data('price') + ',';
                                    list += 'currency: "USD",';
                                    list += ' quantity: 1';
                                    list += '}';



                                }
                            }
                        }
                    }





                    gtag("event", ga4Action, {
                        currency: "USD",
                      
                        items: eval('[' + list + ']')

                    });
                }

               

                if (usingGA3) {


                    if ($('.ProductLink_' + productId)) {
                        ga('mc.ec:addProduct', {
                            'id': itemDetail.data('id'),
                            'name': itemDetail.data('name'),
                            'category': itemDetail.data('category'),
                            'brand': itemDetail.data('brand'),
                            'price': itemDetail.data('price'),
                            'list': itemDetail.data('list'),
                            'quantity': 1
                        });
                    }
                    else if ($(".ProductViewItem").filter("[data-id='" + productId + "']")) {
                        ga('mc.ec:addProduct', {
                            'id': $(".ProductViewItem").filter("[data-id='" + productId + "']").data('id'),
                            'name': $(".ProductViewItem").filter("[data-id='" + productId + "']").data('name'),
                            'category': $(".ProductViewItem").filter("[data-id='" + productId + "']").data('category'),
                            'brand': $(".ProductViewItem").filter("[data-id='" + productId + "']").data('brand'),
                            'price': $(".ProductViewItem").filter("[data-id='" + productId + "']").data('price'),
                            'quantity': 1,
                            'list': $(".ProductViewItem").filter("[data-id='" + productId + "']").data('list')
                        });

                    }


                    if (analyticslist != "") {

                        // we need to get the first element only.
                        // lets check to see if this is a single product page click

                        primarylist = analyticslist.split(">")[0];
                        listAction = primarylist.split(",")[0];



                        if (listAction == "Product Page" || listAction == "Frequently Bought Together" || listAction == "Add Ons") {
                            ga('mc.ec:setAction', 'add');
                            listAction = "Product Page";
                        }
                        else {
                            var thisList = analyticslist.split(",", 1)[0];
                            if (isQuick.toLowerCase().indexOf("pickup") > 0) {
                                thisList = "quick pickup form";
                                listAction = "quick pickup form";
                            }


                            ga('mc.ec:setAction', 'add', { list: thisList });
                        }
                    }
                    else {
                        // ga('mc.ec:setAction', 'add');
                    }
                    // alert(listAction);
                    ga('mc.send', 'event', 'eCommerce', listAction, ct);
                }
            }


        }

        var productcount = 1;

        primarylist = analyticslist.split(">")[0];
        listAction = primarylist.split(",")[0];
        if (listAction == "") {
            listAction = "Add To Cart Click";
        }




        if (listAction == "Product Page") { listAction = "Add Ons"; }

        if (productIds != null && productIds != "") {


          

            SplitIds = productIds.split(',');
            productcount = productcount + SplitIds.length;

            if (usingGA3) {
                if (analyticslist.split(",", 1)[0] == "Interstitial Add Ons") {
                    ga('mc.ec:setAction', 'add', { list: 'Interstitial Add Ons' });
                }
                else {
                    ga('mc.ec:setAction', 'add', { list: listAction });
                }
            }

            var thislist = listAction;
            if (listAction.indexOf("Configurator") >= 0) {
                thislist = listAction;
                isConfigurator = true;
            }

            
            for (cnt = 0; cnt < SplitIds.length; ++cnt) {


                var classkey = SplitIds[cnt];
                if (classkey.indexOf(":") > 0) {
                    classkey = classkey.split(':')[1];

                }
                itemDetail = $('.ProductLink_' + classkey);
                if (usingGA4) {
                    itemDetail = $('[data-id=' + classkey + ']').first();
                }


                if (itemDetail != null && itemDetail.data('id') != null && (typeof (ga) != 'undefined' || usingGA4)) {
                    doPush = true;
                    if (usingGA4 && false) {
                        gtag("event", ga4Action, {
                            currency: "USD",
                            value: $('.ProductLink_' + classkey).data('price'),
                            items: [
                                {
                                    item_id: itemDetail.data('id'),
                                    item_name: (String(itemDetail.data('name') || '')).replace("\\\"", " "),
                                    item_list_id: thislist,
                                    item_list_name: thislist,

                                    index: 0,
                                    item_brand: (String(itemDetail.data('brand') || '')).replace("\\\"", " "),
                                    item_category: (String(itemDetail.data('category') || '')).replace("\\\"", " "),
                                    item_coord: (String(itemDetail.data('coord') || '')).replace("\\\"", " "),
                                    item_core: (String(itemDetail.data('core') || '')).replace("\\\"", " "),

                                    price: itemDetail.data('price'),
                                    currency: "USD",
                                    quantity: 1
                                }
                            ]
                        });
                    }
                    if (usingGA3) {

                        ga('mc.ec:addProduct', {
                            'id': $('.ProductLink_' + classkey).data('id'),
                            'name': $('.ProductLink_' + classkey).data('name'),
                            'category': $('.ProductLink_' + classkey).data('category'),
                            'brand': $('.ProductLink_' + classkey).data('brand'),
                            'price': $('.ProductLink_' + classkey).data('price'),
                            'position': $('.ProductLink_' + classkey).data('position'),
                            'quantity': 1,
                            'list': thislist
                        });




                    }
                }
            }

            if (doPush && typeof (ga) != 'undefined' && usingGA3) {
                if (productcount > 1) {
                    if (analyticslist.split(",", 1)[0] == "Interstitial Add Ons") {
                        ga('mc.ec:setAction', 'add', { list: 'Interstitial Add Ons' });
                    }
                    else {
                        ga('mc.ec:setAction', 'add', { list: listAction });
                    }

                    thislist = listAction;
                    if (listAction.indexOf("Configurator") >= 0) {
                        thislist = listAction;
                    }

                    // need to add total NEED TO GET TOTAL in from configurator.
                    if (totalValue > 0) {
                        ga('mc.send', 'event', 'eCommerce', thislist, ct, totalValue);
                    }
                    else {
                        ga('mc.send', 'event', 'eCommerce', thislist, ct);
                    }

                }

            }
        }
    });


}


var Header = {

    setCartQty: function (quantity) {

        $(".header2022 .cartQTY").html(quantity);

    }
}



function setHTMLDropdowns() {
    

    // lets do the any hrev drop down from ul li list.
    $(".selectorHref").unbind("click");

    $(".selectorHref").click(function () {

        var thisDropdownMenu = $(this).parent().parent().find(".dropdown-menu");

        //$(".dropdown-menu").hide();
        //$(".dropdown-menu").data("closeSelector", false);

        if (!keyisdown) {


            if ($(thisDropdownMenu).css('display') == 'block' || $(thisDropdownMenu).css('display') == 'flex') {
                thisDropdownMenu.hide();
                thisDropdownMenu.data("closeSelector", false);
            }
            else {
                $(".boosted .dropdown-menu").hide();
                thisDropdownMenu.show();
                thisDropdownMenu.data("closeSelector", true);
                thisDropdownMenu.focus();
            }
        }
    });

    $(".boosted .selectorHref").keydown(function (e) {
        $(this).data("keyisdown", true);

    });


    $(document).bind("mouseup touchend", function (e) {

        needhide = false;

        $(".dropdown-menu").each(function () {
            if ($(this).data("closeSelector")) {
                needhide = true;
            }
        });



        if (needhide && !hasTouch && document.activeElement.className.indexOf('hasTouch') < 0 && document.activeElement.className.indexOf('modal') < 0 && document.activeElement.className.indexOf('ui-page') < 0 && document.activeElement.className.indexOf('dropdown-menu') < 0 && document.activeElement.className.indexOf('dropdown-item') < 0 && document.activeElement.className.indexOf('dropdown-itemLI') < 0 && document.activeElement.className.indexOf('selectorHref') < 0 && document.activeElement.className.indexOf('dropdown') < 0 && document.activeElement.className.indexOf('sortByText') < 0) {

            $(".boosted .dropdown-menu").hide();
            $(".dropdown-menu").data("closeSelector", false);


        }


    });

    //$(".boosted").mouseleave(function (e) {
    //    $(".dropdown-menu").hide();
    //    $(".dropdown-menu").data("closeSelector", false);

    //});


    $(".boosted .selectorHref").keyup(function (e) {

        $(this).data("keyisdown", false);

        e.preventDefault();
        var thisDropdownMenu = $(this).parent().parent().find(".dropdown-menu");

        $(".boosted .dropdown-menu").hide();
        $(".boosted .dropdown-menu").data("closeSelector", false);

        if (e.which === 13 || e.which === 40) {


            if (thisDropdownMenu.is(":visible") && e.which != 13) {
                thisDropdownMenu.hide();
                thisDropdownMenu.data("closeSelector", false);

            }
            else {
                thisDropdownMenu.show();
                thisDropdownMenu.data("closeSelector", true);
                thisDropdownMenu.find("a").first().focus();

            }
        }


    });


    $(".boosted .dropdown-menu li a").keyup(function (e) {
        e.preventDefault();
        var focusElement = $(document.activeElement);


        var currentLI = focusElement.parent();

        var thisDropdownMenu = currentLI.parent();
        if (e.which === 27) {
            $(".boosted .dropdown-menu").hide();
            $(".boosted .dropdown-menu").data("closeSelector", false);
            thisDropdownMenu.parent().find(".dropdown .selectorHref").focus();
        }

        if (e.which != 13 && e.which != 27) {



            var currentHref = currentLI.find("a").first().attr("href");
            var lastHref = thisDropdownMenu.find("li").last().find("a").first().attr("href");
            var firstHref = thisDropdownMenu.find("li").first().find("a").first().attr("href");


            if (e.which === 40) {

                // console.log(currentLI);
                // console.log(thisDropdownMenu.find("li").last());
                if (currentHref != lastHref) {

                    currentLI.next().find("a").first().focus();
                }

            }


            if (e.which === 38) {

                if (currentHref != firstHref) {
                    currentLI.prev().find("a").first().focus();
                }
                else {

                    thisDropdownMenu.hide();
                    thisDropdownMenu.data("closeSelector", false);
                    thisDropdownMenu.parent().find(".dropdown .selectorHref").focus();
                }

            }
        }

        //38 up
        //40 down
    }
    );
}


function bindMore() {


    setHTMLDropdowns();


    $('.guided').each(function (index) {

        var dimname = $(this).data("dimname");

        var index = 10;

        var licount = $(this).find('li').length;

        if (licount > index) {

            var hideindex = index - 1;
            $(this).find('li:gt(' + hideindex + ')').hide();
            $(this).append('<li class="more"><a href="#"> + MORE<span class=\"hide-text\"> ' + dimname + '</span></a></li>');
            $(this).append('<li class="less"><a href="#"> - LESS<span class=\"hide-text\"> ' + dimname + '</span></a></li>');

            $(this).find('li.less').hide();



            $(this).find('li.more:eq(0)').click(function () {

                var revealindex = 9;
                $(this).parent().find('li:gt(' + revealindex + ')').show();
                $(this).parent().find('li.less').show();


                $(this).parent().find('li:eq(' + (revealindex + 1) + ')').find('a').first().focus();
                var thishtml = $(this).parent().find('li:eq(' + (revealindex + 1) + ')').find('a').html();

                $("#Aria-Announcements").html(thishtml);

                $(this).hide();
                return false;


            });


            $(this).find('li.less:eq(0)').click(function () {


                $(this).parent().find('li:gt(' + hideindex + ')').hide();
                $(this).parent().find('li.more').show();

                $(this).hide();
                return false;


            });








        }


    });
}


function closeDropdowns() {

    $("#storeInfo").hide();
    $("#accountOptions").hide();
    // $("#hypMyAccountModal").addClass("hide");
    // $("#accountOptions").removeClass("show");
    // $("#accountOptions").addClass("hide");
    //$("#storeInfo").removeClass("show");

    if (!$("body").is("#home") || ($("section").css("width") == "720px")) {
        $(this).find("#mainNavLvl").css("left", "-9999px");
    };

    $(".generalNav ul").css("left", "-9999px");

    $(".brandNav ul").css("left", "-9999px");
}


function ADAUpdates() {



    //  lets add in the observer to force change when dom updates

    const observer = new MutationObserver(function (mutations_list) {


        try {

            if ($(".usabilla_live_button_container").length) {

                $(".usabilla_live_button_container").removeAttr("role");

            }
            $("a:not([href])").each(function () {


                $(this).attr("href", "#");

            });


            $("[onmouseover]").each(function () {


                var attr = $(this).attr("onfocus");

                if (typeof attr !== "undefined" && attr !== false) {

                }
                else {


                    $(this).attr("onfocus", $(this).attr("onmouseover").replace("onMouseOver", "onFocus"));
                    // need to add the attribute for onfocus
                }



            });

            $("[onmouseout]").each(function () {


                var attr = $(this).attr("onblur");

                if (typeof attr !== "undefined" && attr !== false) {

                }
                else {


                    $(this).attr("onblur", $(this).attr("onmouseout").replace("onMouseOut", "onBlur"));

                    // need to add the attribute for onfocus
                }



            });




            // iframe titles

            $("iframe").each(function () {
                var iframeTitle = $(this).attr('title');

                if (typeof iframeTitle == 'undefined' || iframeTitle == false) {

                    $(this).attr('title', 'external ad content');
                }

            });

            if ($("#guided").length && !$("#pnlGuidedNavigation").length) {
                $("#guided").removeAttr("aria-labelledby");
            }

            //mutations_list.forEach(function (mutation) {

            //});
        } catch (ex) {

        }
    });

    observer.observe(document.querySelector("body"), { subtree: false, childList: true });






    // usabilia
    if ($(".usabilla_live_button_container").length) {

        $(".usabilla_live_button_container").removeAttr("role");

    }

    // bizarvoice and missing hrefs and missing alt tags

    $("a:not([href])").each(function () {


        $(this).attr("href", "#");

    });


    $("img").each(function () {

        if ($(this).attr("src") == "https://microcenter.ugc.bazaarvoice.com/static/3520-en_us/profileSnapshotLoading.gif") {

            $(this).attr("src", "/assets/images/blank.gif");
        }
        // fix blank alt
        if ($(this).attr("alt") == "") {
            $(this).attr("alt", "");
        }
    });

    // fix missing alt
    $("img:not([alt])").each(function () {


        $(this).attr("alt", "");

    });



    $("[onmouseover]").each(function () {


        var attr = $(this).attr("onfocus");

        if (typeof attr !== "undefined" && attr !== false) {

        }
        else {


            $(this).attr("onfocus", $(this).attr("onmouseover").replace("onMouseOver", "onFocus"));
            // need to add the attribute for onfocus
        }



    });

    $("[onmouseout]").each(function () {


        var attr = $(this).attr("onblur");

        if (typeof attr !== "undefined" && attr !== false) {

        }
        else {


            $(this).attr("onblur", $(this).attr("onmouseout").replace("onMouseOut", "onBlur"));

            // need to add the attribute for onfocus
        }



    });




    // iframe titles

    $("iframe").each(function () {
        var iframeTitle = $(this).attr('title');

        if (typeof iframeTitle == 'undefined' || iframeTitle == false) {

            $(this).attr('title', 'external ad content');
        }

    });



    // fix general image alts
    $("img:not([alt])").each(function () {


        $(this).attr("alt", "");

    });
    // empty guided nav
    if ($("#guided").length && !$("#pnlGuidedNavigation").length) {
        $("#guided").removeAttr("aria-labelledby");
    }
}


function RenderRecommendations(targetID, recommendationid, productId, recommendationheadLine, RecommendedProductIDs, recommendationlist, keybrand, shareurl, removeitem = "", htmlversion = 1, customerCache = false, cachetime = 0, addcache = false, mergecategory = false, personalized=false, carttype="") {

    var bc = $.cookie("__exponea_etc__");


    var cc = "";
    if (customerCache && bc ) {
        cc = bc;
    }
   
    const dataToSend = {
        recommendheadline: recommendationheadLine,
        productids: RecommendedProductIDs,
        productid: productId,
        recommendation_id: recommendationid,
        recommendation_list: recommendationlist,
        keybrandname: keybrand,
        shareurl: shareurl,
        v: htmlversion,
        c: cc,
        ct: cachetime,
        ac: addcache, 
        mc: mergecategory, 
        pc: personalized,
        carttype: carttype
    };

   

    $.ajax({
        url: '/assets/ajax/recommendationList.aspx', // Replace with your endpoint URL
        type: 'POST',
        data: dataToSend,
        success: function (response) {

            if (response.html != "") {
                var decodedHtml = $("<div/>").html(response.html).text();
               
                $("#" + targetID).html(decodedHtml);

                
                if (removeitem != "") {
                   
                    $(removeitem).remove();
                }

                bindSubmit();
                bindClickItemBR();

                bindListClick();
                setfavorites();
                if (htmlversion == 4) {
                    $("#BRBoughtWithInterstitial").show();
                }
                if (htmlversion == 2) {
                    $(".shuffle").off("click");
                    $(".shuffle").click(function () {

                        var el = $(this).data("elements");

                        $("." + el).shuffle();
                        var max = Number($(this).data("max"));
                        var cnt = 0;
                        $("." + el + " hr").removeClass("hide-text");
                        $("." + el).addClass("border-md-right");
                        $("." + el).each(function () {
                            cnt += 1;
                            if (cnt == 1) {

                                $(this).find("hr").addClass("hide-text");
                            }
                            if (cnt >= max) {


                                $(this).removeClass("border-md-right");
                            }
                            if (cnt > max) {

                                $(this).find("hr").addClass("hide-text");

                            }


                            if (cnt <= max) {
                                $(this).show();
                            }
                            else {
                                $(this).hide();
                            }

                        });


                    });
                }
            }
            else
            {
                if (htmlversion == 4) {
                    $("#BRBoughtWithInterstitial").hide();
                    $(".brTab").hide();
                    if ($('.nav .accTab').length > 1) { 
                        $('.nav .accTab').eq(1).find('a').trigger('click');
                    }
                }
                else {
                    $("#" + targetID).remove();


                    if (removeitem != "") {

                        $(removeitem).show();
                    }
                }
            }
           

        },
        error: function (xhr, status, error) {
            $("#" + targetID).remove();
            if (removeitem != "") {
              
                $(removeitem).show();
            }
        }
    });


}
function BuildRecommendations(targetID, recommendationid, productId, recommendationheadLine, recommendationlist, keybrand, shareurl, catalogfilter, personalized = false, removeitem = "", htmlversion = 1, customerCache = false, cachetime = 0, mergecategory = false, carttype="") {

  
    // recommendations configuration
    var options = {
                                      
                                         recommendationId: recommendationid,
                                         size: 30,
                                         callback:
                                             function (data) {

                                            //    console.log(targetID);
                                            //     console.log(options);
                                            //     console.log(data);
                                                 var RecommendedProductIDs = "";
                                                 if (data && data.length > 0) {
                                                     RecommendedProductIDs = data.map(item => item.item_id).join(',');
                                                     
                                                 }
                                                 RenderRecommendations(targetID, recommendationid, productId, recommendationheadLine, RecommendedProductIDs, recommendationlist, keybrand, shareurl, removeitem, htmlversion, customerCache,cachetime, true, mergecategory, personalized, carttype);

                                             },
                                          
                                        
                                          fillWithRandom: false,
                                         
                                          catalogAttributesWhitelist: ['item_id', 'url', 'title'], // Returns only specified attributes from catalog items. If empty or not set, returns everything.
                                    };

                                if (typeof catalogfilter !== 'undefined' && catalogfilter != '') {
                                        options.catalogFilter = catalogfilter; // Adds additional constrains to catalog when retrieving recommended items.
                                    }

                                    if (productId != '') {

                                        options.items = [productId];
                                    }
                                    else {
                                       // options.items = [];
                                    }


                                if (!personalized) {
                                    //options.experimental = { non_personalized_weblayers: true };
                                    }

                                  // console.log(options);
                                        exponea.getRecommendation(options);
                                    

  

}
// jquery custom scroll bar
/*mousewheel*/


(function (a) {
    function d(b) {
        var c = b || window.event,
            d = [].slice.call(arguments, 1),
            e = 0,
            f = !0,
            g = 0,
            h = 0;
        return (
            (b = a.event.fix(c)),
            (b.type = "mousewheel"),
            c.wheelDelta && (e = c.wheelDelta / 120),
            c.detail && (e = -c.detail / 3),
            (h = e),
            c.axis !== undefined && c.axis === c.HORIZONTAL_AXIS && ((h = 0), (g = -1 * e)),
            c.wheelDeltaY !== undefined && (h = c.wheelDeltaY / 120),
            c.wheelDeltaX !== undefined && (g = (-1 * c.wheelDeltaX) / 120),
            d.unshift(b, e, g, h),
            (a.event.dispatch || a.event.handle).apply(this, d)
        );
    }
    var b = ["DOMMouseScroll", "mousewheel"];
    if (a.event.fixHooks) for (var c = b.length; c;) a.event.fixHooks[b[--c]] = a.event.mouseHooks;
    (a.event.special.mousewheel = {
        setup: function () {
            if (this.addEventListener) for (var a = b.length; a;) this.addEventListener(b[--a], d, !1);
            else this.onmousewheel = d;
        },
        teardown: function () {
            if (this.removeEventListener) for (var a = b.length; a;) this.removeEventListener(b[--a], d, !1);
            else this.onmousewheel = null;
        },
    }),
        a.fn.extend({
            mousewheel: function (a) {
                return a ? this.bind("mousewheel", a) : this.trigger("mousewheel");
            },
            unmousewheel: function (a) {
                return this.unbind("mousewheel", a);
            },
        });
})(jQuery);


















/*custom scrollbar*/
(function (c) {
    var b = {
        init: function (e) {
            var f = {
                set_width: false,
                set_height: false,
                horizontalScroll: false,
                scrollInertia: 950,
                mouseWheel: true,
                mouseWheelPixels: "auto",
                autoDraggerLength: true,
                autoHideScrollbar: false,
                scrollButtons: { enable: false, scrollType: "continuous", scrollSpeed: "auto", scrollAmount: 40 },
                advanced: { updateOnBrowserResize: true, updateOnContentResize: false, autoExpandHorizontalScroll: false, autoScrollOnFocus: true, normalizeMouseWheelDelta: false },
                contentTouchScroll: true,
                callbacks: {
                    onScrollStart: function () { },
                    onScroll: function () { },
                    onTotalScroll: function () { },
                    onTotalScrollBack: function () { },
                    onTotalScrollOffset: 0,
                    onTotalScrollBackOffset: 0,
                    whileScrolling: function () { },
                },
                theme: "light",
            },
                e = c.extend(true, f, e);
            return this.each(function () {
                var m = c(this);
                if (e.set_width) {
                    m.css("width", e.set_width);
                }
                if (e.set_height) {
                    m.css("height", e.set_height);
                }
                if (!c(document).data("mCustomScrollbar-index")) {
                    c(document).data("mCustomScrollbar-index", "1");
                } else {
                    var t = parseInt(c(document).data("mCustomScrollbar-index"));
                    c(document).data("mCustomScrollbar-index", t + 1);
                }
                m.wrapInner("<div class='mCustomScrollBox mCS-" + e.theme + "' id='mCSB_" + c(document).data("mCustomScrollbar-index") + "' style='position:relative; height:100%; overflow:hidden; max-width:100%;' />").addClass(
                    "mCustomScrollbar _mCS_" + c(document).data("mCustomScrollbar-index")
                );
                var g = m.children(".mCustomScrollBox");
                if (e.horizontalScroll) {
                    g.addClass("mCSB_horizontal").wrapInner("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />");
                    var k = g.children(".mCSB_h_wrapper");
                    k.wrapInner("<div class='mCSB_container' style='position:absolute; left:0;' />").children(".mCSB_container").css({ width: k.children().outerWidth(), position: "relative" }).unwrap();
                } else {
                    g.wrapInner("<div class='mCSB_container' style='position:relative; top:0;' />");
                }
                var o = g.children(".mCSB_container");
                if (c.support.touch) {
                    o.addClass("mCS_touch");
                }
                o.after(
                    "<div class='mCSB_scrollTools' style='position:absolute;'><div class='mCSB_draggerContainer'><div class='mCSB_dragger' style='position:absolute;' oncontextmenu='return false;'><div class='mCSB_dragger_bar' style='position:relative;'></div></div><div class='mCSB_draggerRail'></div></div></div>"
                );
                var l = g.children(".mCSB_scrollTools"),
                    h = l.children(".mCSB_draggerContainer"),
                    q = h.children(".mCSB_dragger");
                if (e.horizontalScroll) {
                    q.data("minDraggerWidth", q.width());
                } else {
                    q.data("minDraggerHeight", q.height());
                }
                if (e.scrollButtons.enable) {
                    if (e.horizontalScroll) {
                        l.prepend("<a class='mCSB_buttonLeft' oncontextmenu='return false;'></a>").append("<a class='mCSB_buttonRight' oncontextmenu='return false;'></a>");
                    } else {
                        l.prepend("<a class='mCSB_buttonUp' oncontextmenu='return false;'></a>").append("<a class='mCSB_buttonDown' oncontextmenu='return false;'></a>");
                    }
                }
                g.bind("scroll", function () {
                    if (!m.is(".mCS_disabled")) {
                        g.scrollTop(0).scrollLeft(0);
                    }
                });
                m.data({
                    mCS_Init: true,
                    mCustomScrollbarIndex: c(document).data("mCustomScrollbar-index"),
                    horizontalScroll: e.horizontalScroll,
                    scrollInertia: e.scrollInertia,
                    scrollEasing: "mcsEaseOut",
                    mouseWheel: e.mouseWheel,
                    mouseWheelPixels: e.mouseWheelPixels,
                    autoDraggerLength: e.autoDraggerLength,
                    autoHideScrollbar: e.autoHideScrollbar,
                    scrollButtons_enable: e.scrollButtons.enable,
                    scrollButtons_scrollType: e.scrollButtons.scrollType,
                    scrollButtons_scrollSpeed: e.scrollButtons.scrollSpeed,
                    scrollButtons_scrollAmount: e.scrollButtons.scrollAmount,
                    autoExpandHorizontalScroll: e.advanced.autoExpandHorizontalScroll,
                    autoScrollOnFocus: e.advanced.autoScrollOnFocus,
                    normalizeMouseWheelDelta: e.advanced.normalizeMouseWheelDelta,
                    contentTouchScroll: e.contentTouchScroll,
                    onScrollStart_Callback: e.callbacks.onScrollStart,
                    onScroll_Callback: e.callbacks.onScroll,
                    onTotalScroll_Callback: e.callbacks.onTotalScroll,
                    onTotalScrollBack_Callback: e.callbacks.onTotalScrollBack,
                    onTotalScroll_Offset: e.callbacks.onTotalScrollOffset,
                    onTotalScrollBack_Offset: e.callbacks.onTotalScrollBackOffset,
                    whileScrolling_Callback: e.callbacks.whileScrolling,
                    bindEvent_scrollbar_drag: false,
                    bindEvent_content_touch: false,
                    bindEvent_scrollbar_click: false,
                    bindEvent_mousewheel: false,
                    bindEvent_buttonsContinuous_y: false,
                    bindEvent_buttonsContinuous_x: false,
                    bindEvent_buttonsPixels_y: false,
                    bindEvent_buttonsPixels_x: false,
                    bindEvent_focusin: false,
                    bindEvent_autoHideScrollbar: false,
                    mCSB_buttonScrollRight: false,
                    mCSB_buttonScrollLeft: false,
                    mCSB_buttonScrollDown: false,
                    mCSB_buttonScrollUp: false,
                });
                if (e.horizontalScroll) {
                    if (m.css("max-width") !== "none") {
                        if (!e.advanced.updateOnContentResize) {
                            e.advanced.updateOnContentResize = true;
                        }
                    }
                } else {
                    if (m.css("max-height") !== "none") {
                        var s = false,
                            r = parseInt(m.css("max-height"));
                        if (m.css("max-height").indexOf("%") >= 0) {
                            (s = r), (r = (m.parent().height() * s) / 100);
                        }
                        m.css("overflow", "hidden");
                        g.css("max-height", r);
                    }
                }
                m.mCustomScrollbar("update");
                if (e.advanced.updateOnBrowserResize) {
                    var i,
                        j = c(window).width(),
                        u = c(window).height();
                    c(window).bind("resize." + m.data("mCustomScrollbarIndex"), function () {
                        if (i) {
                            clearTimeout(i);
                        }
                        i = setTimeout(function () {
                            if (!m.is(".mCS_disabled") && !m.is(".mCS_destroyed")) {
                                var w = c(window).width(),
                                    v = c(window).height();
                                if (j !== w || u !== v) {
                                    if (m.css("max-height") !== "none" && s) {
                                        g.css("max-height", (m.parent().height() * s) / 100);
                                    }
                                    m.mCustomScrollbar("update");
                                    j = w;
                                    u = v;
                                }
                            }
                        }, 150);
                    });
                }
                if (e.advanced.updateOnContentResize) {
                    var p;
                    if (e.horizontalScroll) {
                        var n = o.outerWidth();
                    } else {
                        var n = o.outerHeight();
                    }
                    p = setInterval(function () {
                        if (e.horizontalScroll) {
                            if (e.advanced.autoExpandHorizontalScroll) {
                                o.css({ position: "absolute", width: "auto" }).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({ width: o.outerWidth(), position: "relative" }).unwrap();
                            }
                            var v = o.outerWidth();
                        } else {
                            var v = o.outerHeight();
                        }
                        if (v != n) {
                            m.mCustomScrollbar("update");
                            n = v;
                        }
                    }, 300);
                }
            });
        },
        update: function () {
            var n = c(this),
                k = n.children(".mCustomScrollBox"),
                q = k.children(".mCSB_container");
            q.removeClass("mCS_no_scrollbar");
            n.removeClass("mCS_disabled mCS_destroyed");
            k.scrollTop(0).scrollLeft(0);
            var y = k.children(".mCSB_scrollTools"),
                o = y.children(".mCSB_draggerContainer"),
                m = o.children(".mCSB_dragger");
            if (n.data("horizontalScroll")) {
                var A = y.children(".mCSB_buttonLeft"),
                    t = y.children(".mCSB_buttonRight"),
                    f = k.width();
                if (n.data("autoExpandHorizontalScroll")) {
                    q.css({ position: "absolute", width: "auto" }).wrap("<div class='mCSB_h_wrapper' style='position:relative; left:0; width:999999px;' />").css({ width: q.outerWidth(), position: "relative" }).unwrap();
                }
                var z = q.outerWidth();
            } else {
                var w = y.children(".mCSB_buttonUp"),
                    g = y.children(".mCSB_buttonDown"),
                    r = k.height(),
                    i = q.outerHeight();
            }
            if (i > r && !n.data("horizontalScroll")) {
                y.css("display", "block");
                var s = o.height();
                if (n.data("autoDraggerLength")) {
                    var u = Math.round((r / i) * s),
                        l = m.data("minDraggerHeight");
                    if (u <= l) {
                        m.css({ height: l });
                    } else {
                        if (u >= s - 10) {
                            var p = s - 10;
                            m.css({ height: p });
                        } else {
                            m.css({ height: u });
                        }
                    }
                    m.children(".mCSB_dragger_bar").css({ "line-height": m.height() + "px" });
                }
                var B = m.height(),
                    x = (i - r) / (s - B);
                n.data("scrollAmount", x).mCustomScrollbar("scrolling", k, q, o, m, w, g, A, t);
                var D = Math.abs(q.position().top);
                n.mCustomScrollbar("scrollTo", D, { scrollInertia: 0, trigger: "internal" });
            } else {
                if (z > f && n.data("horizontalScroll")) {
                    y.css("display", "block");
                    var h = o.width();
                    if (n.data("autoDraggerLength")) {
                        var j = Math.round((f / z) * h),
                            C = m.data("minDraggerWidth");
                        if (j <= C) {
                            m.css({ width: C });
                        } else {
                            if (j >= h - 10) {
                                var e = h - 10;
                                m.css({ width: e });
                            } else {
                                m.css({ width: j });
                            }
                        }
                    }
                    var v = m.width(),
                        x = (z - f) / (h - v);
                    n.data("scrollAmount", x).mCustomScrollbar("scrolling", k, q, o, m, w, g, A, t);
                    var D = Math.abs(q.position().left);
                    n.mCustomScrollbar("scrollTo", D, { scrollInertia: 0, trigger: "internal" });
                } else {
                    k.unbind("mousewheel focusin");
                    if (n.data("horizontalScroll")) {
                        m.add(q).css("left", 0);
                    } else {
                        m.add(q).css("top", 0);
                    }
                    y.css("display", "none");
                    q.addClass("mCS_no_scrollbar");
                    n.data({ bindEvent_mousewheel: false, bindEvent_focusin: false });
                }
            }
        },
        scrolling: function (h, p, m, j, w, e, A, v) {
            var k = c(this);
            if (!k.data("bindEvent_scrollbar_drag")) {
                var n, o;
                if (c.support.msPointer) {
                    j.bind("MSPointerDown", function (H) {
                        H.preventDefault();
                        k.data({ on_drag: true });
                        j.addClass("mCSB_dragger_onDrag");
                        var G = c(this),
                            J = G.offset(),
                            F = H.originalEvent.pageX - J.left,
                            I = H.originalEvent.pageY - J.top;
                        if (F < G.width() && F > 0 && I < G.height() && I > 0) {
                            n = I;
                            o = F;
                        }
                    });
                    c(document)
                        .bind("MSPointerMove." + k.data("mCustomScrollbarIndex"), function (H) {
                            H.preventDefault();
                            if (k.data("on_drag")) {
                                var G = j,
                                    J = G.offset(),
                                    F = H.originalEvent.pageX - J.left,
                                    I = H.originalEvent.pageY - J.top;
                                D(n, o, I, F);
                            }
                        })
                        .bind("MSPointerUp." + k.data("mCustomScrollbarIndex"), function (x) {
                            k.data({ on_drag: false });
                            j.removeClass("mCSB_dragger_onDrag");
                        });
                } else {
                    j.bind("mousedown touchstart", function (H) {
                        H.preventDefault();
                        H.stopImmediatePropagation();
                        var G = c(this),
                            K = G.offset(),
                            F,
                            J;
                        if (H.type === "touchstart") {
                            var I = H.originalEvent.touches[0] || H.originalEvent.changedTouches[0];
                            F = I.pageX - K.left;
                            J = I.pageY - K.top;
                        } else {
                            k.data({ on_drag: true });
                            j.addClass("mCSB_dragger_onDrag");
                            F = H.pageX - K.left;
                            J = H.pageY - K.top;
                        }
                        if (F < G.width() && F > 0 && J < G.height() && J > 0) {
                            n = J;
                            o = F;
                        }
                    }).bind("touchmove", function (H) {
                        H.preventDefault();
                        H.stopImmediatePropagation();
                        var K = H.originalEvent.touches[0] || H.originalEvent.changedTouches[0],
                            G = c(this),
                            J = G.offset(),
                            F = K.pageX - J.left,
                            I = K.pageY - J.top;
                        D(n, o, I, F);
                    });
                    c(document)
                        .bind("mousemove." + k.data("mCustomScrollbarIndex"), function (H) {
                            if (k.data("on_drag")) {
                                var G = j,
                                    J = G.offset(),
                                    F = H.pageX - J.left,
                                    I = H.pageY - J.top;
                                D(n, o, I, F);
                            }
                        })
                        .bind("mouseup." + k.data("mCustomScrollbarIndex"), function (x) {
                            k.data({ on_drag: false });
                            j.removeClass("mCSB_dragger_onDrag");
                        });
                }
                k.data({ bindEvent_scrollbar_drag: true });
            }
            function D(G, H, I, F) {
                if (k.data("horizontalScroll")) {
                    k.mCustomScrollbar("scrollTo", j.position().left - H + F, { moveDragger: true, trigger: "internal" });
                } else {
                    k.mCustomScrollbar("scrollTo", j.position().top - G + I, { moveDragger: true, trigger: "internal" });
                }
            }
            if (c.support.touch && k.data("contentTouchScroll")) {
                if (!k.data("bindEvent_content_touch")) {
                    var l, B, r, s, u, C, E;
                    p.bind("touchstart", function (x) {
                        x.stopImmediatePropagation();
                        l = x.originalEvent.touches[0] || x.originalEvent.changedTouches[0];
                        B = c(this);
                        r = B.offset();
                        u = l.pageX - r.left;
                        s = l.pageY - r.top;
                        C = s;
                        E = u;
                    });
                    p.bind("touchmove", function (x) {
                        x.preventDefault();
                        x.stopImmediatePropagation();
                        l = x.originalEvent.touches[0] || x.originalEvent.changedTouches[0];
                        B = c(this).parent();
                        r = B.offset();
                        u = l.pageX - r.left;
                        s = l.pageY - r.top;
                        if (k.data("horizontalScroll")) {
                            k.mCustomScrollbar("scrollTo", E - u, { trigger: "internal" });
                        } else {
                            k.mCustomScrollbar("scrollTo", C - s, { trigger: "internal" });
                        }
                    });
                }
            }
            if (!k.data("bindEvent_scrollbar_click")) {
                m.bind("click", function (F) {
                    var x = (F.pageY - m.offset().top) * k.data("scrollAmount"),
                        y = c(F.target);
                    if (k.data("horizontalScroll")) {
                        x = (F.pageX - m.offset().left) * k.data("scrollAmount");
                    }
                    if (y.hasClass("mCSB_draggerContainer") || y.hasClass("mCSB_draggerRail")) {
                        k.mCustomScrollbar("scrollTo", x, { trigger: "internal", scrollEasing: "draggerRailEase" });
                    }
                });
                k.data({ bindEvent_scrollbar_click: true });
            }
            if (k.data("mouseWheel")) {
                if (!k.data("bindEvent_mousewheel")) {
                    h.bind("mousewheel", function (H, J) {
                        var G,
                            F = k.data("mouseWheelPixels"),
                            x = Math.abs(p.position().top),
                            I = j.position().top,
                            y = m.height() - j.height();
                        if (k.data("normalizeMouseWheelDelta")) {
                            if (J < 0) {
                                J = -1;
                            } else {
                                J = 1;
                            }
                        }
                        if (F === "auto") {
                            F = 100 + Math.round(k.data("scrollAmount") / 2);
                        }
                        if (k.data("horizontalScroll")) {
                            I = j.position().left;
                            y = m.width() - j.width();
                            x = Math.abs(p.position().left);
                        }
                        if ((J > 0 && I !== 0) || (J < 0 && I !== y)) {
                            H.preventDefault();
                            H.stopImmediatePropagation();
                        }
                        G = x - J * F;
                        k.mCustomScrollbar("scrollTo", G, { trigger: "internal" });
                    });
                    k.data({ bindEvent_mousewheel: true });
                }
            }
            if (k.data("scrollButtons_enable")) {
                if (k.data("scrollButtons_scrollType") === "pixels") {
                    if (k.data("horizontalScroll")) {
                        v.add(A).unbind("mousedown touchstart MSPointerDown mouseup MSPointerUp mouseout MSPointerOut touchend", i, g);
                        k.data({ bindEvent_buttonsContinuous_x: false });
                        if (!k.data("bindEvent_buttonsPixels_x")) {
                            v.bind("click", function (x) {
                                x.preventDefault();
                                q(Math.abs(p.position().left) + k.data("scrollButtons_scrollAmount"));
                            });
                            A.bind("click", function (x) {
                                x.preventDefault();
                                q(Math.abs(p.position().left) - k.data("scrollButtons_scrollAmount"));
                            });
                            k.data({ bindEvent_buttonsPixels_x: true });
                        }
                    } else {
                        e.add(w).unbind("mousedown touchstart MSPointerDown mouseup MSPointerUp mouseout MSPointerOut touchend", i, g);
                        k.data({ bindEvent_buttonsContinuous_y: false });
                        if (!k.data("bindEvent_buttonsPixels_y")) {
                            e.bind("click", function (x) {
                                x.preventDefault();
                                q(Math.abs(p.position().top) + k.data("scrollButtons_scrollAmount"));
                            });
                            w.bind("click", function (x) {
                                x.preventDefault();
                                q(Math.abs(p.position().top) - k.data("scrollButtons_scrollAmount"));
                            });
                            k.data({ bindEvent_buttonsPixels_y: true });
                        }
                    }
                    function q(x) {
                        if (!j.data("preventAction")) {
                            j.data("preventAction", true);
                            k.mCustomScrollbar("scrollTo", x, { trigger: "internal" });
                        }
                    }
                } else {
                    if (k.data("horizontalScroll")) {
                        v.add(A).unbind("click");
                        k.data({ bindEvent_buttonsPixels_x: false });
                        if (!k.data("bindEvent_buttonsContinuous_x")) {
                            v.bind("mousedown touchstart MSPointerDown", function (y) {
                                y.preventDefault();
                                var x = z();
                                k.data({
                                    mCSB_buttonScrollRight: setInterval(function () {
                                        k.mCustomScrollbar("scrollTo", Math.abs(p.position().left) + x, { trigger: "internal", scrollEasing: "easeOutCirc" });
                                    }, 17),
                                });
                            });
                            var i = function (x) {
                                x.preventDefault();
                                clearInterval(k.data("mCSB_buttonScrollRight"));
                            };
                            v.bind("mouseup touchend MSPointerUp mouseout MSPointerOut", i);
                            A.bind("mousedown touchstart MSPointerDown", function (y) {
                                y.preventDefault();
                                var x = z();
                                k.data({
                                    mCSB_buttonScrollLeft: setInterval(function () {
                                        k.mCustomScrollbar("scrollTo", Math.abs(p.position().left) - x, { trigger: "internal", scrollEasing: "easeOutCirc" });
                                    }, 17),
                                });
                            });
                            var g = function (x) {
                                x.preventDefault();
                                clearInterval(k.data("mCSB_buttonScrollLeft"));
                            };
                            A.bind("mouseup touchend MSPointerUp mouseout MSPointerOut", g);
                            k.data({ bindEvent_buttonsContinuous_x: true });
                        }
                    } else {
                        e.add(w).unbind("click");
                        k.data({ bindEvent_buttonsPixels_y: false });
                        if (!k.data("bindEvent_buttonsContinuous_y")) {
                            e.bind("mousedown touchstart MSPointerDown", function (y) {
                                y.preventDefault();
                                var x = z();
                                k.data({
                                    mCSB_buttonScrollDown: setInterval(function () {
                                        k.mCustomScrollbar("scrollTo", Math.abs(p.position().top) + x, { trigger: "internal", scrollEasing: "easeOutCirc" });
                                    }, 17),
                                });
                            });
                            var t = function (x) {
                                x.preventDefault();
                                clearInterval(k.data("mCSB_buttonScrollDown"));
                            };
                            e.bind("mouseup touchend MSPointerUp mouseout MSPointerOut", t);
                            w.bind("mousedown touchstart MSPointerDown", function (y) {
                                y.preventDefault();
                                var x = z();
                                k.data({
                                    mCSB_buttonScrollUp: setInterval(function () {
                                        k.mCustomScrollbar("scrollTo", Math.abs(p.position().top) - x, { trigger: "internal", scrollEasing: "easeOutCirc" });
                                    }, 17),
                                });
                            });
                            var f = function (x) {
                                x.preventDefault();
                                clearInterval(k.data("mCSB_buttonScrollUp"));
                            };
                            w.bind("mouseup touchend MSPointerUp mouseout MSPointerOut", f);
                            k.data({ bindEvent_buttonsContinuous_y: true });
                        }
                    }
                    function z() {
                        var x = k.data("scrollButtons_scrollSpeed");
                        if (k.data("scrollButtons_scrollSpeed") === "auto") {
                            x = Math.round((k.data("scrollInertia") + 100) / 40);
                        }
                        return x;
                    }
                }
            }
            if (k.data("autoScrollOnFocus")) {
                if (!k.data("bindEvent_focusin")) {
                    h.bind("focusin", function () {
                        h.scrollTop(0).scrollLeft(0);
                        var x = c(document.activeElement);
                        if (x.is("input,textarea,select,button,a[tabindex],area,object")) {
                            var G = p.position().top,
                                y = x.position().top,
                                F = h.height() - x.outerHeight();
                            if (k.data("horizontalScroll")) {
                                G = p.position().left;
                                y = x.position().left;
                                F = h.width() - x.outerWidth();
                            }
                            if (G + y < 0 || G + y > F) {
                                k.mCustomScrollbar("scrollTo", y, { trigger: "internal" });
                            }
                        }
                    });
                    k.data({ bindEvent_focusin: true });
                }
            }
            if (k.data("autoHideScrollbar")) {
                if (!k.data("bindEvent_autoHideScrollbar")) {
                    h.bind("mouseenter", function (x) {
                        h.addClass("mCS-mouse-over");
                        d.showScrollbar.call(h.children(".mCSB_scrollTools"));
                    }).bind("mouseleave touchend", function (x) {
                        h.removeClass("mCS-mouse-over");
                        if (x.type === "mouseleave") {
                            d.hideScrollbar.call(h.children(".mCSB_scrollTools"));
                        }
                    });
                    k.data({ bindEvent_autoHideScrollbar: true });
                }
            }
        },
        scrollTo: function (n, u) {
            var r = c(this),
                k = { moveDragger: false, trigger: "external", callbacks: true, scrollInertia: r.data("scrollInertia"), scrollEasing: r.data("scrollEasing") },
                u = c.extend(k, u),
                j,
                i = r.children(".mCustomScrollBox"),
                s = i.children(".mCSB_container"),
                q = i.children(".mCSB_scrollTools"),
                h = q.children(".mCSB_draggerContainer"),
                t = h.children(".mCSB_dragger"),
                g = (draggerSpeed = u.scrollInertia),
                m,
                f,
                l,
                e;
            if (!s.hasClass("mCS_no_scrollbar")) {
                r.data({ mCS_trigger: u.trigger });
                if (r.data("mCS_Init")) {
                    u.callbacks = false;
                }
                if (n || n === 0) {
                    if (typeof n === "number") {
                        if (u.moveDragger) {
                            j = n;
                            if (r.data("horizontalScroll")) {
                                n = t.position().left * r.data("scrollAmount");
                            } else {
                                n = t.position().top * r.data("scrollAmount");
                            }
                            draggerSpeed = 0;
                        } else {
                            j = n / r.data("scrollAmount");
                        }
                    } else {
                        if (typeof n === "string") {
                            var p;
                            if (n === "top") {
                                p = 0;
                            } else {
                                if (n === "bottom" && !r.data("horizontalScroll")) {
                                    p = s.outerHeight() - i.height();
                                } else {
                                    if (n === "left") {
                                        p = 0;
                                    } else {
                                        if (n === "right" && r.data("horizontalScroll")) {
                                            p = s.outerWidth() - i.width();
                                        } else {
                                            if (n === "first") {
                                                p = r.find(".mCSB_container").find(":first");
                                            } else {
                                                if (n === "last") {
                                                    p = r.find(".mCSB_container").find(":last");
                                                } else {
                                                    p = r.find(n);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                            if (p.length === 1) {
                                if (r.data("horizontalScroll")) {
                                    n = p.position().left;
                                } else {
                                    n = p.position().top;
                                }
                                j = n / r.data("scrollAmount");
                            } else {
                                j = n = p;
                            }
                        }
                    }
                    if (r.data("horizontalScroll")) {
                        if (r.data("onTotalScrollBack_Offset")) {
                            f = -r.data("onTotalScrollBack_Offset");
                        }
                        if (r.data("onTotalScroll_Offset")) {
                            e = i.width() - s.outerWidth() + r.data("onTotalScroll_Offset");
                        }
                        if (j < 0) {
                            j = n = 0;
                            clearInterval(r.data("mCSB_buttonScrollLeft"));
                            if (!f) {
                                m = true;
                            }
                        } else {
                            if (j >= h.width() - t.width()) {
                                j = h.width() - t.width();
                                n = i.width() - s.outerWidth();
                                clearInterval(r.data("mCSB_buttonScrollRight"));
                                if (!e) {
                                    l = true;
                                }
                            } else {
                                n = -n;
                            }
                        }
                        d.mTweenAxis.call(this, t[0], "left", Math.round(j), draggerSpeed, u.scrollEasing);
                        d.mTweenAxis.call(this, s[0], "left", Math.round(n), g, u.scrollEasing, {
                            onStart: function () {
                                if (u.callbacks && !r.data("mCS_tweenRunning")) {
                                    o("onScrollStart");
                                }
                                if (r.data("autoHideScrollbar")) {
                                    d.showScrollbar.call(q);
                                }
                            },
                            onUpdate: function () {
                                if (u.callbacks) {
                                    o("whileScrolling");
                                }
                            },
                            onComplete: function () {
                                if (u.callbacks) {
                                    o("onScroll");
                                    if (m || (f && s.position().left >= f)) {
                                        o("onTotalScrollBack");
                                    }
                                    if (l || (e && s.position().left <= e)) {
                                        o("onTotalScroll");
                                    }
                                }
                                t.data("preventAction", false);
                                r.data("mCS_tweenRunning", false);
                                if (r.data("autoHideScrollbar")) {
                                    if (!i.hasClass("mCS-mouse-over")) {
                                        d.hideScrollbar.call(q);
                                    }
                                }
                            },
                        });
                    } else {
                        if (r.data("onTotalScrollBack_Offset")) {
                            f = -r.data("onTotalScrollBack_Offset");
                        }
                        if (r.data("onTotalScroll_Offset")) {
                            e = i.height() - s.outerHeight() + r.data("onTotalScroll_Offset");
                        }
                        if (j < 0) {
                            j = n = 0;
                            clearInterval(r.data("mCSB_buttonScrollUp"));
                            if (!f) {
                                m = true;
                            }
                        } else {
                            if (j >= h.height() - t.height()) {
                                j = h.height() - t.height();
                                n = i.height() - s.outerHeight();
                                clearInterval(r.data("mCSB_buttonScrollDown"));
                                if (!e) {
                                    l = true;
                                }
                            } else {
                                n = -n;
                            }
                        }
                        d.mTweenAxis.call(this, t[0], "top", Math.round(j), draggerSpeed, u.scrollEasing);
                        d.mTweenAxis.call(this, s[0], "top", Math.round(n), g, u.scrollEasing, {
                            onStart: function () {
                                if (u.callbacks && !r.data("mCS_tweenRunning")) {
                                    o("onScrollStart");
                                }
                                if (r.data("autoHideScrollbar")) {
                                    d.showScrollbar.call(q);
                                }
                            },
                            onUpdate: function () {
                                if (u.callbacks) {
                                    o("whileScrolling");
                                }
                            },
                            onComplete: function () {
                                if (u.callbacks) {
                                    o("onScroll");
                                    if (m || (f && s.position().top >= f)) {
                                        o("onTotalScrollBack");
                                    }
                                    if (l || (e && s.position().top <= e)) {
                                        o("onTotalScroll");
                                    }
                                }
                                t.data("preventAction", false);
                                r.data("mCS_tweenRunning", false);
                                if (r.data("autoHideScrollbar")) {
                                    if (!i.hasClass("mCS-mouse-over")) {
                                        d.hideScrollbar.call(q);
                                    }
                                }
                            },
                        });
                    }
                    if (r.data("mCS_Init")) {
                        r.data({ mCS_Init: false });
                    }
                }
            }
            function o(v) {
                this.mcs = {
                    top: s.position().top,
                    left: s.position().left,
                    draggerTop: t.position().top,
                    draggerLeft: t.position().left,
                    topPct: Math.round((100 * Math.abs(s.position().top)) / Math.abs(s.outerHeight() - i.height())),
                    leftPct: Math.round((100 * Math.abs(s.position().left)) / Math.abs(s.outerWidth() - i.width())),
                };
                switch (v) {
                    case "onScrollStart":
                        r.data("mCS_tweenRunning", true).data("onScrollStart_Callback").call(r, this.mcs);
                        break;
                    case "whileScrolling":
                        r.data("whileScrolling_Callback").call(r, this.mcs);
                        break;
                    case "onScroll":
                        r.data("onScroll_Callback").call(r, this.mcs);
                        break;
                    case "onTotalScrollBack":
                        r.data("onTotalScrollBack_Callback").call(r, this.mcs);
                        break;
                    case "onTotalScroll":
                        r.data("onTotalScroll_Callback").call(r, this.mcs);
                        break;
                }
            }
        },
        stop: function () {
            var g = c(this),
                e = g.children().children(".mCSB_container"),
                f = g.children().children().children().children(".mCSB_dragger");
            d.mTweenAxisStop.call(this, e[0]);
            d.mTweenAxisStop.call(this, f[0]);
        },
        disable: function (e) {
            var j = c(this),
                f = j.children(".mCustomScrollBox"),
                h = f.children(".mCSB_container"),
                g = f.children(".mCSB_scrollTools"),
                i = g.children().children(".mCSB_dragger");
            f.unbind("mousewheel focusin mouseenter mouseleave touchend");
            h.unbind("touchstart touchmove");
            if (e) {
                if (j.data("horizontalScroll")) {
                    i.add(h).css("left", 0);
                } else {
                    i.add(h).css("top", 0);
                }
            }
            g.css("display", "none");
            h.addClass("mCS_no_scrollbar");
            j.data({ bindEvent_mousewheel: false, bindEvent_focusin: false, bindEvent_content_touch: false, bindEvent_autoHideScrollbar: false }).addClass("mCS_disabled");
        },
        destroy: function () {
            var e = c(this);
            e.removeClass("mCustomScrollbar _mCS_" + e.data("mCustomScrollbarIndex"))
                .addClass("mCS_destroyed")
                .children()
                .children(".mCSB_container")
                .unwrap()
                .children()
                .unwrap()
                .siblings(".mCSB_scrollTools")
                .remove();
            c(document).unbind("mousemove." + e.data("mCustomScrollbarIndex") + " mouseup." + e.data("mCustomScrollbarIndex") + " MSPointerMove." + e.data("mCustomScrollbarIndex") + " MSPointerUp." + e.data("mCustomScrollbarIndex"));
            c(window).unbind("resize." + e.data("mCustomScrollbarIndex"));
        },
    },
        d = {
            showScrollbar: function () {
                this.stop().animate({ opacity: 1 }, "fast");
            },
            hideScrollbar: function () {
                this.stop().animate({ opacity: 0 }, "fast");
            },
            mTweenAxis: function (g, i, h, f, o, y) {
                var y = y || {},
                    v = y.onStart || function () { },
                    p = y.onUpdate || function () { },
                    w = y.onComplete || function () { };
                var n = t(),
                    l,
                    j = 0,
                    r = g.offsetTop,
                    s = g.style;
                if (i === "left") {
                    r = g.offsetLeft;
                }
                var m = h - r;
                q();
                e();
                function t() {
                    if (window.performance && window.performance.now) {
                        return window.performance.now();
                    } else {
                        if (window.performance && window.performance.webkitNow) {
                            return window.performance.webkitNow();
                        } else {
                            if (Date.now) {
                                return Date.now();
                            } else {
                                return new Date().getTime();
                            }
                        }
                    }
                }
                function x() {
                    if (!j) {
                        v.call();
                    }
                    j = t() - n;
                    u();
                    if (j >= g._time) {
                        g._time = j > g._time ? j + l - (j - g._time) : j + l - 1;
                        if (g._time < j + 1) {
                            g._time = j + 1;
                        }
                    }
                    if (g._time < f) {
                        g._id = _request(x);
                    } else {
                        w.call();
                    }
                }
                function u() {
                    if (f > 0) {
                        g.currVal = k(g._time, r, m, f, o);
                        s[i] = Math.round(g.currVal) + "px";
                    } else {
                        s[i] = h + "px";
                    }
                    p.call();
                }
                function e() {
                    l = 1000 / 60;
                    g._time = j + l;
                    _request = !window.requestAnimationFrame
                        ? function (z) {
                            u();
                            return setTimeout(z, 0.01);
                        }
                        : window.requestAnimationFrame;
                    g._id = _request(x);
                }
                function q() {
                    if (g._id == null) {
                        return;
                    }
                    if (!window.requestAnimationFrame) {
                        clearTimeout(g._id);
                    } else {
                        window.cancelAnimationFrame(g._id);
                    }
                    g._id = null;
                }
                function k(B, A, F, E, C) {
                    switch (C) {
                        case "linear":
                            return (F * B) / E + A;
                            break;
                        case "easeOutQuad":
                            B /= E;
                            return -F * B * (B - 2) + A;
                            break;
                        case "easeInOutQuad":
                            B /= E / 2;
                            if (B < 1) {
                                return (F / 2) * B * B + A;
                            }
                            B--;
                            return (-F / 2) * (B * (B - 2) - 1) + A;
                            break;
                        case "easeOutCubic":
                            B /= E;
                            B--;
                            return F * (B * B * B + 1) + A;
                            break;
                        case "easeOutQuart":
                            B /= E;
                            B--;
                            return -F * (B * B * B * B - 1) + A;
                            break;
                        case "easeOutQuint":
                            B /= E;
                            B--;
                            return F * (B * B * B * B * B + 1) + A;
                            break;
                        case "easeOutCirc":
                            B /= E;
                            B--;
                            return F * Math.sqrt(1 - B * B) + A;
                            break;
                        case "easeOutSine":
                            return F * Math.sin((B / E) * (Math.PI / 2)) + A;
                            break;
                        case "easeOutExpo":
                            return F * (-Math.pow(2, (-10 * B) / E) + 1) + A;
                            break;
                        case "mcsEaseOut":
                            var D = (B /= E) * B,
                                z = D * B;
                            return A + F * (0.499999999999997 * z * D + -2.5 * D * D + 5.5 * z + -6.5 * D + 4 * B);
                            break;
                        case "draggerRailEase":
                            B /= E / 2;
                            if (B < 1) {
                                return (F / 2) * B * B * B + A;
                            }
                            B -= 2;
                            return (F / 2) * (B * B * B + 2) + A;
                            break;
                    }
                }
            },
            mTweenAxisStop: function (e) {
                if (e._id == null) {
                    return;
                }
                if (!window.requestAnimationFrame) {
                    clearTimeout(e._id);
                } else {
                    window.cancelAnimationFrame(e._id);
                }
                e._id = null;
            },
            rafPolyfill: function () {
                var f = ["ms", "moz", "webkit", "o"],
                    e = f.length;
                while (--e > -1 && !window.requestAnimationFrame) {
                    window.requestAnimationFrame = window[f[e] + "RequestAnimationFrame"];
                    window.cancelAnimationFrame = window[f[e] + "CancelAnimationFrame"] || window[f[e] + "CancelRequestAnimationFrame"];
                }
            },
        };
    d.rafPolyfill.call();
    c.support.touch = !!("ontouchstart" in window);
    c.support.msPointer = window.navigator.msPointerEnabled;
    var a = "https:" == document.location.protocol ? "https:" : "http:";
    c.event.special.mousewheel || document.write('<script src="' + a + '//cdnjs.cloudflare.com/ajax/libs/jquery-mousewheel/3.0.6/jquery.mousewheel.min.js"></script>');
    c.fn.mCustomScrollbar = function (e) {
        if (b[e]) {
            return b[e].apply(this, Array.prototype.slice.call(arguments, 1));
        } else {
            if (typeof e === "object" || !e) {
                return b.init.apply(this, arguments);
            } else {
                c.error("Method " + e + " does not exist");
            }
        }
    };
})(jQuery);


(function ($) {

    $.fn.shuffle = function () {

        var allElems = this.get(),
            getRandom = function (max) {
                return Math.floor(Math.random() * max);
            },
            shuffled = $.map(allElems, function () {
                var random = getRandom(allElems.length),
                    randEl = $(allElems[random]).clone(true)[0];
                allElems.splice(random, 1);
                return randEl;
            });

        this.each(function (i) {
            $(this).replaceWith($(shuffled[i]));
        });

        return $(shuffled);

    };

})(jQuery);



;
