/*
 * returns a valid xmlHttp object or null if the browser doesn't support ajax
 */
function GetXmlHttpObject()
{
var xmlHttp=null;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
    }
  }
return xmlHttp;
}

/*
 * generic ajax function
 */
function ajax(url,id,str,function_onreadystate)
{
	if(url)
	{
	//	if (str.length==0)
	//	{//set the element blank if str is empty 
	//		document.getElementById(id).innerHTML="";
	//		return;
	//	}
		xmlHttp=GetXmlHttpObject();
		if (xmlHttp==null)
		{
		  alert ("Your browser does not support AJAX!");
		  return;
		}
		if(str)
		{
			url=url+"?input="+str;
			url=url+"&sid="+Math.random();		
		} 
		xmlHttp.onreadystatechange= function()
		{
			if (xmlHttp.readyState==4)
			{ 
				document.getElementById(id).innerHTML=xmlHttp.responseText;
				
				if(function_onreadystate)
				{//not working at the moment, need to get it working again, at least for the "student blogs" page
					function_onreadystate();
				}
				
			}
		};
		
		xmlHttp.open("GET",url,true);
		xmlHttp.send(null);
	}

} 
 