jQuery(document).ready(function() {
    $("#url-iframe").fancybox({
        'width'				: 800,
        'height'			: '75%',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'type'				: 'iframe'
    });

    $("a[rel=modal-url-iframe], a.modal-url-iframe").fancybox({
        'width'				: 800,
        'height'			: '75%',
        'autoScale'     	: false,
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'type'				: 'iframe'
    });

    $("a[rel=modal-clip], a.modal-clip").click(function() {
        $.fancybox({
            'padding'		: 0,
            'titlePosition'		: 'inside',
            'autoScale'		: false,
            'transitionIn'	: 'none',
            'transitionOut'	: 'none',
            'title'			: this.title,
            'width'			: 680,
            'height'		: 495,
            'href'			: this.href.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'onClosed'                  : function(){
                $.destroy_iframes;
            },
            'type'			: 'swf',
            'swf'			: {
                'wmode'				: 'transparent',
                'allowfullscreen'	: 'true'
            }
        });

        return false;
    });

    $("a[rel=modal-flv], a.modal-flv").fancybox({
        'padding'		: 0,
        'titlePosition'		: 'inside',
        'autoScale'		: false,
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'onClosed'                  : function(){
            clearIframe();
            //$.destroy_iframes;
        },
        'width'			: 680,
        'height'		: 550,
        'type'				: 'iframe'
    });

    $("rel=modal-audio, .modal-audio").fancybox({
        'padding'		: 0,
        'titlePosition'		: 'inside',
        'autoScale'		: false,
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'width'			: 680,
        'height'		: 495
    });

    $("rel=modal-resources, .modal-resources").fancybox({
        'padding'		: 0,
        'titlePosition'		: 'inside',
        'autoScale'		: false,
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'width'			: 400,
        'height'		: 300,
        'scrolling'             : 'no'
    });
	
    $("rel=picture-modal, .picture-modal").fancybox({
        'padding'		: 0,
        'titlePosition'		: 'inside',
        'autoScale'		: false,
        'transitionIn'		: 'none',
        'transitionOut'		: 'none',
        'width'			: 400,
        'height'		: 300,
        'scrolling'             : 'no',
        'type'				: 'iframe'
    });
});

function clearIframe()
{
    $("#fancybox-warp").load('/empty.html');
    $("#fancybox-frame").load('/empty.html');
    $("#fancy_content").load('/empty.html');
    $("#fancy_ajax").empty();
}


