var xmlhttp;
var elemento;

function GetXmlHttpObject ()
{
	if (window.XMLHttpRequest)
	{
	  return new XMLHttpRequest();
	}
	if (window.ActiveXObject)
	{
	  return new ActiveXObject("Microsoft.XMLHTTP");
	}
	return null;
}

function carregarImagem(id, id_elemento)
{
	xmlhttp = GetXmlHttpObject();
	
	if (xmlhttp==null)
	{
		alert ("Seu navegador nao suporta AJAX. Atualize-o!!");
		return;
	}
	
	elemento = id_elemento;
	
	var url="imagem.php";
	url=url + "?id=" + id;
	xmlhttp.onreadystatechange = stateChanged;
	xmlhttp.open("GET", url, true);
	xmlhttp.send(null);
}

function stateChanged ()
{
	if (xmlhttp.readyState==4) document.getElementById(elemento).innerHTML = xmlhttp.responseText;
}

