function handleMarkAsRead(ret)
{
	var response = ret.responseText.evalJSON();
	if(response.href != 'false')
	{
		window.location.href=response.href;
	}
	if(response.success && response.updateCount == 1)
	{
		var divName = "span_" + response.id;
		$(divName).style.fontWeight = "normal";
		divName = "n_" + response.id;
		$(divName).style.background = "#FFFFFF";
		value = $('notifications').innerHTML;
		num = value.match(/[0-9]+/);
		if(typeof num != 'undefined' && (num - 1) == 0)
		{
			$('notifications').innerHTML = "Notifications";
		}
		else if (typeof num != 'undefined' && num > 0)
		{
			num--;
			$('notifications').innerHTML = "Notifications (<span style='color:red'>" + num + "</span>)";
		}
	}
}

function handleDelete(ret)
{
	var response = ret.responseText.evalJSON();

	var divName = "n_" + response.id;
	$(divName).up().up().remove();

	var table = $('notification').down().childElements(); /*get tbody*/
	var hitOnce = true;
	table.reverse();
	if(table.length == 3)
	{
		if($('notification-pager') !== null)
		{
			location.reload(true);	
		}
		else
		{
			$('notification').remove();
			$('noNotifications').style.display = 'inline';
		}
		
	}
	else
	{
		table.each(function(element)
		{ 
			
			if($(element).identify() == "notification-group-separator" && hitOnce == true)
			{
				$(element).remove();
			}
			else if(!$(element).id)
			{}
			else
			{
				hitOnce = false;
			}
			
			if($(element).identify() == "notification-group-separator")
			{
				hitOnce = true;
			}
			
		});
	}
	if( response.updateCount == 1)
	{
		value = $('notifications').innerHTML;
		num = value.match(/[0-9]+/);
		if(typeof num != 'undefined' && (num - 1) == 0)
		{
			$('notifications').innerHTML = "Notifications";
		}
		else if (typeof num != 'undefined' && num > 0)
		{
			num--;
			$('notifications').innerHTML = "Notifications (<span style='color:red'>" + num + "</span>)";
		}
	}
	
}