function getVersaoJSUtilJS() {
	return "1.20080208";
}

function eNetscape() {
	return (navigator.appName == 'Netscape');
}

function getKey(evento) {
	var retorno;
	if (window.event) {
		retorno = evento.keyCode;
	} else {
		retorno = evento.which;
	}
 	return retorno;
}

function validaInteiro(letra) {
	return (((letra >= 48) && (letra <= 57)) || ((letra >= 96) && (letra <= 105)));
}

function validaTexto(letra) {
	return ((letra = 32) || ((letra >= 65) && (letra <= 90)));
}

function validaInteiroTexto(letra) {
	return ((validaInteiro(letra)) || (validaTexto(letra)));
}

function validaDigitacaoInteiro(letra) {
	return ((letra < ' ') || ((letra >= '0') && (letra <= '9')));
}

function validaInteiroEventoKeyPress(eventoOnKeyPress) {
	return validaDigitacaoInteiro(String.fromCharCode(getKey(eventoOnKeyPress)));
}

function validaRealEventoKeyPress(caixaTexto, eventoOnKeyPress) {
	var letra		= getKey(eventoOnKeyPress);
	var letraTeste	= String.fromCharCode(letra);
	var retorno		= false;
	
	if (letraTeste == '.') {
		if (caixaTexto.value.indexOf(",") == -1) {
			caixaTexto.value += ',';
		}
	} else if (letraTeste == ',') {
		retorno = (caixaTexto.value.indexOf(",") == -1);
	} else {
		retorno = validaDigitacaoInteiro(letra);
	}
	return retorno;
}

function limpaTabela(tabela, manterLinhas) {
	var i = 0;

	if (manterLinhas == null) {
		manterLinhas = 0;
	}
	for (i = (tabela.rows.length -1);i >= manterLinhas; i--) {
		tabela.deleteRow(i);
	}
}

function retornaNumeros(texto) {
	var retorno = "";
	var i = 0;
	
	for (i = texto.length; i >= 0; i--) {
		letra = texto.charAt(i);
		if ((letra >= '0') && (letra <= '9')) {
			retorno = "" + letra + retorno;
		}
	}
	
	return retorno;
}

function Modulo10(numero) {
	auxiliar = "";
	peso = 2;
   
	for (contador = (numero.length -1); contador >= 0; contador--) {
		auxiliar = (parseInt(numero.charAt(contador), 10) * peso) + auxiliar;
		if (peso == 1) {
			peso = 2;
		} else {
			peso = 1;
		}
	}
	
	digito = 0;
	
	for (contador = (auxiliar.length -1); contador >= 0; contador--) {
		digito = digito + parseInt(auxiliar.charAt(contador), 10);
	}
	
	digito = 10 - (digito % 10)	;
	
	if (digito > 9) {
		digito = 0;
	}
	
	return digito;
}

function anoBisexto(ano) {
	return (((ano % 4) == 0) && (((ano % 100) != 0) || ((ano % 400) != 0)));
}

function validaData(textoData) {
	var retorno = ((textoData = retornaNumeros(textoData)).length == 8);
	
	if (retorno) {
		var ano	= parseInt(textoData.substr(4,4), 10);
		
		if (retorno = (ano > 1900)) {
			var dia = parseInt(textoData.substr(0,2), 10);
			var mes = parseInt(textoData.substr(2,2), 10);
			
			var mes30 = {4: 1, 6: 1, 9: 1, 11: 1};
			var mes31 = {1: 1, 3: 1, 5: 1, 7: 1, 8: 1, 10: 1, 12: 1};
			
			retorno = ((dia >= 1) && (((mes == 2) && ((dia <= 28) || ((dia == 29) && (anoBisexto(parseInt(textoData.substr(4,4), 10)))))) || ((mes in mes30) && (dia <= 30)) || ((mes in mes31) && (dia <= 31))));
		}
	}
	
	return retorno;
}

function validaTelefone(textoFone) {
	return (((textoFone= retornaNumeros(textoFone)).length >= 8) && (parseInt(textoFone, 10) > 0))
}

function validaDDD(textoDDD) {
	return (((textoDDD= retornaNumeros(textoDDD)).length == 2) && (parseInt(textoDDD, 10) > 10))
}

function validaCEP(textoCEP) {
	return (((textoCEP= retornaNumeros(textoCEP)).length == 8) && (parseInt(textoCEP, 10) > 0))
}

function isCelular(textoFone) {
	return (validaTelefone(textoFone) && ((textoFone.substr(0, 1) == "9") || (textoFone.substr(0, 1) == "8") || (textoFone.substr(0, 1) == "7")));
}

function proximoFocoOnKeyUp(eventoOnKeyUp, caixaTextoOrigem, caixaTextoDestino, nomeCaixaTextoDestino) {
	var texto = caixaTextoOrigem.value;
	
	if ((texto.length >= caixaTextoOrigem.maxLength) && (validaInteiro(getKey(eventoOnKeyUp))) && ((caixaTextoDestino != null) || ((nomeCaixaTextoDestino != null) && (nomeCaixaTextoDestino != "") && ((caixaTextoDestino = document.getElementById(nomeCaixaTextoDestino)) != null)))) {
		try {
			caixaTextoDestino.focus();
			caixaTextoDestino.select();
		} catch (e) {
		}
	}
}

function onfocusCalendario(caixaTexto, botao) {
	if ((caixaTexto.value == null) || (caixaTexto.value == "")) {
		botao.click();
	}
}

function onfocusCopiaValor(caixaTextoOrigem, caixaTextoDestino) {
	if ((caixaTextoDestino.value == null) || (caixaTextoDestino.value == "")) {
		 caixaTextoDestino.value = caixaTextoOrigem.value;
		 caixaTextoDestino.select();
	}
}

function stringToDouble(valor) {
	return parseFloat(valor.replace(".", "").replace(",", "."));
}

function formataValor(valor, casas) {
	if (casas == null) {
		casas = 2;
	}
	
	var nf = new NumberFormat(valor);
	nf.setSeparators(true, ".", ",");
	nf.setPlaces(casas);
	return nf.toFormatted();
}

function formataCEP(cep) {
	var nf = new NumberFormat(parseInt(cep, 10) / 1000);
	nf.setSeparators(true, ".", "-");
	nf.setPlaces(3);
	return nf.toFormatted();
}

function formataData(data) {//DD/MM/AAAA
	var dia = data.getDate();
	var mes	= (data.getMonth() + 1);
	var ano	= data.getYear();
	
	if (dia < 10) {
		dia = "0" + dia;
	}
	
	if (mes < 10) {
		mes = "0" + mes;
	}
	
	return "" + dia + "/" + mes + "/" + ano;
}

function proporcaoImagem(imagem, maxW, maxH) {
	var w = imagem.width;
	var h = imagem.height;

	while (
		((maxW > 0) && (w > maxW)) ||
		((maxH > 0) && (h > maxH))
	) {
		if (w > maxW) {
			h = ((maxW * h) / w);
			w = maxW;
		} else if (h > maxH) {
			w = ((maxH * w) / h);
			h = maxH;
		}
	}

	imagem.width	= w;
	imagem.height	= h;	
}
function FP_jumpMenu(el,frm,sel) {//v1.0
	var href = el.options[el.selectedIndex].value;
	if(sel){
		el.selectedIndex = 0;
	}
	if (href != "") {
		if('_new' == frm){
			open(href);
		} else {
			eval(frm+".location='"+href+"'");
		}
	}
}
