$(function() {
    // Configura as janelas modais
    $.nyroModalSettings({
        processHandler: function(settings) {
            $.nyroModalSettings({
                type: 'swf',
                height: 355,
                width: 425,
                swf: {
                    allowFullScreen : 'true'
                }
            });
            $('#nav').animate({
                opacity : '0.0'
            });
        },
        endRemove : function() {
            $('#nav').animate({
                opacity : '1'
            });
        }
    });

    $('#videos .video-item a').click(function(e) {


        var titulo = this.title;
        // URL do vídeo
        var url = this.href;

        // Regex de checagem
        var er = /unstv\/([0-9]+)\/([\w0-9-_]+)/;

        // Divide o casamento da Regex com a URL do vídeo
        var matriz = er.exec(url);

        // Obtém o nome do vídeo
        var movie = matriz[2];

        //	Coisas do plugin
        e.preventDefault();

        // Gera a janela modal namualmente
        $.nyroModalManual({
            title : titulo,
            url: '/assets/player.swf?movie='+movie+'&autoplay=on'
        });

        // Retorna falso
        return false;
    });
});