//*******************************************************************************************
//	Banner  
//*******************************************************************************************
function changeOpac(opacity, id){
	var object = document.getElementById(id).style;
	
	object.opacity = (opacity / 101);
	object.MozOpacity = (opacity / 101);
	object.KhtmlOpacity = (opacity / 100);
	object.filter = "alpha(opacity=" + opacity + ")";
}
function blendimage(divid, imageid, imagefile, millisec){
	var speed = Math.round(millisec / 10);
	var timer = 0;
	document.getElementById(divid).style.backgroundImage = "url(" + document.getElementById(imageid).src + ")";
	document.getElementById(imageid).src = imagefile;
	changeOpac(0, imageid);
	for(i = 0; i < 100; i++){
		setTimeout("changeOpac(" + i + ",'" + imageid + "')",(speed * timer));
		timer++;
	}
}
var slideCache = new Array();
function RunSlideShow(divid,imageid,imageFiles,displaySecs){
	var imageSeparator = imageFiles.indexOf(";");
	var nextImage = imageFiles.substring(0,imageSeparator);

	changeOpac(0, imageid);
	blendimage(divid,imageid,nextImage,50);

	var futureImages= imageFiles.substring(imageSeparator+1,imageFiles.length)+ ';' + nextImage;
	setTimeout("RunSlideShow('"+divid+"','"+imageid+"','"+futureImages+"',"+displaySecs+")",displaySecs*1000);

	imageSeparator = futureImages.indexOf(";");
	nextImage = futureImages.substring(0,imageSeparator);
	if (slideCache[nextImage] == null){
		slideCache[nextImage] = new Image;
		slideCache[nextImage].src = nextImage;
	}
}
//*******************************************************************************************
//	Login
//*******************************************************************************************
function login() {
	matricula = document.getElementById("matricula")
	if(matricula.value == "" || document.getElementById("senha").value == "") {
		alert("TODOS os campos deverão ser preenchidos");
		return;
	}
	else if(matricula.value.length < 8 ) {
		alert("O número de matrícula possui 8 dígitos.\nConsidere os zeros à esquerda.\nPor favor redigite o seu número de matrícula.");
		matricula.value = "";
		matricula.focus();
		return;
	}
	else {
		document.getElementById("login").value='ok'; 
		document.getElementById("loginForm").submit();
	}
}
//*******************************************************************************************
//	Valida Form
//*******************************************************************************************
function validaForm(formulario){
	nome = document.getElementById("nome");
	email = document.getElementById("email");
	mensagem = document.getElementById("mensagem");
	
	if(nome.value == ""){
		alert("Por favor, preencha o campo nome.");
		nome.focus();
		return false;
	}else if(email.value < 2 || email.value.indexOf(".") < 1 || email.value.indexOf(".@") > 0 || email.value.indexOf("@.") > 0 || email.value.indexOf(".com.br.") > 0 || email.value.indexOf("..") > 0){
		alert("Este não parece ser um e-mail correto.");
		email.focus();
		return false;
	}else if(mensagem.value == ""){
		alert("Por favor, deixe uma mensagem.");
		mensagem.focus();
		return false;
	}
	document.getElementById("msgJs").value='ok';
	document.getElementById("contato").submit();
}

function openWindow(target){
									
	var w=null;
	
	if (w!=null && !w.closed) w.close();
	
	if (target!=0){
		w=window.open("/asp/secretaria/comunicados/comunicado.html","_blank","top=100,left=100,height="+(screen.height)+",width="+(screen.width)+",scrollbars=yes,status=yes,menubar=no,toolbar=no,resizable=yes,copyhistory=no,directories=no,personalbar=no");
		w.document.open();
		w.document.write('<html><head><link href="/web/biblioteca/estilo.css" rel="stylesheet" type="text/css"></head><body><center>');
		w.document.write('<center><img src="/asp/secretaria/comunicados/imagens/'+target+'"></center>');		
		w.document.write('<form><input type=button value=imprimir onclick=window.print()>&nbsp;');
		w.document.write('<input type=button value=fechar onclick=window.close()></form></center></body></html>');		
		w.document.close();
		w.focus();
	}    
}
//*******************************************************************************************
//	Margem
//*******************************************************************************************
function trocaCSS(){
	var myHeight = 0;
	var tela = document.getElementById("container");
	var divTarefa = document.getElementById("divTarefaCont");
	if( typeof( window.myHeight ) == 'number'){
		myHeight = window.innerHeight;
	}else if( document.documentElement && (document.documentElement.clientHeight)){
		myHeight = document.documentElement.clientHeight;
	}else if( document.body && (document.body.clientHeight)){
		myHeight = document.body.clientHeight;
	}
	if(myHeight < 570){
		tela.style.top = "10px";
		tela.style.margin = "0 0 0 -385px";
		if(divTarefa){
			divTarefa.style.margin = "0 0 0 -395px";
			divTarefa.style.top = "10px";
		}
	}else{
		tela.style.margin = "-285px 0 0 -385px;";
		tela.style.top = "50%";
		if(divTarefa){
			divTarefa.style.margin = "-280px 0 0 -385px";
			divTarefa.style.top = "50%";
		}
	}setTimeout("trocaCSS()",1)
}
//*******************************************************************************************
//	Popup Matriz
//*******************************************************************************************
function abreMatriz(foto){
	foto = "imagens/" + foto + ".gif";
	var conteudo = "";
	conteudo = "<html>\n";
	conteudo += "	<head>\n";
	conteudo += "		<title>Colégio Elias Zarzur</title>\n";
	conteudo += "		<link href='/web/biblioteca/estilo.css' rel='stylesheet' type='text/css'>\n";
	conteudo += "	</head>\n";
	conteudo += "	<body>\n";
	conteudo += "		<a href='javascript:window.close()' title='Clique para fechar'>\n";
	conteudo += "			<img src='" + foto + "' alt='Colégio Elias Zarzur' border=0 />\n";
	conteudo += "		</a>\n";
	conteudo += "	</body>\n";
	conteudo += "</html>";
	var novaJanela = window.open("novapg.html","Nova","toolbar=no, location=no, directories=no, status=yes, menubar=no, scrollbars=yes, resizable=no, width=640, height=400,top=30,left=30");
	novaJanela.document.write(conteudo);
}
//*******************************************************************************************
//	Abre Lista
//*******************************************************************************************
function abre(linkPai){
	var subMenu = linkPai.nextSibling.nextSibling;
	if(subMenu.className==''){
		subMenu.className='aberto';
	}else{
		subMenu.className='';
	}
}
//*******************************************************************************************
//	TAREFA
//*******************************************************************************************
function tarefa(data){
	var vBody = document.body;
	
	var div = document.createElement("div");
	div.id = "divTarefa";
	vBody.appendChild(div);
	
	var divBg = document.createElement("div");
	divBg.id = "divTarefaBg";
	div.appendChild(divBg);
	
	var divCont = document.createElement("div");
	divCont.id = "divTarefaCont";
	
	div.appendChild(divCont);
	requisicaoAjax(data);
}
function tarefaDel(){
	div = document.getElementById("divTarefa");
	div.parentNode.removeChild(div);
}
var ajax = null;
function requisicaoAjax(data){
	if (window.ActiveXObject) ajax = new ActiveXObject('Microsoft.XMLHTTP');
	else if (window.XMLHttpRequest) ajax = new XMLHttpRequest();
	if(ajax != null){
		//abre a requisição ajax, passando o método de acesso, a url solicitada e o parâmetro sobre sincronia
		ajax.open('GET','tarefa.asp?data='+data+'',false);
		ajax.onreadystatechange = statusAjax;
		ajax.send(null);
	}
}
function statusAjax(){
	if(ajax.readyState == 4 && ajax.status == 200){
		retornoAjax(ajax.responseText);
	}
}
function retornoAjax(response){
	div = document.getElementById("divTarefaCont");
	div.innerHTML = response;
}
//*******************************************************************************************
//	TAREFA Conteúdo
//*******************************************************************************************
function mudaCont(obj,bt){
	var divConteudo = document.getElementById("quadro");
	var divObj = document.getElementById(obj);
	for(var i=0;i<divConteudo.childNodes.length;i++){
		if(divConteudo.childNodes[i].nodeName == "DIV"){
			divConteudo.childNodes[i].style.display = "none";
		}
	}
	if(bt){
		var ulMenu = bt.parentNode.parentNode;
		for(var x=0;x<ulMenu.childNodes.length;x++){
			if(ulMenu.childNodes[x].nodeName == "LI"){
				ulMenu.childNodes[x].firstChild.className = "";
			}
		}
		bt.className = "selected";
	}
	divObj.style.display = "block";
}
//*******************************************************************************************
//	Apaga Style
//*******************************************************************************************
function apaga(){
	var vspan = document.getElementsByTagName("span");
	for(i=0;i<vspan.length;i++){
		vspan[i].removeAttribute("style");
	}setTimeout("apaga()",1)
}