/***
@title:
Ajax Loader
@version:
1.0
@author:
Andreas Lagerkvist
@date:
2008-09-25
@url:
http://andreaslagerkvist.com/jquery/ajax-loader/
@license:
http://creativecommons.org/licenses/by/3.0/
@copyright:
2008 Andreas Lagerkvist (andreaslagerkvist.com)
***/
jQuery.fn.ajaxLoader = function (conf) {
	var config = jQuery.extend({
		className:		'jquery-ajax-loader', 
		fadeDuration:	500
	}, conf);

	return this.each(function () {
		var t = jQuery(this);

		if (!this.ajaxLoaderObject) {
			var offset = t.offset();
			var dim = {
				left:	offset.left, 
				top:	offset.top, 
				width:	t.outerWidth(), 
				height:	t.outerHeight()
			};

			this.ajaxLoaderObject = jQuery('<div class="' + config.className + '"></div>').css({
				position:	'absolute', 
				left:		dim.left + 'px', 
				top:		dim.top + 'px',
				width:		dim.width + 'px',
				height:		dim.height + 'px'
			}).appendTo(document.body).hide();
		}

		this.ajaxLoaderObject.fadeIn(config.fadeDuration);
	});
};

jQuery.fn.ajaxLoaderRemove = function () {
	return this.each(function () {
		if (this.ajaxLoaderObject) {
			this.ajaxLoaderObject.fadeOut(500);
		}
	});
};

