(function($) {
	$.fn.extend({
		preload: function(images, callback) {
			var		element = this;
			var		count = 0;
			
			// validate images
			if((images === undefined) || (images.length <= 0)) { return this; }
			
			// hide element
			$(element).hide();
			
			// preload images
			$(images).each(function() {
				$('<img>').attr({ src: this }).load(function() {
					count++;
					if(count == images.length) {
						// show element
						$(element).show();
						
						// call callback
						if((callback !== undefined) && (callback instanceof Function)) {
							callback();
						}
					}
				});
			});
			
			return this;
		}
	});
})(jQuery);

