$(document).ready(function(){
    $('#frontpage-teaser .box-hover').click(function(){
        document.location.href = $('a.btn-yellow', $(this)).attr('href');    
    });
    $('.news-holder .box').click(function(){
        if ($('a.btn-yellow', $(this)).hasClass('btn-youtube')){
            $('a.btn-yellow', $(this)).trigger('click'); 
        }else{
            document.location.href = $('a.btn-yellow', $(this)).attr('href');
        }
    });
    $("a.btn-youtube").click(function(){
        $.fancybox({
            'padding' : 10,
            'showCloseButton' : true,
            'autoScale' : false,
            'href' : this.href.replace(new RegExp('watch\\?v=', 'i'), 'embed/') + '?rel=0&autoplay=1',
            'type' : 'iframe'
        });
        return false;
    });
    $("a.btn-vimeo").click(function(){
        $.fancybox({
            'padding' : 0,
            'showCloseButton' : true,
            'autoScale' : false,
            'href' : this.href.replace(new RegExp("([0-9])","i"),'moogaloop.swf?clip_id=$1'),
            'type' : 'swf',
            'swf' : {'wmode' : 'transparent', 'allowfullscreen' : 'true'}
        });
        return false;
    });
    /* Newsletter signup */
    $('#newsletter-signup input[type="text"]').focus(function(){
        if ($(this).val() == 'Uw e-mailadres'){
            $(this).val('');
        }    
    });
    $('#newsletter-signup input[type="text"]').blur(function(){
        if ($(this).val() == ''){
            $(this).val('Uw e-mailadres');
        }    
    });
    $('#newsletter-signup').submit(function(){
        // Perform ajax request
        $.ajax({
           url : $('#newsletter-signup').attr('action'),
           type : 'post',
           data : $('#newsletter-signup').serialize(),
           beforeSend : function(){
            $('#newsletter-signup-message').html('<p>Bezig met verzenden...</p>');
           },
           success : function(data){
            $('#newsletter-signup-message').html(data);
           }     
        });
        // Default return
        return false;
    });
    /* Fix visuals */
    var _visualheight = $('#content').height();
    $('#nav-visual').css({'overflow' : 'hidden'}).height(_visualheight-33);
    if ($('#nav-visual img').height() < _visualheight){
        $('#nav-visual img').height(_visualheight-33);
    }
});
