function excluirFormacao(fid){
	
	if(confirm("Deseja Excluir?")){								

		goPage('trabalhe_formacao.php?idFormacao='+fid+'&id_curriculo='+document.getElementById('id_trabalhe').value,'divescolaridade')
		
	}	
	
}

function excluirExperiencia(fid){
	
	if(confirm("Deseja Excluir?")){								

		goPage('trabalhe_experiencia.php?idExperiencia='+fid+'&id_curriculo='+document.getElementById('id_trabalhe').value,'divexperiencia')
		
	}	
	
}


function enviarExperiencia(){
	
var flag = true

	if(trim(document.getElementById('empresa').value)==''){
		
		showPopWin('alertar.php?texto=Campo Nome da Empresa não pode ser nulo!', 400, 100, null)
		flag = false
		
	}
	else
	if(trim(document.getElementById('cargo').value)==''){
		
		showPopWin('alertar.php?texto=Campo Último cargo na empresa não pode ser nulo!', 400, 100, null)
		flag = false
		
	}
	else
	if(trim(document.getElementById('salario').value)==''){
		
		showPopWin('alertar.php?texto=Campo Último salário na empresa não pode ser nulo!', 400, 100, null)
		flag = false
		
	}
	else
	if(trim(document.getElementById('atribuicoes').value)==''){
		
		showPopWin('alertar.php?texto=Campo Atribuições / realizações no cargo não pode ser nulo!', 400, 100, null)
		flag = false
		
	}
	
	
	if(flag == true){
		
		var valoget = '?'
		
		valoget = valoget+'mesentrada='+document.getElementById('mesentrada').value
		valoget = valoget+'&anoentrada='+document.getElementById('anoentrada').value
		valoget = valoget+'&messaida='+document.getElementById('messaida').value
		valoget = valoget+'&anosaida='+document.getElementById('anosaida').value		
		valoget = valoget+'&empresa='+document.getElementById('empresa').value				
		valoget = valoget+'&cargo='+document.getElementById('cargo').value						
		valoget = valoget+'&salario='+document.getElementById('salario').value								
		valoget = valoget+'&atribuicoes='+document.getElementById('atribuicoes').value								
		valoget = valoget+'&atual='+document.getElementById('atual').checked								
		valoget = valoget+'&id_curriculo='+document.getElementById('id_trabalhe').value								
		
	
		goPage('trabalhe_experiencia.php'+valoget,'divexperiencia')
	
	}
}


function enviarFormacao(){
	
var flag = true

	if(trim(document.getElementById('curso').value)==''){
		
		showPopWin('alertar.php?texto=Campo Curso não pode ser nulo!', 400, 100, null)
		flag = false
		
	}
	else
	if(trim(document.getElementById('instituicao').value)==''){
		
		showPopWin('alertar.php?texto=Campo Nome da Instituição não pode ser nulo!', 400, 100, null)
		flag = false
		
	}
	
	
	if(flag == true){
		
		var valoget = '?'
		
		valoget = valoget+'grauescolaridade='+document.getElementById('grauescolaridade').value
		valoget = valoget+'&curso='+document.getElementById('curso').value
		valoget = valoget+'&mesinicio='+document.getElementById('mesinicio').value
		valoget = valoget+'&anoinicio='+document.getElementById('anoinicio').value		
		valoget = valoget+'&mesfim='+document.getElementById('mesfim').value				
		valoget = valoget+'&anofim='+document.getElementById('anofim').value						
		valoget = valoget+'&instituicao='+document.getElementById('instituicao').value								
		valoget = valoget+'&id_curriculo='+document.getElementById('id_trabalhe').value								
		
	
		goPage('trabalhe_formacao.php'+valoget,'divescolaridade')
	
	}
}



function desabilitarcampo(){
	
	
	if(document.getElementById('atual').checked==true){
		
		document.getElementById('messaida').disabled = true
		document.getElementById('anosaida').disabled = true
	}
	else
	if(document.getElementById('atual').checked==false){
		
		document.getElementById('messaida').disabled = false
		document.getElementById('anosaida').disabled = false
	}
	
}




function enviarNews(){

	var flag = true
	var obj = eval("document.getElementById('emailNew')");
	var txt = obj.value;

	if(trim(document.getElementById('nomeNew').value)==''){
		
		showPopWin('alertar.php?texto=Nome não pode ser nulo!', 400, 100, null)
		flag = false
		
		
	}else
	if(trim(document.getElementById('emailNew').value)==''){
		
		showPopWin('alertar.php?texto=E-mail não pode ser nulo!', 400, 100, null)
		flag = false
		
		
	}else 
	if(trim(document.getElementById('emailNew').value)!=''){
		
		if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7))){
			
			showPopWin('alertar.php?texto=E-mail Incorreto!', 400, 100, null)
			obj.focus();
			flag = false
			
		}						
	}

	
	if(flag == true){
		
		$.ajax({
			   
			type: "GET",
			url: 'newsletter.php?fnome='+document.getElementById('nomeNew').value+'&femail='+document.getElementById('emailNew').value,			
			success: function(texto){
				
				$("#idnewsletter").html(texto);
				
			}
		});
	
	
	}
}

function pegatecla(valorget) {

	if(window.event.keyCode==13){
		
		location.href = valorget
		
	}
	
}


function LimparCampo(id){
	
	if(trim(document.getElementById(id).value)=='Digite a Busca'){
		
		document.getElementById(id).value = '';
		
	}
	
}


function goPageData(pag,div){
	
	showPopWin('alertarDia.php?texto=Confirma?&click='+pag+'/*/'+div, 400, 100, null)
	
}




function goPage(pag,div){
	
	$.ajax({
		type: "GET",
		url: pag,
		success: function(texto){
			$("#"+div).html(texto);
		}
	});
	
}

/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO PARA ENVIAR DADOS
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////

Só com ID

	fcampos 	= Campos que são OBRIGATORIO
	facao		= pagina da ação do SUBMIT
	fvalidacao 	= Campos para VALIDAÇÂO de DATA, E-mail, CPF e CNPJ
	flimpar		= limpar campos Escondidos

*/
function enviar(fcampos, facao, fvalidacao, flimpar, ftextoalert){
	
	if(trim(flimpar)!=''){
	  spl = flimpar.split('/*/')
	  taSpl = spl.length
	  
		for(p=0;p<taSpl;p++){
			CampoiLimpa = spl[p]
			spr = CampoiLimpa.split(";")
			
			if(document.getElementById(spr[1]).value==''){
				document.getElementById(spr[0]).value=''
			}else if(document.getElementById(spr[0]).value==''){
				document.getElementById(spr[1]).value=''				
			}
		}
	}
	
	var flag = true
	
	if(fcampos!=''){
		A = fcampos.split('/*/')
		B = ftextoalert.split('/*/')
		tamanho = A.length

		for(i=0;i<tamanho;i++){
			
			nomeCampo = A[i]
			
			if(trim(document.getElementById(nomeCampo).value)==''){
				//alert("Campo "+B+" não pode ser Nulo!")
				showPopWin('alertar.php?texto=Campo '+B[i]+' não pode ser Nulo!', 400, 100, null)
				//document.getElementById(nomeCampo).focus()
				flag = false
				i = tamanho
			}	
		}
	}

	if(fvalidacao!=''){
		sp = fvalidacao.split('/*/')
		len = sp.length
		for(ii=0;ii<len;ii++){
			
			NomeValidacao = sp[ii]
			
			if(trim(document.getElementById(NomeValidacao).value)!=''){
				
				TextoCnpj = NomeValidacao.substring(0,4)
				
				
				if(TextoCnpj.toUpperCase()=='CNPJ'){
					
					if(!validaCNPJ(NomeValidacao)){
						
						document.getElementById(NomeValidacao).focus()
						flag = false				
						ii = len
					}			
				}else if(TextoCnpj.toUpperCase()=='CPF_'){
					
					if(!validacaoCPF(NomeValidacao)){
						
						document.getElementById(NomeValidacao).focus()
						flag = false				
						ii = len
					}			
				}else if(TextoCnpj.toUpperCase()=='DATA'){

					if(!validarData(document.getElementById(NomeValidacao))){
						
						document.getElementById(NomeValidacao).focus()
						flag = false				
						ii = len
						
					}			
				}else if(TextoCnpj.toUpperCase()=='EMAI'){
					
						
					var obj = eval("document.getElementById(NomeValidacao)");
					var txt = obj.value;
					if ((txt.length != 0) && ((txt.indexOf("@") < 1) || (txt.indexOf('.') < 7)))
					{
						showPopWin('alertar.php?texto=E-mail Incorreto!', 400, 100, null)
						obj.focus();
						flag = false
						
					}						
				}
			}
		}		
	}


	if(flag==true){
		
		if(trim(facao)=='excluir'){
			
			if(confirm('Desejar Excluir?')){
				
				document.form.submit()		
				
			}
			
		}else{
			
			document.form.submit()		
			
		}
	}
}




/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO PARA MASCARA
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/


function mascara(o,f){
    v_obj=o
    v_fun=f
    setTimeout("execmascara()",1)
}

/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO PARA EXECUTA MASCARA
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/


function execmascara(){
    v_obj.value=v_fun(v_obj.value)
}

/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO PARA LEECH
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/


function leech(v){
    v=v.replace(/o/gi,"0")
    v=v.replace(/i/gi,"1")
    v=v.replace(/z/gi,"2")
    v=v.replace(/e/gi,"3")
    v=v.replace(/a/gi,"4")
    v=v.replace(/s/gi,"5")
    v=v.replace(/t/gi,"7")
    return v
}


/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO PARA SO NUMEROS
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/



function soNumeros(v){
    return v.replace(/\D/g,"")
}

/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO PARA TELEFONE
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/


function telefone(v){
    v=v.replace(/\D/g,"")                 //Remove tudo o que não é dígito
    v=v.replace(/^(\d\d)(\d)/g,"($1) $2") //Coloca parênteses em volta dos dois primeiros dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")    //Coloca hífen entre o quarto e o quinto dígitos
    return v
}

/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO PARA CPF
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/


function cpf(v){
    v=v.replace(/\D/g,"")                    //Remove tudo o que não é dígito
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
    v=v.replace(/(\d{3})(\d)/,"$1.$2")       //Coloca um ponto entre o terceiro e o quarto dígitos
                                             //de novo (para o segundo bloco de números)
    v=v.replace(/(\d{3})(\d{1,2})$/,"$1-$2") //Coloca um hífen entre o terceiro e o quarto dígitos
    return v
}

/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO PARA CEP
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/


function cep(v){
    v=v.replace(/D/g,"")                //Remove tudo o que não é dígito
    v=v.replace(/^(\d{5})(\d)/,"$1-$2") //Esse é tão fácil que não merece explicações
    return v
}

/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO PARA CNPJ
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/


function cnpj(v){
    v=v.replace(/\D/g,"")                           //Remove tudo o que não é dígito
    v=v.replace(/^(\d{2})(\d)/,"$1.$2")             //Coloca ponto entre o segundo e o terceiro dígitos
    v=v.replace(/^(\d{2})\.(\d{3})(\d)/,"$1.$2.$3") //Coloca ponto entre o quinto e o sexto dígitos
    v=v.replace(/\.(\d{3})(\d)/,".$1/$2")           //Coloca uma barra entre o oitavo e o nono dígitos
    v=v.replace(/(\d{4})(\d)/,"$1-$2")              //Coloca um hífen depois do bloco de quatro dígitos
    return v
}

/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO PARA DATA
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/


function data(v) {
	v=v.replace(/^(\d{2})(\d)/,"$1/$2") 
	
}


/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO PARA VERIFICAR NUMERO ROMANO
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/


function romanos(v){
    v=v.toUpperCase()             //Maiúsculas
    v=v.replace(/[^IVXLCDM]/g,"") //Remove tudo o que não for I, V, X, L, C, D ou M
    //Essa é complicada! Copiei daqui: http://www.diveintopython.org/refactoring/refactoring.html
    while(v.replace(/^M{0,4}(CM|CD|D?C{0,3})(XC|XL|L?X{0,3})(IX|IV|V?I{0,3})$/,"")!="")
        v=v.replace(/.$/,"")
    return v
}


/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO PARA VALIDAÇÃO DE SITE
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/


function site(v){
    //Esse sem comentarios para que você entenda sozinho ;-)
    v=v.replace(/^http:\/\/?/,"")
    dominio=v
    caminho=""
    if(v.indexOf("/")>-1)
        dominio=v.split("/")[0]
        caminho=v.replace(/[^\/]*/,"")
    dominio=dominio.replace(/[^\w\.\+-:@]/g,"")
    caminho=caminho.replace(/[^\w\d\+-@:\?=%\(\)\.]/g,"")
    caminho=caminho.replace(/([\?])=/,"$1")
    if(caminho!="")dominio=dominio.replace(/\.+$/,"")
    v="http://"+dominio+caminho
    return v
}

/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
			FUNÇÃO PARA FORMATAÇÃO DE MASCARA DO CAMPO DO JEITO QUE COLOCAR
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/

function txtBoxFormat(objeto, sMask, evtKeyPress) {
var i, nCount, sValue, fldLen, mskLen,bolMask, sCod, nTecla;
if(document.all) { // Internet Explorer
nTecla = evtKeyPress.keyCode; }
else if(document.layers) { // Nestcape
nTecla = evtKeyPress.which;
}else{
nTecla = evtKeyPress.which;
}
sValue = objeto.value;
// Limpa todos os caracteres de formatação que
// já estiverem no campo.
sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( "-", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( ".", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( "/", "" );
sValue = sValue.toString().replace( ":", "" );
sValue = sValue.toString().replace( ":", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( "(", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( ")", "" );
sValue = sValue.toString().replace( " ", "" );
sValue = sValue.toString().replace( " ", "" );
fldLen = sValue.length;
mskLen = sMask.length;
i = 0;
nCount = 0;
sCod = "";
mskLen = fldLen;
if (nTecla != 8) { // backspace
while (i <= mskLen) {
bolMask = ((sMask.charAt(i) == "-") || (sMask.charAt(i) == ".") || (sMask.charAt(i) == "/") || (sMask.charAt(i) == ":"))
bolMask = bolMask || ((sMask.charAt(i) == "(") || (sMask.charAt(i) == ")") || (sMask.charAt(i) == " "))
if (bolMask) {
sCod += sMask.charAt(i);
mskLen++; }
else {
sCod += sValue.charAt(nCount);
nCount++;
}
i++;
}
objeto.value = sCod;
if (sMask.charAt(i-1) == "9") { // apenas números...
return ((nTecla > 47) && (nTecla < 58)); } // números de 0 a 9
else { // qualquer caracter...
return true;
} }
else {
return true;
}
}




/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO DE VALIDAÇÃO DE CNPJ
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/


function validaCNPJ(id) {
	CNPJ = document.getElementById(id).value;
	erro = new String;
	if (CNPJ.length < 18) erro += "É necessario preencher corretamente o número do CNPJ! \n\n";
	if ((CNPJ.charAt(2) != ".") || (CNPJ.charAt(6) != ".") || (CNPJ.charAt(10) != "/") || (CNPJ.charAt(15) != "-")){
	if (erro.length == 0) erro += "É necessário preencher corretamente o número do CNPJ! \n\n";
	}
	//substituir os caracteres que não são números
	if(document.layers && parseInt(navigator.appVersion) == 4){
		x = CNPJ.substring(0,2);
		x += CNPJ. substring (3,6);
		x += CNPJ. substring (7,10);
		x += CNPJ. substring (11,15);
		x += CNPJ. substring (16,18);
		CNPJ = x;
	} else {
		CNPJ = CNPJ. replace (".","");
		CNPJ = CNPJ. replace (".","");
		CNPJ = CNPJ. replace ("-","");
		CNPJ = CNPJ. replace ("/","");
	}
	var nonNumbers = /\D/;
	if (nonNumbers.test(CNPJ)) erro += "A verificação de CNPJ suporta apenas números! \n\n";
	var a = [];
	var b = new Number;
	var c = [6,5,4,3,2,9,8,7,6,5,4,3,2];
	for (i=0; i<12; i++){
	a[i] = CNPJ.charAt(i);
	b += a[i] * c[i+1];
	}
	if ((x = b % 11) < 2) { a[12] = 0 } else { a[12] = 11-x }
	b = 0;
	for (y=0; y<13; y++) {
	b += (a[y] * c[y]);
	}
	if ((x = b % 11) < 2) { a[13] = 0; } else { a[13] = 11-x; }
	if ((CNPJ.charAt(12) != a[12]) || (CNPJ.charAt(13) != a[13])){
	erro +="CNPJ inválido!";
	}
	if (erro.length > 0){
	//alert(erro);
	showPopWin('alertar.php?texto='+erro+'', 400, 100, null)
	return false;
	}
	return true;
}




/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO DE VALIDAÇÃO DE CPF
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/


function validacaoCPF(cpf) {  
	cpf = document.getElementById(cpf).value;
	d1 = d2 = 0;  
	digito1 = digito2 = resto = 0;  
	
	if(document.layers && parseInt(navigator.appVersion) == 4){
		x = cpf.substring(0,3);
		x += cpf. substring (4,3);
		x += cpf. substring (8,3);
		x += cpf. substring (12,2);
		cpf = x;
	} else {
		cpf = cpf. replace (".","");
		cpf = cpf. replace (".","");
		cpf = cpf. replace ("-","");
	}	
	retorno= valida_cpf(cpf);
	if (!retorno){
		//alert("CPF invalido!");
		showPopWin('alertar.php?texto=CPF invalido!', 400, 100, null)
	}
	return retorno;
}  



/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO DE VALIDAÇÃO DE CPF
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/



function valida_cpf(cpf)
{
var numeros, digitos, soma, i, resultado, digitos_iguais;
digitos_iguais = 1;
if (cpf.length < 11)
	return false;
for (i = 0; i < cpf.length - 1; i++)
	if (cpf.charAt(i) != cpf.charAt(i + 1))
		  {
		  digitos_iguais = 0;
		  break;
		  }
if (!digitos_iguais)
	{
	numeros = cpf.substring(0,9);
	digitos = cpf.substring(9);
	soma = 0;
	for (i = 10; i > 1; i--)
		  soma += numeros.charAt(10 - i) * i;
	resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
	if (resultado != digitos.charAt(0))
		  return false;
	numeros = cpf.substring(0,10);
	soma = 0;
	for (i = 11; i > 1; i--)
		  soma += numeros.charAt(11 - i) * i;
	resultado = soma % 11 < 2 ? 0 : 11 - soma % 11;
	if (resultado != digitos.charAt(1))
		  return false;
	return true;
	}
else
	return false;
}

function validarData(campo){
var expReg = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;
var msgErro = 'Formato inválido de data.';
if ((campo.value.match(expReg)) && (campo.value!='')){
var dia = campo.value.substring(0,2);
var mes = campo.value.substring(3,5);
var ano = campo.value.substring(6,10);

//alert('DIA='+dia+' MES='+mes+' ANO='+ano)

if((mes==4 || mes==6 || mes==9 || mes==11) && dia > 30){
//alert("Dia incorreto !!! O mês especificado contém no máximo 30 dias.");
showPopWin('alertar.php?texto=Dia incorreto !!! O mês especificado contém no máximo 30 dias.', 400, 100, null)
return false;
} else{
if(ano%4!=0 && mes==2 && dia>28){
//alert("Data incorreta!! O mês especificado contém no máximo 28 dias.");
showPopWin('alertar.php?texto=Data incorreta!! O mês especificado contém no máximo 28 dias.', 400, 100, null)
return false;
} else{
if(ano%4==0 && mes==2 && dia>29){
//alert("Data incorreta!! O mês especificado contém no máximo 29 dias.");
showPopWin('alertar.php?texto=Data incorreta!! O mês especificado contém no máximo 29 dias.', 400, 100, null)
return false;
} else{ 
return true;
}}}} else {
//alert(msgErro);
showPopWin('alertar.php?texto='+msgErro, 400, 100, null)
campo.focus();
return false;
}}



/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO DE VALIDAÇÃO DE DATA
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/



function Valida_data(campo){
var expReg = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;
var msgErro = 'Formato inválido de data.';
if ((campo.match(expReg)) && (campo!='')){
var dia = campo.substring(0,2);
var mes = campo.substring(3,5);
var ano = campo.substring(6,10);

//alert('DIA='+dia+' MES='+mes+' ANO='+ano)

if((mes==4 || mes==6 || mes==9 || mes==11) && dia > 30){
alert("Dia incorreto !!! O mês especificado contém no máximo 30 dias.");
return false;
} else{
if(ano%4!=0 && mes==2 && dia>28){
alert("Data incorreta!! O mês especificado contém no máximo 28 dias.");
return false;
} else{
if(ano%4==0 && mes==2 && dia>29){
alert("Data incorreta!! O mês especificado contém no máximo 29 dias.");
return false;
} else{ 
return true;
}}}} else {
alert(msgErro);
return false;

}}



/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO DE RETIRAR ESPAÇO COMO CARACTER
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/


function trim(stringToTrim) {
	return stringToTrim.replace(/^\s+|\s+$/g,"");
}


////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////*Validar Email*/////////////////////////////////////////////////////////
function checkMail(mail){
    var er = new RegExp(/^[A-Za-z0-9_\-\.]+@[A-Za-z0-9_\-\.]{2,}\.[A-Za-z0-9]{2,}(\.[A-Za-z0-9])?/);
    if(typeof(mail) == "string"){
        if(er.test(mail)){ return true; }
    }else if(typeof(mail) == "object"){
        if(er.test(mail.value)){
                    return true;
                }
    }else{
        return false;
        }
}

/*
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
							FUNÇÃO FORMATAR VALOR
////////////////////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////////////////////
*/

function Limpar(valor, validos) {
// retira caracteres invalidos da string
var result = "";
var aux;
for (var i=0; i < valor.length; i++) {
aux = validos.indexOf(valor.substring(i, i+1));
if (aux>=0) {
result += aux;
}
}
return result;
}


function Formata(campo,tammax,teclapres,decimal) {
var tecla = teclapres.keyCode;
vr = Limpar(campo.value,"0123456789");
tam = vr.length;
dec=decimal

if (tam < tammax && tecla != 8){ tam = vr.length + 1 ; }

if (tecla == 8 )
{ tam = tam - 1 ; }

if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
{

if ( tam <= dec )
{ campo.value = vr ; }

if ( (tam > dec) && (tam <= 5) ){
campo.value = vr.substr( 0, tam - 2 ) + "," + vr.substr( tam - dec, tam ) ; }
if ( (tam >= 6) && (tam <= 8) ){
campo.value = vr.substr( 0, tam - 5 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ;
}
if ( (tam >= 9) && (tam <= 11) ){
campo.value = vr.substr( 0, tam - 8 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
if ( (tam >= 12) && (tam <= 14) ){
campo.value = vr.substr( 0, tam - 11 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - dec, tam ) ; }
if ( (tam >= 15) && (tam <= 17) ){
campo.value = vr.substr( 0, tam - 14 ) + "." + vr.substr( tam - 14, 3 ) + "." + vr.substr( tam - 11, 3 ) + "." + vr.substr( tam - 8, 3 ) + "." + vr.substr( tam - 5, 3 ) + "," + vr.substr( tam - 2, tam ) ;}
}

}

function mudarFundo(fidmuda, fclassemuda){
	
	document.getElementById(fidmuda).className = fclassemuda
	
}


//////////////////// EXIBE / ESCONDE DIV ////////////////////

function displayDiv(name) {
	if (document.getElementById(name).style.display=='') {
		document.getElementById(name).style.display='none';
	} else {
		document.getElementById(name).style.display='';
	}
}
