(function($) {

$.showAlert   = function(opts) { showAlertWindow(opts); };
$.hideAlert = function(opts) {  close(opts); };

$.showAlert.defaults = {
    message:  '<p>Processing, Please wait...</p>'
};

function showAlertWindow(opts) {
	$("#alertBoxOuter").remove();
	$("#alertUIBlocker").remove();
	
    var msg = opts && opts.message !== undefined ? opts.message : undefined;
    opts = $.extend({}, $.showAlert.defaults, opts || {});
    msg = msg === undefined ? opts.message : msg;

	var lyr1 = $('<div id="alertUIBlocker" style="z-index:1500;cursor:wait;border:none;margin:0;padding:0;width:100%;height:100%;position:fixed;"></div>');
	
	var lyr2 = $('<div align="center" class="loading" id="alertBoxOuter" style="z-index:1500;position:fixed;background-color:#EF3601; width:150px;	-moz-border-radius:5px;	-webkit-border-radius:5px;"><div><img src="/misc/images/processing.gif" height=50 width=150 /><div><div><b>'+msg+'</b></div></div>');

    $([lyr1[0],lyr2[0]]).insertBefore('body');
	lyr2.css({top: 0,left: (($(document).width()/2)-(($("#alertBoxOuter").width())/2))});
	lyr1.css({top: 0,left: (($(document).width()/2)-(($("#alertUIBlocker").width())/2))}); 
};

function close(opts) { 
  opts = $.extend({}, $.showAlert.defaults, opts || {});
  $("#alertUIBlocker").remove();
  $("#alertBoxOuter").remove();
  
};

})(jQuery);
