/*
 * Waiting 1.0 - jQuery Plugin
 * http://www.smartango.com/articles/jquery.waiting.plugin
 * Copyright (c) 2009 Daniele Cruciani
 * Dual licensed under the MIT and GPL licenses
 */

(function($){

$.fn.waiting = function(options) {
	var settings = $.extend({
		css: {'opacity':'0.6', 'background-color':'#777', 'text-align':'center', 'font-size':'25px', 'text-decoration':'blink', 'color':'black', 'padding-top':'20%', 'font-weight':'bold'},
		imgsrc: "aj-blue.gif",
		text: 'Deleting...'
	},options);
	var offset = this.offset();
	var height = this.height();
	var height = '100%';
	var width = this.width();
	var width = '100%';
	var id = this[0].id;
	var newid = id + "waiting";
	this[0].waitid = newid;
	var div = $("<div />").css({'position':'absolute','top':offset.top,'left':offset.left,'height':height,'width':width}).css(settings.css)
	.attr('id',newid).appendTo("body");
	div.html(settings.text);
	var img = $("<img />").attr("src",settings.imgsrc);
	var imgheight = img.height();
	var imgwidth = img.width();
	img.css({'position':'absolute','top':((height/2)-(imgheight/2))/*offset.top +(height/2)-(imgheight/2)*/,'left':((width/2)-(imgwidth/2)),'z-index':3000});
	img.appendTo(div);
	return this;
}

$.fn.stopWaiting = function() {
	var waitid = this[0].waitid;
	$("#"+waitid).remove();
	return this;
}

})(jQuery);

