$(document).ready(function()
{
	var AjaxCount = 0;

	// These give us the cool upper right red google like thing
	$("#notice")
	.ajaxStart(function()
	{
		$(this).show();
		$.blockUI({ 
			css: { 
				border: 'none', 
				padding: '15px', 
				backgroundColor: '#000', 
				'-webkit-border-radius': '10px', 
				'-moz-border-radius': '10px', 
				opacity: '.5', 
				color: '#fff' ,
				fontFamily: 'Arial, Helvetica, sans-serif',
				fontSize: '14px',
				lineHeight: '18px',
				fontWeight: 'bold'
		    },
			message: "Communicating with the server..."
		});
	})
	.ajaxStop(function()
	{
		if (AjaxCount == 0) 
		{
			$(this).hide();
			$.unblockUI();
		}
	});

	$("#msg")
	.ajaxComplete(function(request, settings){
  		$(this).append("<li>" + request.type + "  " + AjaxCount + "</li>");
	})
	.ajaxSend(function(request, settings){
		AjaxCount++;
  		$(this).append("<li>" + request.type + "  " + AjaxCount + "</li>");
	})
	.ajaxError(function(request, settings){
  		$(this).append("<li>" + request.type + "  " + AjaxCount + "</li>");
	})
	.ajaxSuccess(function(request, settings){
		AjaxCount--;
		AjaxCount = AjaxCount < 0 ? 0 : AjaxCount;
  		$(this).append("<li>" + request.type + " " + AjaxCount + "</li>");
	})
	.click(function()
	{
		alert($('#items a.toggleBoxen').length);
	});

});