var xmlHttp;

function mudaexpo(str)
 { 
 xmlHttp=GetXmlHttpObject();
 if (xmlHttp==null)
  {
  alert ("Browser does not support HTTP Request");
  return;
  } 
 var url="responsexmlcoleccao.php";
 url=url+"?q="+str;
 url=url+"&sid="+Math.random();
 xmlHttp.onreadystatechange=stateChanged;
 xmlHttp.open("GET",url,true);
 xmlHttp.send(null);
 }

 function limpa(){
	xmlHttp=GetXmlHttpObject();

	if (xmlHttp==null)
	{
		alert ("Browser does not support HTTP Request");
		return;
	} 

	document.getElementById("autor").innerHTML = "";	
	document.getElementById("texto").innerHTML = "";
	//document.getElementById("conteudoimagem").style.background = "url() no-repeat";
	document.getElementById("asd").style.width ="430px";
	document.getElementById("asd").style.height ="370px";
	document.getElementById("asd").src = "img/Pared2.jpg";

}
 
 
function stateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
{
 xmlDoc=xmlHttp.responseXML;
 document.getElementById("autor").innerHTML = xmlDoc.getElementsByTagName("autor")[0].childNodes[0].nodeValue;
 document.getElementById("texto").innerHTML = xmlDoc.getElementsByTagName("texto")[0].childNodes[0].nodeValue;

 var asd2 = xmlDoc.getElementsByTagName('nomefoto')[0].childNodes[0].nodeValue;
 var caminho = "fotos/"+asd2;

 var com=xmlDoc.getElementsByTagName("widthaux")[0].childNodes[0].nodeValue;
 var alt= xmlDoc.getElementsByTagName("heightaux")[0].childNodes[0].nodeValue;
 
 var comaux = com/430;
 var altaux = alt/370;

if (comaux >1 || altaux>1) {
  if (altaux >= comaux) {
    alt= alt/(altaux);
    com= com/(altaux);
  }
  else{
    alt= alt/(comaux);
    com= com/(comaux);
  }
}


 document.getElementById("asd").style.width = com + "px";
 document.getElementById("asd").style.height = alt + "px";
 document.getElementById("asd").src = caminho;

 }
}


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