/* hover covers */
(function ($) {
Drupal.behaviors.kirjasampo = {
  attach: function(context) {
    // attach click function to our thumbnails which removes the default click action
    $('a.kulsa_thumb').click(function(e){
      e.preventDefault();
    });
    // create a variable of the original image so that we can add it back later
    var originalimg = $('.hovercarousel .carousel_orig_img').children('img').attr('src');
    //hover over and out functions
    function imgOver(){
      //grab the hrep attributes of the thumb to pass into the bigger image's source
      var image = $(this).attr('href');
      //$(this).parents('.hovercarousel .carousel_orig_img').children('.image').children('img').attr('src', image);
      $('.hovercarousel .carousel_orig_img').children('img').attr('src', image);
    }
    function imgOut(){
      //revert back to our original image
      //if($('.hovercarousel .carousel_orig_img').children('img').attr('src') == $(this).attr('href')) {
      //   $('.hovercarousel .carousel_orig_img').children('img').attr('src', originalimg);
      //}
      //alert('OUT');
    }
    // hoverIntent configuration
    var config = {    
      sensitivity: 3, // number = sensitivity threshold (must be 1 or higher)    
      interval: 0, // number = milliseconds for onMouseOver polling interval    
      over: imgOver, // function = onMouseOver callback (REQUIRED)    
      timeout: 50, // number = milliseconds delay before onMouseOut
      out: imgOut // function = onMouseOut callback (REQUIRED)    
    };
    // attaching hoverIntent to our thumbnails
    $('a.kulsa_thumb').hoverIntent(config);
  }
}
})(jQuery);
