;(function($) {
	$.fn.preloading = function(options) {
		var settings = {
			speed: 500,
			delay: 555,
			setParent: false,
			finish: null
		};
		if (options) $.extend(settings, options);
		
		var $images = $(this);
		
		var init = function() {
			if ( !$images.size() ) return false;
			
			$(window).bind('load', function() {
				$images.each(function() {
					var _this = $(this);
					_this.parent().width(_this.width()).height(_this.height());
					_this.css('visibility', 'visible');
				});
				
				$images.hide();
				var size = $images.size();
				var index = 0;
				var timer = setInterval(function() {
					if ( index >= size ) {
						clearInterval(timer);
						if ( settings.finish ) {
							settings.finish.call($images);
						}
					}
					$images.eq(index++).fadeIn(settings.speed);
				}, settings.delay);
			});
		};
		
		init();
	};
})(jQuery);
