﻿$(document).ready(function() {

    try { $('a[rel=lightbox]').fancybox(); } catch (e) { };
    try { $('a[rel=lightbox group]').fancybox(); } catch (e) { };

    $('a[rel=lightbox]').each(function (i) {
        /*** SOCIAL SITES ***/
        /* Youtube */
        if ($(this).attr('href').match(/youtube\.com/i)) {
            $(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>");
        };
        /* Vimeo */
        if ($(this).attr('href').match(/vimeo\.com/i)) {
            $(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");
        };
        /*** /SOCIAL SITES ***/
    });

    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 { $('a[rel=lightbox]').fancybox(); } catch (e) { };
    try { $('a[rel=lightbox group]').fancybox(); } catch (e) { };

    $('a[rel=lightbox]').each(function (i) {
        /*** SOCIAL SITES ***/
        /* Youtube */
        if ($(this).attr('href').match(/youtube\.com/i)) {
            $(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>");
        };
        /* Vimeo */
        if ($(this).attr('href').match(/vimeo\.com/i)) {
            $(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");
        };
        /*** /SOCIAL SITES ***/
    });
    
	try { reflectionInit(); } catch (e) { };
	try { $('.reflect').reflect(); } catch (e) { }; 
	
	try{$('a.media').media();}catch(e){};
    try{$('.tooltip').tooltip({showURL: false,showBody: " - "});}catch(e){};
    });
    
 

