
function seguranca_senha(val, tamanho) {

            document.getElementById('mensagemSenha').innerHTML = "";
			document.getElementById('senha1').style.width='0%'
			document.getElementById('senha1').style.backgroundColor='#ffffff'
			document.getElementById('senha2').style.width='100%'			
			document.getElementById('senha2').style.backgroundColor='#e0e0e0'

            var lc = /[a-z]{1}/; // lowercase letters

            var uc = /[A-Z]{1}/; // uppercase letters

            var nm = /[0-9]{1}/; // numbers

            var un = /[^A-Za-z0-9]{1}/; // upper- and lower-case letters and numbers

            var ec = /[@!#$%&*+=?|-]/; //caracteres especiais

            if(   val.length >= tamanho && val.search(/[a-z]/) != -1 && val.search(/[A-Z]/) != -1 && val.search(/[0-9]/) != -1 

                        ||val.length >= tamanho && val.search(/[a-z]/) != -1 && val.search(/[A-Z]/) != -1 && val.search(/[@!#$%&*+=?|-]/) 

                        ||val.length >= tamanho && val.search(/[a-z]/) != -1 && val.search(/[@!#$%&*+=?|-]/) != -1 && val.search(/[0-9]/) 

                        ||val.length >= tamanho  && val.search(/[@!#$%&*+=?|-]/) != -1 && val.search(/[A-Z]/) != -1 && val.search(/[0-9]/) )

                        {

                                    document.getElementById('mensagemSenha').innerHTML = "Forte";

                                    document.getElementById('senha1').style.width='100%'

                                    document.getElementById('senha1').style.backgroundColor='green'

                                    document.getElementById('senha2').style.width='0%'

                                    document.getElementById('senha2').style.backgroundColor='#e0e0e0'

            } 

            else{

                        if(   val.length >= tamanho && val.search(/[a-z]/) != -1 && val.search(/[A-Z]/) != -1 

                                    ||val.length >= tamanho && val.search(/[a-z]/) != -1 && val.search(/[0-9]/) != -1 

                                    ||val.length >= tamanho && val.search(/[a-z]/) != -1 && val.search(/[@!#$%&*+=?|-]/) != -1

                                    ||val.length >= tamanho && val.search(/[A-Z]/) != -1 && val.search(/[0-9]/) != -1

                                    ||val.length >= tamanho && val.search(/[A-Z]/) != -1 && val.search(/[@!#$%&*+=?|-]/) != -1

                                    ||val.length >= tamanho && val.search(/[0-9]/) != -1 && val.search(/[@!#$%&*+=?|-]/) != -1){

 

                                    document.getElementById('mensagemSenha').innerHTML = "Média";

                                    document.getElementById('senha1').style.width='60%'

                                    document.getElementById('senha1').style.backgroundColor='orange'

                                    document.getElementById('senha2').style.width='40%'

                                    document.getElementById('senha2').style.backgroundColor='#e0e0e0'

                                                

                        } 

                        else {

                                    if(val.length >= tamanho)

                                    {

                                                document.getElementById('mensagemSenha').innerHTML = "Fraca";

                                                document.getElementById('senha1').style.width='30%'

                                                document.getElementById('senha1').style.backgroundColor='red'

                                                document.getElementById('senha2').style.width='70%'

                                                document.getElementById('senha2').style.backgroundColor='#e0e0e0'

                                    }

                        }

            }

}



// ##############################################################################################


	
	function press_enter(e, func)
	{
	  var tecla=(window.event)?event.keyCode:e.which;
	  
	  if (tecla == 13 && typeof(func) == 'function')
	  {	func.call(); }
	  
	  return true;
	}
	
	
	
	function set_autoTab(campo, mask, maxlength, target)
	{	
		if (mask != '')
		{
			if (campo.value.indexOf(mask) > -1)
			{ return; }
		}
		
		if (maxlength == campo.value.length)
		{	document.getElementById(target).focus(); }
	}
	
	
// ##############################################################################################		
	
	
	function check_error(campo, func)
	{	
		if (typeof(func) == 'function')
		{
			if (func(campo) == true)
			{	$('#error_'+campo.id).hide(0); }	
		}
		else
		{
			if (campo.value.length > 0)
			{	$('#error_'+campo.id).hide(0); }
		}
	}
	
	
	function check_error_length(campo, number, mask)
	{	
		var a;
		a = campo.value;
		
		if (mask != '')
		{ a = a.replace(mask, ''); }
		
		if ( a.length >= number )
		{ $('#error_'+campo.id).hide(0); }
	}
	
	
	
// ##############################################################################################	


	function error_data(campo)
	{
		$('#error_'+campo.id).hide(0);
		$('#error_'+campo.id).fadeIn('fast');
					
		$('#'+campo.id).unmask();
		campo.value="";
		$('#'+campo.id).mask("99/99/9999");
		
		return false;
	}
	
	
	function error_cep(campo)
	{
		$('#error_'+campo.id).hide(0);
		$('#error_'+campo.id).fadeIn('fast');
					
		$('#'+campo.id).unmask();
		campo.value="";
		$('#'+campo.id).mask("99999-999");
		
		return false;
	}
	
	
	function error_cpf(campo)
	{
		$('#error_'+campo.id).hide(0);
		$('#error_'+campo.id).fadeIn('fast');
					
		$('#'+campo.id).unmask();
		campo.value="";
		$('#'+campo.id).mask("999.999.999-99");
		
		return false;
	}
	
	
	function error_celular_telefone(campo)
	{
		$('#error_'+campo.id).hide(0);
		$('#error_'+campo.id).fadeIn('fast');
					
		$('#'+campo.id).unmask();
		campo.value="";
		$('#'+campo.id).mask("99 9999-9999");
		
		return false;
	}
	
	
// ##############################################################################################	
	
	
	
	function ajusta_moeda(e, func)
	{ 
	    var tecla=(window.event)?event.keyCode:e.which;		

		if((tecla <= 47 || tecla > 58))
        {  
		  if (tecla == 13 && typeof(func) == 'function')
	  	  {	func.call(); 
		  	return true;
		  }
		  
		  if( tecla == 44 || tecla == 0 || tecla == 8 )
		  { return true; }
		   
		  return false; 
		}
		
	}
	
	
	function ajusta_moeda_jv(e, campo)
	{ 
	    var valor;
		valor = campo.value;
		
	    var tecla=(window.event)?event.keyCode:e.which;		
				
		if((tecla <= 47 || tecla > 58))
        {  
		   if( tecla == 13 || tecla == 0 || tecla == 8 )
		   { return true; }
		   
		   if (tecla == 44 && valor.indexOf(',') == -1)
		   { return true; }
		   
		   return false; 
		}
		
	}
	
	
	

// ##################################################################################################
	
	
	
	function valida_numero(sText)
	{
	   	var ValidChars = "0123456789";
   		var Char;

   			for (i = 0; i < sText.length; i++) { 
		   	   	Char = sText.charAt(i); 
		   	   	if (ValidChars.indexOf(Char) == -1) 
		   	   	{	return false; }
			}
		return true;
	}
	
	
	
	var reEmail1 = /^[\w!#$%&'*+\/=?^`{|}~-]+(\.[\w!#$%&'*+\/=?^`{|}~-]+)*@(([\w-]+\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	var reEmail2 = /^[\w-]+(\.[\w-]+)*@(([\w-]{2,63}\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	var reEmail3 = /^[\w-]+(\.[\w-]+)*@(([A-Za-z\d][A-Za-z\d-]{0,61}[A-Za-z\d]\.)+[A-Za-z]{2,6}|\[\d{1,3}(\.\d{1,3}){3}\])$/;
	var reEmail = reEmail3;	
	
    function valida_email(campo)
	{
		pFmt = 1;
		
		eval("reEmail = reEmail" + pFmt);
		
		if (reEmail.test(campo.value)) {
	                return true;
		} else if (campo.value != null && campo.value != "") {
			return false;
	        }
	}
	
	
	
	var rePrefixoCelular = "347 899 149 249 759 329 779 989 659 979 189 739 749 448 429 447 328 388 389 457 359 229 699 969 669 877 878 879 887 147 148 839 178 177 869 868 867 687 688 689 188 187 179 857 858 859 169 667 758 757 748 747 738 647 228 469 287 777 778 797 658 657 649 648 697 698 737 799 798 288 378 289 248 377 498 387 458 327 348 449 428 357 538 668 467 379 247 459 227 539 499 497 349 427 537 619 559 987 617 127 927 997 957 958 637 128 638 468 618 898 897 889 888 138 137 129 558 959 168 939 978 639 949 838 837 829 828 827 167 938 937 998 967 988 968 977 948 947 928 929 999 557 679 917 677 678 519 198 337 157 158 159 918 197 849 717 439 437 436 718 919 417 418 419 719 819 319 218 489 629 118 628 517 627 488 277 217 117 549 318 317 338 847 848 199 477 547 548 219 818 216 119";
	
	var rePrefixo4Celular = "1167"
	var rePrefixo5Celular = "11634 11665"
	

	

	
   function valida_celular(campo)
   {
		var a, b, c, d1, d2, d3;
		a = campo.value;
		b = "_";
		d1 = true;
		d2 = true;
		d3 = true;
		
		a = a.replace(b, "");
		
		if ( a.length == 12 )
		{
			c = Mid(a, 0, 2) + Mid(a, 3, 3);
			if (rePrefixo5Celular.indexOf(c) == -1 )
			{	d1 = false;	}
						
			c = Mid(a, 0, 2) + Mid(a, 3, 2);
			if (rePrefixo4Celular.indexOf(c) == -1 )
			{	d2 = false;	}
				
			c = Mid(a, 0, 2) + Mid(a, 3, 1);
			if (rePrefixoCelular.indexOf(c) == -1 )
			{	d3 = false;	}
			
			if (d1 == false && d2 == false && d3 == false)
			{	return error_celular_telefone(campo);	}
			else
			{   return true; }
				
		}
		else
		{ return false; }
		
   }
   
   
   
   function valida_telefone(campo)
   {
		var a, b, c, d1, d2, d3;
		a = campo.value;
		b = "_";
		d1 = false;
		d2 = false;
		d3 = false;
		
		a = a.replace(b, "");
		
		if ( a.length == 12 )
		{
			c = Mid(a, 0, 2) + Mid(a, 3, 3);		
			if (c.indexOf(b) == -1 && rePrefixo5Celular.indexOf(c) > -1 )
			{	d1 = true;	}
						
			c = Mid(a, 0, 2) + Mid(a, 3, 2);
			if (c.indexOf(b) == -1 && rePrefixo4Celular.indexOf(c) > -1 )
			{	d2 = true;	}
				
			c = Mid(a, 0, 2) + Mid(a, 3, 1);
			if (c.indexOf(b) == -1 && rePrefixoCelular.indexOf(c) > -1 )
			{	d3 = true;	}
			
				
			if (d1 == false && d2 == false && d3 == false)
			{   return true; }
			else
			{	return error_celular_telefone(campo);	}
			

		}
		else
		{ return false; }
		
   }
   
   
   function valida_linha_voip(campo)
   {
		var a, b, c;
		a = campo.value;
		b = "_";
		c = " ";
		
		if ( a.indexOf(b) == -1 && a.indexOf(c) == -1 )
		{	return true;  }
		else
		{	return false; }
		
   }
   
   
   
   
	

   
   function valida_data(campo){   
   
	 data = campo.value
	 data = data.replace("_", "");
	 obrigatorio = 1;
	 
    	var strdata = data;
    	if((obrigatorio == 1) || (obrigatorio == 0 && strdata != "")){   
        //Verifica a quantidade de digitos informada esta correta.   
        if (strdata.length != 10){   
            return false
        }   
		
        //Verifica máscara da data   
        if ("/" != strdata.substr(2,1) || "/" != strdata.substr(5,1)){   
            return false   
        }   
        dia = strdata.substr(0,2)   
        mes = strdata.substr(3,2);   
        ano = strdata.substr(6,4);   
        //Verifica o dia   
        if (isNaN(dia) || dia > 31 || dia < 1){   
            return error_data(campo)  
        }   
        if (mes == 4 || mes == 6 || mes == 9 || mes == 11){   
            if (dia == "31"){   
                return error_data(campo)   
            }   
        }   
        if (mes == "02"){   
            bissexto = ano % 4;   
            if (bissexto == 0){   
                if (dia > 29){   
                    return error_data(campo)   
                }   
            }else{   
                if (dia > 28){   
                    return error_data(campo)   
                }   
            }   
        }   
    //Verifica o mês   
        if (isNaN(mes) || mes > 12 || mes < 1){   
           return error_data(campo)  
        }   
        //Verifica o ano   
        if (isNaN(ano)){   
            return error_data(campo)   
        }   
    	} 
		
		
	return true;
   }
   
   
   function valida_cep(campo){
    obrigatorio = 1;
   	
	var strcep
	strcep = campo.value
	strcep = strcep.replace("_", "");
  	
	
	
    if((obrigatorio == 1) || (obrigatorio == 0 && strcep != "")){   
        if (strcep.length != 9){   
             return false  
        }else{   
            if (strcep.indexOf("-") != 5){   
                return error_cep(campo)
            }else{   
                if (isNaN(strcep.replace("-","0"))){   
                    return error_cep(campo)  
                }   
            }   
        } 
	}       
   
    
	return true;
   
   }
   
   
    function valida_cpf(campo)
	{ 
		var cpf = campo.value;
		
		if (cpf == "")
		{ return false; }
		
		cpf = cpf.replace (".","");
		cpf = cpf.replace (".","");
		cpf = cpf.replace ("-","");
		cpf = cpf.replace ("_","");
		
		
		if (cpf.length != 11)
		{ return false; }
		
		
		if (cpf == "11111111111" || cpf == "22222222222" || cpf == "33333333333" || cpf == "44444444444" || cpf == "55555555555" || cpf == "66666666666" || cpf == "77777777777" || cpf == "88888888888" || cpf == "99999999999")
		{ return error_cpf(campo); }
		
		
		var i; 
		s = cpf; 
		var c = s.substr(0,9); 
		var dv = s.substr(9,2); 
		var d1 = 0; 
	  
	  
		for (i = 0; i < 9; i++) 
		{ d1 += c.charAt(i)*(10-i); } 
	  
		if (d1 == 0)
		{ return error_cpf(campo); 	} 
	  
	  
		d1 = 11 - (d1 % 11); 
	  	
		if (d1 > 9)
			d1 = 0; 
	  	if (dv.charAt(0) != d1) 
	  	{ return error_cpf(campo); 	} 
	
	
		d1 *= 2; 
		for (i = 0; i < 9; i++) 
		{ d1 += c.charAt(i)*(11-i); } 
	  
		d1 = 11 - (d1 % 11); 
		  
		if (d1 > 9)
			d1 = 0; 
		  
		if (dv.charAt(1) != d1) 
		{ return error_cpf(campo); } 
	  
	  
		return true; 

	} 
   
   
   
   
   
   function valida_cnpj(cnpjForm){
      CNPJ = cnpjForm;
      erro = new String;
   
              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 +="Dígito verificador com problema!";
      }
      if (erro.length > 0){
              return false;
      } 
      return true;
      
   }
   
   
    
	