Extract Fancybox logic to separate functions