﻿
function ExternalLinks() {
    if (!document.getElementsByTagName) return;
    var anchors = document.getElementsByTagName("a");
    for (var i = 0; i < anchors.length; i++) {
        var anchor = anchors[i];
        if (anchor.getAttribute("href") && anchor.getAttribute("rel") == "external")
            anchor.target = "_blank";
    }
}

function ActivarEnlaceVideoYoutube(selector, url, texto) {
    $(selector).click(function() {
        $.fancybox({
            'modal': false,
            'autoScale': false,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'titleShow': true,
            'titlePosition': 'inside',
            'titleFormat': function() { return texto; },
            'width': 400,
            'height': 300,
            'href': url.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type': 'swf',    // <--add a comma here
            'swf': { 'allowfullscreen': 'true' } // <-- flashvars here
        });
        return false;
    });
}

/*function GetYoutubeId(url) {
    var ytid = url.match("[\\?&]v=([^&#]*)");
    ytid = ytid[1].replace(/^\s+/g, '').replace(/\s+$/g, '');
    return ytid;
};

function ActivarEnlaceVideoYoutube(selector, imagen, url, texto) {
    //cargar imagen
    /*var codigo = GetYoutubeId(url);
    
    $(imagen).attr('src', 'http://img.youtube.com/vi/' + codigo + '/0.jpg');

    //cargar fancy
    $(selector).click(function() {
        $.fancybox({
            'modal': false,
            'autoScale': false,
            'transitionIn': 'elastic',
            'transitionOut': 'fade',
            'titleShow': true,
            'titlePosition': 'inside',
            'titleFormat': function() { return texto; },
            'width': 400,
            'height': 300,
            'href': url.replace(new RegExp("watch\\?v=", "i"), 'v/'),
            'type': 'swf',    // <--add a comma here
            'swf': { 'allowfullscreen': 'true'} // <-- flashvars here
        });
        return false;
    });
}*/

function Inicio() {
    ExternalLinks();
}

$(document).ready(function() {
    Inicio();
});

