<!--
function mascara(src, mask){
	var i = src.value.length;
	var saida = mask.substring(0,1);
	var texto = mask.substring(i)
	if (texto.substring(0,1) != saida){src.value += texto.substring(0,1);}
}

function sNumero(e){
    var tecla=(window.event)?event.keyCode:e.which;
    if((tecla > 47 && tecla < 58)) return true;
    else{
    if (tecla != 8) return false;
    else return true;
    }
}

function FormataTelefone(objeto,teclapres){
	var tammax = 14;
	var tecla			= teclapres.keyCode;
	var tamanhoObjeto	= objeto.value.length;
	if ((tecla == 8) && (tamanhoObjeto == tammax)){
		tamanhoObjeto = tamanhoObjeto - 1 ;
	}
	
	var v = objeto.value;
	var n='';
	var v2='';

	if (tecla == 9){return false}//tab 
	if(tecla==13){return false;}//alert(tecla)
	if (tecla == 37 || tecla == 39){return false} //{seta direita e esquerda}
    if (( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) && ((tamanhoObjeto+1) <= tammax)){
		v=v.replace('(','');
		v=v.replace(')','');
		v=v.replace('-','');
		v2='(';
		for (i=0;i<=v.length;i++){
			n = v.substring(i,i+1);
			if (n==0 || n==1 || n==2 || n==3 || n==4 || n==5 || n==6 || n==7 || n==8 || n==9){
				if(i==2){v2+=')x' }
				if(i==7){v2+='-'}
				v2+=n;
			}
		}
		if (tecla != 8){
			v2=v2.replace('x',' ')
			v2=v2.replace('  ',' ')
		
			objeto.value = v2.substr(0, tammax);
			window.event.returnValue = true;
		}
	}else{
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	}


	
}


function FormataCPF(objeto,teclapres){
	var tammax=14
	var tecla			= teclapres.keyCode;
	var tamanhoObjeto	= objeto.value.length;
	if ((tecla == 8) && (tamanhoObjeto == tammax)){
		tamanhoObjeto = tamanhoObjeto - 1 ;
	}
	
	var v = objeto.value;
	var n='';
	var v2='';
	var x=0;

	if (tecla == 9){return false}//tab 
	if(tecla==13){return false;}//alert(tecla)
	if (tecla == 37 || tecla == 39){return false} //{seta direita e esquerda}
    if (( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) && ((tamanhoObjeto+1) <= tammax)){
		v=v.replace('.','');
		v=v.replace('-','');
		v2='';
		x=1;
		for (i=v.length;i>=0;i--){
			n = v.substring(i-1,i);
			if (n==0 || n==1 || n==2 || n==3 || n==4 || n==5 || n==6 || n==7 || n==8 || n==9){
				if(i==(v.length-1)){
					v2=n+'-'+v2;x=1;
				}else{
					if(x==3 && i>0){v2=n+'.'+v2;x=0;}
					else{v2=n+v2;}
					x++;
				}
			}
		}
		if (tecla != 8){
			v2=v2.replace(' ','')
			objeto.value = v2.substr(0, tammax-1);
			window.event.returnValue = true;
		}
	}else{
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	}

}


function FormataData(objeto,teclapres){
	var tammax = 10;
	var tecla			= teclapres.keyCode;
	var tamanhoObjeto	= objeto.value.length;
	if ((tecla == 8) && (tamanhoObjeto == tammax)){
		tamanhoObjeto = tamanhoObjeto - 1 ;
	}
	
	var v = objeto.value;
	var n='';
	var v2='';
	var x=0;

	if (tecla == 9){return false}//tab 
	if(tecla==13){return false;}//alert(tecla)
	if (tecla == 37 || tecla == 39){return false} //{seta direita e esquerda}
    if (( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) && ((tamanhoObjeto+1) <= tammax)){
		v=v.replace('/','');
		v2='';
		for (i=0;i<=v.length;i++){
			n = v.substring(i,i+1);
			if (n==0 || n==1 || n==2 || n==3 || n==4 || n==5 || n==6 || n==7 || n==8 || n==9){
				if(i==2 || i==4){v2+='/' }
				v2+=n;
			}
		}
		if (tecla != 8){
			v2=v2.replace(' ','')
			objeto.value = v2.substr(0, tammax-1);
			window.event.returnValue = true;
		}
	}else{
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	}


}


function FormataCep(objeto,teclapres){
	var tammax = 9;
	var tecla			= teclapres.keyCode;
	var tamanhoObjeto	= objeto.value.length;
	if ((tecla == 8) && (tamanhoObjeto == tammax)){
		tamanhoObjeto = tamanhoObjeto - 1 ;
	}
	
	var v = objeto.value;
	var n='';
	var v2='';

	if (tecla == 9){return false}//tab 
	if(tecla==13){return false;}//alert(tecla)
	if (tecla == 37 || tecla == 39){return false} //{seta direita e esquerda}
    if (( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) && ((tamanhoObjeto+1) <= tammax)){
		v=v.replace('-','');
		v2='';
		for (i=0;i<=v.length;i++){
			n = v.substring(i,i+1);
			if (n==0 || n==1 || n==2 || n==3 || n==4 || n==5 || n==6 || n==7 || n==8 || n==9){
				if(i==5){v2+='-' }
				v2+=n;
			}
		}
		if (tecla != 8){
			v2=v2.replace('x',' ')
			v2=v2.replace('  ',' ')
		
			objeto.value = v2.substr(0, tammax);
			window.event.returnValue = true;
		}
	}else{
		window.event.cancelBubble = true;
		window.event.returnValue = false;
	}


	
}

function FormataValor(objeto,teclapres,tammax,decimais) 
{
	var tecla			= teclapres.keyCode;
	var tamanhoObjeto	= objeto.value.length;
	if ((tecla == 8) && (tamanhoObjeto == tammax))
	{
		tamanhoObjeto = tamanhoObjeto - 1 ;
	}
    if (( tecla == 8 || tecla == 88 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 ) && ((tamanhoObjeto+1) <= tammax))
	{
		vr	= objeto.value;
		vr	= vr.replace( "/", "" );
		vr	= vr.replace( "/", "" );
		vr	= vr.replace( ",", "" );
		vr	= vr.replace( ".", "" );
		vr	= vr.replace( ".", "" );
		vr	= vr.replace( ".", "" );
		vr	= vr.replace( ".", "" );
		tam	= vr.length;
		if (tam < tammax && tecla != 8)
		{
			tam = vr.length + 1 ;
		}
		if ((tecla == 8) && (tam > 1))
		{
			tam = tam - 1 ;
			vr = objeto.value;
			vr = vr.replace( "/", "" );
			vr = vr.replace( "/", "" );
			vr = vr.replace( ",", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
			vr = vr.replace( ".", "" );
		}
		if ( tecla == 8 || tecla >= 48 && tecla <= 57 || tecla >= 96 && tecla <= 105 )
		{
			if (decimais > 0)
			{
				if ( (tam <= decimais) )
				{ 
					objeto.value = ("0," + vr) ;
				}
				if( (tam == (decimais + 1)) && (tecla == 8))
				{
					objeto.value = vr.substr( 0, (tam - decimais)) + ',' + vr.substr( tam - (decimais), tam ) ;	
				}
				if ( (tam > (decimais + 1)) && (tam <= (decimais + 3)) &&  ((vr.substr(0,1)) == "0"))
				{
					objeto.value = vr.substr( 1, (tam - (decimais+1))) + ',' + vr.substr( tam - (decimais), tam ) ;
				}
				if ( (tam > (decimais + 1)) && (tam <= (decimais + 3)) &&  ((vr.substr(0,1)) != "0"))
				{
				    objeto.value = vr.substr( 0, tam - decimais ) + ',' + vr.substr( tam - decimais, tam ) ; 
				}
				if ( (tam >= (decimais + 4)) && (tam <= (decimais + 6)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 3) ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
			 	if ( (tam >= (decimais + 7)) && (tam <= (decimais + 9)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 6) ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
				if ( (tam >= (decimais + 10)) && (tam <= (decimais + 12)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 9) ) + '.' + vr.substr( tam - (decimais + 9), 3 ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
				if ( (tam >= (decimais + 13)) && (tam <= (decimais + 15)) )
				{
			 		objeto.value = vr.substr( 0, tam - (decimais + 12) ) + '.' + vr.substr( tam - (decimais + 12), 3 ) + '.' + vr.substr( tam - (decimais + 9), 3 ) + '.' + vr.substr( tam - (decimais + 6), 3 ) + '.' + vr.substr( tam - (decimais + 3), 3 ) + ',' + vr.substr( tam - decimais, tam ) ;
				}
			}
			else if(decimais == 0)
			{
				if ( tam <= 3 )
				{ 
			 		objeto.value = vr ;
				}
				if ( (tam >= 4) && (tam <= 6) )
				{
					if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr(0, tam - 3) + '.' + vr.substr( tam - 3, 3 ); 
				}
				if ( (tam >= 7) && (tam <= 9) )
				{
					if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr( 0, tam - 6 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ); 
				}
				if ( (tam >= 10) && (tam <= 12) )
				{
			 		if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr( 0, tam - 9 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ); 
				}

				if ( (tam >= 13) && (tam <= 15) )
				{
					if(tecla == 8)
					{
						objeto.value = vr.substr(0, tam);
						window.event.cancelBubble = true;
						window.event.returnValue = false;
					}
					objeto.value = vr.substr( 0, tam - 12 ) + '.' + vr.substr( tam - 12, 3 ) + '.' + vr.substr( tam - 9, 3 ) + '.' + vr.substr( tam - 6, 3 ) + '.' + vr.substr( tam - 3, 3 ) ;
				}			
			}
		}
	}
	else if((window.event.keyCode != 8) && (window.event.keyCode != 9) && (window.event.keyCode != 13) && (window.event.keyCode != 35) && (window.event.keyCode != 36) && (window.event.keyCode != 46))
		{
			window.event.cancelBubble = true;
			window.event.returnValue = false;
		}
}





function isDate(myDate){
	if(myDate=='' || myDate=='00/00/0000'){
		return false;
	}else{
		var expReg = /^(([0-2]\d|[3][0-1])\/([0]\d|[1][0-2])\/[1-2][0-9]\d{2})$/;
		if ((myDate.match(expReg)) && (myDate!='')) {
			return true;
		} else {
			return false;
		}
	}
}



/********************************************************************************************************
 * PROTÓTIPOS:
 * método String.lpad(int pSize, char pCharPad)
 * método String.trim()
 *
 * String unformatNumber(String pNum)
 * String formatCpfCnpj(String pCpfCnpj, boolean pUseSepar, boolean pIsCnpj)
 * String dvCpfCnpj(String pEfetivo, boolean pIsCnpj)
 * boolean isCpf(String pCpf)
 * boolean isCnpj(String pCnpj)
 * boolean isCpfCnpj(String pCpfCnpj)
 */


NUM_DIGITOS_CPF  = 11;
NUM_DIGITOS_CNPJ = 14;
NUM_DGT_CNPJ_BASE = 8;


/**
 * Adiciona método lpad() à classe String.
 * Preenche a String à esquerda com o caractere fornecido,
 * até que ela atinja o tamanho especificado.
 */
String.prototype.lpad = function(pSize, pCharPad)
{
var str = this;
var dif = pSize - str.length;
var ch = String(pCharPad).charAt(0);
for (; dif>0; dif--) str = ch + str;
return (str);
} //String.lpad


/**
 * Adiciona método trim() à classe String.
 * Elimina brancos no início e fim da String.
 */
String.prototype.trim = function()
{
return this.replace(/^\s*/, "").replace(/\s*$/, "");
} //String.trim


/**
 * Elimina caracteres de formatação e zeros à esquerda da string
 * de número fornecida.
 * @param String pNum
 * String de número fornecida para ser desformatada.
 * @return String de número desformatada.
 */
function unformatNumber(pNum)
{
return String(pNum).replace(/\D/g, "").replace(/^0+/, "");
} //unformatNumber


/**
 * Formata a string fornecida como CNPJ ou CPF, adicionando zeros
 * à esquerda se necessário e caracteres separadores, conforme solicitado.
 * @param String pCpfCnpj
 * String fornecida para ser formatada.
 * @param boolean pUseSepar
 * Indica se devem ser usados caracteres separadores (. - /).
 * @param boolean pIsCnpj
 * Indica se a string fornecida é um CNPJ.
 * Caso contrário, é CPF. Default = false (CPF).
 * @return String de CPF ou CNPJ devidamente formatada.
 */
function formatCpfCnpj(pCpfCnpj, pUseSepar, pIsCnpj)
{
if (pIsCnpj==null) pIsCnpj = false;
if (pUseSepar==null) pUseSepar = true;
var maxDigitos = pIsCnpj? NUM_DIGITOS_CNPJ: NUM_DIGITOS_CPF;
var numero = unformatNumber(pCpfCnpj);

numero = numero.lpad(maxDigitos, '0');
if (!pUseSepar) return numero;

if (pIsCnpj)
{
reCnpj = /(\d{2})(\d{3})(\d{3})(\d{4})(\d{2})$/;
numero = numero.replace(reCnpj, "$1.$2.$3/$4-$5");
}
else
{
reCpf  = /(\d{3})(\d{3})(\d{3})(\d{2})$/;
numero = numero.replace(reCpf, "$1.$2.$3-$4");
}
return numero;
} //formatCpfCnpj


/**
 * Calcula os 2 dígitos verificadores para o número-efetivo pEfetivo de
 * CNPJ (12 dígitos) ou CPF (9 dígitos) fornecido. pIsCnpj é booleano e
 * informa se o número-efetivo fornecido é CNPJ (default = false).
 * @param String pEfetivo
 * String do número-efetivo (SEM dígitos verificadores) de CNPJ ou CPF.
 * @param boolean pIsCnpj
 * Indica se a string fornecida é de um CNPJ.
 * Caso contrário, é CPF. Default = false (CPF).
 * @return String com os dois dígitos verificadores.
 */
function dvCpfCnpj(pEfetivo, pIsCnpj)
{
if (pIsCnpj==null) pIsCnpj = false;
var i, j, k, soma, dv;
var cicloPeso = pIsCnpj? NUM_DGT_CNPJ_BASE: NUM_DIGITOS_CPF;
var maxDigitos = pIsCnpj? NUM_DIGITOS_CNPJ: NUM_DIGITOS_CPF;
var calculado = formatCpfCnpj(pEfetivo, false, pIsCnpj);
calculado = calculado.substring(2, maxDigitos);
var result = "";

for (j = 1; j <= 2; j++)
{
k = 2;
soma = 0;
for (i = calculado.length-1; i >= 0; i--)
{
soma += (calculado.charAt(i) - '0') * k;
k = (k-1) % cicloPeso + 2;
}
dv = 11 - soma % 11;
if (dv > 9) dv = 0;
calculado += dv;
result += dv
}

return result;
} //dvCpfCnpj


/**
 * Testa se a String pCpf fornecida é um CPF válido.
 * Qualquer formatação que não seja algarismos é desconsiderada.
 * @param String pCpf
 * String fornecida para ser testada.
 * @return <code>true</code> se a String fornecida for um CPF válido.
 */
function isCpf(pCpf)
{
var numero = formatCpfCnpj(pCpf, false, false);
var base = numero.substring(0, numero.length - 2);
var digitos = dvCpfCnpj(base, false);
var algUnico, i;

// Valida dígitos verificadores
if (numero != base + digitos) return false;

/* Não serão considerados válidos os seguintes CPF:
 * 000.000.000-00, 111.111.111-11, 222.222.222-22, 333.333.333-33, 444.444.444-44,
 * 555.555.555-55, 666.666.666-66, 777.777.777-77, 888.888.888-88, 999.999.999-99.
 */
algUnico = true;
for (i=1; i<NUM_DIGITOS_CPF; i++)
{
algUnico = algUnico && (numero.charAt(i-1) == numero.charAt(i));
}
return (!algUnico);
} //isCpf


/**
 * Testa se a String pCnpj fornecida é um CNPJ válido.
 * Qualquer formatação que não seja algarismos é desconsiderada.
 * @param String pCnpj
 * String fornecida para ser testada.
 * @return <code>true</code> se a String fornecida for um CNPJ válido.
 */
function isCnpj(pCnpj)
{
var numero = formatCpfCnpj(pCnpj, false, true);
var base = numero.substring(0, NUM_DGT_CNPJ_BASE);
var ordem = numero.substring(NUM_DGT_CNPJ_BASE, 12);
var digitos = dvCpfCnpj(base + ordem, true);
var algUnico;

// Valida dígitos verificadores
if (numero != base + ordem + digitos) return false;

/* Não serão considerados válidos os CNPJ com os seguintes números BÁSICOS:
 * 11.111.111, 22.222.222, 33.333.333, 44.444.444, 55.555.555,
 * 66.666.666, 77.777.777, 88.888.888, 99.999.999.
 */
algUnico = numero.charAt(0) != '0';
for (i=1; i<NUM_DGT_CNPJ_BASE; i++)
{
algUnico = algUnico && (numero.charAt(i-1) == numero.charAt(i));
}
if (algUnico) return false;

/* Não será considerado válido CNPJ com número de ORDEM igual a 0000.
 * Não será considerado válido CNPJ com número de ORDEM maior do que 0300
 * e com as três primeiras posições do número BÁSICO com 000 (zeros).
 * Esta crítica não será feita quando o no BÁSICO do CNPJ for igual a 00.000.000.
 */
if (ordem == "0000") return false;
return (base == "00000000"
|| parseInt(ordem, 10) <= 300 || base.substring(0, 3) != "000");
} //isCnpj


/**
 * Testa se a String pCpfCnpj fornecida é um CPF ou CNPJ válido.
 * Se a String tiver uma quantidade de dígitos igual ou inferior
 * a 11, valida como CPF. Se for maior que 11, valida como CNPJ.
 * Qualquer formatação que não seja algarismos é desconsiderada.
 * @param String pCpfCnpj
 * String fornecida para ser testada.
 * @return <code>true</code> se a String fornecida for um CPF ou CNPJ válido.
 */
function isCpfCnpj(pCpfCnpj)
{
var numero = pCpfCnpj.replace(/\D/g, "");
if (numero.length > NUM_DIGITOS_CPF)
return isCnpj(pCpfCnpj)
else
return isCpf(pCpfCnpj);
} //isCpfCnpj
//************************************************************************************************

function FormataCNPJ(el){ 
	vr = el.value; 
	tam = vr.length; 
	if ( vr.indexOf(".") == -1 ){ 
	if ( tam <= 2 ) 
	el.value = vr; 
	if ( (tam > 2) && (tam <= 6) ) 
	el.value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, tam ); 
	if ( (tam >= 7) && (tam <= 10) ) 
	el.value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '.' + vr.substr( 5, 3 ) + '/'; 
	if ( (tam >= 11) && (tam <= 18) ) 
	el.value = vr.substr( 0, 2 ) + '.' + vr.substr( 2, 3 ) + '.' + vr.substr( 5, 3 ) + '/' + vr.substr( 8, 4 ) + '-' + vr.substr( 12, 2 ) ; 
	} 
	return true; 
} 


-->