// JavaScript Document

(function($) {
	
	$.fn.imageLoader = function(options,callback) {
		var opts = {
			div: '',
			loaderClass : '',
			path: '',
			fade: true
		};
		
		if ( options ) { 
			$.extend( opts, options );
		}
		
		return this.each(function() {
			var $this = $(this);
			$this.mouseover(function() {
					$(opts.div).html('');
					$(opts.div).addClass(opts.loaderClass);
					img = new Image();
					$(img).load(function() {			 
						$(img).hide();
						$(opts.div).removeClass(opts.loaderClass).append(img);
						$(img).attr({'width':$(img).width(),'height':$(img).height()});
						if(opts.fade == true) {
							$(img).stop(true,true).fadeIn('slow');
						}
						else {
							$(img).stop(true,true).show();
						}
						if(typeof callback == 'function') callback(this);
					}).attr('src',opts.path+$this.attr('alt')+".png");
				}		
			);
								  
		}); // end each
		
	}; //end imageLoader
	
})(jQuery);
