function gera_ajax(){
try{ ajax=new XMLHttpRequest(); }
catch(ee){
    try{ ajax=new ActiveXObject("Msxml2.XMLHTTP"); }
	catch(e){
        try{ ajax=new ActiveXObject("Microsoft.XMLHTTP"); }
		catch(E){ ajax=false;}}} return ajax; }
function tuffy_checar(caixa){
if(document.getElementById(caixa).value.length>500){ alert('Atenção! Não exceda o limite de 500 caracteres.'); document.getElementById(caixa).value=document.getElementById(caixa).value.substr(0,500); document.getElementById(caixa).focus(); }
}

function valida_tuffy(){
	if(document.frm_tuffy.txtrazao.value==""){ alert("Informe a razão social."); return false; }	
	if(document.frm_tuffy.txtendereco.value==""){ alert("Informe o endereço."); return false; }	
	if(document.frm_tuffy.txtano.value==""){ alert("Informe o ano."); return false; }	
	if(document.frm_tuffy.txtunidades.value==""){ alert("Informe as unidades."); return false; }	
	if(document.frm_tuffy.txtnfunc.value==""){ alert("Informe o número de funcionários."); return false; }	
	if(document.frm_tuffy.txtprodutos.value==""){ alert("Informe os produtos."); return false; }	
	if(document.frm_tuffy.txtatividades.value==""){ alert("Informe as atividades."); return false; }	
	if(document.frm_tuffy.txtclientes.value==""){ alert("Informe os clientes."); return false; }	
	if(document.frm_tuffy.txtconcorrentes.value==""){ alert("Informe os concorrentes."); return false; }	
	if(document.frm_tuffy.txtconcorrencia.value==""){ alert("Informe a concorrência."); return false; }	
	if(document.frm_tuffy.txtbeneficios.value==""){ alert("Informe os benefícios."); return false; }	
	if(document.frm_tuffy.txtinvestimentos.value==""){ alert("Informe os investimentos."); return false; }	
	if(document.frm_tuffy.txtcomunidade.value==""){ alert("Informe as ações."); return false; }	
	if(document.frm_tuffy.txtambientais.value==""){ alert("Informe as ações."); return false; }	
	if(document.frm_tuffy.txtevolucao.value==""){ alert("Informe a evolução."); return false; }	
	if(document.frm_tuffy.txtrealizacoes.value==""){ alert("Informe as realizações."); return false; }	
	if(document.frm_tuffy.txtcase.value==""){ alert("Informe os cases."); return false; }	
	return true;
}
function numeros(e){
    var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58)) return true;
    else{
    if (tecla != 8) return false;
    else return true;
    }
}

function consultar(){
	    var con=document.getElementById('cbocon').value; 
		var conteudo=document.getElementById('mostrar'); 
		var n=Math.random();
		var ajax=gera_ajax();
		ajax.open("GET","tuffy_relatorio.php?con="+con+"&n="+n,true);
		ajax.onreadystatechange=function(){
			if(ajax.readyState==4 && ajax.status==200){ conteudo.innerHTML=unescape(ajax.responseText); }
			else{ conteudo.innerHTML="<center><font color='#000000'><b>Carregando Informações...</b></font></center>";	}}
		ajax.send(null); }
