// Menu Justification snippet (function ($) { $.fn.justifyNav = function () { return this.each(function () { var $this = $(this), $children = $this.children(), containerWidth = $this.width(), linksWidth = 0, count = $children.length; $children.each(function () { linksWidth += $(this).outerWidth(); }); // Don't give the last item or the 2nd to last item any right margin, then float the last item right. // This will account for small errors in JQuery's calculation of the item widths. // Otherwise the list can overflow the container! var linkSpacing = Math.floor((containerWidth - linksWidth) / (count - 1)); $children .css('margin-right', linkSpacing + "px") .filter(":last") .css({ "margin-right": 0, "float": "right" }) .prev() .css({ "margin-right": 0 }); }); }; })(jQuery); // Menu hover and multi column height matching $('ul.nav li.dropdown').hover(function () { if (window.matchMedia("(min-width: 992px)").matches) { $(this).find('.dropdown-menu').stop(true, true).show(); if ($(this).attr('id') == "KnowledgeMenu") { setTimeout(ResizeMenuColumns(".knowledgeColumn"),200); } } }, function () { if (window.matchMedia("(min-width: 992px)").matches) { $(this).find('.dropdown-menu').stop(true, true).delay(200).fadeOut(200); } }); $(".columnResize").on("click", function () { if (window.matchMedia("(min-width: 992px)").matches) { ResizeMenuColumns($(this).data("target")); } }); /* Layout scripts */ var currentSize; function CheckSize() { var xs = window.matchMedia("(min-width: 480px) and (max-width: 767px)"); var sm = window.matchMedia("(min-width: 768px) and (max-width: 991px)"); var md = window.matchMedia("(min-width: 992px) and (max-width: 1199px)"); var lg = window.matchMedia("(min-width: 1200px)"); if (xs.matches && currentSize != "xs") { currentSize = "xs"; SmallSize(); } else if (sm.matches && currentSize != "sm") { currentSize = "sm"; SmallSize(); } else if (md.matches && currentSize != "md") { currentSize = "md"; LargeSize(); } else if (lg.matches && currentSize != "lg") { currentSize = "lg"; LargeSize(); } else { if ($(".navbar-nav").height() > 37) { console.log("Catch"); DoMenu() } } } function DoMenu() { $(".nav > li > a").each(function (index) { $(this).removeAttr('style'); }); //maxMenuWidth = navbar-collapse.width var maxAvailWidth = $(".navbar .collapse").width() - 8; // 6 is to account for the divider borders //numOfMenus = count .menu-top-label var menuItems = $(".menu-top-label"); var numOfMenus = $(menuItems).length; var cellSize = maxAvailWidth / numOfMenus; //for numOfMenus $(menuItems).each(function (index) { //get this item width var padding = (cellSize - $(this).outerWidth(true)) / 2; //add padding to left and right $(this).css({ "padding-left": padding + "px", "padding-right": padding + "px" }) }); } function RemoveMenu() { $(".nav > li > a").each(function (index) { $(this).removeAttr('style'); }); $(".dropdown-menu").each(function (index) { $(this).removeAttr('style'); }); } function SmallSize() { RemoveMenu(); } function LargeSize() { //FPOImages(); // Clean up left over styles from justifyNav() // $('.navbar-nav > li').removeAttr('style'); //setTimeout(DoMenu, 5); DoMenu(); } function ResizeMenuColumns(target) { if (target != undefined) { // Get an array of all element heights var elementHeights = $(target).map(function () { return $(this).height(); }).get(); // Math.max takes a variable number of arguments // `apply` is equivalent to passing each height as an argument var maxHeight = Math.max.apply(null, elementHeights); // Set each height to the max height $(target).height(maxHeight); } } function RemoveColumnSizing() { $(".knowledgeColumn").removeAttr('style'); } function CookieNotification() { var cookieNotificationShown = Cookies.get('CookieNotificationShown'); if (cookieNotificationShown != 1) { toastr.options = { "closeButton": true, "debug": false, "newestOnTop": false, "progressBar": false, "positionClass": "toast-bottom-full-width", "preventDuplicates": true, "onclick": null, "showDuration": "300", "hideDuration": "1000", "timeOut": "0", "extendedTimeOut": "1000", "showEasing": "swing", "hideEasing": "linear", "showMethod": "fadeIn", "hideMethod": "fadeOut" } toastr.options.onHidden = function () { Cookies.set('CookieNotificationShown', 1, { expires: 365 }); } toastr.warning("This website uses cookies for key functionality. By continuing to use this website you are giving consent to the use of cookies. Click here to read our Privacy Policy", "Cookie Notice"); } } /* Homepage */ var rotatorImages = ["ROTATOR01.jpg", "ROTATOR02.jpg", "ROTATOR03.jpg", "ROTATOR04.jpg", "ROTATOR05.jpg"]; var rotatorData = [{ Image: "ROTATOR01.jpg" },{ Image: "ROTATOR02.jpg" },{ Image: "ROTATOR03.jpg" },{ Image: "ROTATOR04.jpg" },{ Image: "ROTATOR05c.jpg" }]; var rotateCounter = 0; var prevRotatorBtn = 0; var autoRotater; var autoRotating = false; var rotatorLang = 'en'; function swapRotate() { if (rotatorData[rotateCounter].AppendLanguage) { $("#HomeRotatorImage img").prop('src', '/Content/images/home/' + rotatorData[rotateCounter].Image + rotatorLang + '.jpg'); } else { $("#HomeRotatorImage img").prop('src', '/Content/images/home/' + rotatorData[rotateCounter].Image); } $("#HomeRotatorImage").fadeIn(200); $("#RotatorBtn" + rotateCounter + " img").prop("src", "/Content/images/home/Rotator_On.png"); $("#RotatorBtn" + prevRotatorBtn + " img").prop("src", "/Content/images/home/Rotator_Off.png"); prevRotatorBtn = rotateCounter; SetButtons(); }; function Rotate(lang) { rotatorLang = lang; autoRotater = window.setInterval(RotateAuto, 5000); autoRotating = true; document.addEventListener("SizeChange", SetButtons, false); SetButtons(); } function RotateAuto() { prevRotatorBtn = rotateCounter; if (rotateCounter == rotatorData.length - 1) { rotateCounter = 0; } else { rotateCounter += 1; } $("#HomeRotatorImage").fadeOut(200, swapRotate); } function RotateStop() { window.clearInterval(autoRotater); autoRotating = false; } function RotateLeft() { if (autoRotating) { RotateStop(); } prevRotatorBtn = rotateCounter; if (rotateCounter == 0) { rotateCounter = rotatorData.length - 1; } else { rotateCounter -= 1; } $("#HomeRotatorImage").fadeOut(200, swapRotate); } function RotateRight() { if (autoRotating) { RotateStop(); } prevRotatorBtn = rotateCounter; if (rotateCounter == rotatorData.length - 1) { rotateCounter = 0; } else { rotateCounter += 1; } $("#HomeRotatorImage").fadeOut(200, swapRotate); } function RotateTo(target) { if (autoRotating) { RotateStop(); } rotateCounter = target; $("#HomeRotatorImage").fadeOut(200, swapRotate); } function SetButtons() { if (rotatorData[rotateCounter].FullImageLink) { $("#HomeRotatorImage").css("cursor", "pointer").on("click", function () { window.location = rotatorData[rotateCounter].FullImageLinkUrl; }); } else { $("#HomeRotatorImage").css("cursor", "default").off("click"); } } function ClearButtons() { $("#Btn1").hide(); $("#Btn2").hide(); } //function SetupHomeThumbnails() { // $(".homeThumbnailCell").on("mouseover", function () { // $(this).css("background-image", "url('/Content/images/Home/HOME_PRODUCT_" + $(this).data("name") + "_on.jpg')"); // }); // $(".homeThumbnailCell").on("mouseout", function () { // $(this).css("background-image", "url('/Content/images/Home/HOME_PRODUCT_" + $(this).data("name") + "_off.jpg')"); // }); //} var allImages = [ "ROTATOR01.jpg", "ROTATOR02.jpg", "ROTATOR03.jpg", "ROTATOR04.jpg", "ROTATOR05c.jpg", "HOME_PRODUCT_Lean_off.jpg", "HOME_PRODUCT_Lean_on.jpg", "HOME_PRODUCT_Custom_off.jpg", "HOME_PRODUCT_Custom_on.jpg", "HOME_PRODUCT_Facility_off.jpg", "HOME_PRODUCT_Facility_on.jpg", "HOME_PRODUCT_FirstAid_off.jpg", "HOME_PRODUCT_FirstAid_on.jpg", "HOME_PRODUCT_Furniture_off.jpg", "HOME_PRODUCT_Furniture_on.jpg", "HOME_PRODUCT_Matting_off.jpg", "HOME_PRODUCT_Matting_on.jpg", "HOME_PRODUCT_Signage_off.jpg", "HOME_PRODUCT_Signage_on.jpg", "HOME_PRODUCT_Striping_off.jpg", "HOME_PRODUCT_Striping_on.jpg" ]; var cache = []; // Arguments are image paths relative to the current page. $.preLoadImages = function () { var args_len = allImages.length; for (var i = args_len; i--;) { var cacheImage = document.createElement('img'); cacheImage.src = "/Content/images/home/" + allImages[i]; cache.push(cacheImage); } } /* Utility */ var currentSection function ShowContent(sectionId) { if (currentSection == null) { currentSection = $("div").find("[data-state='visible']").prop('id'); } if (currentSection == sectionId) { var state = $("#" + sectionId).data('state'); if (state == "hidden") { $("#" + sectionId).slideDown(); $("#" + sectionId + "Icon").prop("src", "/Content/images/minus.png"); $("#" + sectionId).data('state', "visible"); } else { $("#" + sectionId).slideUp(); $("#" + sectionId + "Icon").prop("src", "/Content/images/plus.png"); $("#" + sectionId).data('state', "hidden"); } } else { if (currentSection != "") { $("#" + currentSection).slideUp(); $("#" + currentSection + "Icon").prop("src", "/Content/images/plus.png"); $("#" + currentSection).data('state', "hidden"); } $("#" + sectionId).slideDown(); $("#" + sectionId + "Icon").prop("src", "/Content/images/minus.png"); $("#" + sectionId).data('state', "visible"); currentSection = sectionId; } } function ShowContentOnCheck(event) { var target = $(event.target).data("target"); if ($(event.target).is(':checked')) { $("#" + target).slideDown(); } else { $("#" + target).slideUp(); } }