function ajax() {
};
ajax.prototype.iniciar = function() {

    try{
        this.xmlhttp = new XMLHttpRequest();
    }catch(ee){
        try{
            this.xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
        }catch(e){
            try{
                this.xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
            }catch(E){
                this.xmlhttp = false;
            }
        }
    }
    return true;
}

ajax.prototype.ocupado = function() {
    estadoAtual = this.xmlhttp.readyState;
    return (estadoAtual && (estadoAtual < 4));
}

ajax.prototype.processa = function() {
    if (this.xmlhttp.readyState == 4 && this.xmlhttp.status == 200) {
        return true;
    }
}

ajax.prototype.enviar = function(url, metodo, modo) {
    if (!this.xmlhttp) {
        this.iniciar();
    }
    if (!this.ocupado()) {
        if(metodo == "GET") {
            this.xmlhttp.open("GET", url, modo);
            this.xmlhttp.send(null);
        } else {        
            this.xmlhttp.open("POST", url, modo);
            this.xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=UTF-8");
            this.xmlhttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
            this.xmlhttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
            this.xmlhttp.setRequestHeader("Pragma", "no-cache");
            this.xmlhttp.send(url);
        }    

        if (this.processa) {
            return unescape(this.xmlhttp.responseText.replace(/\+/g," "));
        }
    }
    return false;
}
function verifica_login(url, metodo, modo) {
var login = document.getElementById('login').value;
if(login !== "") { 
remoto  = new ajax();
xmlhttp = remoto.enviar(url + "?login=" + login, metodo, modo );
if(xmlhttp) {
alert('Este usuário já está em uso, escolha outro.');
document.getElementById("login").focus();
return false;
}    
}
}
function valida_login() { 
if(document.getElementById("login").value == "") { 
alert('Digite seu nome de usuário (login)');
document.getElementById("login").focus();
return false;
}
if(document.getElementById("senha").value == "") { 
alert('Digite sua senha');
document.getElementById("senha").focus();
return false;
}
var conta = 0;
if (conta == 0){
conta++;
return true;
}
else {
alert("O formulário de contato está sendo enviado, aguarde...!");
return false;
}
document.login_auth.submit();
}

function valida_trabalhe() {
if(document.getElementById("nome").value == "") { 
alert('Digite seu nome.');
document.getElementById("nome").focus();
return false;
}
if(document.getElementById("email").value == "") { 
alert('Digite seu email.');
document.getElementById("email").focus();
return false;
}
if(document.getElementById("uf").value == "") { 
alert('Digite seu estado.');
document.getElementById("uf").focus();
return false;
}
if(document.getElementById("cidade").value == "") { 
alert('Digite seu cidade.');
document.getElementById("cidade").focus();
return false;
}
if(document.getElementById("endereco").value == "") { 
alert('Digite seu endereço.');
document.getElementById("endereco").focus();
return false;
}
if(document.getElementById("bairro").value == "") { 
alert('Digite seu bairro.');
document.getElementById("bairro").focus();
return false;
}
if(document.getElementById("cep").value == "") { 
alert('Digite seu cep.');
document.getElementById("cep").focus();
return false;
}
if(document.getElementById("ddd_tel").value == "") { 
alert('Digite seu DDD.');
document.getElementById("ddd_tel").focus();
return false;
}
if(document.getElementById("telefone").value == "") { 
alert('Digite seu telefone.');
document.getElementById("telefone").focus();
return false;
}
document.trabalhe_conosco.submit();
}
function valida_aluno() { 
if(document.getElementById("cod_unidade").value == "") { 
alert('Selecione uma unidade');
document.getElementById("cod_unidade").focus();
return false;
}
if(document.getElementById("nome").value == "") { 
alert('Digite o nome');
document.getElementById("nome").focus();
return false;
}
if(document.getElementById("email").value == "") { 
alert('Digite o e-mail');
document.getElementById("email").focus();
return false;
}
if(document.getElementById("email").value !== "") { 
var valido;
var str = document.getElementById("email").value;
var filter = /^([\w-]+(?:\.[\w-]+)*)@((?:[\w-]+\.)*\w[\w-]{0,66})\.([a-z]{2,6}(?:\.[a-z]{2})?)$/i;
if(filter.test(str))
valido = true;
else {
alert("Este endereço de email não é válido!");
document.getElementById("email").focus();
valido = false;
return false;
}
}
if(document.getElementById("rg").value == "") { 
alert('Digite o RG');
document.getElementById("rg").focus();
return false;
}
if(document.getElementById("cpf").value == "") { 
alert('Digite o CPF');
document.getElementById("cpf").focus();
return false;
}
if(document.getElementById("dia").value == "") { 
alert('Digite o dia da data de nascimento');
document.getElementById("dia").focus();
return false;
}
if(document.getElementById("mes").value == "") { 
alert('Digite o mês da data de nascimento');
document.getElementById("mes").focus();
return false;
}
if(document.getElementById("ano").value == "") { 
alert('Digite o ano da data de nascimento');
document.getElementById("ano").focus();
return false;
}
if(document.getElementById("uf").value == "") { 
alert('Selecione o estado');
document.getElementById("uf").focus();
return false;
}
if(document.getElementById("cidade").value == "") { 
alert('Selecione a cidade');
document.getElementById("cidade").focus();
return false;
}
if(document.getElementById("endereco").value == "") { 
alert('Digite o endereço');
document.getElementById("endereco").focus();
return false;
}
if(document.getElementById("telefone").value == "") { 
alert('Digite o telefone');
document.getElementById("telefone").focus();
return false;
}
document.cad_aluno.submit();
}
function valida_contato() { 
if(document.getElementById("nome").value == "") { 
alert('Digite seu nome completo');
document.getElementById("nome").focus();
return false;
}
if(document.getElementById("email").value == "") { 
alert('Digite seu email');
document.getElementById("email").focus();
return false;
}
if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("email").value)))  { 
alert("Preencha o seu email corretamente");
document.getElementById("email").focus();
return false;
}
if(document.getElementById("telefone").value == "") { 
alert('Digite seu telefone');
document.getElementById("telefone").focus();
return false;
}
if(document.getElementById("mensagem").value == "") { 
alert('Digite sua mensagem');
document.getElementById("mensagem").focus();
return false;
}
var conta = 0;
if (conta == 0){
conta++;
return true;
}
else {
alert("O formulário de contato está sendo enviado, aguarde...!");
return false;
}
document.contato.submit();
}
function horarios_unidade(div) {
var atividade = document.getElementById("atividade").value;	
var cod_unidade = document.getElementById("cod_unidade").value;	
ajaxHTML(div,"horarios2.php?cod_unidade="+cod_unidade+"&atividade="+atividade); 
}

function campo_focus(campo,type,valid) { 
if(type == "in") { 
document.getElementById(campo).style.backgroundColor = "#FFFCCC";
document.getElementById(campo).style.borderColor = "#666666";
} else { 
document.getElementById(campo).style.backgroundColor = "#FFFFFF";
document.getElementById(campo).style.borderColor = "#999999";
}
if(valid) { 
if(document.getElementById(campo).value == "") { 
alert('Digite o '+campo+'');
document.getElementById(campo).focus();
document.getElementById(campo).style.backgroundColor = "#FFFCCC";
document.getElementById(campo).style.borderColor = "#666666";
return false;
}
}
}
function completaTelefone(campo) {
qtdcaracteres = (campo.value).length;
telefone = campo.value;
if(qtdcaracteres == 4)
campo.value = campo.value + "-";
}
function FormataCPF(Campo, teclapres)
{
	var tecla = teclapres.keyCode;
	
	var vr = new String(Campo.value);
	vr = vr.replace(".", "");
	vr = vr.replace(".", "");
	vr = vr.replace("-", "");

	tam = vr.length + 1;
	
	if (tecla != 9 && tecla != 8)
		{
		if (tam > 3 && tam < 7)
			Campo.value = vr.substr(0, 3) + '.' + vr.substr(3, tam);
		if (tam >= 7 && tam <10)
			Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,tam-6);
		if (tam >= 10 && tam < 12)
			Campo.value = vr.substr(0,3) + '.' + vr.substr(3,3) + '.' + vr.substr(6,3) + '-' + vr.substr(9,tam-9);
		}
		
}
function completaCEP(campo)  {
qtdcaracteres = (campo.value).length;
telefone = campo.value;
if(qtdcaracteres == 5)
campo.value = campo.value + "-";
}

function minuscula(campo) { document.getElementById(campo).value = document.getElementById(campo).value.toLowerCase(); }
function maiuscula(campo) { document.getElementById(campo).value = document.getElementById(campo).value.toUpperCase(); }

function numerico(campo) { 
document.getElementById(campo).value = document.getElementById(campo).value.toLowerCase(); 
var caracteres = "abcdefghijklmnopqrstuvwxyzáéíóúàèìòùâêîôûäëïöüãõ@#$%^&*()-_+=~` ç.\/[]{}<>?!|:;,"; 
var retorno  = ""; 
for(i=0;i<caracteres.length;i++) { 
for(j=0;j<document.getElementById(campo).value.length;j++)  { 
retorno = document.getElementById(campo).value.replace(caracteres.substr(i,1),""); 
document.getElementById(campo).value = retorno; 
} 
} 
}

function pula(obj1, dest, num){
if (obj1.value.length==num){
obj2=obj1.form;
destino=eval("obj2."+dest);
destino.focus();
}
}
function cidades(div,uf,cidade) {                            ajaxHTML(div,"cidades.php?uf="+uf+"&cidade="+cidade);                   }

function mudatit(titulo) { document.getElementById("titulo").innerHTML=titulo; }
function loadContent(url) { 
ajaxHTML('conteudo',url);
}
function loadplanos(div,cod_unidade) {                       ajaxHTML(div,"planos.php?cod_unidade=" + cod_unidade);          }

function loadatividades(div,cod_unidade,cod_atividade) {     ajaxHTML(div,"atividades.php?cod_unidade="+cod_unidade+"&cod_atividade="+cod_atividade);        }
function loadprofessores(div,cod_unidade,cod_professor) {    ajaxHTML(div,"professores.php?cod_unidade="+cod_unidade+"&cod_professor="+cod_professor);       }
function loadmodalidades(div,cod_atividade,cod_modalidade) { ajaxHTML(div,"modalidades.php?cod_atividade="+cod_atividade+"&cod_modalidade="+cod_modalidade); }

function loadDestinarios(div,cod_unidade,tipo) { ajaxHTML(div,"destinarios.php?cod_unidade="+cod_unidade+"&tipo="+tipo); }
function carregafoto(div,cod_destinario,tipo) { ajaxHTML(div,"foto_destinario.php?cod_destinario="+cod_destinario+"&tipo="+tipo); }

function addEvent(obj, evt, func) {
if (obj.attachEvent ) {
return obj.attachEvent(("on"+evt), func);
} else if (obj.addEventListener) {
obj.addEventListener(evt, func, true);
return true;
}
return false;
}
function XMLHTTPRequest() {
try {
return new XMLHttpRequest(); // FF, Safari, Konqueror, Opera, ...
} catch(ee) {
try {
return new ActiveXObject("Msxml2.XMLHTTP"); // activeX (IE5.5+/MSXML2+)
} catch(e) {
try {
return new ActiveXObject("Microsoft.XMLHTTP"); // activeX (IE5+/MSXML1)
} catch(E) {
return false; // doesn't support
}
}
}
}
function processReqChange()
{
if (req.readyState == 4)
{
if (req.status ==200)
{
document.getElementById('pagina').innerHTML = req.responseText;
}
else
{
alert("Houve um problema ao obter os dados:n" + req.statusText);
}
}
}
function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}
function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}
function tmt_confirm(msg){ 	document.MM_returnValue=(confirm(unescape(msg))); }
function valida_newsletter() {
if(document.getElementById("nome").value == "") { 
alert('Digite seu nome.');
document.getElementById("nome").focus();
return false;
}
if(document.getElementById("email").value == "") { 
alert('Digite seu e-mail.');
document.getElementById("email").focus();
return false;
}
document.newsletter.submit();
}
function valida_freepass() {
if(document.getElementById("nome").value == "") { 
alert('Digite seu nome.');
document.getElementById("nome").focus();
document.getElementById("nome").style.backgroundColor = "#FFFCCC";
document.getElementById("nome").style.borderColor = "#666666";
return false;
}
if(document.getElementById("email").value == "") { 
alert('Digite seu e-mail.');
document.getElementById("email").focus();
document.getElementById("email").style.backgroundColor = "#FFFCCC";
document.getElementById("email").style.borderColor = "#666666";
return false;
}
if (!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.getElementById("email").value)))  { 
alert("Preencha seu email corretamente.");
document.getElementById("email").focus();
document.getElementById("email").style.backgroundColor = "#FFFCCC";
document.getElementById("email").style.borderColor = "#666666";
return false;
}
if(document.getElementById("telefone").value == "") { 
alert('Digite seu telefone.');
document.getElementById("telefone").focus();
document.getElementById("telefone").style.backgroundColor = "#FFFCCC";
document.getElementById("telefone").style.borderColor = "#666666";
return false;
}
var conta = 0;
if (conta == 0){
conta++;
return true;
}
else {
alert("O formulrio de freepass est sendo gerado, aguarde...!");
return false;
}
document.getElementById("freepass").submit();
}