var xmlHttp

function getmail(id)
{
if (document.getElementById("EmailSpan").name!="Emailed")
{
xmlHttp=GetXmlHttpObject();
if (xmlHttp==null)
  {
  alert ("Error, your browser does not support ajax");
  return;
  } 
var showmail="javascripts/showmail.php?id="+id+"&amp;rac="+Math.random();
xmlHttp.onreadystatechange=stateChanged;
xmlHttp.open("GET",showmail,true);
xmlHttp.send(null);
}
}

function stateChanged() 
{ 
	if (xmlHttp.readyState==1||xmlHttp.readyState==2||xmlHttp.readyState==3)
	{ 
		document.getElementById("EmailSpan").innerHTML="Processing...";
	}
	if (xmlHttp.readyState==4)
	{ 
		document.getElementById("EmailSpan").innerHTML=xmlHttp.responseText;
		document.getElementById("EmailSpan").name="Emailed"; 
	}
}

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;
}
