var slideShowGaleriaStart = 0;

function ajaxGeral(pagina, div){
	var ajax = null;
	if(window.XMLHttpRequest)	var ajax = new XMLHttpRequest();
	else if(window.ActiveXObject)	var ajax = new ActiveXObject("Microsoft.XMLHTTP");
	else alert("Este navegador não suporta ajax");

	ajax.open("get", pagina, true);
	ajax.onreadystatechange = function() {
		if(ajax.readyState == 4) { 
			if(ajax.status == 200){
				document.getElementById(div).innerHTML = ajax.responseText;
			}
		}
	}
	ajax.send(null);
}

function selecionaMenu(posicaoAtual, idMenu, imgTr1, imgTr2, imgTr3){

	if(idMenu==1)referencia = '/rumo-nossa-historia.php';
	if(idMenu==2)referencia = '/pre_vestibulinho/escolastecnicas.php';
	if(idMenu==3)referencia = '/pre_vestibular/faculdadestecnologicas.php';

	for(i=1;i<= 3;i++){
		imgSel = eval("imgTr"+i)

		if(i==idMenu){
			document.getElementById('tdMenu'+i).innerHTML = "<img src='"+imgSel+"_.jpg' alt='"+referencia+"' onmouseover=selecionaMenu("+posicaoAtual+","+i+",'/images/o_rumo','/images/medio_tecnico_rumo','/images/superior_rumo',referencia)  Style='cursor:pointer' onmousedown='abreItemMenu(referencia)'>";
		}else{
			if(posicaoAtual!=i)
				document.getElementById('tdMenu'+i).innerHTML = "<img src='"+imgSel+".jpg' alt='"+referencia+"' onmouseover=selecionaMenu("+posicaoAtual+","+i+",'/images/o_rumo','/images/medio_tecnico_rumo','/images/superior_rumo',referencia)  Style='cursor:pointer' onmousedown='abreItemMenu(referencia)'>";
		}

	}
}

function abreItemMenu(itemMenu){
	if(itemMenu==8)
		open("http://www.blogdorumo.com.br", "_blank")
	else		
		open( itemMenu, "_top")
}

function mostraGaleria(galeriaID){
	open("galeria.php?nID="+galeriaID, "_top")
}
function slideShowGaleria(){
	clearInterval(slideShowGaleriaStart);
	slideShowGaleriaStart = setInterval("ajaxGeral('includes/slideShowGaleria.php','divGaleriaInterna')", 5000)
}

function slideShowGaleriaStop(){
	clearInterval(slideShowGaleriaStart);
}

function slideShowGaleriaPreview(imgID){
	imgID = document.getElementById('hdImagemInicio').value;
	imgID = eval(imgID)-1;
	if(imgID==0) imgID = 5;
	clearInterval(slideShowGaleriaStart);
	ajaxGeral('includes/slideShowGaleria.php?imgID='+imgID,'divGaleriaInterna')
}

function slideShowGaleriaNext(imgID){
	imgID = document.getElementById('hdImagemInicio').value;
	imgID = eval(imgID)+1
	clearInterval(slideShowGaleriaStart);
	ajaxGeral('includes/slideShowGaleria.php?imgID='+imgID,'divGaleriaInterna')
}

function galeriaImagemMedia(imgID){
	clearInterval(slideShowGaleriaStart);
	ajaxGeral('includes/slideShowGaleria.php?imgID='+imgID,'divGaleriaInterna')
}


var Rollar = "sim";
var tipo = "left";
var roll = 0;
var tmp = 29;

function Duplicar(){
	var Marquee = document.getElementById("Marquee");
	Cont = Marquee.innerHTML;
	if (tipo=="left" || tipo=="right"){
		IDA = "<div style=\"float:left; position:relative;margin-left:-"+Marquee.clientWidth+";width:"+Marquee.clientWidth+"; height:"+Marquee.clientHeight+";\">"+Cont+"</div>";
		IDB = "<div style=\"float:right; position:relative;margin-right:-"+Marquee.clientWidth+";width:"+Marquee.clientWidth+"; height:"+Marquee.clientHeight+";\">"+Cont+"</div>";
		IDC = IDA + IDB + Cont;
	}
	if(tipo=="top" || tipo=="down"){
		IDA = "<div style=\"float:left; position:relative;margin-top:-"+Marquee.clientHeight+";width:"+Marquee.clientWidth+"; height:"+Marquee.clientHeight+";\">"+Cont+"</div>";
		IDB = "<div style=\"float:left; position:relative;margin-bottom:-"+Marquee.clientHeight+";width:"+Marquee.clientWidth+"; height:"+Marquee.clientHeight+";\">"+Cont+"</div>";
		IDC = IDA + Cont + IDB;
	}
	Marquee.innerHTML = IDC;
}
function Fmarquee(){
	var Marquee = document.getElementById("Marquee");
	var Caixa = document.getElementById("caixa");
	
	if(tipo=="left" || tipo=="right"){
		var Altura = Caixa.clientWidth;
	}else if(tipo=="down" || tipo=="top"){
		var Altura = Caixa.clientHeight;
	}

	roll++;

	var total = ((((eval(document.getElementById('hdToImgGa').value)-16)*45)+(eval(document.getElementById('hdToImgGa').value)-17))+2);
	if(roll >= total){
	    document.getElementById('tdGaleriaSetaDireita').innerHTML  = "<img src='/rumoimages/setagaleriadir_.jpg' width='30' height='33'>";
 	    return false;
	}

	if(Altura==roll){
		roll = (roll*-1);
	}

	if(tipo == "top"){
		Marquee.style.marginTop = (roll*-1)+"px";
	} else if (tipo == "down"){
		Marquee.style.marginTop = roll+"px";
	} else if (tipo == "left"){
		Marquee.style.marginLeft = (roll*-1)+"px";
	} else if (tipo == "right"){
		Marquee.style.marginLeft = roll+"px";
	}
	
	if((tipo=="right")&&(roll==0)){
	    document.getElementById('tdGaleriaSetaEsquerda').innerHTML = "<img src='/rumoimages/setagaleriaesq_.jpg' width='30' height='33'>";
 	    Rollar = "nao";
 	    return false;
	}

	if(Rollar == "sim"){
	   setTimeout("Fmarquee()",tmp);
	}
}
function playR(){
	if(tipo=="right")
		roll = eval(roll)-eval(roll)*2

        document.getElementById('tdGaleriaSetaEsquerda').innerHTML = "<img src='/rumoimages/setagaleriaesq.jpg' width='30' height='33' onmouseout='stopM();' onmouseover='playL()'>";
	tipo 	= "left"
	Rollar 	= "sim";
	Fmarquee();
}

function playL(){
	if(tipo=="left")
		roll = eval(roll)-eval(roll)*2
	tipo 	= "right"
	Rollar 	= "sim";
	if(roll!=0){
	    document.getElementById('tdGaleriaSetaEsquerda').innerHTML = "<img src='/rumoimages/setagaleriaesq.jpg' width='30' height='33'>";
	    Fmarquee();
	}
}

function stopM(){
	Rollar = "nao";
}

window.onload = function(){
	Rollar = "nao";
	Fmarquee();
	Duplicar();
}


function galeriaMostraImagemGrande(galeriaID, nomeImagem, tituloImagem, tituloGaleria, descricaoImagem){
	document.getElementById('tdGaleriaImgPrincipal').innerHTML = "<img src='/rumoimagens/galeria/"+galeriaID+"/g"+nomeImagem+"' alt='"+tituloImagem+"' title='"+tituloImagem+"' Style='margin-top:8px'>"
	textoDescritivo = "<p><span class='tituloAzul'>"+tituloGaleria+"<br /></span><span class='textoguia'><strong>"+tituloImagem+"</strong></span><br />"+descricaoImagem+" <br /></p>";
	document.getElementById('tdGaleriaTextoDescritivo').innerHTML = textoDescritivo;
}

function galeriasAnteriores(pagina){
 	ajaxGeral("includes/galeriasAnteriores.php?pID="+pagina, 'tdGaleriasAnteriores')
}


function abreLinkAreaRestrita(){
	if(document.getElementById('slcAreaRestrita').value!=""){
		open(document.getElementById('slcAreaRestrita').value, "_blank");
	}
}


function mostraDestaque(dID){
	if(dID==1) link = "/ensino_medio/matriculas-ensino-medio-colegio-rumo.php";
	if(dID==2) link = "/nono_ano_integrado/matriculas-nono-ano-integrado.php";
	if(dID==3) link = "/pre_vestibulinho/matriculas-cursinho-pre-vestibulinho.php";
	if(dID==4) link = "/pre_vestibular/matriculas-vestibulares-pre-vestibular.php";

	open(link, "_top");
}

function mostraArquivoteca(){
	open("/arquivoteca-do-rumo.php", "_top");
}


function bannersInicio(){
	setInterval("bannerTimer()", 6000)
}

function bannerTimer(){

	total  	     = document.getElementById("hdTotalBanner").value
	if(total<=1){
		return false
	}else{
		posicao = document.getElementById("hdPosicaoTimer").value;
		if(posicao == total)
			document.getElementById("hdPosicaoTimer").value = 1;
		else
			document.getElementById("hdPosicaoTimer").value = eval(document.getElementById("hdPosicaoTimer").value)+1;
		
		campo = "hdBanner"+document.getElementById("hdPosicaoTimer").value;
		objeto = document.getElementById(campo).value;
		document.getElementById("tdMostraBanner").innerHTML = objeto;

	}
}

function enviaMensagem(){
	if(document.contato.txtNome.value==''){
		alert("O Nome deve ser Preenchido!");
		document.contato.txtNome.focus();
		return false;
	}
	if(document.contato.txtEmail.value==''){
		alert("O Email deve ser Preenchido!");
		document.contato.txtEmail.focus();
		return false;
	}
	if(document.contato.txtComentarios.value==''){
		alert("O Comentario deve ser Preenchido!");
		document.contato.txtComentarios.focus();
		return false;
	}
	document.contato.action ='enviaFaleConosco.php';
	document.contato.submit();
}

function enviaTrabalhe(){
	if(document.contato.txtNome.value==''){
		alert("O Nome deve ser Preenchido!");
		document.contato.txtNome.focus();
		return false;
	}
	if(document.contato.txtEmail.value==''){
		alert("O Email deve ser Preenchido!");
		document.contato.txtEmail.focus();
		return false;
	}
	if(document.contato.txtArquivo.value==''){
		alert("O Arquivo para Envio deve ser Selecionado!");
		document.contato.txtArquivo.focus();
		return false;
	}
	document.contato.action ='enviaTrabalheConosco.php';
	document.contato.submit();
}

function selecionaMateriaProfessor(valor){
	if(valor=='Professor')
		document.contato.slcDisciplina.disabled = false;
	else
		document.contato.slcDisciplina.disabled = true;
}

function cadastraInformativo(){
	if(document.contato.txtNome.value==''){
		alert("O Nome deve ser Preenchido!");
		document.contato.txtNome.focus();
		return false;
	}
	if(document.contato.txtEmail.value==''){
		alert("O Email deve ser Preenchido!");
		document.contato.txtEmail.focus();
		return false;
	}
	document.contato.action ='includes/cadastraInformativo.php';
	document.contato.submit();
}

function mostradiv(div){
	document.getElementById(div).style.display = "block";
}

function retornaBusca(){
	valor = document.getElementById('txtBusca').value;
	if(valor==""){
		alert("O Campo Busca deve ser preenchido!!");
		document.getElementById('txtBusca').focus();
		return false;
	}
	open("/retornabusca.php?busca="+valor, target="_top");
}

function buscaArquivoteca(tipo){
	open("/arquivoteca-do-rumo.php?tID="+tipo, "_top");
}
