$(document).ready(function(){
       
    // open in new window
    $('a[rel*=external]').click(function(event){
        window.open(this.href);
        event.preventDefault();
    });
    $('a[rel*=nofollow]').click(function(event){
        window.open(this.href);
        event.preventDefault();
    });
    
    
    $('.mceTmpl a').click(function(event){
        if ( this.rel == 'external')return;
        if ( this.rel == 'nofollow')return;
        if (!$(this).hasClass('fancybox')){            
            window.open(this.href);
            event.preventDefault();
        } 
    });
    
    
    $('a[rel=lightbox]').filter(function(){
        this.rel="galery";
        $(this).addClass('fancybox');
    /* $(this).css('border','solid 1px red'); */
    });
    $('a[rel=galery]').filter(function(){
        $(this).addClass('fancybox');
    });
    
    $("a.fancybox").fancybox({
        'transitionIn'	:	'elastic',
        'transitionOut'	:	'elastic',
        'speedIn'		:	600,
        'speedOut'		:	200,
        'hideOnOverlayClick': true,
        'hideOnContentClick': false,
        'overlayShow'       : true,
        'overlayOpacity'    : 0.5,
        'overlayColor'      : '#000'
	
    });
});
