﻿jQuery(document).ready(function () {
    jQuery("div.aside").click(function () {
        var addr = $("a", this).attr("href");
        var title = $("a", this).attr("title");
        var showVideo = $("a", this).attr("class") == "showVideo";
        var newWindow = $("a", this).attr("target") == "_blank";
        if (showVideo) {
            addr = addr.replace(new RegExp("watch\\?v=", "i"), 'v/').replace(new RegExp("user/fizikTV#p/u/[0-9]+", "i"), 'v');
            jQuery.fancybox({
                'padding': 0,
                'autoScale': false,
                'transitionIn': 'none',
                'transitionOut': 'none',
                'title': title,
                'width': 680,
                'height': 495,
                'href': addr,
                'type': 'swf',
                'swf': {
                    'wmode': 'transparent',
                    'allowfullscreen': 'true'
                },
                'onStart': function () {
                    if ($.browser.msie || $.browser.opera) $('.video-wrapper').hide();
                },
                'onClosed': function () {
                    if ($.browser.msie || $.browser.opera) $('.video-wrapper').show();
                }
            });
        }
        else {
            if (newWindow)
                window.open(addr);
            else
                location.href = addr;
        }
        return false;
    });
});
