/****************************************************************
*	Criado em: 08/03/2007			Por: ANDRÉ LUIZ
****************************************************************/

/*# Faz menu funcionar nos IEs */
sfHover = function() {
	if (document.getElementById("nav")) {
		var sfEls = document.getElementById("nav").getElementsByTagName("LI");
		for (var i=0; i<sfEls.length; i++) {
			sfEls[i].onmouseover=function() {
				this.className+=" sfhover";
			}
			sfEls[i].onmouseout=function() {
				this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
			}
		}
	}
}

if (window.attachEvent) window.attachEvent("onload", sfHover);


/*# mostra/esconde responstas das FAQs */
function showHideResposta(vc_obj) {
	// verifica se o elemento existe
	if (document.getElementById(vc_obj)) {
		var obj_detalhe	= document.getElementById(vc_obj);
		
		if (obj_detalhe.style.display != 'none')
			obj_detalhe.style.display	= 'none';
		else
			obj_detalhe.style.display	= 'inline';
	}
}


/*# mostra/esconde forms */
function showHideForm(vc_obj) {
	// verifica se o elemento existe
	if (document.getElementById(vc_obj)) {
		var dv_00	= document.getElementById(vc_obj);
		
		if (dv_00.style.display != 'none')
			dv_00.style.display	= 'none';
		else
			dv_00.style.display	= 'block';
		
		// reseta form
		eval('document.frm_' + vc_obj + '.reset()');
	}
}

/*# VALIDA E-MAIL [expressão regular] */
function verficaEmail(campo) {
	if (/^\w+([\.-]?\w+)*@\w+([\.-]?\w+)*(\.\w{2,3})+$/.test(campo)) {
		return	'';
	}
	return '- O E-MAIL digitado é inválido.\n';
}

/*# aceita só números digitados num campo */
function soNumero(evtKeyPress) {
	var nTecla;
	nTecla = (evtKeyPress.which) ? evtKeyPress.which : evtKeyPress.keyCode;
	
	if((nTecla > 47 && nTecla < 58) || nTecla == 8 || nTecla == 9)
		return true;
	else
		return false;
}

/*# MASCARA */
function mascarar(vc_campo,vc_mascara) {
	var i		= vc_campo.value.length;
	var x		= vc_mascara.substring(0,1);
	var y		= vc_mascara.substring(i);
	
	if (y.substring(0,1) != x) {
		vc_campo.value += y.substring(0,1);
	}
}

/*# VERIFICA DATA #*/
function verificaData(vc_campo) { 
	if (vc_campo.value.length > 0) {  
		it_dia		= (vc_campo.value.substring(0,2)); 
		it_mes		= (vc_campo.value.substring(3,5)); 
		it_ano		= (vc_campo.value.substring(6,10)); 
		it_erro		= 0; 
		
		if ((it_dia < 01) || (it_dia < 01 || it_dia > 30) && (it_mes == 04 || it_mes == 06 || it_mes == 09 || it_mes == 11 ) || it_dia > 31) { 
			it_erro	= 1; 
		} 

		if (it_mes < 01 || it_mes > 12 ) { 
			it_erro	= 1; 
		} 

		if (it_mes == 2 && (it_dia < 01 || it_dia > 29 || (it_dia > 28 && (parseInt(it_ano / 4) != it_ano / 4)))) { 
			it_erro	= 1; 
		} 

		if ((it_ano < 1900) || (it_ano>2078)){
			it_erro	= 1;
		}
		
		if (it_erro == 1) { 
			alert("Por favor, preencha uma data válida!"); 
			vc_campo.value	= '';
			vc_campo.focus(); 
		}
	} 
}

/*# iFrame virtual [ crossBrowser ] #*/
function iframe_virtual(vc_url) {
	// pega iframeVirtual pelo ID ou cria um iframeVirtual caso ñ exista
	var tempIFrame = (document.getElementById('iframe_virtual')) ? document.getElementById('iframe_virtual') : document.createElement('iframe');
	
	tempIFrame.style.border		= '0px';
	tempIFrame.style.width		= '0px';
	tempIFrame.style.height		= '0px';
	
	tempIFrame.setAttribute('id','iframe_virtual');
	tempIFrame.setAttribute('name','iframe_virtual');
	tempIFrame.setAttribute('src',vc_url);
	
	IFrameObj		= document.body.appendChild(tempIFrame);
}

function logonValida(){

	var vc_erro	=	''
	if(document.getElementById('loginVC').value.length == 0){
		vc_erro	+=	'- Digite o seu Login\n'
	}
	if(document.getElementById('senhaVC').value.length == 0){
		vc_erro	+=	'- Digite a sua Senha\n'
	}

	if(document.getElementById('tipo_loginIT').value == 0){
		vc_erro	+=	'- Selecione o tipo de acesso: ALUNO ou  PROFESSOR ou COLABORADOR\n'
	}

	if(vc_erro.length > 0){
			alert('ATENÇÃO \n\n Informe os seguintes dados:\n' + vc_erro);
	}else{
		document.frm_login.submit();

	}
}

// PERMITE APENAS NÚMEROS 
function Numeros(){
	var tecla = event.keyCode;
	if (tecla > 47 && tecla < 58){ 
		return true;
	}else{
		if (tecla != 8){
			event.keyCode = 0;
		}else{
			return true;
		}
	}
}

function popupVideo(id_arquivo) {
	var W	= 470; 	
	var H	= 420;
	var X	= Math.ceil( (window.screen.height - H) / 2 ) - 20;
	var Y	= Math.ceil( (window.screen.width - W) / 2 ) - 16;
	
	window.open('popup/video.asp?arquivoID='+id_arquivo,'video','width='+W+',height='+H+',top='+X+',left='+Y+',location=no,status=no,menubar=no,scrollbars=no,resizable=no,directories=no,toolbar=no');
}