
function pullCounts()
{
	// First clear the box (in case it takes a while).
clearDialog("messageNotifier");
clearDialog("InboxCount");
clearDialog("NoteCount");

	var sURL = '/S/com.spiff.comms.center.S_CCenter_AJAXCheckMessages'+"?rD="+(new Date().getTime() % 100000)
	ajaxCounts(sURL, doAJAXCounts, true);
}




function clearDialog(id)
{
	window.document.getElementById("dialog0").setContent = " ";
}



function ajaxCounts(url, callback, async)
{
	function ajaxBindCallback()
	{
		if (ajaxRequest.readyState == 4) 
		{
			if (ajaxRequest.status == 200) 
			{
				if (ajaxCallback)
				{
					ajaxCallback(ajaxRequest);
				} 
				else 
				{
					alert('no callback defined');
				}
			} 
			else 
			{
				//alert("There was a problem retrieving the xml data:\n" + ajaxRequest.status + ":\t" + ajaxRequest.statusText + "\n" + ajaxRequest.responseText);
			}
		}
	}


	// use a local variable to hold our request and callback until the inner function is called...
	var ajaxRequest = null;
	var ajaxCallback = callback;


	// bind our callback then hit the server...
	if (window.XMLHttpRequest) 
	{
		// moz et al
		ajaxRequest = new XMLHttpRequest();
		ajaxRequest.onreadystatechange = ajaxBindCallback;
		ajaxRequest.open("GET", url, async);
		ajaxRequest.send(null);
	}
	else if (window.ActiveXObject) 
	{
		// ie
		ajaxRequest = new ActiveXObject("Microsoft.XMLHTTP");
		if (ajaxRequest) 
		{
			ajaxRequest.onreadystatechange = ajaxBindCallback;
			ajaxRequest.open("GET", url, async);
			ajaxRequest.send();
		}
	}

	if(!async)
	{
		doAJAXCounts(ajaxRequest, id1,id2);
	}
}




function doAJAXCounts(ajaxRequest)
{
	var str = ajaxRequest.responseText;
	var words = str.split(" ");
	
	var total = words[0];
	var inbox = words[1];
	var note = words[2];



	try
	{
		var o = window.document.getElementById("messageNotifier");
		if(o.src != null)
		{
			window.document.getElementById("messageNotifier").src = total;
		}
		else
		{
			window.document.getElementById("messageNotifier").innerHTML = total;
		}
	}
	catch(err)
	{
		//alert("Error, couldn't find element: 'messageNotifier'");
	}


	if(window.document.getElementById("InboxCount"))
	{
		window.document.getElementById("InboxCount").innerHTML = inbox;
	}
	if(window.document.getElementById("NoteCount"))
	{
		window.document.getElementById("NoteCount").innerHTML = note;
	}
}





