var xmlhttp = getXmlHttpRequest();
	
	function getXmlHttpRequest() {
		if (window.XMLHttpRequest) {
			return new XMLHttpRequest();
		} else if (window.ActiveXObject) {
			return new ActiveXObject("Microsoft.XMLHTTP");
		}
	}
	
function Inserir(url,produto,titulo){
	  xmlhttp.open("GET", url + '?produto=' + produto + '&titulo=' + titulo, true);
	  xmlhttp.onreadystatechange = function(){
	  
		   if (xmlhttp.readyState == 4){
		   
			   var texto = xmlhttp.responseText;
			   texto = texto.replace(/\+/g," ");
			   texto = unescape(texto);
			   if (texto == 1) {
			   	window.location = 'pagina.php?id=4';
			   }
			}
	  } 
	  xmlhttp.send(null);
 }
 
function Excluir(url,produto){
  document.getElementById("centro").innerHTML = "<strong>Carregando...</strong>";
  xmlhttp.open("GET", url + '?produto=' + produto, true);
  xmlhttp.onreadystatechange = function(){
  
   if (xmlhttp.readyState == 4){
   
   var texto = xmlhttp.responseText;
   texto = texto.replace(/\+/g," ");
   texto = unescape(texto);
	div = document.getElementById(produto);
	div.style.display = 'none';
	document.getElementById("centro").innerHTML = xmlhttp.responseText;
   }
  } 
  xmlhttp.send(null);
 }
 
 function Alterar(url,produto){
  document.getElementById("centro").innerHTML = "<strong>Carregando...</strong>";
  qtd = document.getElementById("qtd"+produto).value;
  xmlhttp.open("GET", url + '?produto=' + produto + '&qtd=' + qtd, true);
  xmlhttp.onreadystatechange = function(){
  
   if (xmlhttp.readyState == 4){
   
   var texto = xmlhttp.responseText;
   texto = texto.replace(/\+/g," ");
   texto = unescape(texto);
	window.location = 'pagina.php?id=4'
   }
  } 
  xmlhttp.send(null);
 }
 
