/* =============================	  ENQUETE	   =============================  */

var xmlHttp;

function createXMLHttpRequest() {
    if (window.ActiveXObject) {
        xmlHttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    else if (window.XMLHttpRequest) {
        xmlHttp = new XMLHttpRequest();
    }
}

function votacao(varForm) {
	
marcado = -1
resposta = ""
for (i=0; i<varForm.radio.length; i++) {
	if (varForm.radio[i].checked) {
		marcado = i
		resposta = varForm.radio[i].value
	}
}

if (marcado == -1) {
	alert("Selecione uma resposta.");
	varForm.radio[0].focus();
	return false;
}
	
	createXMLHttpRequest();
	xmlHttp.onreadystatechange = handleStateChangeEnquete;
	xmlHttp.open("POST", "asp/resultado_enquete.asp", true);

	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
	xmlHttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	xmlHttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	xmlHttp.setRequestHeader("Pragma", "no-cache");

	xmlHttp.send("radio=" + resposta);
}

function handleStateChangeEnquete() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
            document.getElementById("cadastro_enquete").innerHTML = xmlHttp.responseText;
        }
    }
}

/* ============================= 		SUGESTÃO		============================= */

function novaSugestao(varForm) {
	
var varNome;

var varEmail;

var varMensagem;

var errorMsg = "";

// Atribui valores as variáveis
varNome  = escape(varForm.nome.value);
//varTelefone = escape(varForm.txtTelefone.value);
varEmail    = escape(varForm.email.value);
//varSite  = escape(varForm.txtSite.value);
varMensagem    = escape(varForm.mensagem.value);

//verifica os campos
	var ok = true;

    var tamanho = varEmail;
    var BadChars = "*|,\":<>[]{}`/'';()&$#% =+¨!?ª°º§^áéíóúäãü~õôâ´"; 

	if (varNome == "Nome" || varNome == ""){
		errorMsg += "\t O Campo Nome é de preenchimento obrigatório \n";
		varForm.nome.focus(); 
	}

	if (varNome == "Nome" || varNome == ""){
		errorMsg += "\t O Campo Nome é de preenchimento obrigatório \n";
		varForm.mensagem.focus(); 
	}

	if (varEmail == "" || varEmail == "E-mail"){
		errorMsg += "\t O E-mail é de preenchimento obrigatório \n";
		varForm.email.focus(); 
	}

	if (varEmail.search("@") == -1) {
		errorMsg += "\t O E-mail deve conter " + "'" + "@" + "'" + "\n";
		varForm.email.focus(); 
	} else if (varEmail.search("[.*]") == -1) {
		errorMsg += "\t Seu E-mail não contém " + "'" + "." + "'" + "\n";
		varForm.email.focus(); 
	} else if (tamanho.length < 6) {
		errorMsg += "\t Seu E-mail não contém o mínimo de 6 caracteres - \n";
		varForm.email.focus(); 
	}

	for (var i = 0; i < tamanho.length; i++) { 
    	if (BadChars.indexOf(tamanho.charAt(i)) != -1) {
		   errorMsg += "\t Seu E-mail contém caracteres inválidos " + "'" + (tamanho.charAt(i)) + "'" + "\n";
           varForm.email.focus(); 
   	    }
    }

	if (errorMsg != ""){
		msg = "Para que este formulário seja enviado, os seguintes dados devem ser preenchidos:\n\n";
		errorMsg += alert(msg + errorMsg + "\n");
		return false;
	}

	createXMLHttpRequest();
	xmlHttp.onreadystatechange = handleStateChangeSugestao;
	xmlHttp.open("POST", "asp/sugestao.asp", true);

	xmlHttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded; charset=iso-8859-1");
	xmlHttp.setRequestHeader("Cache-Control", "no-store, no-cache, must-revalidate");
	xmlHttp.setRequestHeader("Cache-Control", "post-check=0, pre-check=0");
	xmlHttp.setRequestHeader("Pragma", "no-cache");

	xmlHttp.send("nome=" + varNome + "&email=" + varEmail + "&mensagem=" + varMensagem);
}

function handleStateChangeSugestao() {
    if(xmlHttp.readyState == 4) {
        if(xmlHttp.status == 200) {
            document.getElementById("sugestoes").innerHTML = xmlHttp.responseText;
        }
    }
}

/* =============================    FLASH    =============================*/

function GerarSWF_ensinos($arquivo){
	$(".banner").html(
		"<object classid='clsid:D27CDB6E-AE6D-11cf-96B8-444553540000' codebase='http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=9,0,28,0' name='banner_flash' width='482' height='216' id='banner_flash'>"+
			"<param name='movie' value='"+$arquivo+"' />"+
			"<param name='quality' value='high' />"+
			"<param name='wmode' value='opaque' />"+
			"<embed src='"+$arquivo+"' width='482' height='216' quality='high' wmode='opaque' pluginspage='http://www.adobe.com/shockwave/download/download.cgi?P1_Prod_Version=ShockwaveFlash' type='application/x-shockwave-flash' name='banner_flash'></embed>"+
		"</object>"
	);
}

/* =============================	IMPRIMIR    =============================*/

function DoPrinting(){
	if (!window.print){
		alert("Use o Netscape ou Internet Explorer \n nas versões 4.0 ou superior!")
		return
	}
	window.print()
}

/* =============================    PROFISSÂO    =============================*/

function profissao(letra) { 
	$("#lista").fadeOut("slow");
	//$("#lista").html("<div align='center'><img src='imagens/site/loading-bar-black.gif' /></div>");
	 setTimeout( function(){
		$.ajax({
			method: "get",url: "asp/profissoes.asp", data: "inicial=" + letra,
			success: function(html){
				$("#lista").html(html);
				$("#lista").fadeIn("slow");
				execJS(document.getElementById("principal"));
			}
		})
	}, 500);
}

/* =============================    ORIENTAÇÕES    =============================*/

function pagina_1(id) {
	$("#area_orientacoes").fadeOut("slow");
	 setTimeout( function(){
		$.ajax({
			method: "get",url: "asp/orientacoes_pg1.asp", data: "id=1",
			success: function(html){
				$("#area_orientacoes").html(html);
				$("#area_orientacoes").fadeIn("slow");
				execJS(document.getElementById("principal"));
			}
		})
	}, 500);
}

function pagina_2() { 
	$("#area_orientacoes").fadeOut("slow");
	 setTimeout( function(){
		$.ajax({
			method: "get",url: "asp/orientacoes_pg2.asp", data: "id=1",			
			success: function(html){
				$("#area_orientacoes").html(html);
				$("#area_orientacoes").fadeIn("slow");
				execJS(document.getElementById("principal"));
			}
		})
	}, 500);
}

/* =============================    SETEMIDIA    =============================   */

function fundo_download( elemento ){
	document.getElementById( elemento.id ).className = "mouse_over download";
	//document.getElementById( "conteudo" ).className = "mouse_over";
}

function fundo_normal( elemento ){
	document.getElementById( elemento.id ).className = "bordaBox download";
	//document.getElementById( "conteudo" ).className = "mouse_over";
}

function sete_midia(pagina) {
	$("#area_setemidia").fadeOut("slow");
	 setTimeout( function(){
		$.ajax({
			method: "get",url: pagina, data: "id=1",
			success: function(html){
			$("#area_setemidia").html(html);
			$("#area_setemidia").fadeIn("slow");
			execJS(document.getElementById("principal"));
			}
		});
	}, 500);
}

function sete_midia_campanhas(pagina) {
	$("#area_campanhas").fadeOut("slow");
	 setTimeout( function(){
		$.ajax({
			method: "get",url: pagina, data: "id=1",
			success: function(html){
			$("#area_campanhas").html(html);
			$("#area_campanhas").fadeIn("slow");
			execJS(document.getElementById("principal"));
			}
		});
	}, 500);
}

/* =============================    PAGINA INICIAL    =============================  */

function pagina_inicial(pagina, parametro) {
	$("#principal").fadeOut("normal");
	setTimeout( function(){
		$.ajax({
			method: "get",url: pagina, data: parametro,
			success: function(html){
			$("#principal").html(html);
			$("#principal").fadeIn("normal");
			execJS(document.getElementById("principal"));
			}
		});
	}, 500);
}

function pagina_inicial_cad(pagina, parametro) {
	$("#principal").fadeOut("normal");	
	setTimeout( function(){
		$("#conteudo_site").html("<div id='principal' style='visibility:hidden'><iframe frameborder='0' onkeydown='return false' oncontextmenu='return false' src='"+pagina+"' name='conteudo' id='conteudo_iframe'/></div>");
	}, 500);
	setTimeout( function(){
		$("#principal").css({'visibility' : 'visible'});
	}, 1000);
}

/* =============================    CARREGANDO CSS    =============================   */

function loadCSS(url){
    var lnk = document.createElement('link');
    lnk.setAttribute('type', "text/css" );
    lnk.setAttribute('rel', "stylesheet" );
    lnk.setAttribute('href', url );
    document.getElementsByTagName("head").item(0).appendChild(lnk);
}

function remover_CSSENSINOS(){
	removejscssfile( "esporte.css", "css" );
	removejscssfile( "fundamental1.css", "css" );
	removejscssfile( "fundamental2.css", "css" );
	removejscssfile( "infantil.css", "css" );
	removejscssfile( "medio.css", "css" );
	removejscssfile( "tecnico.css", "css" );
}

function removejscssfile(filename, filetype){
	var targetelement=(filetype=="js")? "script" : (filetype=="css")? "link" : "none" //determina o tipo de elemento para criar a lista
	var targetattr=(filetype=="js")? "src" : (filetype=="css")? "href" : "none" //determina o atributo correspondente para teste de repetição
	var allsuspects=document.getElementsByTagName(targetelement)
	for (var i=allsuspects.length; i>=0; i--){ //search backwards within nodelist for matching elements to remove
		if (allsuspects[i] && allsuspects[i].getAttribute(targetattr)!=null && allsuspects[i].getAttribute(targetattr).indexOf(filename)!=-1)
		allsuspects[i].parentNode.removeChild(allsuspects[i]) //remove element by calling parentNode.removeChild()
	}
}

/* ============================= 	PROJETOS PEDAGOGICOS    =============================*/

function institucional( id ) {
	$(".lc").fadeOut("normal");
	 setTimeout( function(){
		$.ajax({
			method: "get",url: "asp/select_institucional.asp", data: "id=" + id,
			success: function(html){
			$(".lc").html(html);
			$(".lc").fadeIn("normal");
			execJS(document.getElementById("principal"));
			}
		});
	}, 500);
}

/* =============================	GUIA DE PROFISSÕES    =============================*/

function pagina_1(pagina) {
	$("#area_orientacoes").fadeOut("normal");
	 setTimeout( function(){var eventos_show = $(this).attr("title");
		$.ajax({
			method: "get",url: pagina, data: "",
			success: function(html){
			$("#area_orientacoes").html(html);
			$("#area_orientacoes").fadeIn("normal");
			execJS(document.getElementById("principal"));
			}
		});
	}, 500);
}

/* =============================	ANIVERSARIANTES    =============================*/

function abrir_mes(mes, arquivo) {
	$("#Marquee").fadeOut("normal");
	$("#Marquee").html("<div style='float: left; height: 915px'></div>");
	$("#aniversariente_mes").html(mes + " de 2009");
	 setTimeout( function(){var eventos_show = $(this).attr("title");
		$.ajax({
			method: "get",url: "aniversariantes/" + arquivo, data: "id=1",
			success: function(html){
			$("#Marquee").html(html);
			$("#Marquee").fadeIn("normal");
			execJS(document.getElementById("principal"));
			}
		});
	}, 500);
}


/* =============================	PESQUISA    =============================*/

function Valida_Biblioteca_Pesquisa( pagina, index ){
	var boolValid = false;
	var nome = $("#nome").attr("value");
	var opcao = "";
	$('input:radio').each(function() {
		if ( $(this).is(':checked') ) {
			opcao = $(this).attr("value");
			boolValid = true;
		}
	});

	if( index == 0 ){
		if (boolValid && nome != "") {
			pagina_inicial_cad( "","" );
			setTimeout( function(){document.getElementById('conteudo_iframe').src = "pesquisabiblioteca.asp?nome="+nome+"&opcao="+opcao+"&pagina="+pagina}, 1500 );
		}
	}else{
		pesquisa_biblioteca(nome, opcao, pagina);
	}
}

function pesquisa_biblioteca(nome, opcao, pagina) {
	if( (nome == "") || (opcao == "")) return false;
	$("#principal").fadeOut("normal");
	 setTimeout( function(){var eventos_show = $(this).attr("title");
		$.ajax({
			method: "get",url: "asp/pesquisa_biblioteca.asp", data: "nome="+escape(nome)+"&opcao="+opcao+"&pagina="+pagina,
			success: function(html){
			$("#principal").html(html);
			$("#principal").fadeIn("normal");
			execJS(document.getElementById("principal"));
			}
		});
	}, 500);
}