$(document).ready(function () {
                   let searchbox = document.querySelector("input.search-input");
                   let searchIcon = document.getElementById("customSearchIcon");
        
                   // Open search in a new tab when Enter key is pressed 
                   $(searchbox).on("keydown", (event) => {
                       if (event.key === "Enter") {
                           //console.log("Enter key pressed");
                           let query = searchbox.value;
                           if (query) {
                           let searchUrl = "/search?q=" + encodeURIComponent(query);
                           console.log("Opening new tab:", searchUrl);
                              let newTab = window.open(searchUrl, "_blank");
                                 if(!newTab)
                                 {
                                    alert("Please allow pop-ups for this site.");
                                 }         
                                    }
                       }
                      });
                      // Open search in new tab when search icon is clicked.
                       searchIcon.addEventListener("click", function (event) {
                       //console.log("search button is clicked");
                      
                       let query= searchbox.value;
                       if (query) {
                         let searchUrl = "/search?q=" + encodeURIComponent(query);
                         //console.log("Opening new tab", searchUrl);
                         window.open(searchUrl, "_blank"); // Open in a new tab
                       }
                      });
}); 
