function Alertas(Mensagem){
	$('#Mensagens #Conteudo').html(Mensagem);
	$('#Mensagens').slideDown('fast');
	setTimeout("$('#Mensagens').slideUp('fast');", 5000 );
}

function ValidaLogin(){
	var d =  document.fLogin;

 	if (d.login.value == "" ){
		Alertas('O Login deve ser preenchido!');
		d.login.value="";
		d.login.focus();
		return false;
	}
 	if (d.senha.value == "" ){
		Alertas('A Senha deve ser preenchido!');
		d.senha.value="";
		d.senha.focus();
		return false;
	}
}
function ValidaArquivo(){
	var d =  document.fArquivo;

 	if (d.texto.value == "" ){
		Alertas('Texto sobre o Arquivo deve ser preenchido!');
		d.texto.value="";
		d.texto.focus();
		return false;
	}
 	if (d.arquivo.value == "" ){
		Alertas('Escolha um Arquivo!');
		d.arquivo.value="";
		d.arquivo.focus();
		return false;
	}
}
function ValidaCadastroAluno(){
	var d = document.ACadastro;

	if (d.email.value != "" ){
        if(!d.email.value.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+.[a-zA-Z0-9._-]+)/gi)){
            Alertas("Informe um e-mail válido!");
            d.email.focus();
 			return false
        }
  	}
	if (d.email.value == "" ) {
		Alertas("O campo email deve ser preenchido!");
		d.email.focus();
		return false
	}
	
}
/**********************************************************/
function Somente_Numero(input, evnt){
 //Chama a função Bloqueia_Caracteres para só permitir a digitação de números
 	return Bloqueia_Caracteres(evnt);
}
function Bloqueia_Caracteres(evnt){
 if (navigator.appName.indexOf('Microsoft') != -1){clientNavigator = "IE";}
 else{clientNavigator = "Other"; }

 //Função permite digitação de números
 	if (clientNavigator == "IE")
    {  if (evnt.keyCode < 48 || evnt.keyCode > 57)
           {return false}
 	}
    else
    {if ((evnt.charCode < 48 || evnt.charCode > 57) && evnt.keyCode == 0)
        {return false}
 	}
}


function ValidaCadastroNoticia(){
	var d = document.RTEDemo;
	
	if (d.titulo.value == "" ){
		Alertas('O título deve ser preenchido!');
		d.titulo.focus();
        return false;
  	}
  	if (d.tipo[0].selected == true) {
    	Alertas("Escolha um tipo de notícia!");
    	d.tipo.focus();
        return false;
  	}
}


function ValidaCadastroLink(){
	var d =  document.fLinksProfessores;

 	if (d.titulo.value == "" ){
		Alertas('O Titulo deve ser preenchido!');
		d.titulo.value="";
		d.titulo.focus();
		return false;
	}
 	if (d.link.value == "" ){
		Alertas('A Link deve ser preenchido!');
		d.link.value="";
		d.link.focus();
		return false;
	}else{
		var RegExPattern = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/
		//validar o link
		if(!d.link.value.match(RegExPattern)){
			alert('A Link não é valido, use http:// ou http:// no inicio do enderço');
			d.link.focus();	
			return false;
		}
	}
	
}

/**************************************************************************/

function Ajusta_Cep(input, evnt){
 if (navigator.appName.indexOf('Microsoft') != -1){clientNavigator = "IE";}
 else{clientNavigator = "Other"; }
 //Ajusta máscara de CEP e só permite digitação de números
 	if (input.value.length == 5){
 		if(clientNavigator == "IE"){
 			input.value += "-";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += "-";
 			}
 		}
 	}
 //Chama a função Bloqueia_Caracteres para só permitir a digitação de números
 	return Bloqueia_Caracteres(evnt);
}
function Ajusta_CPF(input, evnt){
 if (navigator.appName.indexOf('Microsoft') != -1){clientNavigator = "IE";}
 else{clientNavigator = "Other"; }
 //Ajusta máscara de CPF e só permite digitação de números
 	if ((input.value.length == 3)||(input.value.length == 7)){
 		if(clientNavigator == "IE"){
 			input.value += ".";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += ".";
 			}
 		}
 	}
 	if (input.value.length == 11){
 		if(clientNavigator == "IE"){
 			input.value += "-";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += "-";
 			}
 		}
 	}
 	//Chama a função Bloqueia_Caracteres para só permitir a digitação de números
 	return Bloqueia_Caracteres(evnt);
}

function Ajusta_Telefone(input, evnt){
 if (navigator.appName.indexOf('Microsoft') != -1){clientNavigator = "IE";}
 else{clientNavigator = "Other"; }
 //Ajusta para numero de telefones, permitindo so numeros
     if (input.value.length == 0){
 		if(clientNavigator == "IE"){
 			input.value += "(";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += "(";
 			}
 		}
 	}
    if (input.value.length == 3){
 		if(clientNavigator == "IE"){
 			input.value += ")-";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += ")-";
 			}
 		}
 	}
 	if (input.value.length == 9){
 		if(clientNavigator == "IE"){
 			input.value += "-";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += "-";
 			}
 		}
 	}
 	//Chama a função Bloqueia_Caracteres para só permitir a digitação de números
 	return Bloqueia_Caracteres(evnt);
}

function Ajusta_Data(input, evnt){
 if (navigator.appName.indexOf('Microsoft') != -1){clientNavigator = "IE";}
 else{clientNavigator = "Other"; }
 //Ajusta máscara de DATA e só permite digitação de números
 	if (input.value.length == 4){
 		if(clientNavigator == "IE"){
 			input.value += "-";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += "-";
 			}
 		}
 	}
 	if (input.value.length == 7){
 		if(clientNavigator == "IE"){
 			input.value += "-";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += "-";
 			}
 		}
 	}
 	return Bloqueia_Caracteres(evnt);
}

function Ajusta_DataBR(input, evnt){
 if (navigator.appName.indexOf('Microsoft') != -1){clientNavigator = "IE";}
 else{clientNavigator = "Other"; }
 //Ajusta máscara de DATA e só permite digitação de números
 	if (input.value.length == 2){
 		if(clientNavigator == "IE"){
 			input.value += "/";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += "/";
 			}
 		}
 	}
 	if (input.value.length == 5){
 		if(clientNavigator == "IE"){
 			input.value += "/";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += "/";
 			}
 		}
 	}
 	return Bloqueia_Caracteres(evnt);
}

/**************************************************************************/
function Ajusta_DataTimeBR(input, evnt){
 if (navigator.appName.indexOf('Microsoft') != -1){clientNavigator = "IE";}
 else{clientNavigator = "Other"; }
 //Ajusta máscara de DATATIME e só permite digitação de números
	  
 	if ((input.value.length == 2)||(input.value.length == 5)){
 		if(clientNavigator == "IE"){
 			input.value += ":";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += ":";
 			}
 		}
 	}
 	if (input.value.length == 8){
 		if(clientNavigator == "IE"){
 			input.value += " ";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += " ";
 			}
 		}
 	}
 	if ((input.value.length == 11)||(input.value.length == 14)){
 		if(clientNavigator == "IE"){
 			input.value += "/";
 		}else{
 			if(evnt.keyCode == 0){
 				input.value += "/";
 			}
 		}
 	}
 	return Bloqueia_Caracteres(evnt);
}


/*************************************************************************/
function Somente_Nota(input, evnt){
 	//Chama a função Bloqueia_Caracteres para só permitir a digitação de números
 	return Somente_Float(evnt);
}
function Somente_Float(evnt){
 if (navigator.appName.indexOf('Microsoft') != -1){clientNavigator = "IE";}
 else{clientNavigator = "Other"; }

 	//Função permite digitação de números
 	
	if (clientNavigator == "IE"){ 
		if (evnt.keyCode < 48 || evnt.keyCode > 57){
			if(evnt.keyCode != 44) return false
		}
 	}
    else{
		if ((evnt.charCode < 48 || evnt.charCode > 57) && evnt.keyCode == 0){
			if(evnt.keyCode != 44) return false
		}
 	}
}
/*********************************************************************/
function ValidaAlteracaoLogin(input, evnt){
 if (navigator.appName.indexOf('Microsoft') != -1){clientNavigator = "IE";}
 else{clientNavigator = "Other"; }

 var Key = window.evnt ? evnt.keyCode : evnt.which;   
 
 if ((Key < 48 && ((Key!=45)&&(Key!=46))) || (Key > 57 && Key < 65) || (Key > 90 && Key < 97 && Key!=95) || (Key > 122)){ 
				return false
		}
}

/*********************** Cadastro de Usuários Administradores ******************/

function ValidaCadastroAdministradores(){
	var d = document.ACadastro;

  	if (d.nome.value == "" ) {
		Alertas("O nome deve ser preenchido!");
		d.nome.focus();
		return false
	}
  	if (d.usuario.value == "" ) {
		Alertas("O login deve ser preenchido!");
		d.usuario.focus();
		return false
	}
	if (d.senha.value != d.resenha.value ) {
		Alertas("Senha e resenha devem ser iguais!");
		d.senha.focus();
		return false
	}
	if (d.email.value == "" ) {
		Alertas("O campo email deve ser preenchido!");
		d.email.focus();
		return false
	}
	if (d.email.value != "" ){
        if(!d.email.value.match(/([a-zA-Z0-9._-]+@[a-zA-Z0-9._-]+.[a-zA-Z0-9._-]+)/gi)){
            Alertas("Informe um e-mail válido!");
            d.email.focus();
 			return false
        }
  	}
  	if (d.cpf.value == "" ) {
		Alertas("O CPF deve ser preenchido!");
		d.cpf.focus();
		return false
	}
	if (d.data_nasc.value == "" ) {
		Alertas("O campo data de nascimento deve ser preenchido!");
		d.data_nasc.focus();
		return false
	}
}

/***********************************************************************************/

function CheckAdminSet(vetor){
	var vetor = vetor.split("|");
	var objs = document.ACadastro.getElementsByTagName("input");
	for (i=0,j=0; i<objs.length, j<vetor.length; i++){
		if (objs[i].type=="checkbox"){
			if(vetor[j]=='Y'){
				objs[i].checked = true;
			}else if(vetor[j]=='N'){
				objs[i].checked = false;
			}j++;
		}
	}
}


//**************************************************************************//


/*$(".LinkProf").click(function(){ 
	alert('OK');
	Alertas('Erro!');
	fidProfessor = $(this).attr("name"); 
	fidLink = $(this).attr("tabindex"); alert(fidProfessor + '' + fidLink);
	$.post(
		"../phpajax/AddVisitaLink.php",
		{Professor: fidProfessor, Link: fidLink},
		function(data){
			if(data == false){ 
				Alertas('Erro!')
			}else{
				
			}
		}
	);
});
*/


//******************** Mostra Esconde **************************************//

dropped = 'block';
function droptop(e){
	var el = document.getElementById(e);
	dropped = (el.style.display == 'block');
    if (!dropped) dropit(e);
    else {
     el = document.getElementById(e);
     el.style.display = 'none';
 	}
}
function dropit(e){
	var el = document.getElementById(e);
	if (el.style.display == 'none') el.style.display = 'block';
	else el.style.display = 'none';
}
function hideall(e){
	var Nodes = document.getElementById('CliqueDrop').getElementsByTagName('div')
	var max = Nodes.length
	for(var i = 0;i < max;i++){
		var nodeObj = Nodes.item(i);
		nodeObj.style.display = 'none';
	}
}
hiding="hideall(0)"




