function abrirjanela(url) {
window.open(url, '_blank');
}

function right(e) {
   if (navigator.appName == 'Netscape' && (e.which == 3 || e.which == 2))
      return false;
   else if (navigator.appName == 'Microsoft Internet Explorer' && (event.button == 2 || event.button == 3)) {
      alert("Acesso Negado.\nAdministração de Informática " );
      return false;
   }
   return true;
}

document.onmousedown = right;
document.onmouseup = right;

if (document.layers) 
   window.captureEvents(Event.MOUSEDOWN);
if (document.layers) 
   window.captureEvents(Event.MOUSEUP);
   
window.onmousedown = right;
window.onmouseup = right;


function clickField(f,v) {
	if (f.value == v) {
	f.value = "";
	return;
	}
	if (f.value == "") f.value = v;
	}

function exibeFlash(swf, width, height, wmode, cache)
{
	noCache = cache || cache == undefined ? "" : "?" + new Date();
	wmode = wmode || wmode == undefined ? "opaque" : "transparent";

	monta_swf = "";
	monta_swf += "<object classid=\"clsid:D27CDB6E-AE6D-11cf-96B8-444553540000\" codebase=\"http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=7,0,19,0\" width=\""+ width +"\" height=\""+ height +"\" title=\"\">";
	monta_swf += "<param name=\"movie\" value=\""+ swf + noCache +"\" />";
	monta_swf += "<param name=\"quality\" value=\"high\" />";
	monta_swf += "<param name=\"menu\" value=\"0\" />";

	monta_swf += "<param name=\"wmode\" value=\"transparent\" />";
	monta_swf += "<param name=\"scale\" value=\"noborder\" />";


	monta_swf += "<embed src=\""+ swf + noCache +"\" quality=\"high\" wmode=\"transparent\" pluginspage=\"http://www.macromedia.com/go/getflashplayer\" type=\"application/x-shockwave-flash\" width=\""+ width +"\" height=\""+ height +"\"></embed>";
	monta_swf += "</object>";

	document.write(monta_swf);
}


function openWinCenter(URL, N, W, H, S)
{
  L = (screen.width - W) / 2;
  T = (screen.height - H) / 2;
  newWin = window.open(URL, N,"scrollbars="+S+",width=" + W + ",height=" + H +",top=" + T+ ",left=" + L);
  newWin.focus();
}

function Bloqueia_Caracteres(evnt){

	if (navigator.appName.indexOf('Microsoft') != -1) {
		 clientNavigator = "IE";
	} else {
		 clientNavigator = "Other";
	}

	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 Ajusta_Data(input, evnt){

	if (navigator.appName.indexOf('Microsoft') != -1) {
		 clientNavigator = "IE";
	} else {
		 clientNavigator = "Other";
	}

	if (input.value.length == 2 || input.value.length == 5){
		if(clientNavigator == "IE"){
			input.value += "/";
		}else{
			if(evnt.keyCode == 0){
				input.value += "/";
			}
		}
	}
	return Bloqueia_Caracteres(evnt);
}


function MM_jumpMenu(targ,selObj,restore){ //v3.0
  eval(targ+".location='"+selObj.options[selObj.selectedIndex].value+"'");
  if (restore) selObj.selectedIndex=0;
}

function validaArtigo(acao)
{
   if (document.formint.semestre.value == '0')
  {
    window.alert('Preencha o campo Semestre.');
	document.formint.semestre.focus();
    return false;
  }    
  if (document.formint.ano.value == '0')
  {
    window.alert('Preencha o campo Ano.');
	document.formint.ano.focus();
    return false;
  }      
  if (document.formint.titulo.value == '')
  {
    window.alert('Preencha o campo Título.');
	document.formint.titulo.focus();
    return false;
  }  
    if (document.formint.autores.value == '')
  {
    window.alert('Preencha o campo Autores.');
	document.formint.autores.focus();
    return false;
  }      
    if (document.formint.resumo.value == '')
  {
    window.alert('Preencha o campo Resumo.');
	document.formint.resumo.focus();
    return false;
  }  
    if (document.formint.palavra_chave.value == '')
  {
    window.alert('Preencha o campo Palavra-chave.');
	document.formint.palavra_chave.focus();
    return false;
  }
      if (document.formint.curso.value == '0')
  {
    window.alert('Preencha o campo Curso.');
	document.formint.curso.focus();
    return false;
  }
  
  if ((acao != 'alterar') && (document.formint.file.value == ''))
  {
    window.alert('Insira um Arquivo .PDF');
    return false;
  }
  return true;
}



function validaRepresentate()
{
   if (document.formint.representante.value == '')
  {
    window.alert('Preencha o campo Representante!');
    return false;
  }    
     if (document.formint.desc_representante.value == '')
  {
    window.alert('Preencha o campo Descrição do Representante!');
    return false;
  }    

  return true;
}

function validaNews()
{
   if (document.form2.nome.value == '')
  {
    window.alert('Preencha o campo Nome!');
    return false;
  }    
  if (!(valida_email(document.form2.email, false, false)))
  {
    window.alert('O campo E-Mail está vazio ou é inválido.');
    return false;
  }
  return true;
}


function validaBusca()
{
   if (document.formint.curso.value == '0')
  {
    window.alert('Selecione o campo Curso!');
    return false;
  }    
  return true;
}

function validaNoticia()
{
   if (document.formint2.titulo.value == '')
  {
    window.alert('Preencha o campo Título!');
    return false;
  }    
  return true;
}


function validaCPF()
{
     if (!check_cpf (document.formint2.cpf.value))
  {
    window.alert('CPF inválido! Digite Novamente. Sem pontos');
    return false;
  }	  
  return true;
}




function validaPalavra()
{
   if (document.form3.palavra.value.length < 4) {
	window.alert('Campo "Busca" em branco ou com tamanho menor que 4 caracteres!');
	document.form3.palavra.focus();
	return false;
   } 
  return true;
}


function validalogin()
{

  if (!(valida_email(document.form4.email, false, false)))
  {
    window.alert('O campo E-Mail está vazio ou é inválido.');
    return false;
  }
  
     if (document.form4.senha.value == '')
  {
    window.alert('Preencha o campo Senha!');
    return false;
  }    
     if (document.form4.senha.value == 'Senha')
  {
    window.alert('Preencha o campo Senha!');
    return false;
  }    
  
  
  return true;
}

function validaContato()
{  
  
   
   if (document.form.Nome.value == '')
  {
    window.alert('Preencha o campo Nome!');
    return false;
  }    
  
  if (!(valida_email(document.form.Email, false, false)))
  {
    window.alert('O campo E-Mail está vazio ou é inválido.');
    return false;
  }

   if (document.form.Assunto.value == '')
  {
    window.alert('Preencha o campo Assunto!');
    return false;
  }  
  
  if ( ( document.form.Site[0].checked == false )
    && ( document.form.Site[1].checked == false )
	&& ( document.form.Site[2].checked == false )
	&& ( document.form.Site[3].checked == false ) )
    {
        alert ( "Marque uma opção 'O que achou do site?!'  " );
        return false;
    }
  
  
  return true;
}


function validaCadastro()
{
 
   if (document.formint2.curso.value == '0')
  {
    window.alert('O campo Área de Interesse não pode ser vazio.');
    return false;
  }
 
   if (document.formint2.nome.value == '')
  {
    window.alert('O campo Nome não pode ser vazio.');
    return false;
  }  

  if (!(valida_email(document.formint2.email, false, false)))
  {
    window.alert('O campo E-Mail está vazio ou é inválido.');
    return false;
  }
    if (document.formint2.senha.value == '')
  {
    window.alert('O campo Senha não pode ser vazio.');
    return false;
  }
  
	if ( ( document.formint2.divulgacao[0].checked == false )
    && ( document.formint2.divulgacao[1].checked == false )
	&& ( document.formint2.divulgacao[2].checked == false )
	&& ( document.formint2.divulgacao[3].checked == false ) )
    {
        alert ( "Marque uma opção 'Como ficou sabendo'!  " );
        return false;
    }
  return true;
}



function valida_email(o_email, branco, alerta)
{
  p_email = o_email.value.toLowerCase();
  
  if (branco) // Permite o e-mail em branco
  {
    if (p_email == '')
      return true;
  }

  reg_email = /^[\w\-\.]+@[\w\-\.]+\.[a-z]{2,4}$/;
  if (! reg_email.test(p_email))
  {
    if (alerta)
    {
      alert('E-mail inválido');
      o_email.focus();
      o_email.select();
    }
    return false;
  }
  return true;
}


function check_cpf (numcpf)
{

x = 0;
soma = 0;
dig1 = 0;
dig2 = 0;
texto = "";
numcpf1="";
len = numcpf.length; x = len -1;

for (var i=0; i <= len - 3; i++) {
y = numcpf.substring(i,i+1);
soma = soma + ( y * x);
x = x - 1;
texto = texto + y;

}

// % retorna o resto da divisão por 11
dig1 = 11 - (soma % 11);

if (dig1 == 10) dig1=0 ;
if (dig1 == 11) dig1=0 ;

numcpf1 = numcpf.substring(0,len - 2) + dig1 ;
x = 11; soma=0;

for (var i=0; i <= len - 2; i++) {
soma = soma + (numcpf1.substring(i,i+1) * x);
x = x - 1;

}
dig2= 11 - (soma % 11);

if (dig2 == 10) dig2=0;
if (dig2 == 11) dig2=0;

if ((dig1 + "" + dig2) == numcpf.substring(len,len-2)) {
//alert("Ok.Seu CPF está correto!!!!");
return true;
}

//alert("ERRO. CPF inválido! Digite Novamente. Sem pontos");
return false;

}


function validaEmail()
{  
  if (!(valida_email(document.form.email, false, false)))
  {
    window.alert('O campo E-Mail está vazio ou é inválido.');
    return false;
  }
  return true;
}