// Initialization
$.fade = {
	init: function() {
		for (module in $.fade) {
			if ($.fade[module].init)
				$.fade[module].init();
		}
	}
};

$(document).ready($.fade.init);

$.fade.hover = {
	init: function() {
		$('IMG.FadeButton')
			.bind('mouseover', this.enter)
			.bind('mouseout', this.exit)
			.each(this.preload);
	},
	preload: function() {
		this.preloaded = new Image;
		this.preloaded.src = this.src.replace(/^(.+)(\.[a-z]+)$/, "$1_over$2");
		this.delay=parseInt(this.className.replace(/^(.+)delay_([0-9]+)$/,"$2"));
		this.delay=isNaN(this.delay)?0:this.delay;
		$(this).wrap('<div class="fade_wrap"></div>');
		$(this).parent().width($(this).width());
		$(this).parent().height($(this).height());
//		$(this).animate({opacity:0},0);
//		$(this).delay(this.delay*1000).animate({opacity:1},1000,
//			function(){
				$(this).parent().css("background", "url('"+this.preloaded.src+"') 0 0 no-repeat")
//			}
//		);
	},
	enter: function() {
		$(this).stop(true,true);
		$(this).animate({opacity:0},500);
	},
	exit: function() {
		$(this).stop(true,true);
		$(this).animate({opacity:1},500);
	}
};

//EOF
