$(function(){
	if($('#ajax-loading-notifer').length==0){
		$('<div id="ajax-loading-notifer"></div>').appendTo('body');
	}
	
	$("#ajax-loading-notifer").bind("ajaxStart", function(){
		$(this).show();
	}).bind("ajaxStop", function(){
		$(this).hide();
	});

	if($('#ajax-error-msg').length==0){
		$('<div id="ajax-error-msg"></div>').appendTo('body');
	}	
	
	$("#ajax-error-msg")
	.bind("ajaxError", function(event, XMLHttpRequest, ajaxOptions, thrownError){
		$(this).html(XMLHttpRequest.responseText)
		.dialog({
			modal:true,
			close:function(){
				$("#ajax-error-msg").html("").dialog('destroy');
			},
			title: "Ajax Request Error",
			bgiframe: true
		});
	});	
});
