﻿function icJq() {

    $('a[rel=lightbox]').fancybox();
    $('a[rel=lightbox group]').fancybox();

    $('a[rel=lightbox]').each(function (i) {

        if ($(this).attr('href').match(/youtube\.com/i)) {/* Youtube */
            $(this).fancybox({
                'padding': 0,
                'autoScale': false,
                'transitionIn': 'none',
                'transitionOut': 'none',
                'title': this.title,
                'width': 680,
                'height': 495,
                'href': $(this).attr('href').replace(new RegExp("watch\\?v=", "i"), 'v/'),
                'type': 'swf',
                'swf': { 'wmode': 'transparent', 'allowfullscreen': 'true' }
            });
            var results = $(this).attr('href').match("[\\?&]v=([^&#]*)");
            var vid = results[1];
            $(this).text("");
            $(this).append("<img style='border:none' src='http://img.youtube.com/vi/" + vid + "/2.jpg' /><div style='font-size:9px;letter-spacing:2px;width:122px'>" + this.title + "</div>");
        }
        else if ($(this).attr('href').match(/vimeo\.com/i)) {/* Vimeo */
            $(this).fancybox({
                'padding': 0,
                'autoScale': false,
                'transitionIn': 'none',
                'transitionOut': 'none',
                'title': this.title,
                'width': 680,
                'height': 495,
                'href': 'http://www.vimeo.com/moogaloop.swf?clip_id=' + $(this).attr('href').split('/')[3],
                'type': 'swf',
                'swf': { 'wmode': 'transparent', 'allowfullscreen': 'true' }
            });
            //$(this).text("PLAY VIDEO");
        }

    });

}

$(document).ready(function () {

    try { icJq() } catch (e) { };
    try { $('img.reflect').reflect() } catch (e) { };

    try { $('a.media').media(); } catch (e) { };
    try { $('.tooltip').tooltip({ showURL: false, showBody: " - " }); } catch (e) { };

});

var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_endRequest(function() {

    try { icJq() } catch (e) { };
    setTimeout("try { icJq() } catch (e) { };", 1500);
    setTimeout("try { $('img.reflect').reflect() } catch (e) { };", 1500);

    try { $('a.media').media(); } catch (e) { };
    try { $('.tooltip').tooltip({ showURL: false, showBody: " - " }); } catch (e) { };
    
});
    
 


