// Ocultando Data de Demissão - Cad. de Experiências Profissionais //
	function disabledInput( valor, campo ){
		if( valor ){
			document.getElementById(campo).value = "";
			document.getElementById(campo).disabled = true;
		}
		else{
			document.getElementById(campo).disabled = false;
			document.getElementById(campo).focus();
		}
	}
// =============================================================== //

function valForm(){
	var nome = document.getElementById('nome');
	var email = document.getElementById('email');
	var ddd = document.getElementById('ddd');
	var fone = document.getElementById('fone');
	var mensagem = document.getElementById('mensagem');
	
	if( nome.value == "" ){
        alert( "O campo NOME é obrigatório!" );
        nome.focus();
        return false;
    }
	
	if( !valida_email( email.value ) ){
        alert( "O campo E-MAIL está incorreto!" );
        email.focus();
        return false;
    }
	
	if( ddd.value == "" || fone.value == "" ){
        alert( "O campo TELEFONE é obrigatório!" );
        ddd.focus();
        return false;
    }
	
	if( mensagem.value == "" ){
        alert( "O campo MENSAGEM é obrigatório!" );
        mensagem.focus();
        return false;
    }
	
	return false;
}

function valida_email( campo ) {
	erro = true;
	p1 = campo.indexOf( "@" )
	p2 = campo.lastIndexOf( "." )
	t = campo.length - 1;
	
	if( ( p1 == t ) || ( p2 == t ) || ( p2 == -1 ) || ( p1 > p2 ) || ( ( p2 - p1 ) == 1 ) ){
		erro = false;
	}

	return erro;
}

// Contador e Limitador de Caracteres
function counterUpdate(opt_countedTextBox, opt_countBody, opt_maxSize) {
        var countedTextBox = opt_countedTextBox ? opt_countedTextBox : "counttxt";
        var countBody = opt_countBody ? opt_countBody : "countBody";
        var maxSize = opt_maxSize ? opt_maxSize : 1024;

        var field = document.getElementById(countedTextBox);

        if (field && field.value.length >= maxSize) {
                field.value = field.value.substring(0, maxSize);
        }
        var txtField = document.getElementById(countBody);
                if (txtField) { 
                txtField.innerHTML = field.value.length;
        }
	}

// Função que Checka todos os Checks
function marcaDesmarca( cont, campo, acao ){
	var cont  = cont;
	var campo = campo;
	var acao  = acao;
	alert(cont);
	alert(campo);
	for( i = 0; i < cont; i++ ){
		alert(document.getElementById("" + campo + "" + i + "").checked);
		alert(acao)
		//document.getElementById("" + campo + "" + i + "").checked = acao;
	}
}

// esta função valida o email
function valida_email(campo) {
	erro = true;
	p1 = campo.indexOf("@")
	p2 = campo.lastIndexOf(".")
	t = campo.length - 1;
	if((p1==t) || (p2==t) || (p2==-1) || (p1>p2) || ((p2-p1)==1))
	 erro = false;
	return erro;
}
	
	// Classe que esconde a DIV de mensage //
	function fechar(){
		document.getElementById("divMensagem").style.display = "none";
	}
	// =================================== //
	
	function valFormPesquisa(){
		var termo = document.getElementById("termo");
		
		if( termo.value == "Informe aqui seu termo de busca" ){
			alert("O campo [Informe aqui seu termo de busca] é obrigatório!");
			termo.focus();
			return false;
		}
	}
	
	function limpaCampo( campo ){
		if( campo.value == 'Informe aqui seu termo de busca' ){ campo.value = '' };
	}
	
	function escreveCampo( campo ){
		if( campo.value == '' ){ campo.value = 'Informe aqui seu termo de busca'; }
	}
	
	
	<!--
/* This script and many more are available free online at
The JavaScript Source :: http://javascript.internet.com
Created by: Mario Costa ::  */

function currencyFormat(fld, milSep, decSep, e) {
  var sep = 0;
  var key = '';
  var i = j = 0;
  var len = len2 = 0;
  var strCheck = '0123456789';
  var aux = aux2 = '';
  var whichCode = (window.Event) ? e.which : e.keyCode;

  if (whichCode == 13) return true;  // Enter
  if (whichCode == 8) return true;  // Delete
  key = String.fromCharCode(whichCode);  // Get key value from key code
  if (strCheck.indexOf(key) == -1) return false;  // Not a valid key
  len = fld.value.length;
  for(i = 0; i < len; i++)
  if ((fld.value.charAt(i) != '0') && (fld.value.charAt(i) != decSep)) break;
  aux = '';
  for(; i < len; i++)
  if (strCheck.indexOf(fld.value.charAt(i))!=-1) aux += fld.value.charAt(i);
  aux += key;
  len = aux.length;
  if (len == 0) fld.value = '';
  if (len == 1) fld.value = '0'+ decSep + '0' + aux;
  if (len == 2) fld.value = '0'+ decSep + aux;
  if (len > 2) {
    aux2 = '';
    for (j = 0, i = len - 3; i >= 0; i--) {
      if (j == 3) {
        aux2 += milSep;
        j = 0;
      }
      aux2 += aux.charAt(i);
      j++;
    }
    fld.value = '';
    len2 = aux2.length;
    for (i = len2 - 1; i >= 0; i--)
    fld.value += aux2.charAt(i);
    fld.value += decSep + aux.substr(len - 2, len);
  }
  return false;
}
//-->

// a função recebe como parâmetro uma variável string
 function checaCPF(CPF) {
	CPF = CPF.replace( ".", "" );
	CPF = CPF.replace( ".", "" );
	CPF = CPF.replace( "-", "" );
	
	if (CPF.length != 11 || CPF == "00000000000" || CPF == "11111111111" ||
		CPF == "22222222222" ||	CPF == "33333333333" || CPF == "44444444444" ||
		CPF == "55555555555" || CPF == "66666666666" || CPF == "77777777777" ||
		CPF == "88888888888" || CPF == "99999999999")
		return false;
	soma = 0;
	for (i=0; i < 9; i ++)
		soma += parseInt(CPF.charAt(i)) * (10 - i);
	resto = 11 - (soma % 11);
	if (resto == 10 || resto == 11)
		resto = 0;
	if (resto != parseInt(CPF.charAt(9)))
		return false;
	soma = 0;
	for (i = 0; i < 10; i ++)
		soma += parseInt(CPF.charAt(i)) * (11 - i);
	resto = 11 - (soma % 11);
	if (resto == 10 || resto == 11)
		resto = 0;
	if (resto != parseInt(CPF.charAt(10)))
		return false;
	return true;
 }

// VALIDA DATA
function validaData(str){
	dia = (str.substring(0,2)); 
	mes = (str.substring(3,5)); 
	ano = (str.substring(6,10)); 

	cons = true;

	if((dia < 01) || (dia < 01 || dia > 30) && 
		(mes == 04 || mes == 06 ||
		mes == 09 || mes == 11) ||
		dia > 31) {
		cons = false;
	} if (mes < 01 || mes > 12) {
		cons = false;
	} if (mes == 2 && ( dia < 01 || dia > 29 ||
		(dia > 28 && (parseInt(ano / 4) != 4 / 4)))) {
		cons = false;
	} if (cons == false) {
		return false;
	} else {
		var datadigitada= new Date(ano,(mes-1),dia);
		var miliqq=datadigitada.getTime();

		var mydate= new Date()
		var mili=mydate.getTime();

		if(miliqq > mili){
			return false;
		}  else {
			return true;
		} 			
		
	}
}

// VERIFICA SE DATA FINAL É MAIOR QUE INICIAL
function verificaDatas(dtInicial, dtFinal){
	
	var dtini = dtInicial;
	var dtfim = dtFinal;
	
	datInicio = new Date(dtini.substring(6,10), 
						 dtini.substring(3,5), 
						 dtini.substring(0,2));
	datInicio.setMonth(datInicio.getMonth() - 1); 
	
	
	datFim = new Date(dtfim.substring(6,10), 
					  dtfim.substring(3,5), 
					  dtfim.substring(0,2));
					 
	datFim.setMonth(datFim.getMonth() - 1); 

	if(datInicio <= datFim){
		return true;
	} else {
		return false;
	}	
}

// VERIFICA SE NOME CONTÉM LETRAS
function isNum(campo){
	var numeros="0123456789";
	var texto = campo.value;

   for( i = 0; i < texto.length; i++ ){
		if( numeros.indexOf( texto.charAt( i ), 0 ) != -1 ){
			alert( "O NOME deve conter apenas letras!" );
			campo.value = "";
			campo.focus();
			return false;
		}
   }
   
   return true;
}
