Drupal.behaviors.fancyhover = function (context)
{
  $('a.fancyhover').each(function(i){

    //construim div-ul de hover
    var title = $(this).attr('title');
    if (title.indexOf(' - ') > -1)
    {
      var split = title.split(' - ', 2);
      title = split[0] + '<br/>' + split[1];
    }
    $(this).append('<div class="fancyhover-hover"><h2>' + title + '</h2></div>');
    $('.fancyhover-hover', this).height($(this).children('img:first').height());
    $('.fancyhover-hover', this).width($(this).children('img:first').width());
    $('.fancyhover-hover h2', this).width($(this).children('img:first').width());

    //adaugam evenimentul de hover
    $(this).hover(
      function (){
        $('.fancyhover-hover', this).stop().css("opacity", 0).show().fadeTo(300, 0.70);
      },
      function (){
        $('.fancyhover-hover', this).fadeOut(300);
      });
  })
}

