function buscaCep (){
	open('http://www.correios.com.br/servicos/cep/cep_default.cfm','ShowCep','location=no,resize=no, width=730,height=650,left=18,top=18,maximized=1,scrollbars=1');
}

// verifica se um campo de um formulário está vazio ou só com espaços
function Empty(campo)
{
  if(campo.value.length)
  {
    for(i = 0; i < campo.value.length; i++)
    {
      if(campo.value.charAt(i) != " ")
        return false;
    }
    return true;
  }
  else
    return true;
}

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;
		}
}

function validarCep(cep)
{
	txCep = trim(cep);
	if(txCep.length == 0)
		return false;

	txCep = txCep.replace("-","");
	txCep = txCep.replace(".","");
	if(txCep.length != 8 || isNaN(txCep))
		return false;
	else
		return true;
}

// Pula para o próximo campo ao atingir o maxlength
function pulaCampo(campoOrigem, campoDestino, tamCampoOrigem){

	if (campoOrigem.value.length >= tamCampoOrigem){
	
		campoDestino.focus();
	}
}