$(document).ready(function() {
    
    // Alle links met rel="external" in een nieuw venster openen
    $("a[rel=external]").each(function(i){
        this.target="_blank";
    });

    
    // Cufon
    doCufon(); 
    
    $('.social-media-button-stats').click(function() {
    	sModule = $(this).data('module');
    	sType = $(this).data('type');
		$.post(Website.Config.sBaseUrl + 'stats_social_media/statistiek/set-social-media', {nodeId : Website.Config.iNodeId , used_module : sModule, type : sType});
    });
    
    
    //De hele themblokken op de homepage klikbaar maken
    $(".thema-blok").click(function(){
         window.location= $(this).find("a").attr("href");
         return false;
    }); 
    
    $(".navigatie-blok").click(function(){
        window.location = $(this).find("a").attr("href");
        return false;      
    });
    
    $("ul#thema-navigatie-blokken li").click(function(){
        window.location = $(this).find("a").attr("href");
        return false;
    });    
    
    $("#nieuws-shortlist ul li").click(function(){
        window.location = $(this).find("a").attr("href");
        return false;
    });
    
    
    $(".stelling-form input").uniform();
    $("#rekentool input").uniform();
    $("#cosmetica_filter input, #cosmetica_filter select").uniform();
    $(".donatie-form input:not([type='submit']), .donatie-form select").uniform();    
    $("form#aanmeldFormulier input:not([type='submit']), form#aanmeldFormulier select").uniform();    
    doEqualHeight();

});




function doCufon() {

    Cufon('.cufon', {
        hover: true
    });    
    
    Cufon.replace('h1');
    Cufon.replace('h2');
    Cufon.replace('h3');
    Cufon.replace('h4');
    Cufon.replace('#stemmen span');
    Cufon.replace('#donatie-balk-inner a#donatie-knop');
    Cufon.replace('#aanmeldFormulier input#submit');
    Cufon.replace('ul.donatie-progress li span'); 
    Cufon.replace('#main-visual #slider-code .pager li a'); 
    

}

function doEqualHeight(){
    //Nieuwsberichten op de homepage even hoog maken, zodat de border mooi doorloopt.
    var highestCol = Math.max($('#nieuws-wrap .nieuws-item:nth-child(1)').height(),$('#nieuws-wrap .nieuws-item:nth-child(2)').height());
    $('#nieuws-wrap .nieuws-item').height(highestCol);
    
    var highestCol = Math.max($('#nieuws-wrap .nieuws-item:nth-child(1) h3').height(),$('#nieuws-wrap .nieuws-item:nth-child(2) h3').height());
    $('#nieuws-wrap .nieuws-item h3').height(highestCol);
    
    
    var highestCol = Math.max($('#interactie-wrap .interactie-blok:nth-child(1)').height(),$('#interactie-wrap .interactie-blok:nth-child(2)').height(),$('#interactie-wrap .interactie-blok:nth-child(3)').height());
    $('#interactie-wrap .interactie-blok').height(highestCol);
    
}

$(document).ajaxSuccess(function() {
    Cufon.refresh();
});

