function setForm(form) {
	this.form	= eval('document.' + form);
}

//setTimeout("cep_carregar()",3000);

function cep_carregar() {
	form.vc_status.value			= 'Digite o CEP e aguarde.';
}

function cep_enable() {
	cep_erase();
	
	with(form) {
		vc_endereco.disabled			= false;
		vc_complemento.disabled			= false;
		vc_bairro.disabled				= false;
		vc_cidade.disabled				= false;
		vc_estado.disabled				= false;
	}
}

function cep_readonly() {
	with(form) {
		vc_endereco.readOnly			= true;
		vc_complemento.readOnly			= false;
		vc_bairro.readOnly				= true;
		vc_cidade.readOnly				= true;
		vc_estado.readOnly				= true;
	}
}

function cep_disabled() {
	with(form) {
		vc_endereco.disabled			= true;
		vc_complemento.disabled			= true;
		vc_bairro.disabled				= true;
		vc_cidade.disabled				= true;
		vc_estado.disabled				= true;
	}
}

function cep_erase() {
	with(form) {
		vc_endereco.value				= '';
		vc_complemento.value			= '';
		vc_bairro.value					= '';
		vc_cidade.value					= '';
		vc_estado.value					= '';
	}
}

function contar_cep(frmName, evtKeyPress) {
	if (form.vc_cep.value.length == 5) {
		form.vc_cep.value				= form.vc_cep.value + '-';
	} else if (form.vc_cep.value.length > 8) {
		form.vc_status.value			= 'Aguarde! Pesquisando...';
			
		iframe_virtual('wm/temp/cep.asp?cep='+form.vc_cep.value)

	}
	
	var it_tecla;
	it_tecla = (evtKeyPress.which) ? evtKeyPress.which : evtKeyPress.keyCode;
//	alert(it_tecla);
	if(it_tecla == 13) return false;	// ñ deixa submeter o form ao pressionar [ENTER] no campo CEP
}

function cep_preencher(vc_informacoes) {
	if (vc_informacoes != 0) {
		var vc_informacao				= vc_informacoes.split("#");
		
		cep_enable();
		
		with(form) {
			vc_status.value				= 'CEP encontrado!';
			vc_endereco.value			= vc_informacao[0];
			vc_complemento.value		= '';
			vc_bairro.value				= vc_informacao[1];
			vc_cidade.value				= vc_informacao[2];
			vc_estado.value				= vc_informacao[3];
		}
		
//		cep_readonly();

		form.vc_complemento.focus();

	} else {
		cep_enable();
		
		form.vc_status.value			= 'CEP não encontrado!';
//		form.vc_endereco.focus();
		form.vc_complemento.focus();
	}
}
