$.fadeElement = {init: function() {for (module in $.fadeElement){if ($.fadeElement[module].init) $.fadeElement[module].init();}}};
$(document).ready($.fadeElement.init);
$.fadeElement.start = {
	init: function() {$('.FadeElement').each(this.preload);},
	preload: function() {
		var pos = $(this).position();
		var h = $(this).outerHeight({margin:true})+10;
		var w = $(this).outerWidth({margin:true})+10;
		this.sid = $(this).attr("id")+'_shade';
		this.swait = 0;
		this.snum = $(this).find("img").length-1;
		this.delay=parseInt(this.className.replace(/^(.+)delay_([0-9]+)$/,"$2"));
		this.delay=isNaN(this.delay)?0:this.delay;
		var target = this;
//		console.log(pos.top+':'+pos.left+':'+w+':'	+h)
		$(this).after('<div id="'+target.sid+'" style="position:absolute;background-color:white;top:'+(pos.top-3)+'px;left:'+(pos.left-3)+'px;width:'+w+'px;height:'+h+'px;"></div>');
		$(this).css({visibility:"visible"});
		$(this).find("img").each(function(){
			var src = $(this).attr("src");
			if(src!=undefined){
				var img = new Image();
				$(img).load(function(){
					if(target.swait<target.snum){
						target.swait++;
					}else{
						$('#'+target.sid).delay(target.delay*1000).animate({opacity:0},1000, function(){$(this).remove();});
					}
				}).error(function () {
				}).attr('src', src);
			}
		});
		if(target.snum<0){
			$('#'+target.sid).delay(target.delay*1000).animate({opacity:0},1000, function(){$(this).remove();});
		}
	}
};
//EOF


