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;
 var alt;
 
 com = xmlDoc.getElementsByTagName("widthaux")[0].childNodes[0].nodeValue;
 alt = xmlDoc.getElementsByTagName("heightaux")[0].childNodes[0].nodeValue;
 
 while((alt > 740) || (com > 860)){
	com = com-(com * 0.50);
	alt = alt-(alt * 0.50);
 }
 
 while((alt > 370)||(com > 430)){ 
	com = com-(com * 0.01);
	alt = alt-(alt * 0.01);
 } 
 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;
 }