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);
				alert(texto);
				
	  
				window.location.href = 'orcamento.php';
				setTimeout(function()
				{
					window.location = 'orcamento.php';
				}, 0);		  
				
			}
	  } 
	  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){
	  
	  qtd = document.getElementById("qtd"+produto).value;
	  qtd2 = document.getElementById("qtd2"+produto).value;
	  xmlhttp.open("GET", url + '?produto=' + produto + '&qtd=' + qtd + '&qtd2=' + qtd2, true);
	  xmlhttp.onreadystatechange = function(){
	  
		   if (xmlhttp.readyState == 4){
	  
				window.location.href = 'orcamento.php';
				setTimeout(function()
				{
					window.location = 'orcamento.php';
				}, 0);		  
				
			}
	  } 
	  xmlhttp.send(null);
 }

