try{
	var xmlhttp=new XMLHttpRequest()
}catch(e){
	try{
		var xmlhttp=new ActiveXObject("Msxml2.XMLHTTP")
	}catch(ee){
		try{
			var xmlhttp=new ActiveXObject("Microsoft.XMLHTTP")
		}catch(E){
			var xmlhttp=false
		}
	}
}
function ajaxCadastro(){
	var nome = document.getElementById("frmnome");
	var email = document.getElementById("frmemail");
	if (nome.value == "") {
		alert("Por favor, informe seu nome!");
		nome.focus();
		return false;
	}
	if (email.value.indexOf("@") == -1 || email.value.indexOf(".") == -1) {
		alert("Por favor, informe seu e-mail!");
		email.focus();
		return false;
	}
	var href = "/secoes/cadastro.php?nome="+ nome.value +"&email="+ email.value
	xmlhttp.open("GET", href, true)
	xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4){
				var retorno = xmlhttp.responseText
				if (retorno == "cadastro_sucesso") {
					nome.value = ""
					email.value = ""			
					alert("Cadastro efetuado com sucesso!");
				}else if (retorno == "cadastro_existente") {
					alert("Os dados informados já estão cadastrados em nosso site!");	
				}else if (retorno == "email_invalido") {
					alert("Por favor, informe um e-mail válido!");	
				}
			}
		}
	xmlhttp.send(null)
}
function ajaxRepresentantes(estado) {
	var estado = estado;
	var linha_resultado = document.getElementById("linha_resultado");
	var resultado = document.getElementById("resultado");
	if (estado == "") {
		linha_resultado.style.display = "none";
		resultado.innerHTML = "";
	}else{
		var href = "/secoes/representantes.php?estado="+ estado
		xmlhttp.open("GET", href, true)
		xmlhttp.onreadystatechange = function(){
				if (xmlhttp.readyState == 4){
					linha_resultado.style.display = "";
					resultado.innerHTML = xmlhttp.responseText
					callbfResize();					
				}
			}
		resultado.innerHTML = "<span>Aguarde, carregando representantes...</span>"
		xmlhttp.send(null)
	}
}
function ajaxCertificadoras(letra) {
	var letra = letra;
	var linha_resultado = document.getElementById("linha_resultado");
	var resultado = document.getElementById("resultado");
	if (letra == "") {
		linha_resultado.style.display = "none";
		resultado.innerHTML = "";
	}else{
		var href = "/secoes/certificadoras.php?letra="+ letra
		xmlhttp.open("GET", href, true)
		xmlhttp.onreadystatechange = function(){
				if (xmlhttp.readyState == 4){
					linha_resultado.style.display = "";
					resultado.innerHTML = xmlhttp.responseText
					callbfResize();					
				}
			}
		resultado.innerHTML = "<span>Aguarde, carregando certificadoras...</span>"
		xmlhttp.send(null)
	}
}
function ajaxContato() {
	var nome = document.getElementById("frmcontato_nome");
	var empresa = document.getElementById("frmcontato_empresa");
	var email = document.getElementById("frmcontato_email");
	var telefone = document.getElementById("frmcontato_telefone");
	var fax = document.getElementById("frmcontato_fax");
	var assunto = document.getElementById("frmcontato_assunto");
	var mensagem = document.getElementById("frmcontato_mensagem");
	if (nome.value == "") {
		alert("Por favor, informe seu nome!");
		nome.focus();
		return false;
	}
	if (empresa.value == "") {
		alert("Por favor, informe a empresa!");
		empresa.focus();
		return false;
	}
	if (email.value.indexOf("@") == -1 || email.value.indexOf(".") == -1) {
		alert("Por favor, informe seu e-mail!");
		email.focus();
		return false;
	}
	if (telefone.value == "") {
		alert("Por favor, informe o telefone!");
		telefone.focus();
		return false;
	}
	if (assunto.value == "") {
		alert("Por favor, informe o assunto!");
		assunto.focus();
		return false;
	}	
	if (mensagem.value == "") {
		alert("Por favor, informe a mensagem!");
		mensagem.focus();
		return false;
	}
	var href = "/secoes/contato.php?nome="+ nome.value +"&empresa="+ empresa.value +"&email="+ email.value +"&telefone="+ telefone.value +"&fax="+ fax.value +"&assunto="+ assunto.value +"&mensagem="+ mensagem.value
	xmlhttp.open("GET", href, true)
	xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4){
				var retorno = xmlhttp.responseText
				if (retorno == "envio_sucesso") {
					nome.value = ""
					empresa.value = ""
					email.value = ""
					telefone.value = ""
					fax.value = ""
					mensagem.value = ""				
					alert("Dados enviados com sucesso!");
				}
			}
		}
	xmlhttp.send(null)
}
function ajaxProdutos(pagina) {
	var pagina = pagina;
	var produtos = document.getElementById("produtos");
	var produtos_inicial = document.getElementById("produtos_inicial");
	var produtos_info = document.getElementById("produtos_info");
	var href = "/secoes/produtos.php?pagina="+ pagina
	
	xmlhttp.open("GET", href, true)
	xmlhttp.onreadystatechange = function(){
			if (xmlhttp.readyState == 4) {
				if (xmlhttp.responseText == "erro") {
					produtos_inicial.style.display = '';
					produtos_info.style.display = '';
				}else{
					produtos.style.display = '';
					produtos_inicial.style.display = 'none';
					produtos_info.style.display = 'none';
					produtos.innerHTML = xmlhttp.responseText
					callbfResize();
				}
			}
		}
	produtos.innerHTML = "<span>Aguarde, carregando os produtos...</span>"
	xmlhttp.send(null)
}