$(function() {

    if($.browser.msie && $.browser.version > 9 || !$.browser.msie) {$('#no-ie').css({'visibility':'hidden'});
    }
    
    // Hide some element so they can be animated when background has loaded
    $('h2').next().toggle();

    $('#butterfly').css({'display':'none'});
    $('#zieook').css({'display':'none'});
    $('#footercontainer').css({'display':'none'});
    $('body').smartBackgroundImage('http://arievanboxel.nl/ee/images/uploads/margou200802.jpg');

});

/**
 * Use this plugin like
 * $('body').smartBackgroundImage('http://example.com/image.png');
 */
$.fn.smartBackgroundImage = function(url) {
    var t = this;
    //create an img so the browser will download the image:
    $('<img />')
    .attr('src', url)
    .load(function() {
        //attach onload to set background-image
        t.each(function() {
            $(this).css('backgroundImage', 'url(' + url + ')');
	    $('#butterfly').fadeIn(3000);
            $('#zieook').fadeIn(3000);
	    $('#footercontainer').fadeIn(3000);
            $('h2').next().toggle('short');
        });
    });
    return this;
}

