function eCep(st) {
 if (st!="") {
  ci = st.substr(0,5);
  cf = st.substr(6,3);
  if (!eNum(ci) || !eNum(cf)) return false;
  if (ci<1000) return false;
 }
 return true; 
}

function ChkCep(obj) {
 if (!eCep(obj.value)) {
  alert("Cep inválido");
  obj.focus();
  return false;
 }
 return true;
}

function FmtCep(obj,tc) {
 tc = tc.keyCode;
 vr = obj.value;
 tm = vr.length;
 if (tc!=45) {
  if (tm==5) obj.value = vr.substr(0,5) + '-' + vr.substr(5,1);
 }
}

function CarCep(obj) {
 vr = obj.value;
 tm = vr.length;
 if (tm==9) {
  if (ChkCep(obj)) {	  
   pa = "cep.asp?cep=" + vr;
   window.open(pa,"_blank","top=5000,left=0,width=10,height=10"); 
   obj.focus();
  }
 }
}

function AtuCep(c1,c2,c3,c4) {
 obj = document.form;
 obj.endereco.value = c1;
 obj.bairro.value = c2;
 obj.cidade.value = c3;
 obj.uf.value = c4;
 obj.endereco.focus();
}
