(function($) {
  	$.fn.imageLoader = function(params) {
		return this.each(function(){
			$(this).hide();
			var $this = $(this);
			var img = new Image();
			var src = $(this).attr('src');
			var w = $(this).css('width');
			var h = $(this).css('height');
			var parent = $(this).parent();		
			$(parent)
				.css('width',w)
				.css('height',h)
				.addClass('loading');
			$(img)
			.load(function () {
				$this.fadeIn();
				$(parent).removeClass('loading');
				//$(parent).removeAttr('style');
			})
			.attr('src',src);
		});
  	};
})(jQuery);
$(function () {
	// this selector needs to be the image(s)
	// that are being loaded
	$('.large-image').imageLoader();
});
