// Custom JS

$(document).ready(function(){
    
    $('a[rel="videobox"]').lightBox({
        containerBorderSize: 0,
        videoMaxWidth:708,
        containerBorderColor:'#333333',
        controllerColor:'#000000',
        imageBtnClose: '/assets/templates/filmformat.ch/images/close-top.png',
        imageLoading:  '/assets/templates/filmformat.ch/images/loading.gif',
        displacement:  220,
        siteUrl: 'http://' + window.location.hostname + '/',
        enlargeVideo: true
    });
    
    $('.leftColumn,.imageColumn').each(function(){    
        $(this).find('a[rel^="lightbox"]').lightBox({
            containerBorderColor:'#333333',
            containerBorderSize: 0,
            imageLoading:  '/assets/templates/filmformat.ch/images/loading.gif',
            imageBtnClose: '/assets/templates/filmformat.ch/images/close-top.png',
            imageBtnPrev:  '/assets/templates/filmformat.ch/images/prev.png',
            imageBtnNext:  '/assets/templates/filmformat.ch/images/next.png',
            txtImage:      'Bild',
            txtOf:	       'von',
            displacement:  220
            });
    });    

    $('.video img')
        .bind('overlay', function () {
    
        var imgHeight = $(this).attr('height');
        var imgWidth = $(this).attr('width');
        
        $(this).before('<div class="overlay" style="width:'+imgWidth+'px;height:'+imgHeight+'px;"></div>');
        })
        .trigger('overlay');
        
    $('.video a').mouseenter(function () {
        $(this).children('.overlay').css('display', 'none');
        
        var h2HTML = $(this).siblings('h2').html();
        var h5HTML = $(this).siblings('h5').html();
        
        $('#videoTitle h2').html(h2HTML);
        $('#videoTitle h2').css('width', function(){
            $(this).width() + 'px';
        });
        $('#videoTitle h5').html(h5HTML);
    });
    $('.video a').mouseleave(function(){
        $(this).children('.overlay').css('display', 'block');    
        
        $('#videoTitle h2').html('');
        $('#videoTitle h5').html('');

    });
    
/*     $('.expandable-body').hide(); */
    
    $('.expandable-header').click(function(){
        var body = $(this).next('.expandable-body');
        if (body.css('display') == 'none') {
            body.slideDown('medium');
        } else {
            body.slideUp('medium');
        }
    });
    
});

