$(document).ready(function() {
    $('a[href^=http]').not('a[href*="ronduithattem.nl"]').click(function() {
        _gaq.push(['_trackEvent', 'outgoing', 'Links' ,"'" + this.href + "'"]);
    });

    $('textarea.expanding').autogrow();
    $('img.vergrootbaar').each(function(){

        var this_src = $(this).attr('src');
        var this_alt = $(this).attr('alt');
        var this_w   = $(this).attr('width');
        var this_h   = $(this).attr('height');

        if (this_src.substring(0,10) == '/user/img/') {

            new_w = ( this_w && this_w > 0 ) ? this_w : 200;
            new_h = ( new_w * 2 )

            new_src = this_src.replace('/user/img/', '/imgsrc/'+new_w+'/'+new_h+'/user/img/');
            href    = this_src.replace('/user/img/', '/imgsrc/800/600/user/img/');

            $(this).attr({'src':new_src});
            $(this).wrap('<a href="'+href+'" title="'+this_alt+'" rel="enlarge" />');
        }
    });

    $('a[rel=enlarge], a.enlarge').live('click', function(e){
        $.fn.colorbox({href:$(this).attr('href'), title:$(this).attr('title'), open:true, transition:'fade', previous:'vorige', next:'volgende', close:'sluiten', current:'', innerWidth:'800px'});
        return false;
    });
});
