
/* 
	UNAMA - Universidade da Amazônia
	Author: Emanuel Junior - jrtweb@gmail.com - (91) 81176867
	Creation Date: 01.12.2005
	Description:  This aquivo contains the scripts of portal
	*/

/*
	Function:		Shows the date for extensive
    Author:			Antonio Sampaio Jr.
	Creation Date: 	08 Jan 2002
	last Update:  	02 Dec 2005
*/


<!--
/* função MostraAba */
var display1 = 0;
var display2 = 0;
var display3 = 0;
function mudaBox(tipo,elemento){
	if (tipo=="mostraAba1"){
		display1="block";
		background1="url(../../comunicadoOnLine/img/box-abas/comunicadoOnlineBT1.png) no-repeat";
		
		display2="none";
		background2="url(../../comunicadoOnLine/img/box-abas/tvunamaBT1.png) no-repeat";
		
		display3="none";
		background3="url(../../comunicadoOnLine/img/box-abas/runamaBT1.png) no-repeat";
	}
	
	if (tipo=="mostraAba2"){
		display1="none";
		background1='url(../../comunicadoOnLine/img/box-abas/comunicadoOnlineBT2.png) no-repeat';
		
		display2="block";
		background2='url(../../comunicadoOnLine/img/box-abas/tvunamaBT2.png) no-repeat';
		
		display3="none";
		background3="url(../../comunicadoOnLine/img/box-abas/runamaBT2.png) no-repeat";
	
	} if (tipo=="mostraAba3"){
		display1="none";
		background1='url(../../comunicadoOnLine/img/box-abas/comunicadoOnlineBT3.png) no-repeat';
		
		display2="none";
		background2='url(../../comunicadoOnLine/img/box-abas/tvunamaBT3.png) no-repeat';
		
		display3="block";
		background3="url(../../comunicadoOnLine/img/box-abas/runamaBT3.png) no-repeat";
	}
	
	
	document.getElementById('boxAba1').style.display = display1;
	document.getElementById('linkAba1').style.background = background1;
	
	document.getElementById('boxAba2').style.display = display2;
	document.getElementById('linkAba2').style.background = background2;
	
	document.getElementById('boxAba3').style.display = display3;
	document.getElementById('linkAba3').style.background = background3;

}
//-->


function validDate(formField,fieldLabel,required)
{
	var result = true;
	if (required && !validRequired(formField,fieldLabel)) 
		result = false;
	if (result)
	{
		var elems = formField.value.split("/");
		result = (elems.length == 3); // should be three components
		if (result) 
		{
			var day = parseFloat(elems[0]);
			var month = parseFloat(elems[1]);
			var year = parseFloat(elems[2]);
			result = allDigits(elems[0]) && allDigits(elems[1]) && allDigits(elems[2]) &&
			(day > 0) && (day < 32) && (month > 0) && (month < 13) &&
			(elems[2].length == 4) && 
			(((day < 30) && (month == 2)) || ((day < 32) && (month != 2))) &&
			(((day < 31) && (month == 4)) || ((day < 32) && (month != 4))) &&
			(((day < 31) && (month == 6)) || ((day < 32) && (month != 6))) &&
			(((day < 31) && (month == 9)) || ((day < 32) && (month != 9))) &&
			(((day < 31) && (month == 11)) || ((day < 32) && (month != 11)));
		}
		if (!result){
			//alert('A data deve ter o formato MM/DD/YYYY para o campo "' + fieldLabel +'".');
			alert('A data deve ter o formato DD/MM/YYYY para o campo "' + fieldLabel +'".');
			formField.focus(); 
		}
			return result;
	}
}

function validRequired(formField,fieldLabel){
	var result = true;
	if (formField.value == ""){
		alert('O campo "' + fieldLabel +'" deve ser preenchido.');
		formField.focus();
		result = false;
	}
	
	return result;
}

function allDigits(str){
   return inValidCharSet(str,"0123456789");
}

function inValidCharSet(str,charset){
	var result = true;
	for (var i=0;i<str.length;i++)
		if (charset.indexOf(str.substr(i,1))<0) {
			result = false;
			break;
		}
	
	return result;
}

function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}

function MM_changeProp(objName,x,theProp,theValue) { //v6.0
  var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}

function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

  var data = new Date();
  var mes = data.getMonth();
  if (mes == '0')
     mes = 'janeiro';
  else if (mes == '1')
     mes = 'fevereiro';		
  else if (mes == '2')
     mes = 'mar&ccedil;o';                 
  else if (mes == '3')
     mes = 'abril';		
  else if (mes == '4')
     mes = 'maio';
  else if (mes == '5')
     mes = 'junho';		
  else if (mes == '6')
     mes = 'julho';
  else if (mes == '7')
     mes = 'agosto';		
  else if (mes == '8')
     mes = 'setembro';
  else if (mes == '9')
     mes = 'outubro';
  else if (mes == '10')
     mes = 'novembro';		
  else  mes = 'dezembro';  
  var today = data.getDate()+' de '+mes+' de '+data.getFullYear()

/*
	Function:		Loads the images randomly
    Author:			Antonio Sampaio Jr.
	Creation Date: 	08 Jan 2002
	last Update:  	02 Dec 2005
*/
/*
var imagens_pag = new Array();
var imagens_titulo = new Array();

for (imgCont=0;imgCont<3;imgCont++)
{
	imagens_pag[imgCont] = new Image(); 	
}
<!-- Especificando o titulo de cada imagem --!>
imagens_titulo[0] = 'Campi';
imagens_titulo[1] = 'Tecnologia';
imagens_titulo[2] = 'Laboratorios';
imagens_titulo[3] = 'Cultura';
imagens_titulo[4] = 'Esportes';
imagens_titulo[5] = 'Auditórios';
imagens_titulo[6] = 'Informática';
imagens_titulo[7] = 'Pesquisa';
imagens_titulo[8] = 'Processo Seletivo';
imagens_titulo[9] = 'Campus Alcindo Cacela';
imagens_titulo[10] = 'Campus Quintino';
imagens_titulo[11] = 'Campus Senador Lemos';
imagens_titulo[12] = 'Laboratórios';
imagens_titulo[13] = 'Educação a Distância';
imagens_titulo[14] = 'Campus BR';
<!-- Escolhe a imagem aleatoriamente --!>	
var cont = Math.floor(Math.random()*imagens_pag.length);
<!-- Disponibiliza a imagem escolhida --!>
imagens_pag[cont].src = 'lib/img/ifotos/rotativas/foto'+(cont)+'.jpg';
var imgRandom = '<img title="'+imagens_titulo[cont]+'" src="'+imagens_pag[cont].src+'" border=0>'
document.write('<img title="'+imagens_titulo[cont]+'" + src="'+imagens_pag[cont].src+'"+ border=0>')
*/
function loginWebmail() {
 var usuario = document.emailUnama.vf_user.value; 
 var senha = document.emailUnama.vf_pass.value;  
 var valido = ((usuario!="") && (senha!="") );
 if (!valido) {
	 alert("Entre com o Login e a Senha");
     return false;	 
 } 

 document.emailUnama.vf_user.value = "";
 document.emailUnama.vf_pass.value = ""; 
 
 return true;
}

function loginServico() {
 var formulario = document.servonline;
 var usuario = formulario.vusuario.value; 
 var senha = formulario.vsenha.value;  
 var servico = formulario.action;

 var valido = ((usuario!="") && (isNaN(servico)));
 if (!valido) {
	 alert("Entre com o Login, a Senha e o Servico a ser acessado");
    return false;	 
 } 


// if (servico=="http://xingu.unama.br/Aonline/validaLogin.jsp") {
//   alert('*** AVISO! ***\nEm caso de problema com o novo sistema do Aluno On-Line, ligar para\n4009-3090 ou 4009-3055');
// }
 //campos de 'login' (por causa do FireFOX):
 document.servonline.arroz.value = usuario;
 document.servonline.sol.value = usuario;
 document.servonline.login.value = usuario;
 document.servonline.usuario.value = usuario;

 //campos de 'senha' (por causa do FireFOX):
 document.servonline.feijao.value = senha;
 document.servonline.lua.value = senha;
 document.servonline.senha.value = senha;

 //Zerando os campos visiveis
 document.servonline.vusuario.value = ""; 
 document.servonline.vsenha.value = "";  
 
 // Troca dos nomes dos campos, de acordo com o servico (Funciona só no IE)
 // document.servonline.iusuario.name = document.servonline.nusuario.value;
 // document.servonline.isenha.name = document.servonline.nsenha.value;

 return true;

}

function validaFaleConosco() {
	//verifica se existe o editor TinyMCE no formulario tinyMCE.getContent()
	var existeEditor = true;
	try {
 	 var teste = tinyMCE.getContent();
	} catch(e) {
		existeEditor=false;
	}
	
	for (var i=0;i<document.form.elements.length;i++)
  {
	var campo = document.form.elements[i];
    if ( (campo.type!="hidden") && ((campo.alt == "CAMPO OBRIGATÓRIO") || (campo.alt == "CAMPO OBRIGAT&Oacute;RIO")) ) {

	  //campos text e textarea
//	  if ((campo.type == 'text') || (campo.type == 'textarea') || (campo.type == 'textarea')) {
	    if ((campo.value == 0) || (campo.value == "0") || (campo.value == "") || (campo.value == null)) {
		 alert("Preencha os campos obrigatórios.\nO cursor vai para o campo obrigatório que você deixou de preencher.");
		 campo.focus();
		 return false;
		}
//	  }
//	   alert("-"+document.form.elements[4].name+": "+document.form.elements[4].null+"-");
	  //campos checkbox
	  if (campo.type == 'checkbox') {
	    if (!(campo.checked)) {
		 alert("Preencha os campos obrigatórios");
		 campo.focus();
		 return false;
		}
	  }

	}
  }
  
  var valido = true;
  var erros = "";
  if ((document.form.elements[0].value==0) || (document.form.elements[0].value=="0")) {
	  erros+="\nEscolha um Destinatário para sua mensagem";
	  alert(erros);
	  valido = false;
  }
  //if (!(validaEmail(document.form.elements[2]))) valido = false;
  if (!(validaEmail(document.getElementById("email")))) valido = false;
  
  var ultimo=document.form.elements.length-1;

  var mensagemNula;
  if (existeEditor) {
    mensagemNula =  ( (tinyMCE.getContent()==null) || (tinyMCE.getContent()=="") );	  
  }
  else {
    mensagemNula =  ( (document.form.elements[ultimo].value==null) || (document.form.elements[ultimo].value==""));	
  }
  if (mensagemNula) {
	  erros+="\nPreencha sua mensagem";
	  alert(erros);
	  valido = false;	  
  }
  
  if (valido) {
   document.form.submit();
   processa();
  }
}

function validaInteiro(campo, pStr)
{
	var reDigits = /^\d+$/;
	if ((pStr!=null) && (!(pStr==""))) {
	if (!reDigits.test(pStr)) {
		alert(pStr + " NÃO contém apenas números. Verifique o "+campo+" digitado.");
		return false;
	}
	}
	return true;
}

function validaData(pStr)
{
	var reDate = /^((0[1-9]|[12]\d)\/(0[1-9]|1[0-2])|30\/(0[13-9]|1[0-2])|31\/(0[13578]|1[02]))\/\d{4}$/;	
	if (!reDate.test(pStr)) {
		alert(pStr + " NÃO é uma data válida");
		return false;
	} else if (pStr == null || pStr == "") {
		alert(pStr + " NÃO é uma data válida");
		return false;
	}
	return true;
}

function validaPreInscricao() {
  var valido = true;
  
  formulario = document.form;
  
  if(formulario.selectTipoPreInscricao.value == "0"){
	  alert("Escolha o tipo de pré-inscrição!");
	  document.selectTipoPreInscricao.focus();
	  return;
	  }	 
  if (formulario.nome.value=="") {
	  alert("Informe seu NOME");
	  document.form.nome.focus();
	  return;
  }
  if (formulario.rg.value=="") {
	  alert("Informe seu RG");
	  document.form.rg.focus();
	  return;	  
  }  
  if (formulario.sexo.value=="") {
	  alert("Informe seu SEXO");
	  document.form.sexo.focus();
	  return;	  
  }  
  if (formulario.nascimento.value=="") {
	  alert("Informe seu NASCIMENTO");
	  document.form.nascimento.focus();
	  return;	  
  }
  if(formulario.endereco.value == ""){
	  alert("Informe ENDEREÇO");
	  document.form.endereco.focus();
	  return;
	  }

  if(formulario.numero.value == ""){
	  alert("Informe NUMERO");
	  document.form.numero.focus();
	  return;
 	  }
  if(formulario.cep.value == ""){
	  alert("Informe CEP");
	  document.form.cep.focus();
	  return;	  
	  }	   
	 	  
  if (formulario.cidade.value=="") {
	  alert("Informe sua CIDADE");
	  document.form.cidade.focus();
	  return;	  
  	  }

  if (formulario.uf.value=="") {
	  alert("Informe seu ESTADO(UF)");
	  document.form.uf.focus();
	  return;	  
     }
  if(formulario.pais.value == ""){
	  	alert("Informe PAÍS");
		document.form.pais.focus();
	  	return;
	  }
  if(formulario.anoConclusao.value == "erro" || formulario.anoConclusao.value == null){
	  alert("Informe ano de conclusão.");
	  document.form.anoConclusao.focus();
	  return;
	  }	  
  /*if(formulario.observacoes.value == ""){
	  alert("");
	  document.form.observacoes.focus();
	  return;
	  }*/
  if (formulario.idCurso[0].value=="0") {
	  alert("Informe seu Curso de 1a. Opção");
	  document.form.idCurso[0].focus();
	  return;	  
  }
  if (formulario.idCurso[1].value=="0") {
	  alert("Informe seu Curso de 2a. Opção");
	  	  document.form.idCurso[1].focus();
	  return;	  
  }
  
  if (!(validaInteiro("RG",formulario.rg.value))){ 
		  valido = false;
		 // document.		  
	}  
  if (!(validaData(formulario.nascimento.value))) valido = false;  
  if (!(validaEmail(document.getElementById("email")))) valido = false;  
  if (!(validaInteiro("Número de Telefone",formulario.telefone.value))) valido = false;    
  if (!(validaInteiro("Número de Telefone Celular",formulario.celular.value))) valido = false;      
  if (valido) {
   document.form.submit();

   return true;
  }
}

function validaFaleConoscoRetorno() {
	for (var i=0;i<document.form.elements.length;i++)
  {
	var campo = document.form.elements[i];
    if ((campo.alt == "CAMPO OBRIGATÓRIO") || (campo.alt == "CAMPO OBRIGAT&Oacute;RIO")) {

	  //campos text e textarea
//	  if ((campo.type == 'text') || (campo.type == 'textarea')) {
	    if ((campo.value == 0) || (campo.value == "0") || (campo.value == "") || (campo.value == null)) {
		 alert("Preencha os campos obrigatórios.\nO cursor vai para o campo obrigatório que você deixou de preencher.");
		 campo.focus();
		 return false;
		}
//	  }
//	   alert("-"+document.form.elements[4].name+": "+document.form.elements[4].null+"-");
	  //campos checkbox
	  if (campo.type == 'checkbox') {
	    if (!(campo.checked)) {
		 alert("Preencha os campos obrigatórios");
		 campo.focus();
		 return false;
		}
	  }

	}
  }
  
  var valido = true;
  var erros = "";
  if ( (document.getElementById("destinatario").value==0) || (document.getElementById("destinatario").value=="0") || (document.getElementById("destinatario").value=="") || (document.getElementById("destinatario").value==null)) {
	  erros+="Escolha um Destinatário para sua mensagem";
	  alert(erros);
	  valido = false;
  }
  //if (!(validaEmail(document.form.elements[2]))) valido = false;
  if (!(validaEmail(document.getElementById("email")))) valido = false;
  if ( (document.getElementById("mensagem").value==null) || (document.getElementById("mensagem").value=="")) {
	  erros+="Preencha sua mensagem";
	  alert(erros);
	  valido = false;
  }  
  if (valido) {
	alert("Seu pedido já será processado. \nClique em OK e aguarde a mensagem de conclusão.");
	return true;
  } else return false;
}


function validaLogin() {
	for (var i=0;i<document.form.elements.length;i++)
  {
	var campo = document.form.elements[i];
    if ((campo.alt == "CAMPO OBRIGATÓRIO") || (campo.alt == "CAMPO OBRIGAT&Oacute;RIO")) {

	  //campos text e textarea
//	  if ((campo.type == 'text') || (campo.type == 'textarea')) {
	    if ((campo.value == 0) || (campo.value == "0") || (campo.value == "") || (campo.value == null)) {
		 alert("Preencha os campos obrigatórios.\nO cursor vai para o campo obrigatório que você deixou de preencher.");
		 campo.focus();
		 return false;
		}
//	  }
//	   alert("-"+document.form.elements[4].name+": "+document.form.elements[4].null+"-");
	  //campos checkbox
	  if (campo.type == 'checkbox') {
	    if (!(campo.checked)) {
		 alert("Preencha os campos obrigatórios");
		 campo.focus();
		 return false;
		}
	  }

	}
  }
  document.form.submit();
  processa();
}

 function processa() {
     MM_showHideLayers('VAmpola','','show');
 }

function validaEmail(formField)
{
   if (formField.value == "") {
		alert("Informe seu e-mail.");
		formField.focus();
		formField.select();
		return false;
	} else {
		prim = formField.value.indexOf("@")
		if(prim < 2) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf("@",prim + 1) != -1) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf(".") < 1) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf(" ") != -1) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf("zipmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf("hotmeil.com") > 0) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf(".@") > 0) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf("@.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf(".com.br.") > 0) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf("/") > 0) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf("[") > 0) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf("]") > 0) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf("(") > 0) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf(")") > 0) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
		if(formField.value.indexOf("..") > 0) {
			alert("O e-mail informado parece não estar correto.");
			formField.focus();
			formField.select();
			return false;
		}
	}
		return true;
}
function valida() {
	alert("hum...");
}
 function validaRespostaPerfil() {
   var resposta = document.getElementById("idResposta").value;
   if ((resposta==0) || (resposta=="0") || (resposta=="")) {
	    alert("Por favor, escolha uma resposta.");
		return false;
   }
   /*var respostaOutros = document.getElementById("idResposta").value;
   var outros = document.formEnquete.outros.value;
   if ((respostaOutros==5) && outros==""){
	   alert("Por favor, informe o curso que a Unama deve implantar!");
	   formEnquete.outros.focus();
		return false;
   }*/
   var perfil = document.formEnquete.idPerfil.value;
   if ((perfil==0) || (perfil=="0")) {
	    alert("Por favor, aponte seu perfil.");
		return false;
   }
   return true;
 }
<!--
function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

//-->