// Anime Details Preview
$(document).ready(function() {
  $('a.tooltipEl, img.tooltipEl').tooltip({
    classes: {
      "ui-tooltip": "highlight"
    },
    position: {
      my: 'left center',
      at: 'right+0 center'
    },
    content: function(callback) {
      var animeId = $(this).attr('animeid');
      $.post('/theme/6anime/pages/ajax.details.php', {
        animeid: animeId
      }, function(data) {
        callback(data);
      });
    },
    open: function(event, ui) {
      ui.tooltip.hover(
        function() {
          $(this).stop(true).fadeTo(400, 1);
        },
        function() {
          $(this).fadeOut("400", function() {
            $(this).remove();
          })
        }
      );
    }
  });
});
 


// Ajax Search Function
$(document).ready(function () {
          // Send Search Text to the server
          $("#searching").keyup(function () {
            let searchText = $(this).val();
            if (searchText != "") {
              $.ajax({
                url: "/theme/6anime/pages/ajax.search.php",
                method: "post",
                data: {
                  query: searchText,
                },
                success: function (response) {
                  $("#search-suggest").html(response);
                },
              });
            } else {
              $("#search-suggest").html("");
            }
          });
          // Set searched text in input field on click of search button
        //   $(document).on("click", "a", function () {
        //     $("#searching").val($(this).text());
        //     $("#search-suggest").html("");
        //   });
        });