jQuery(document).ready(function($) {
	if(!($.browser.mozilla || ($.browser.msie && $.browser.version > 6))) return;

	$('img').each(function(){
		var width = $(this).width();
		var height = $(this).height();
		var img = $('<img src="gfx/loading.gif" class="loading" alt="Lade..." />').css({
			'margin-top': Math.floor((height/2-8))+'px',
			'margin-left': Math.floor((width/2-8))+'px'
		});
		var div = $('<div class="loader"></div>').css({
			display: 'inline-block',
			width: width+'px',
			height: height+'px'
		});
		$(this).wrap(div).parent().prepend(img);
		$(this).hide();

		if(this.complete || ($.browser.msie && parseInt($.browser.version) == 6)) $(this).trigger("load");
	});

	$(window).load(function(){
		$('img.loading').remove();
		$('div.loader').each(function(){
			var $c = $(this).contents();
			//alert(c);
			$(this).before($c);
			$c.show();
			$(this).remove();
		});
	});
});
