
function Ajax(){
	var xmlhttp=false;
	try{
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	}
	catch(e){
		try {
			xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
		}
		catch(E){
			xmlhttp = false;
		}
	}
	if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
		xmlhttp = new XMLHttpRequest();
	}
	return xmlhttp;
}

function OrdenarPor(campo, ordem, pagina, url, radio){
//alert(radio);
//alert(ordem);
//alert(pagina);
//alert(url);
	 //div onde ira o resultado
	 divListado = document.getElementById("resultado");
	 
	 var carregando = document.getElementById("resultado");
	 carregando.innerHTML='<img src="imagens/load.gif" /> carregando...';
	//alert(radio);
	ajax=Ajax();
	//Especifica o arquivo da consulta e as variaveis
	ajax.open("GET", url+"?campo="+campo+"&ordem="+ordem+"&pagina="+pagina+"&radio="+radio);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
			carregando.innerHTML = null;
			divListado.innerHTML = ajax.responseText
		}
	}
			
	ajax.send(null)
		
}

function ConfirmDialog(id, url, url2, radio) {
//alert(radio);
	var carregando = document.getElementById("carregar");
    document.getElementById("carregando").style.background = '#000000';
	document.getElementById("carregando").style.display = 'inline';
	document.getElementById("carregar").style.display = 'inline';
	carregando.innerHTML="<div class=\"titulo\">Excluir Dados ???</div><span class=\"fechar\"><a onclick=\"HideDiv()\">X</a></span><div class=\"imagem\"><p>Você tem certeza que deseja excluir esta linha?</p><p class=\"confirma\"><input type=\"button\" onclick=\"Excluir('"+id+"','"+url+"','"+url2+"','"+radio+"');\" value=\"Sim\" />&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"button\" value=\"Não\" onclick=\"HideDiv();\" /></p></div>";

}

function Excluir(id, url, url2, radio){
//alert (radio);	
//alert (url);	
//alert (url2);	
//alert (id);	
 var url3 = url+"?codigo="+id;
 //alert (url3);	
//	nDiv = "_"+id;
	//alert (radio);	
//	DelDiv = document.getElementById(nDiv);
			
//	var carregando = document.getElementById("carregar");
//	document.getElementById("carregando").style.background = '#000000';
	//document.getElementById("carregando").style.display = 'inline';
//	carregando.innerHTML='<div class="loading"><img src="imagens/load.gif" /></div>';			
	ajax=Ajax();
	//Especifica o arquivo da consulta e as variaveis
	ajax.open("GET", url3, true);
	ajax.onreadystatechange=function() {
		if (ajax.readyState==4) {
		//	carregando.innerHTML="<div class=\"titulo\">Sucesso !!!</div><span class=\"fechar\"><a onclick=\"HideDiv()\">X</a></span><div class=\"imagem\"><p>Os dados selecionados foram excluídos do banco de dados com sucesso.</p></div><input type=\"button\" value=\"Fechar\" onclick=\"HideDiv();\" />";
//			DelDiv.style.display = 'none';
			alert('O Produto foi excluido com sucesso !!!','Aviso!!!');
	//		window.onload(document.getElementById);
			window.top.location.href = url2;
		}
	}
			
	ajax.send(null)
}

function HideDiv(){

	document.getElementById("carregando").style.display = 'none';
	document.getElementById("carregar").style.display = 'none';

}
