/*
 * 'whenLoaded' jQuery plugin
 *
 * @author James Padolsey / R
 * @description Runs a callback function (specified as argument) when all selected elements have loaded.
 *              Works only with certain elements, i.e. those which have an onload event (e.g. iframe,img etc.)
 * @namespace jQuery.whenLoaded
 * @namespace jQuery.fn.whenLoaded
 * @version 2.0
 * 
 */

(function($){
    $.fn.whenLoaded = function(fn){

        if ( $(this).attr("complete") )
        {
          fn.call();
        }
        else
        {
          $(this).load(function(){
            fn.call();
          });
        }
    }
})(jQuery);