/**
* preloadr: a jQuery Plugin
* @author: Trevor Morris (trovster)
* @url: http://www.trovster.com/lab/code/plugins/jquery.preloadr.js
* @documentation: http://www.trovster.com/lab/plugins/preloadr/
* @published: 11/09/2008
* @updated: 29/09/2008
*
* @notes: 
* Convention *I* use:
*  - $var is a jQuery object
*  - Quote key/value pairs
*  - Use o['key'] syntax when reading key/value
*/
if(typeof jQuery != 'undefined') {
	jQuery(function($) {
		$.fn.extend({
			preloadr: function(options) {
				var settings = $.extend({}, $.fn.preloadr.defaults, options);
				
				return this.each(
					function() {
						if($.fn.jquery < '1.2.6') {return;}
						var $t = $(this);
						var o = $.metadata ? $.extend({}, settings, $t.metadata()) : settings;
						
						var targetUrl = o.replaceWith;
						var image = new Image();
						image.onload = function(){
							$t.attr('src', targetUrl);
						}
						image.src = targetUrl;
					}
				);
			}
		});
		
		/**
		* Set your Plugin Defaults Here…
		*/
		$.fn.preloadr.defaults = {
			replaceWith: null
		};
	});
}
