	
	//procura de escola ******************************************************************************************
	function mostra_procura_escola(valor) { 
        document.getElementById('resulado-escola').innerHTML=valor;
        document.getElementById('apoio1').style.display="none";
        document.getElementById('apoio2').style.display="block";
	}
	//form de procura de escola **************************************
	function env_procura_escola() {
        document.getElementById('descricao-escola').style.display="none";
        document.getElementById('foto-escola').innerHTML="";
        document.getElementById('info-escola').innerHTML="";
		document.getElementById('portal_escola').value="";
		dir = document.getElementById('sel_diretoria').value;
        tre = document.getElementById('txt_escola_trecho').value;
		if(tre.length<1) {
			alert('Campo Escola inválido.');
			return false;
		}
		if(document.getElementById('rad_escola_nome').checked)
		    fil = 'nome_fantasia';
		if(document.getElementById('rad_escola_bairro').checked)
		    fil = 'bairro';
        document.getElementById('resulado-escola').innerHTML="<span class='carregando'>Carregando...</span>";
        document.getElementById('resulado-escola').style.display="block";
		x_procura_escola(dir, tre, fil, 'formulario', mostra_procura_escola);
	}
	//alfabeto de procura de escola **********************************
	function alfa_procura_escola(e) {
		document.getElementById('descricao-escola').style.display="none";
        document.getElementById('foto-escola').innerHTML="";
        document.getElementById('info-escola').innerHTML="";
		document.getElementById('portal_escola').value="";
        dir = document.getElementById('sel_diretoria').value;
	    //Correção para eventos quebrados da Microsoft
        if(typeof(e)=='undefined')
	        var e=window.event
        source=e.target?e.target:e.srcElement
        //Correção para o bug do Konqueror/Safari
        if(source.nodeType==3)
	        source=source.parentNode
        //Obtém o número quebrando a url
        tre=source.getAttribute("href").replace(/.*=/g,"")
		if(document.getElementById('rad_escola_nome').checked)
		    fil = 'nome_fantasia';
		if(document.getElementById('rad_escola_bairro').checked)
		    fil = 'bairro';
        document.getElementById('resulado-escola').innerHTML="<span class='carregando'>Carregando...</span>";
        document.getElementById('resulado-escola').style.display="block";
		x_procura_escola(dir, tre, fil, 'alfabeto', mostra_procura_escola);
        //Cancela o click (evita a navegação)
        return false
	}
	
	//seleciona escola ***************************************************************************************
	function mostra_descricao_foto_escola(valor) {
		//document.getElementById('foto-escola').innerHTML=valor;
	}
	function mostra_descricao_info_escola(valor) {
        document.getElementById('info-escola').innerHTML=valor;
	}
	function mostra_descricao_logon_escola(valor) {
        document.getElementById('portal_escola').value=valor;
	}
	function selescola(id) {
 		document.getElementById('id_escola').value=id;
		document.getElementById('se_diretoria').value = 0;
		document.getElementById('resulado-escola').innerHTML="";
        document.getElementById('resulado-escola').style.display="none";
        document.getElementById('descricao-escola').style.display="block";
        document.getElementById('info-escola').innerHTML="<span class='carregando'>Carregando...</span>";
        //document.getElementById('foto-escola').innerHTML="<span class='carregando'>Carregando...</span>";
		//patrocinador
		//if(layout_carrega_patrocinador) {
		    //carregar_patrocinador();
            //document.getElementById('apoio1').style.display="block";
            //document.getElementById('apoio2').style.display="none";
		//}
		x_descricao_logon_escola(id, mostra_descricao_logon_escola);
		x_descricao_info_escola(id, mostra_descricao_info_escola);
		x_descricao_foto_escola(id, mostra_descricao_foto_escola);
	}

    //logon de escola ******************************************************************************************
	function form_login(user_logado) {
		if(user_logado) {
		    document.getElementById('nome-user').innerHTML=user_logado;
			document.getElementById('logon-escola-user').style.display="block";
		    document.getElementById('logon-escola-form').style.display="none";
		} else {
		    document.getElementById('nome-user').innerHTML='';
		    document.getElementById('logon-escola-user').style.display="none";
		    document.getElementById('logon-escola-form').style.display="block";
		}
	}
	function login_escola(valor) { 
		var nome = valor.split(':::');
		if(!nome[0]) {
		    document.getElementById('logon-escola-erro').innerHTML='<strong>LOGIN INVÁLIDO</strong><br />Verifique o LOGIN e/ou SENHA digitados.';
	    } else {
		    document.getElementById('logon-escola-erro').innerHTML='';
			form_login(nome[0]);
            var contar = parametro_contar(); 
			//1058784493sp  alterasenha 
			if((nome[1]!=3)&&(nome[1]!=5)) 
			    janela_total('sistemas/popup.php?l=1largura='+largura+''+contar, 'sef');
			else
			    document.location.href='sef/previous/popup.php';
                document.getElementById('login').value='';
                document.getElementById('senha').value='';
			//janela_popup('sistemas2/adframes_1/server/banner_popup.php','banner_centro','300','250','no');
		}
	}
	function logon_escola() {
		document.getElementById('logon-escola-erro').innerHTML="<span class='carregando'>Verificando...</span>";
        login  = document.getElementById('login').value;
        senha  = document.getElementById('senha').value;
        portal = document.getElementById('portal_escola').value;
        id     = document.getElementById('id_escola').value;
        dir    = document.getElementById('se_diretoria').value;
		setTimeout('x_logon(login, senha, portal, id, dir, login_escola)',1000);
	}

    //logon de escola ******************************************************************************************
	function logout_escola(valor) {
		document.getElementById('logon-escola-erro').innerHTML='';
		user_logado = false;
		form_login(user_logado);
	}
	function sair_escola() {
		document.getElementById('logon-escola-erro').innerHTML="<span class='carregando'>Carregando...</span>";
		x_logout('sair', logout_escola);
	}

    //conteudo dir menu ******************************************************************************************
	function exibir_menu_dir_onde(valor) {
		document.getElementById('onde').innerHTML=valor;
	}
	function exibir_menu_dir_conteudo(valor) {
		document.getElementById('conteudo').innerHTML=valor;
	}
	function carregar_menu_dir_conteudo(o,d) {
 		var idr = document.getElementById('id_regional').value;
		document.getElementById('comoacessar').style.display="none";
		document.getElementById('onde').innerHTML="";
		document.getElementById('conteudo').innerHTML="<span class='carregando'>Carregando...</span>";
		x_dir_menu_onde(o, idr, d, exibir_menu_dir_onde);
		x_dir_menu_conteudo(o, idr, d, exibir_menu_dir_conteudo);
	}
	function carregar_menu_dir_conteudo_login(o,d) {
        janela_popup('sistemas/eesp_1.0/server/login_membro.php?m='+o+'&d='+d,'membro',350,50,'yes');
    }

    //LAYOUT PADRÃO //////////////////////////////////////////////////////////////////////////////////////////////
    // Diretoria **************************************************************************************************
	function exibir_diretoria_nome(valor) {
		var diretoria=document.getElementById("diretoria");
        var nome_diretoria=diretoria.getElementsByTagName("h2");
        nome_diretoria[0].innerHTML=valor;
	}
	function exibir_diretoria_cargo(valor) {
		var diretoria=document.getElementById("diretoria");
	}
	function exibir_diretoria_dirigente(valor) {
        var diretoria=document.getElementById("diretoria");
        var data_diretoria=diretoria.getElementsByTagName("p");
        data_diretoria[0].innerHTML=valor;
	}
	function exibir_diretoria_logo(valor) {
		//document.getElementById("logotipo").innerHTML=valor;
	}
	function carregar_diretoria() {
		var h  = location.hostname;
		if(location.search=='?outras')
		    h += location.search;
		if(h=='www.eesp.com.br')           {var d = 'Todas';}
		if(h=='www.eesp.com.br?outras')    {var d = 'Outras';}
		if(h=='www.centro.eesp.com.br')    {var d = 'Centro';}
		if(h=='www.centrosul.eesp.com.br') {var d = 'Centro Sul';}
		if(h=='www.norte2.eesp.com.br')    {var d = 'Norte 2';}
		if(h=='www.sul1.eesp.com.br')      {var d = 'Sul 1';}
		if(h=='www.sul3.eesp.com.br')      {var d = 'Sul 3';}
		if(h=='www.dmejac.com.br')         {var d = 'Jacupiranga';}
		if(h=='localhost')                 {var d = 'Todas';}
		if(h=='201.81.140.29:48781')                 {var d = 'Todas';}
		//if(h=='www.adframes.com.br')       {var d = 'Todas';}
		//x_diretoria_nome(h, exibir_diretoria_nome);
		//x_diretoria_cargo(h, exibir_diretoria_cargo);
		//x_diretoria_dirigente(h, exibir_diretoria_dirigente); // and ($urle!="201.81.140.29:48781")
		//x_diretoria_logo(h, exibir_diretoria_logo);
		var s = document.getElementById("sel_diretoria");
		for(var i=0;i<s.length;i++)
		    if(s.options[i].value==d)
			    s.options[i].selected = true
	}
	function direciona_diretoria() {
		var h = document.getElementById('sel_diretoria').value;
		document.getElementById("procura-escola").innerHTML="<span class='carregando'>Carregando Diretoria...</span>";
		if(h=='Todas')       { document.location.href='http://www.eesp.com.br'}
		if(h=='Outras')      { document.location.href='http://www.eesp.com.br/?outras'}
		if(h=='Centro')      { document.location.href='http://www.centro.eesp.com.br'}
		if(h=='Centro Sul')  { document.location.href='http://www.centrosul.eesp.com.br'}
		if(h=='Norte 2')     { document.location.href='http://www.norte2.eesp.com.br'}
		if(h=='Sul 1')       { document.location.href='http://www.sul1.eesp.com.br'}
		if(h=='Sul 3')       { document.location.href='http://www.sul3.eesp.com.br'}
		if(h=='Jacupiranga') { document.location.href='http://www.dmejac.com.br'}
		//if(h=='Todas')      { document.location.href='http://www.adframes.com.br'}
	}
	function exibir_diretoria_id(valor) {
		document.getElementById("id_regional").value=valor;
		x_diretoria_nome(valor, exibir_diretoria_nome);
		x_diretoria_cargo(valor, exibir_diretoria_cargo);
		x_diretoria_dirigente(valor, exibir_diretoria_dirigente);
	    
		carregar_noticias_dir(0,layout_qtd_noticias);
		if(!esc_selecionada) {
            seldiretoria();
		}
	    if(layout_carrega_patrocinador)
		    carregar_patrocinador()

	}
	function carregar_id_regional() {
        var id = document.getElementById('id_escola').value;
		var re = document.getElementById('sel_diretoria').value;
		x_diretoria_id(id, re, exibir_diretoria_id);
	}
	function seldiretoria() {
        var id = document.getElementById('id_regional').value;
		document.getElementById('se_diretoria').value = 1;
		document.getElementById('resulado-escola').innerHTML="";
        document.getElementById('resulado-escola').style.display="none";
        document.getElementById('descricao-escola').style.display="block";
        document.getElementById('apoio1').style.display="none";
        document.getElementById('info-escola').innerHTML="<span class='carregando'>Carregando...</span>";
        //document.getElementById('foto-escola').innerHTML="<span class='carregando'>Carregando...</span>";
		x_descricao_logon_diretoria(id, mostra_descricao_logon_escola);
		x_descricao_info_diretoria(id, mostra_descricao_info_escola);
		//x_descricao_foto_diretoria(id, mostra_descricao_foto_escola);
	}
	
	//Patrocinador ***********************************************************************************************
	function mostra_patrocinador_banner(valor) {
		document.getElementById('apoio-banner1').innerHTML=valor;
	    if(layout_carrega_patrocinador)
		    document.getElementById('apoio-banner2').innerHTML=valor;
	}
	function mostra_patrocinador_logo(valor) {
        document.getElementById('apoio-logo1').innerHTML=valor;
	    if(layout_carrega_patrocinador)
            document.getElementById('apoio-logo2').innerHTML=valor;
	}
	function carregar_patrocinador() {
 		return
		var id = document.getElementById('id_escola').value;
 		var idr = document.getElementById('id_regional').value;
        document.getElementById('apoio-banner1').innerHTML="<span class='carregando'>Carregando patrocinador...</span>";
	    if(layout_carrega_patrocinador)
            document.getElementById('apoio-banner2').innerHTML="<span class='carregando'>Carregando patrocinador...</span>";
		x_patrocinador_banner(id, idr, mostra_patrocinador_banner);
		x_patrocinador_logo(id, mostra_patrocinador_logo);
	}
	
	//ajuda Login ************************************************************************************************
	function ajuda_login() {
		funcao_conteudo('ajuda')
	}
    // Menu Dir **************************************************************************************************
	function exibir_dir_menu_1(valor) {
		document.getElementById('menu1').innerHTML=valor;
	}
	function exibir_dir_menu_2(valor) {
		document.getElementById('menu2').innerHTML=valor;
	}
	function exibir_dir_menu_3(valor) {
		document.getElementById('menu3').innerHTML=valor;
	}
	function exibir_dir_menu_4(valor) {
		document.getElementById('menu4').innerHTML=valor;
	}
	function exibir_dir_menu_5(valor) {
		document.getElementById('menu5').innerHTML=valor;
	}
	function exibir_dir_menu_6(valor) {
		document.getElementById('menu6').innerHTML=valor;
	}
	function exibir_dir_menu_7(valor) {
		document.getElementById('menu7').innerHTML=valor;
	}
	function exibir_dir_menu_8(valor) {
		document.getElementById('menu8').innerHTML=valor;
	}
	function exibir_dir_menu_9(valor) {
		document.getElementById('menu9').innerHTML=valor;
	}
	function exibir_dir_menu_10(valor) {
		document.getElementById('menu10').innerHTML=valor;
	}
	function exibir_dir_menu_11(valor) {
		document.getElementById('menu11').innerHTML=valor;
	}
	function exibir_dir_menu_12(valor) {
		document.getElementById('menu12').innerHTML=valor;
	}
	function exibir_dir_menu_13(valor) {
		document.getElementById('menu13').innerHTML=valor;
	}
	function exibir_dir_menu_14(valor) {
		document.getElementById('menu14').innerHTML=valor;
	}
	function exibir_dir_menu_15(valor) {
		document.getElementById('menu15').innerHTML=valor;
	}
	function exibir_dir_menu_16(valor) {
		document.getElementById('menu16').innerHTML=valor;
	}
	function exibir_dir_menu_17(valor) {
		document.getElementById('menu17').innerHTML=valor;
	}
	function exibir_dir_menu_18(valor) {
		document.getElementById('menu18').innerHTML=valor;
	}
	function exibir_dir_menu_19(valor) {
		document.getElementById('menu19').innerHTML=valor;
	}
	function exibir_dir_menu_20(valor) {
		document.getElementById('menu20').innerHTML=valor;
	}
	function exibir_dir_menu_21(valor) {
		document.getElementById('menu21').innerHTML=valor;
	}
	function carregar_menu_dir() {
		var idr = document.getElementById('sel_diretoria').value;
		if(layout_qtd_menu>=1)  { x_dir_menu(1, idr, exibir_dir_menu_1); }
		if(layout_qtd_menu>=2)  { x_dir_menu(2, idr, exibir_dir_menu_2); }
		if(layout_qtd_menu>=3)  { x_dir_menu(3, idr, exibir_dir_menu_3); }
		if(layout_qtd_menu>=4)  { x_dir_menu(4, idr, exibir_dir_menu_4); }
		if(layout_qtd_menu>=5)  { x_dir_menu(5, idr, exibir_dir_menu_5); }
		if(layout_qtd_menu>=6)  { x_dir_menu(6, idr, exibir_dir_menu_6); }
		if(layout_qtd_menu>=7)  { x_dir_menu(7, idr, exibir_dir_menu_7); }
		if(layout_qtd_menu>=8)  { x_dir_menu(8, idr, exibir_dir_menu_8); }
		if(layout_qtd_menu>=9)  { x_dir_menu(9, idr, exibir_dir_menu_9); }
		if(layout_qtd_menu>=10) { x_dir_menu(10, idr, exibir_dir_menu_10); }
		if(layout_qtd_menu>=11) { x_dir_menu(11, idr, exibir_dir_menu_11); }
		if(layout_qtd_menu>=12) { x_dir_menu(12, idr, exibir_dir_menu_12); }
		if(layout_qtd_menu>=13) { x_dir_menu(13, idr, exibir_dir_menu_13); }
		if(layout_qtd_menu>=14) { x_dir_menu(14, idr, exibir_dir_menu_14); }
		if(layout_qtd_menu>=15) { x_dir_menu(15, idr, exibir_dir_menu_15); }
		if(layout_qtd_menu>=16) { x_dir_menu(16, idr, exibir_dir_menu_16); }
		if(layout_qtd_menu>=17) { x_dir_menu(17, idr, exibir_dir_menu_17); }
		if(layout_qtd_menu>=18) { x_dir_menu(18, idr, exibir_dir_menu_18); }
		if(layout_qtd_menu>=19) { x_dir_menu(19, idr, exibir_dir_menu_19); }
		if(layout_qtd_menu>=20) { x_dir_menu(20, idr, exibir_dir_menu_20); }
		if(layout_qtd_menu>=21) { x_dir_menu(21, idr, exibir_dir_menu_21); }
	}
    // Noticias Dir **************************************************************************************************
	function exibir_noticias_dir(valor) {
		var str = valor.split(":::");
		document.getElementById('onde').innerHTML=str[0].replace(':::','');
		document.getElementById('conteudo').innerHTML=str[1].replace(':::','');
	}
	function carregar_noticias_dir(inicio,fim) {
 		var idr = document.getElementById('id_regional').value;
		x_dir_noticias(inicio, fim, idr, exibir_noticias_dir);
	}
	// Acesso Rapido ************************************************************************************************
	function exibir_enviar_contato(valor) {
		document.getElementById('nome').value='';
		document.getElementById('email').value='';
		document.getElementById('ddd').value='';
		document.getElementById('telefone').value='';
		document.getElementById('assunto').value='';
		document.getElementById('mensagem').value='';
		document.getElementById('conteudo').innerHTML="<div class=\"texto\">"+valor+"</div>";
	}
	function enviar_contato() {
		var idr          = document.getElementById('id_regional').value;
		var autor        = document.getElementById('nome').value;
		var email        = document.getElementById('email').value;
		var ddd          = document.getElementById('ddd').value;
		var telefone     = document.getElementById('telefone').value;
        
		
        var destinatario = 'de10102g@see.sp.gov.br';

        var titulo       = "Mensagem do Portal: "+document.getElementById('assunto').value;
		var msg          = document.getElementById('mensagem').value;
		if(!autor) {
		    alert('O campo Nome é obrigatório !');
			return false;
		}
		if(!telefone) {
		    alert('O campo Telefone é obrigatório !');
			return false;
		}
		if(!msg) {
		    alert('O campo Mensagem é obrigatório !');
			return false;
		}
		document.getElementById('conteudo').innerHTML="<div class=\"texto\">Enviando mensagem...</div>"+document.getElementById('conteudo').innerHTML;
		x_enviar_contato(idr,autor,email,destinatario,titulo,msg,ddd,telefone, exibir_enviar_contato);
	}
	function exibir_contato(valor) {
		document.getElementById('conteudo').innerHTML=valor;
	}
	function acesso_rapido(acao) {
        if(acao=='fechar') {
            document.getElementById('resulado-escola').style.display="none";
            document.getElementById('descricao-escola').style.display="none";
		} else if(acao=='contato') {
 		    var idr = document.getElementById('id_regional').value;
		    document.getElementById('onde').innerHTML='Fale conosco';
			document.getElementById('conteudo').innerHTML="<span class='carregando'>Carregando...</span>";
		    x_contato(idr, exibir_contato);
        } else if(acao=='noticias') {
			carregar_noticias_dir(0,layout_qtd_noticias);
		}
    }
	
	function fechar_descricao() {
		document.getElementById('descricao-escola').style.display="none";
	}

    //start ******************************************************************************************************
	function iniciar(){
		//LAYOUT PADRAO //////////////////////////////////////////////////////////////////////////////////////////////
		//Diretoria
	    //carregar_diretoria()
	    //***********************************************************
		//Id_regional
		carregar_id_regional();
	    //***********************************************************
		//Cookie com a ultima escola
	    if(esc_selecionada) {
			selescola(esc_selecionada)
            //document.getElementById('apoio1').style.display="block";
            //document.getElementById('apoio2').style.display="none";
		} else {
		//***********************************************************
		//Patrocinador
            document.getElementById('apoio1').style.display="none";
            document.getElementById('apoio2').style.display="block";
		}
	    //***********************************************************
		//Abre os links em outra janela (js/_blank.js)
		createExternalLinks()
	    //***********************************************************
		//Menu Dir
	    carregar_menu_dir()
	    //***********************************************************
		//Noticias Dir
		document.getElementById('onde').innerHTML="";
		document.getElementById('conteudo').innerHTML="<span class='carregando'>Carregando notícias...</span>";
	    //***********************************************************
		//EVENTOS ////////////////////////////////////////////////////////////////////////////////////////////////
		//Session usuario logado
		form_login(user_logado)
	    //***********************************************************
		//Ajuda Login
        //var ajuda=document.getElementById("logon-escola-form")
        //var ajuda=ajuda.getElementsByTagName("a")
        //ajuda[0].onclick=ajuda_login
		//***********************************************************
		//Procura escola form
	    var procura_escola = document.getElementById("bt_id_filtro")
	    procura_escola.onclick=env_procura_escola
	    //***********************************************************
		//Procura escola alfabeto
        var alfabeto=document.getElementById("alfabeto")
        var links=alfabeto.getElementsByTagName("a")
        for(var i=0;i<links.length;i++)
            links[i].onclick=alfa_procura_escola
	    //***********************************************************
		//Logon form
	    var logon = document.getElementById("logon")
	    logon.onclick=logon_escola
	    //***********************************************************
		//Logout
	    var sair = document.getElementById("sair")
	    sair.onclick=sair_escola
	    //***********************************************************
	}
	window.onload=iniciar
