jQuery(document).ready(function () { // Hamburger menu (same as before) jQuery(".toggle-nav").click(function () { jQuery("#menu-menu-main").slideToggle('slow', 'swing'); }); // Submenu hover and click functionality function handleSubMenu() { if (window.innerWidth <= 768) { // Mobile view (adjust the breakpoint as needed) // Mobile - Toggle submenu on click jQuery('.menu-item-has-children > a').click(function (e) { var submenu = jQuery(this).siblings('ul'); if (submenu.is(':visible')) { submenu.stop(true, true).slideUp('slow', 'swing'); jQuery(this).removeClass('open'); } else { submenu.stop(true, true).slideDown('slow', 'swing'); jQuery(this).addClass('open'); } e.preventDefault(); // Prevent the default link action if necessary }); } else { // Desktop - Hover to show submenu jQuery('.menu-item-has-children').hover( function () { // On mouse enter, slide down the submenu jQuery(this).children('ul').stop(true, true).slideDown('slow', 'swing'); jQuery(this).children('a').addClass('open'); }, function () { // On mouse leave, slide up the submenu after a delay var menuItem = jQuery(this); setTimeout(function () { // Only close submenu if mouse leaves the entire menu item and submenu if (!menuItem.is(':hover') && !menuItem.children('ul').is(':hover')) { menuItem.children('ul').stop(true, true).slideUp('slow', 'swing'); menuItem.children('a').removeClass('open'); } }, 200); // Adjust delay if needed } ); // Optional: If you want to close the menu when mouse leaves the whole parent menu jQuery('.menu-item-has-children > ul').hover( function () { // Prevent the submenu from closing when hovering over the submenu }, function () { // If the mouse leaves the submenu, close it var menuItem = jQuery(this).parent(); menuItem.children('ul').stop(true, true).slideUp('slow', 'swing'); menuItem.children('a').removeClass('open'); } ); } } // Run the handleSubMenu function on page load and window resize handleSubMenu(); jQuery(window).resize(function () { handleSubMenu(); }); }); //chat box 360 jQuery(document).ready(function () { if ($("#kpd_koopidtag").length > 0) { $.getScript("https://us-east.dx.dialpad.com/static/common/js/koopid-embed.min.js").done(function () { kpde.server = "https://us-east.dx.dialpad.com"; $('a[href="#livechat"], a[href="livechat"]').on("click", function (e) { e.preventDefault(); var checker = setInterval(function () { if ($("#kpd_koopidtag").length) { $("#kpd_koopidtag").trigger("click"); } clearInterval(checker); }, 100); }); }); } }); //tabs script function openCourseType(evt, courseType) { var i, coursetabcontent, coursetablinks; coursetabcontent = document.getElementsByClassName("coursetabcontent"); for (i = 0; i < coursetabcontent.length; i++) { coursetabcontent[i].style.display = "none"; } coursetablinks = document.getElementsByClassName("coursetablinks"); for (i = 0; i < coursetablinks.length; i++) { coursetablinks[i].className = coursetablinks[i].className.replace(" coursetypeactive", ""); } document.getElementById(courseType).style.display = "block"; evt.currentTarget.className += " coursetypeactive"; } //accordian script jQuery('.accordion-cont').click(function(){ jQuery(this).toggleClass('accordion-active'); jQuery(this).parent().find('.arrow').toggleClass('arrow-animate'); jQuery(this).parent().find('.accordian-panel').slideToggle(280); }); // //pop-up script jQuery(function() { // Open jQuery('[data-popup-open]').on('click', function(e) { var targeted_popup_class = jQuery(this).attr('data-popup-open'); jQuery('[data-popup="' + targeted_popup_class + '"]').fadeIn(350); e.preventDefault(); }); // Close jQuery('[data-popup-close]').on('click', function(e) { var targeted_popup_class = jQuery(this).attr('data-popup-close'); jQuery('[data-popup="' + targeted_popup_class + '"]').fadeOut(350); e.preventDefault(); }); }); //search searchsubmit.setAttribute('value',''); jQuery("form#searchform input:first-of-type").attr("placeholder", " Search"); // // //chat box // function NewTab() { // window.open("https://static.zdassets.com/web_widget/latest/liveChat.html?v=10#key=safetyprovisions.zendesk.com", // "", "width=500, height=600"); // } // function NewTab() { // (function ($) { // if ($("#kpd_koopidtag").length > 0) { // $.getScript("https://us-east.dx.dialpad.com/static/common/js/koopid-embed.min.js").done(function () { // kpde.server = "https://us-east.dx.dialpad.com"; // $('a[href="#livechat"], a[href="livechat"]').on("click", function (e) { // e.preventDefault(); // var checker = setInterval(function () { // if ($("#kpd_koopidtag").length) { // $("#kpd_koopidtag").trigger("click"); // } // clearInterval(checker); // }, 100); // }); // }); // } // })(jQuery); // } //scroll to top mybutton = document.getElementById("myTopBtn"); // When the user scrolls down 20px from the top of the document, show the button window.onscroll = function() {scrollFunction()}; function scrollFunction() { if (document.body.scrollTop > 700 || document.documentElement.scrollTop > 700) { mybutton.style.display = "block"; } else { mybutton.style.display = "none"; } } // When the user clicks on the button, scroll to the top of the document function topFunction() { // Check if the browser supports smooth scrolling if ('scrollBehavior' in document.documentElement.style) { window.scrollTo({ top: 0, behavior: 'smooth' // Smooth scrolling for supported browsers }); } else { // Fallback for browsers that don't support smooth scrolling document.body.scrollTop = 0; // For Safari document.documentElement.scrollTop = 0; // For Chrome, Firefox, IE, and Opera } }