function ajax()
{
    try {
        return new ActiveXObject("Microsoft.XMLHTTP");
    } catch(e) {
        try {
            return new ActiveXObject("Msxml2.XMLHTTP");
        } catch(ex) {
            try {
                return new XMLHttpRequest();
            } catch(exc) {
                alert("Esse browser não tem recursos para uso do AJAX");
                return false;
            }
        }
    }
}



function mostraCamada(obj) {
  document.all[obj].style.visibility = 'visible';
}

function ocultaCamada(obj) {
  document.all[obj].style.visibility = 'hidden';
}



function createXMLHTTP(){
	try{ ajax = new ActiveXObject("Microsoft.XMLHTTP");
	}catch(e){
		try{
			ajax = new ActiveXObject("Msxml2.XMLHTTP");
			alert(ajax);
		}catch(ex){
			try{ ajax = new XMLHttpRequest();
			}catch(exc){
				alert("Esse browser não tem recursos para uso do Ajax");
				ajax = null;
			}
		}
		return ajax;

	}
	var arrSignatures = ["MSXML2.XMLHTTP.5.0", "MSXML2.XMLHTTP.4.0","MSXML2.XMLHTTP.3.0", "MSXML2.XMLHTTP","Microsoft.XMLHTTP"];
	for (var i=0; i < arrSignatures.length; i++) {
		try {
			var oRequest = new ActiveXObject(arrSignatures[i]);
			return oRequest;
		}catch (oError){}
	}
	throw new Error("MSXML is not installed on your system.");
}




function CarregaPagina(idLayer,Pagina,Parametros,Resposta){
		var oHTTPRequest = createXMLHTTP(); 
		oHTTPRequest.open("GET", Pagina + '?R=' + Relogio() + Parametros, true);
		oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oHTTPRequest.onreadystatechange=function(){
			if (oHTTPRequest.readyState==4){
				if (oHTTPRequest.status==200){
					document.all[idLayer].innerHTML = oHTTPRequest.responseText;
				}else{
					document.all[idLayer].innerHTML = Resposta;
				}
			}
		}
		oHTTPRequest.send();
}

function CarregaPaginaD(idLayer,Pagina,Parametros,Resposta){
		var oHTTPRequest = createXMLHTTP(); 
		oHTTPRequest.open("POST", Pagina + '?R=' + Relogio() + Parametros, true);
		oHTTPRequest.setRequestHeader("Content-Type", "multipart/form-data");
		oHTTPRequest.onreadystatechange=function(){
			if (oHTTPRequest.readyState==4){
				if (oHTTPRequest.status==200){
					document.all[idLayer].innerHTML = oHTTPRequest.responseText;
				}else{
					document.all[idLayer].innerHTML = Resposta;
				}
			}
		}
		oHTTPRequest.send();
}



function CarregaLogin(LLogin,idLayer,Pagina,Parametros,Resposta){
		var oHTTPRequest = createXMLHTTP(); 
		oHTTPRequest.open("GET", Pagina + '?R=' + Relogio() + Parametros, true);
		oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oHTTPRequest.onreadystatechange=function(){
			if (oHTTPRequest.readyState==4){
				if (oHTTPRequest.status==200){
					if (oHTTPRequest.responseText.replace(' ','') == "OK") {
						document.location.href='main.php';

					}else{
					  document.all[idLayer].innerHTML = oHTTPRequest.responseText;
					}
				}else{
					document.all[idLayer].innerHTML = Resposta;
				}
			}
		}
		oHTTPRequest.send();
}

function CarregaLoginP(Pagina,Parametros){
		var oHTTPRequest = createXMLHTTP(); 
		oHTTPRequest.open("GET", Pagina + '?R=' + Relogio() + Parametros, true);
		oHTTPRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
		oHTTPRequest.onreadystatechange=function(){
			if (oHTTPRequest.readyState==4){
				if (oHTTPRequest.status==200){
					if (oHTTPRequest.responseText.replace(' ','') == "1") {
						document.location.href='membros/index.php';
					} else {
						document.location.href='membros/index.php';
					}
				}
			}
		}
		oHTTPRequest.send();
}



function Relogio(){
	momentoAtual = new Date() 
    hora = momentoAtual.getHours() 
    minuto = momentoAtual.getMinutes() 
    segundo = momentoAtual.getSeconds() 
	milisegundoComposto = momentoAtual.getTime()
	Teste = hora.toString() + minuto.toString() + segundo.toString() + milisegundoComposto.toString();
	return Teste;
}

function dataVal(obj){
	verdata = window.open("include/ClsDate.asp?objeto=" + obj + "","calendatriodata","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no,copyhistory=no,screenX=30,screenY=80,left=200,top=180,width=225,height=210")
}
function ExibeMensagem(){ 
 	alert("Clique no ícone do calendário para escolher a data no calendário!");
}



function setaParametro(obj) {
	document.all['parametros'].value = document.all['parametros'].value +''+obj ;
}

function Calendario(Objeto){
verdata = window.open("include/ClsDate.asp?objeto=" + Objeto + "","calendatriodata","toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,scrollbars=no,copyhistory=no,screenX=30,screenY=80,left=200,top=180,width=225,height=210")
}



function Gerar(Pagina,TamH,TamW){
	if(!TamH || !TamW){
		TamH = 500;
		TamW = 900;
	}
	

//	var topo = ((document.documentElement.scrollHeight - TamH)/2);
//	var esquerda = ((document.documentElement.scrollWidth - TamW)/2);
	
	var topo = ((window.screen.height - TamH)/2);
	var esquerda = ((window.screen.width - TamW)/2);
	
window.open(Pagina,"Relatório","scrollbars=yes,toolbar=no,location=no,directories=no,status=no,menubar=no,resizable=no,copyhistory=no,left=" + esquerda +",top="+topo+",width=" + TamW + ",height="+TamH);
	
	
}

	

function habilitabotao(obj) {
	
	document.all[obj].disabled=false
  	
}


function desabilitabotao(obj) {
	
	document.all[obj].disabled=true
  	
}

function checaCampo(nome) {
			 
	if (document.all[nome].value='') {
		
		alert("É necessário preencher o campo data");
		exit(1);
		
	}
	
}

function checaarray(nome) {

    desabilitabotao('gerarel');
	if(document.all[nome].length) {
	for (x=0;x<document.all[nome].length;x++) {			
        if (document.all[nome][x].checked) {
		     habilitabotao('gerarel');
	     }
	}
	}else{
		if(document.all[nome].checked){ habilitabotao('gerarel'); }
	}
   
		    
}
	

function checaCheckbox(nome) {
	resposta = "" ;
	if(document.all[nome].length){		
		for (x=0;x<document.all[nome].length;x++) {			
        if (document.all[nome][x].checked) {
		   	
             resposta += document.all[nome][x].value + ',';
 			
		}
		
		}
		resposta = resposta.substring(0,resposta.length-1);
		}else{
		 resposta =document.all[nome].value;	
		}
     
  	    Gerar('rel.asp?nlotes='+resposta,500,700);
        
}

function exibeMensagem() {
	alert("Clique no Calendário para escolher uma data");
}	


function posicionaCamada(obj,posx,posy) {
     
	 document.all[obj].style.pixelTop = posx;
 	 document.all[obj].style.pixelLeft = posy;
	
		
}



function efeitoCamada(obj,quant,cont,tipo,cpPagina,cpParametros,cpErro) {
	
		if (cont==0) {
           document.all[obj].innerHTML = '<img src="imgs/aguarde.gif" width="32" height="32"><span class="opMenu"> Aguarde, processando... </span>';
		}

	    
    mostraCamada(obj);

    if (tipo==1) {
		if (cont==0) {
        document.all[obj].style.pixelTop = 0;
  	    document.all[obj].style.pixelLeft = 0;
		}
	
    var posxi = document.all[obj].style.pixelTop+2;
    var posyi = document.all[obj].style.pixelLeft;

    posicionaCamada(obj,posxi+2,posyi);
	
   opacity = (quant+cont+20);
   document.all[obj].style.filter="alpha(opacity="+opacity+")";
		   
	if (quant>cont) {
	   cont = cont + 1 ;	
	   setTimeout("efeitoCamada('"+obj+"',"+quant+","+cont+","+tipo+",'"+cpPagina+"','"+cpParametros+"','"+cpErro+"')",3); 
    } else {
      document.all[obj].innerHTML = '<img src="imgs/aguarde.gif" width="32" height="32"><span class="opMenu"> Aguarde, processando... </span>';
      setTimeout("CarregaPagina('"+obj+"','"+cpPagina+"','"+cpParametros+"','"+cpErro+"')",0);	
	  document.all[obj].style.filter="alpha(opacity=100)";
	}

	return false;       


} else {
	
    if (cont%2) {
      document.all[obj].style.filter="alpha(opacity=50)";
	} else {
   	  document.all[obj].style.filter="alpha(opacity=100)";
	}
		   
	if (quant>cont) {
	   cont = cont + 1 ;	
	   setTimeout("efeitoCamada('"+obj+"',"+quant+","+cont+","+tipo+",'"+cpPagina+"','"+cpParametros+"','"+cpErro+"')",3); 
    } else {
      document.all[obj].innerHTML = '<img src="imgs/aguarde.gif" width="32" height="32"><span class="opMenu"> Aguarde, processando... </span>';
	  setTimeout("CarregaPagina('"+obj+"','"+cpPagina+"','"+cpParametros+"','"+cpErro+"')",0);	
	  document.all[obj].style.filter="alpha(opacity=100)";

	}

	return false;       
	
}
}

function geraSomaRegional(obj,oqsomar) {
	
	    var soma;
		soma=0;	
		
		document.write(oqsomar);
		
		if(document.all[obj]) {
		   
		   soma = soma + document.all[obj].innerHTML + oqsomar;
		   document.all[obj].innerHTML = ""+soma;
			
		}
		

}

function ChecaData(obj,e) {
	
    var tecla=(window.event)?event.keyCode:e.which;
	var valor = document.getElementById(obj).value;
	
	
	if (tecla==08) {
		var tamanho = valor.length;
		document.getElementById(obj).value = valor.substring(0,tamanho);
		
    } else {
	    

	
	if (valor.length==2) {
			document.getElementById(obj).value = valor + '/';
	}
	if (valor.length==5) {
        document.getElementById(obj).value = valor + '/';
	}
	}
	
}

function ChecaVazio(obj,classe) {

    var classo = obj.className;
	
	
	if (obj.value.length==0 && classo==classe) {
       
	   return false;
	   
	} else { 
	return true;
	
	}
		

	
}


function ChecaForm(form,classe) {
	
    var retorno=true;
	
   document.getElementById('divretorno').innerHTML = '';
	
	
	for(i=0;i<document.forms[form].length;i++)
	{
		if(document.forms[form].elements[i].type == "text" || document.forms[form].elements[i].type == "textarea" || document.forms[form].elements[i].type == "password" )
			if (!retorno) {
				ChecaVazio(document.forms[form].elements[i],classe);
			} else {
				retorno = ChecaVazio(document.forms[form].elements[i],classe);
			}
	}
	    if (retorno==true) {
	       retorno=checaSenhas();
		   } else {
      	   document.getElementById('divretorno').innerHTML=document.getElementById('divretorno').innerHTML + '<div class="diverro">Os Campos * são Obrigatórios!</div>';
		   }
		
		return retorno;

 }
 
  function checaSenhas() {
  
   if (document.getElementById("Senha1").value != document.getElementById("Senha2").value || document.getElementById("Senha1").value=="" || document.getElementById("Senha2").value=="" ) {
       var obj1 = document.getElementById('Senha1');
       var obj2 = document.getElementById('Senha2');
       return false;
	   document.getElementById('divretorno').innerHTML=document.getElementById('divretorno').innerHTML + '<div class="diverro">As Senhas não conferem!</div>';
   } else { 
       return true;
   }
  
  }

 
 
 function checaTitulo(obj) {
	
    var retorno=true;
	

			if (!retorno) {
				ChecaVazio(document.getElementById(obj).value);
			} else {
				retorno = ChecaVazio(document.getElementById(obj).value);
			}
			return retorno;

}

 
 


function SemEnter(obj,e){
    var tecla=(window.event)?event.keyCode:e.which;


   if((tecla == 13)) {
		return false;
    }else{
			return true;
		}
}


	
		

	
	
	
	
	
	

	


