// FancyPlayer.js - A spicy mix of FancyBox and Flowplayer

$(document).ready(function() {

      /* ez a resz nyitja a kepet */
      $("a[rel=fancy-box-gallery]").fancybox({
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'titlePosition' 	: 'over',
        'titleFormat'		: function(title, currentArray, currentIndex, currentOpts) {
          return '<!--span id="fancybox-title-over">Képek: ' + (currentIndex + 1) + ' / ' + currentArray.length + (title.length ? ' &nbsp; ' + title : '') + '</span-->';
        }
      });

    /* ez a resz nyitja a videot */
    $(".video_link").each(function(){
        
        var videoclip=$(this).attr("rel");
       
        $(this).fancybox({
		'hideOnContentClick':false,
		'overlayOpacity' :.6,
		'zoomSpeedIn'    :400,
		'zoomSpeedOut'   :400,
		'easingIn'		 : 'easeOutBack',
		'easingOut'		 : 'easeInBack',
		'onComplete' :function (){
                        
			player = $f("fancybox-inner",swfplayer,{
				play:{opacity:0},
				clip:{
					autoPlay:true,
					autoBuffering:true,
					url:videoclip,
					onStart:function(clip){
						var wrap=jQuery(this.getParent());
						var clipwidth = clip.metaData.width;
						var clipheight= clip.metaData.height;
						var pos = $.fn.fancybox.getViewport();
						$("#fancy_outer").css({width:clipwidth,height:clipheight});
						$("#fancy_outer").css('left', ((clipwidth + 36) > pos[0] ? pos[2] : pos[2] + Math.round((pos[0] - clipwidth	- 36)	/ 2)));
						$("#fancy_outer").css('top',  ((clipheight + 50) > pos[1] ? pos[3] : pos[3] + Math.round((pos[1] - clipheight - 50)	/ 2)));
					},
					onFinish:function(){
						$('#fancy_close').trigger('click');
					}
				}
			});
			player.load();
			$('#fancy_close').click(function(){
				$("#fancy_div_api").remove();
			});
    } ,
		'onClosed':function(){
			$("#fancy_div_api").remove();
		}
	});
        
    });
}); 