validarCEP<!--
function doPost(formName, actionName)
{
    var hiddenControl = document.getElementById('action');
    var theForm = document.getElementById(formName);
    
    hiddenControl.value = actionName;
    theForm.submit();
}

function validarCEP() {
var CEP;
CEP = limpa_string(document.formulario.txtCep.value);
	if (CEP.length < 8) {
		alert("O CEP informado não é válido!");
		return false; }
	else  {
		doPost('formulario', 'cep'); }
}

function limpa_string(S){
	// Deixa so os digitos numericos
	var Digitos = "0123456789";
	var temp = "";
	var digito = "";

	for (var i=0; i<S.length; i++)	{
		digito = S.charAt(i);
		if (Digitos.indexOf(digito)>=0)	{
			temp=temp+digito	}
	} //for

	return temp
}

function formataCEP(formato, keypress, objeto)
{
//onKeyPress="formataCEP('CEP', window.event.keyCode, this);"
campo = eval(objeto);
if (formato=='CEP')
	{
	caracteres = '01234567890';
	separacoes = 1;
	separacao1 = '-';
	conjuntos = 2;
	conjunto1 = 5;
	conjunto2 = 3;
	if ((caracteres.search(String.fromCharCode (keypress))!=-1) && campo.value.length <= (conjunto1 + conjunto2 + 1))
		{
		if (campo.value.length == conjunto1) 
		   campo.value = campo.value + separacao1;
		}
	else 
		event.returnValue = false;
	}
}

//Formatar MOEDA			- xx.xxx,xx
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 = '';
fld.value = fld.value.replace('R$ ','')
var whichCode = (window.Event) ? e.which : e.keyCode;
if (whichCode == 13) return true;  // Enter
if (whichCode == 8) return true;  // Delete (Bug fixed)
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 && len < 8) {
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);
}
fld.value = 'R$ ' + fld.value;
if (len >= 8) {
 alert('O valor máximo permitido é R$ 99.999,99');
 return false;
}
return false;
}


function formataNumero(keypress, objeto)
{
//onKeyPress="formataNumero(window.event.keyCode, this);"
	campo = eval(objeto);
	caracteres = '01234567890';

	if (caracteres.search(String.fromCharCode (keypress)) != -1)
	{
		campo.value = campo.value;
	}
	else 
		event.returnValue = false;
}

 	var MudarCampo = true;

	document.onkeypress = HabilitarTABAutom;

	function HabilitarTABAutom(evt)
	{
		var codTecla;

	 	var e = evt ? evt : window.event; 

		if(e.keyCode)  // IE
		{
			codTecla = e.keyCode;
		}
		else // Netscape/Firefox/Opera
		{
			codTecla = e.which;
		}

		if ( (codTecla < 48) || (codTecla >  255) )
			MudarCampo = false;
		else
			MudarCampo = true;

	}

	function tabAutom(quem, e) 
	{
		if ( ( quem.value.length == quem.maxLength ) && ( MudarCampo ) ){
			var i=0,j=0, indice=-1;
			// Localiza em qual form está o input no documento
			for (i=0; i<document.forms.length; i++) {
				for (j=0; j<document.forms[i].elements.length; j++) {
					if (document.forms[i].elements[j].name == quem.name) {
						indice=i;
						break;
					}
				}
				if (indice != -1)
			         break;
			}

			// Localiza o input no documento e verifica se existe outro input para receber o foco
			for (i=0; i<document.forms[indice].elements.length; i++) 
			{
				if (document.forms[indice].elements[i].name == quem.name) 
				{
					while ( ((i+1) < document.forms[indice].elements.length) && 
					        ( (document.forms[indice].elements[(i+1)].type == "hidden") || 
						  (document.forms[indice].elements[(i+1)].name == "Lim") ) )
					{
								i++;
					}
					if ( (i+1) < document.forms[indice].elements.length )
					{
						document.forms[indice].elements[(i+1)].focus();
						MudarCampo = false;
					}
					break;
				} 
			}
		} 
	}

//<!-- -->
-->