function check_cpf (numcpf)
{
	x = 0;
	soma = 0;
	dig1 = 0;
	dig2 = 0;
	texto = "";
	numcpf1="";
	len = numcpf.length; x = len -1;
	// var numcpf = "12345678909";
	for (var i=0; i <= len - 3; i++) {
		y = numcpf.substring(i,i+1);
		soma = soma + ( y * x);
		x = x - 1;
		texto = texto + y;
	}
	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;
	//alert ("Digito Verificador : " + dig1 + "" + dig2);
	if ((dig1 + "" + dig2) == numcpf.substring(len,len-2)) {
		return true;
	}
	alert ("Número do CPF inválido.");
	return false;
}

// Auto: Leonardo Neves
// Data : 09/05/2000
// Retorna a data atual no formato dd/mm/aaaa
function fJSToday()
{
	var today = new Date();
		
	ano = today.getFullYear()
	mes = today.getMonth() + 1
	dia = today.getDate()
				
	if ( (mes.toString).length == 1 )
	{ mes = '0' + mes }
	
	if ( (dia.toString).length == 1 )
	{ dia = '0' + dia }
	
	today = dia + '/' + mes + '/' + ano
	
	return today
}

// Autor: Mônica Coelho Mitkiewicz
// Data : 27/08/1999
// Inverte a posicão do dia e o mes
function fJSInverteDiaMes( lData )
{
    var lPos
    var lDia
    var lMes
    var lAno
    var lResto
    var lDataRet
    
	lPos = fJSRetornaPosCaracter(lData, "/")
	lDia = lData.substr(0, lPos)
	
    lResto = lData.substr(lPos + 1, lData.length - lPos - 1)
    lPos = fJSRetornaPosCaracter(lResto, '/')
	lMes = lResto.substr(0, lPos)
	lAno = lResto.substr(lPos + 1, lResto.length - lPos - 1)
    lDataRet = lMes + '/' + lDia  + '/' + lAno
    return lDataRet

}

// Autor: Fabio Ruela
// Data : 17/08/1999
// Compara duas datas de acordo com o operador informado
function fJSComparaData(data1, data2, operador)
{
//	var dt1_aux =  ( (data1.getYear()*100000000) + (data1.getMonth()*1000000) + (data1.getDate()*10000) + (data1.getHours()*100) + data1.getMinutes()); 
//	var dt2_aux =  ( (data2.getYear()*100000000) + (data2.getMonth()*1000000) + (data2.getDate()*10000) + (data2.getHours()*100) + data2.getMinutes()); 

	var dt1_aux =  new Date( data1 ); 
	var dt2_aux =  new Date( data2 );
	
	dt1_aux =  ( (dt1_aux.getYear()*100000000) + (dt1_aux.getMonth()*1000000) + (dt1_aux.getDate()*10000) + (dt1_aux.getHours()*100) + dt1_aux.getMinutes()); 
	dt2_aux =  ( (dt2_aux.getYear()*100000000) + (dt2_aux.getMonth()*1000000) + (dt2_aux.getDate()*10000) + (dt2_aux.getHours()*100) + dt2_aux.getMinutes()); 

	if ( operador == '=' ) {
	   if ( dt1_aux == dt2_aux)
	   {
          return true;
       }
	   return false;
	}

	if ( operador == '>=' ) {
	   if ( dt1_aux >= dt2_aux)
	   {
          return true;
       }
	   return false;
	}
	
	if ( operador == '<=' ) {
	   if ( dt1_aux <= dt2_aux)
	   {
          return true;
       }
	   return false;
	}

	if ( operador == '>' ) {
	   if ( dt1_aux > dt2_aux)
	   {
          return true;
       }
	   return false;
	}
	if ( operador == '<' ) {
	   if ( dt1_aux < dt2_aux)
	   {
          return true;
       }
	   return false;
	}

	if ( operador == '!=' ) {
	   if ( dt1_aux != dt2_aux)
	   {
          return true;
       }
	   return false;
	}
	   
}

// Autor: Leonardo Neves
// Data : 03/03/2000
// Remove os espaços no inicio e fim da string
function fJSTrim (lString)
{
		
	var lPosInicial, lPosFinal, lStringFinal
	
	for (i = 0; i < lString.length; i++)
	{		
		if (lString.substr(i, 1) != ' ')
		{
			lPosInicial = i
			break
		}		
	}
	
	for (i = lString.length - 1; i >= 0; i--)
	{		
		if (lString.substr(i, 1) != ' ')
		{
			lPosFinal = i
			break
		}		
	}
		
	lNumBrancos = lPosInicial + (lString.length - 1 - lPosFinal)
	lStringFinal = lString.substr(lPosInicial, lString.length - lNumBrancos);

	return lStringFinal
}

// Autor: Leonardo Neves
// Data: 22/03/2000
// Procura padrão dentro de uma String

function fJSInStr(lString, lPadrao)
{
	
	if (lPadrao.length <= lString.length)
	{
		for (i = 0; i <= lString.length - lPadrao.length; i++)
		{		
			if (lString.substr(i, lPadrao.length) == lPadrao)
			{
				return true
			}		
		}
	}
	return false
}

function fJSTestaData(strDate)
{
  var lRetorno

  if (fJSIsNull(strDate))
	{
	 return true
	}
  else
	{
	 lRetorno = fJSValidaData(strDate);
	}

  if (!(lRetorno))
    {
      return false
    }
  return true
}

function fJSRetornaPosCaracter( string, caracter )
{
	for (var i=0; i<=string.length; i++)
	{
		if (string.substr(i, 1) == caracter)
		{
			return i;
		}
	}
	return 0;
}

// Autor: Fabio Ruela
// Data : 17/08/1999
// Retorna a posicao do caracter na string
function fJSRetornaPosCaracterPaulo( string, caracter )
{
	for (var i=0; i<=string.length; i++)
	{
		if (string.substr(i, 1) == caracter)
		{
			return i;
		}
	}
	return -1;
}


// Autor: Fabio Ruela
// Data : 17/08/1999
// Verifica se o numero informado está entre os parâmetros ini e fim incluse.
function fJSInRange( inputStr, ini, fim ){
  var num = parseInt(inputStr, 10)
  if ( num < ini || num > fim ) {
     return false
  }
  return true
}


// Autor: Fabio Ruela
// Data : 17/08/1999
// Checa o tamanho do mes
function fJSChecaTamanhoMes( mm, dd )
{
  var Mes = parseInt( mm );
  var Dia = parseInt( dd );
  
  if ( ( Mes == 4 || Mes == 6 || Mes == 9 || Mes == 11 ) && 
       ( Dia > 30 ) ) return false
  return true;     
}


// Autor: Fabio Ruela
// Data : 17/08/1999
// Checa ano bissexto
function fJSChecaAnoBissexto( mm, dd, yyyy ){
   if ( mm == 2 ){
      if ( yyyy % 4 > 0 && dd > 28 ) return false
      else if ( dd > 29 ) return false
   }
   return true;
}


// Autor: Fabio Ruela
// Data : 17/08/1999
// Conta dentro de uma string a quantidade de caracteres "/"
function fJSContaBarra(strdata)
{
	var count = 0;
	
	for (var i=0; i<=strdata.length; i++)
	{
		if (strdata.substr(i, 1) == '/')
		{
			count += 1;
		}
	}
	return count;
}



// Autor: Fabio Ruela
// Data : 17/08/1999
// Valida uma string data no formato dd/mm/aaaa
function fJSValidaData( lData )
{

	if ( fJSContaBarra(lData) != 2 ) { return false; }

	var npos = fJSRetornaPosCaracter(lData, '/');
	
	if ( npos > 0  ){
	
		var dia = lData.substr(0, npos);
		
		if (dia.length > 2){
			return false;
		}
		else{
			if (dia.length < 2){
				dia = '0' + dia;
			}
		}
		
		var lResto = lData.substr(npos+1, lData.length-npos-1);
		npos = fJSRetornaPosCaracter(lResto,'/');
		
		if (npos > 0){
			var mes = lResto.substr(0, npos);
		
			if (mes.length > 2){
				return false;
			}
			else{
				if (mes.length < 2){
				mes = '0' + mes
				}
			}

			var ano = lResto.substr(npos+1, lResto.length-npos-1)
			if (ano.length < 4){
				return false;
			}
		}
		else{
			return false;
		}
	}
	else{
		return false;
	}
	
    if ( !(fJSIsNumber(dia)) && !(fJSIsNumber(mes)) && !(fJSIsNumber(ano)) ) { return false;	}   
    
	if (fJSInRange(dia,1,31) && fJSInRange(mes,1,12) && fJSInRange(ano,1900,3000)){
	
	   if (!fJSChecaTamanhoMes(mes, dia)) return false
	   if (!fJSChecaAnoBissexto( mes, dia, ano )) return false 
	   
       var aux = new Date( mes + '/' + dia + '/' + ano );
       
	   if (aux.toString() == 'NaN'){
		   return false;
	   } 
    }
	else{
          return false;
		}
		
    return true
		
}


// Autor: Gabriel Guedes
// Data : 04/02/2000
// Valida entrada de dados numérica para objetos text
// Obs: passar como parâmetro o objeto
function fJSTestaNumero(objText)
{
  var lRetorno
  
  if (fJSIsNull(objText.value))
	{
	 return true
	}
  else
	{
	 lRetorno = fJSIsNumber(objText.value);
	}

  if (!(lRetorno))
    {
      alert('Valor inválido!') 
      objText.focus()
      return false
    }
  return true
  
}


// Autor: Fabio Ruela
// Data : 17/08/1999
// Valida uma string data
function fJSValidaData( lData )
{

	if ( fJSContaBarra(lData) != 2 ) { return false; }

	var npos = fJSRetornaPosCaracter(lData, '/');
	
	if ( npos > 0  ){
	
		var dia = lData.substr(0, npos);
		
		if (dia.length > 2){
			return false;
		}
		else{
			if (dia.length < 2){
				dia = '0' + dia;
			}
		}
		
		var lResto = lData.substr(npos+1, lData.length-npos-1);
		npos = fJSRetornaPosCaracter(lResto,'/');
		
		if (npos > 0){
			var mes = lResto.substr(0, npos);
		
			if (mes.length > 2){
				return false;
			}
			else{
				if (mes.length < 2){
				mes = '0' + mes
				}
			}

			var ano = lResto.substr(npos+1, lResto.length-npos-1)
			if (ano.length < 4){
				return false;
			}
		}
		else{
			return false;
		}
	}
	else{
		return false;
	}
	
    if ( !(fJSIsNumber(dia)) && !(fJSIsNumber(mes)) && !(fJSIsNumber(ano)) ) { return false;	}   
    
	if (fJSInRange(dia,1,31) && fJSInRange(mes,1,12) && fJSInRange(ano,1900,3000)){
	
	   if (!fJSChecaTamanhoMes(mes, dia)) return false
	   if (!fJSChecaAnoBissexto( mes, dia, ano )) return false 
	   
       var aux = new Date( mes + '/' + dia + '/' + ano );
       
	   if (aux.toString() == 'NaN'){
		   return false;
	   } 
    }
	else{
          return false;
		}
		
    return true
		
}



// Autor: Fabio Ruela
// Data : 17/08/1999
// Verifica se o parametro passado é 

function fJSIsNull( strNull )
{
   if ( strNull == "" || strNull == null ) {
      return true
   }
   return false
}


// Autor: Fabio Ruela
// Data : 17/08/1999
// Verifica se é um número válido
function fJSIsNumber( num )
{
  var numeros = '0123456789,.';
  var valor = num.toString();
  var lCount = 0;
  
  for ( var i=0; i < valor.length; i++ )
  {
      if ( numeros.indexOf( valor.substr(i,1) ) == -1 ) 
      {
          return false
      }
      
      if ( valor.substr(i,1) == ',' ) {
         lCount += 1
         if ( lCount > 1 ) { return false }
      }
  }
  return true
}

// Autor: Gabriel
// Data : 25/04/2000
// Verifica se é um número válido
function fJSTestaNumeroPuro( num )
{
  var numeros = '0123456789';
  var valor = num.toString();
  var lCount = 0;
  
  for ( var i=0; i < valor.length; i++ )
  {
      if ( numeros.indexOf( valor.substr(i,1) ) == -1 ) 
      {
          return false
      }
  }
  return true
}


// Autor: Fabio Ruela
// Data : 17/08/1999
// Muda a propriedade src do objeto image
function fJSImageSrc(indice,imagem,status)
{
	document.images[indice].src = imagem;
	window.status = status;
}

// Autor: Mônica Coelho Mitkiewicz
// Data : 26/08/1999
// Valida hora, minuto, segundo
// O parâmetro lStrHorario deve estar no formato hh:mm ou hh:mm:ss
function fJSValidaHorario( lStrHorario )
{
	var lHora, lMinuto, lSegundo, lPrimeiroSeparador, lSegundoSeparador
	
	if (lStrHorario.length < 5){
		return false
	}
	if (lStrHorario.length > 8){
		return false
	}
	
	lHora = lStrHorario.substr(0, 2)
	lPrimeiroSeparador = lStrHorario.substr(2, 1)
	if (lPrimeiroSeparador != ':'){
		return false
	}
	lMinuto = lStrHorario.substr(3, 2)
	if (lStrHorario.length > 5){
		lSegundoSeparador = lStrHorario.substr(5, 1)
		if (lSegundoSeparador != ':'){
			return false
		}
		lSegundo = lStrHorario.substr(6, 2)
		if (lSegundo.length < 2){
			return false
		}
	}
	
    //Valida Hora
    if (!(fJSIsNumber(lHora))){
		return false
	}
	if (!(fJSInRange(lHora, 0, 23))){
		return false
	}
		
	//Valida Minuto
	if (!(fJSIsNumber(lMinuto))){
		return false
	}
	if (!(fJSInRange(lMinuto, 0, 59))){
		return false
	}
		
	//Valida Segundo
	if (lStrHorario.length > 5){
		if (!(fJSIsNumber(lSegundo))){
			return false
		}
		if (!(fJSInRange(lSegundo, 0, 59))){
			return false
		}
	}
	return true
}



// ***************************************************************************************
// ***************************************************************************************
// ***************************************************************************************


var iDelay = 500 // Delay to hide in milliseconds
var iNSWidth = 100 // Default width for netscape
var sDisplayTimer = null, oLastItem; 

function getRealPos(i,which) 
  { 
  var iPos = 0

  while (i!=null) {    
	iPos += i["offset" + which] 
	i = i.offsetParent  }
  return iPos
  }
  
function showDetails(sDest,itop,ileft,iWidth) {
  if (document.all!=null) {    
	var i = window.event.srcElement    
	stopTimer()
    dest = document.all[sDest]    
    if ((oLastItem!=null) && (oLastItem!=dest))
      hideItem()    
    if (dest) {      // Netscape Hack
    if (i.offsetWidth==0)         
    if (iWidth)          
       i.offsetWidth=iWidth
    else 
       i.offsetWidth=iNSWidth;      
    if (ileft) 
        dest.style.pixelLeft = ileft      
    else
        dest.style.pixelLeft = getRealPos(i,"Left") + i.offsetWidth + 5
    if (itop)        
        dest.style.pixelTop = itop      
    else
        dest.style.pixelTop = getRealPos(i,"Top")
      dest.style.visibility = "visible"    
      }  
    oLastItem = dest  }}

function stopTimer() {  
    clearTimeout(sDisplayTimer)}

function startTimer(el) {
  if (!el.contains(event.toElement)) {    
    stopTimer()
    sDisplayTimer = setTimeout("hideItem()",iDelay)  }}

function hideItem() {
  if (oLastItem)    
     oLastItem.style.visibility="hidden"}

function checkOver() {
  if ((oLastItem) && (oLastItem.contains(event.srcElement)))    
     stopTimer()}

function checkOut() {  
  if (oLastItem==event.srcElement)
    startTimer(event.srcElement)}document.onmouseover = checkOver
    document.onmouseout = checkOut
    

// ***************************************************************************************
// ***************************************************************************************
// ***************************************************************************************
    
    
    function ValidaCPF()
{
	if ( fJSTrim(document.frmPesquisaCurriculo.txtCPF.value) == '' )
	{
		alert('Informe seu CPF');
		document.frmPesquisaCurriculo.txtCPF.focus();
		return false
	}
	
	if ( !check_cpf(document.frmPesquisaCurriculo.txtCPF.value) )
	{
		document.frmPesquisaCurriculo.txtCPF.focus();
		return false	
	}
	

	//document.frmPesquisaCurriculo.CPF.value = document.frmPesquisaCurriculo.txtCPF.value;
	//document.frmPesquisaCurriculo.action= 'cadastro_curriculos.asp'
	//alert(document.frmPesquisaCurriculo.action)
	

	document.frmPesquisaCurriculo.Acao.value = "E"
	
	document.frmPesquisaCurriculo.submit();
	return false
}

function ValidaCPFEnviaEmail()
{
	if ( fJSTrim(document.frmPesquisaCurriculo.txtCPF.value) == '' )
	{
		alert('Informe seu CPF');
		document.frmPesquisaCurriculo.txtCPF.focus();
		return false
	}
	
	if ( !check_cpf(document.frmPesquisaCurriculo.txtCPF.value) )
	{
		document.frmPesquisaCurriculo.txtCPF.focus();
		return false	
	}
	

	//document.frmPesquisaCurriculo.CPF.value = document.frmPesquisaCurriculo.txtCPF.value;
	//document.frmPesquisaCurriculo.action= 'cadastro_curriculos.asp'
	//alert(document.frmPesquisaCurriculo.action)
	

	document.frmPesquisaCurriculo.Acao.value = "E"
	
	document.frmPesquisaCurriculo.submit();
	return false
}


function ValidaSenhaCPF()
{
	if ( fJSTrim(document.frmPesquisaCurriculo.txtCPF.value) == '' )
	{
		alert('Para acessar o cadastro de currículo, digite seu CPF.');
		document.frmPesquisaCurriculo.txtCPF.focus();
		return false
	}
	
	if ( !check_cpf(document.frmPesquisaCurriculo.txtCPF.value) )
	{
		document.frmPesquisaCurriculo.txtCPF.focus();
		return false	
	}
	
	if ( fJSTrim(document.frmPesquisaCurriculo.txtSenha.value) == '')
	{
		alert('Você deve digitar sua senha. Se esse é o seu primeiro acesso, guarde a senha que você digitar. Você irá usá-la para atualizar seu cadastro depois.');
		return false	
	}
	
	//document.frmPesquisaCurriculo.CPF.value = document.frmPesquisaCurriculo.txtCPF.value;
	//document.frmPesquisaCurriculo.action= 'cadastro_curriculos.asp'
	//alert(document.frmPesquisaCurriculo.action)
	
	document.frmPesquisaCurriculo.action = "cadastro_curriculos.asp"
	document.frmPesquisaCurriculo.submit();
	return false
}

function ValidaCPF()
{
	if ( fJSTrim(document.frmPesquisaCurriculo.txtCPF.value) == '' )
	{
		alert('Para acessar o cadastro de currículo, digite seu CPF.');
		document.frmPesquisaCurriculo.txtCPF.focus();
		return false
	}
	
	if ( !check_cpf(document.frmPesquisaCurriculo.txtCPF.value) )
	{
		document.frmPesquisaCurriculo.txtCPF.focus();
		return false	
	}
	
	document.frmPesquisaCurriculo.action = "cadastro_curriculos.asp"
	document.frmPesquisaCurriculo.submit();
	return false
}
// ***************************************************************************************
// ***************************************************************************************
// ***************************************************************************************

 //branco = new Image();
 //branco.src="http://www.bms.com.br/images/branco.gif";
  
  function acende (imgname,imgname2) {
    if (document.images){
      document.images[imgname].src = eval(imgname +"_on.src") ;
      document.images['menu_frase'].src = eval(imgname2 +".src") ;
 
  	}
  }

  function apaga (imgname) {
    if (document.images){
     document.images[imgname].src = eval(imgname +"_off.src") ;
      document.images['menu_frase'].src = branco.src ;
    
    }
  }
