function fecharAviso(){
	document.getElementById("divAviso").style.display = 'none';
}

function fecharAviso2(){
	document.getElementById("divAviso2").style.display = 'none';
}

function mOvr(src,clname) {
	src.className = clname;
}
function mOut(src,clname) {
	src.className = clname;
}

function VerificaDados(form) {
	for (i = 0; i < requiredfields.length; i++) {
		obj = form[requiredfields[i]];
		if (obj.value == "") return erro(requireddescs[i],requiredfields[i],obj);
	}
	return true;
}

function erro(desc,campo,obj) {
	alert("O Campo '" + desc + "' tem que ser preenchido!");
	obj.focus();
	return false;
}

function ExcluirDados(form) {
	if (confirm("Tem certeza que deseja excluir este registro ?")) {
		form.S_action.value = "3";
		form.submit();
	}
}

function EfetuarLoginAO(form) {
	requiredfields = new Array("login", "senha");
	requireddescs  = new Array("E-mail", "Senha");

	if (VerificaDados(form)) return true;
	else return false;
}

function validaTecla(campo, event, type) {
	var BACKSPACE=8;
	var key;
	var tecla;

	CheckTAB=true;
	if(navigator.appName.indexOf("Netscape")!= -1) { tecla= event.which; }
	else { tecla= event.keyCode; }

	key = String.fromCharCode(tecla);
	if (tecla == 13)                      { return false; }
	if (tecla == BACKSPACE || tecla == 0) { return true;  }
	return (isNum(key, type));
}

function isNum(caractere, type) {
	     if (type == "number")  var strValidos = "0123456789";
	else if (type == "phone")   var strValidos = "0123456789+()- ";
	else if (type == "alfanum") var strValidos = "0123456789ABCDEFGHILMNOPQRSTUXZYWKabcdefghijlmnopqrstuvxzkyw";
	if (strValidos.indexOf(caractere) == -1) { return false; }
	return true;
}

function radarFGF() {
	window.open('/radar.htm','','fullscreen=yes, scrolling=no');
}

function consultaACERVO() {
	window.open('http://www.fgf.edu.br/acervo/','','top=0,left=100,width=770px,height=370px,toolbar=no,location=no,status=no,menubar=no,scrolling=yes,scrollbars=yes,resizable=no');
}

function abreWebmail() {
	window.open('/novo/alunoOnline/webmailTesteIframe.asp','','top=40,left=100,width=740px,height=560px,toolbar=no,location=no,status=no,menubar=no,scrolling=yes,scrollbars=yes,resizable=no');
}

function fecharEnquete() {
	document.getElementById("divEnquete").style.display = 'none';
}

function imprimeHorarioNovo() {
	window.open('/novo/alunoOnline/matricula04.asp','_blank','top=60,left=100,width=639px,height=400px,toolbar=no,location=no,status=no,menubar=no,scrolling=yes,scrollbars=yes,resizable=no');
}

function declaracaoIR() {
	window.open('/alunoonline/declaracaoIR.asp','IAB','scrollbars=yes,width=680,height=400');
}

function FormataCep(obj, teclapres) {

	var tecla = teclapres.keyCode;

	tam = 0;
	if (tecla == 8 || tecla == 46) { tam = tam - 1 ; return; }

	vr = obj.value;

	aux1 = /\./gi;
	aux2 = /\-/gi;
	vr = vr.replace( aux1, '');
	vr = vr.replace( aux2, '');

	tam = vr.length + 1;

	if ( tam > 2 && tam <= 3 )		obj.value = vr.substr( 0, tam - 1  ) + '.' + vr.substr( tam - 1, tam );
	if ( tam > 3 && tam < 6 )		obj.value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, tam - 2 );
	if ( tam >= 6 && tam <= 10 )	obj.value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '-' + vr.substr( 5, 3 );
}

function FormataCpf(campo, teclapres) {
	var tecla = teclapres.keyCode;
	var vr    = event.srcElement.value;
	
	aux1 = /\./gi;
	aux2 = /\-/gi;
	vr = vr.replace( aux1, '');
	vr = vr.replace( aux2, '');

	tam = vr.length;


	if (tecla == 8 || tecla == 46) { tam = tam - 1 ; return; }		
	
	//if (tam > tamCampoCPFCNPJ) return false;
	
	if (tecla != 8) tam = vr.length + 1
	else tam = tam - 1

	if ( tam <= 3 ) 						event.srcElement.value = vr ;
	else if ( (tam >= 3) && (tam <= 6) )	event.srcElement.value = vr.substr( 0, 3 )  + '.' + vr.substr( 3, 3 ) ;
	else if ( (tam >= 7) && (tam <= 9) )	event.srcElement.value = vr.substr( 0, 3 )  + '.' + vr.substr( 3, 3 ) + '.'  + vr.substr( 6, 3 );
	else if ( (tam >= 9) && (tam <= 11) )	event.srcElement.value = vr.substr( 0, 3 )  + '.' + vr.substr( 3, 3 ) + '.'  + vr.substr( 6, 3 )  + '-' + vr.substr( 9, 2 );
	
	return true;
}

function verificaCPF (obj) {
	
	if (obj.value == "") return true;
	
	var soma1, soma2, s1, s2;

	var form = obj.form;
	var cpf  = obj.value;

	var str_cpf = "";
	var verifzero = 0;

	for (i = 0; i <= cpf.length - 1; i++)
	if ((cpf.charAt(i)).match(/\d/)) {
		str_cpf += cpf.charAt(i);
		verifzero+=cpf.charAt(i);
	}
	else if (!(cpf.charAt(i)).match(/[\.\-]/)) return erroForm(obj, 'CPF');

	if (str_cpf.length != 11) return erroForm(obj, 'CPF');

	if (verifzero==0) return erroForm(obj, 'CPF');

	if (str_cpf==11111111111 || str_cpf==22222222222 || str_cpf==33333333333 || str_cpf==44444444444 || str_cpf==55555555555 || str_cpf==66666666666 || str_cpf==77777777777 || str_cpf==88888888888 || str_cpf==99999999999) return erroForm(obj, 'CPF');

	soma1 = soma2 = 0;
	for (i = 0; i <= 8; i++) {
		soma1 += str_cpf.charAt(i) * (10-i);
		soma2 += str_cpf.charAt(i) * (11-i);
	}
	s1 = ((soma1 * 10) % 11) % 10;
	s2 = (((soma2 + (s1 * 2)) * 10) % 11) % 10;

	if ((s1 != str_cpf.charAt(9)) || (s2 != str_cpf.charAt(10))) return erroForm(obj, 'CPF');

	return true;
}

function FormataTel(obj, teclapres) {

	var tecla = teclapres.keyCode;

	tam = 0;
	if (tecla == 8 || tecla == 46) { tam = tam - 1 ; return; }

	vr = obj.value;

	aux1 = /\(/gi;
	aux2 = /\)/gi;
	aux3 = /-/gi;
	aux4 = /\+/gi;
	aux5 = /\ /gi;
	vr = vr.replace( aux1, '');
	vr = vr.replace( aux2, '');
	vr = vr.replace( aux3, '');
	vr = vr.replace( aux4, '');
	vr = vr.replace( aux5, '');

	tam = vr.length + 1;

	if ( tam > 2) { obj.value = '(' + vr.substr(0, 2) + ')' + ' ' + vr.substr(2, 4) + '-' + vr.substr(6, 4); }

}

function erroForm(obj, descricao)
{
	alert('Desculpe, o valor para o campo "' + descricao + '" digitado é inválido!');
	//obj.value = '';
	obj.focus();
	return false;
}


function validar_email() {
<!--
	var Email = document.id_form.Email.value;
	//Checando se o endereço e-mail não esta vazio
	if(Email=="") {
		alert("É necessário o preenchimento deste campo.");
		document.id_form.Email.focus();
		return false;
	}
	//Checando se o endereço de e-mail é válido
	if(!(/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(document.id_form.Email.value))) {
		alert("É necessário o preenchimento de um endereço de e-mail válido.");
		document.id_form.Email.focus();
		return false;
	}
}

