//http://imasters.uol.com.br/artigo/10205/asp/cadastrando_listando_e_deletando_com_ajax__asp/
function adicionaCesta(idProduto,idCategoria,Quant) {

	var url = "add_cesta.asp?id_produto="+idProduto+"&id_categoria="+idCategoria+"&Quant="+Quant+"";
	//window.open(url);
	if((Quant!=0) && (Quant!='')){	
	 
		http.open("GET", url, false);
		enProceso = true;
		http.send(null);
		if (http.readyState == 4) { 
		   if (http.status == 200) {
			  if (http.responseText.indexOf("invalid") == -1) {
				 results = http.responseText.split(","); 
				 if (results[0] != ""){
					document.getElementById("ler_Dados").innerHTML = "<b>Atenção</b>: A lista de pedidos contém produtos. <B><a href='view_cesta.asp'>VEJA SEU PEDIDO MONTADO</a></B>";
					document.getElementById("Resposta").innerHTML = "Adicionado a lista com Sucesso! <b><a href='view_cesta.asp'>VEJA SEU PEDIDO MONTADO</a></B>";
					document.getElementById("quatidade_"+idProduto).value = 0;
				 }
				 enProceso = false;
			  }
		   }
		}	   
	}else{
		alert("Digite uma quantidade maior que zero para inclusão do produto.")
	}

}
 
 
function getHTTPObject() {
	var xmlhttp;
	/*@cc_on
	@if (@_jscript_version >= 5)
	   try {
		  xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	   } catch (e) {
		  try {
			 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		  } catch (E) { xmlhttp = false; }
	   }
	@else
	xmlhttp = false;
	@end @*/
	if (!xmlhttp && typeof XMLHttpRequest != "undefined") {
	   try {
		  xmlhttp = new XMLHttpRequest();
	   } catch (e) { xmlhttp = false; }
	}
	return xmlhttp;
}
 
var enProceso = false; // lo usamos para ver si hay un proceso activo
var http = getHTTPObject(); // Creamos el objeto XMLHttpRequest
 
function lerCesta() {
	var URLler = "VerificaStatusCesta.asp";
	http.onreadystatechange = stateChanged;
	http.open("GET", URLler, true);
	http.send(null);
}

function stateChanged() {
	if (http.readyState==4) {
		if(document.getElementById("ler_Dados") != null)
			document.getElementById("ler_Dados").innerHTML = http.responseText;
	}
}

if(document.getElementById("ler_Dados") != null){
	window.onload = lerCesta;
}


// Início - Deletar
function apagar(id, rowIndex) {
    if (confirm("Tem certeza que deseja excluir este registro?")) {
        document.getElementById("tabela").deleteRow(rowIndex);

        http.open("POST","Cadastro.asp?Deletar=Ok&id="+ id, false);
		http.send(null);
    }
}
// Final - Deletar