$(document).ready(function () {
  $(".thumbFoto").each(function(){
    var e=$(this);
    var imgsrc=$(this).css('background-image');
    if(imgsrc.lastIndexOf('")')>0){
      imgsrc=imgsrc.substring(5,imgsrc.lastIndexOf('")'));
    } else{
      imgsrc=imgsrc.substring(4,imgsrc.lastIndexOf(')'));
    }
    if(imgsrc!=''){
      e.qtip({ 
        hide: { when: "mouseout" , fixed: true },
        show: { solo: true },
        content: '<div style="text-align:center"><a href="'+e.attr('href')+'"><img src="'+imgsrc+'" alt="'+e.attr('title')+'"/></a></div>',
        api: {
          beforeShow: function() {
            this.options.position.adjust.x=($(this.elements.tooltip).width()+e.width())/-2;
            this.options.position.adjust.y=($(this.elements.tooltip).height()+e.height())/-2;
            this.updatePosition();
          }
        }  
      });
    }
  });
  
  $(".qtip-active").live('mouseout', function(){ $(this).hide(); });
});