jQuery.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+')' );
          $(this).show();
       });
    });

   return this;
 }
jQuery(document).ready( function() {
$('body').prepend('<div id="backgroundimage"></div>');
jQuery('#backgroundimage').hide();
jQuery('#backgroundimage').smartBackgroundImage(bgurl);
});

