setTimeout("cep_carregar()",1000);

function cep_carregar() {
	document.frm.vc_status.readonly		= true;
	document.frm.vc_status.value			= 'Digite o CEP e aguarde.';
	
	cep_disabled();
}

function cep_readonly() {
	document.all.vc_endereco.readOnly			= true;
	document.all.vc_complemento.readOnly		= false;
	document.all.vc_bairro.readOnly				= true;
	document.all.vc_cidade.readOnly				= true;
	document.all.vc_estado.readOnly				= true;
}

function cep_disabled() {
	document.all.vc_endereco.disabled			= false;
	document.all.vc_complemento.disabled		= false;
	document.all.vc_bairro.disabled				= false;
	document.all.vc_cidade.disabled				= false;
	document.all.vc_estado.disabled				= false;

	document.frm.vc_endereco.readOnly			= false;
	document.frm.vc_complemento.readOnly		= false;
	document.frm.vc_bairro.readOnly				= false;
	document.frm.vc_cidade.readOnly				= false;
	document.frm.vc_estado.readOnly				= false;
}

function cep_erase() {
	document.all.vc_endereco.value				= '';
	document.all.vc_complemento.value			= '';
	document.all.vc_bairro.value				= '';
	document.all.vc_cidade.value				= '';
	document.all.vc_estado.value				= '';
}

function contar_cep() {
	if (document.all.vc_cep.value.length == 5) {
		document.all.vc_cep.value				= document.all.vc_cep.value + '-';
	} else if (document.all.vc_cep.value.length > 8) {
		document.all.vc_status.value			= 'Aguarde! Pesquisando...';
			
		iframe_virtual('./wm/temp/cep.asp?cep='+document.all.vc_cep.value)
	}
	if(window.event.keyCode == 13) {
		event.keyCode							= 0;
		event.returnValue						= false;
	}
}

function cep_preencher(vc_informacoes) {
	if (vc_informacoes != 0) {
		var vc_informacao						= vc_informacoes.split("#");
		
		cep_readonly();
		
		document.all.vc_status.value			= 'CEP encontrado!';
		document.all.vc_endereco.value			= vc_informacao[0];
		document.all.vc_complemento.value		= '';
		document.all.vc_bairro.value			= vc_informacao[1];
		document.all.vc_cidade.value			= vc_informacao[2];
		document.all.vc_estado.value			= vc_informacao[3];
		document.all.vc_complemento.focus();
		
	} else {
		cep_disabled();
		cep_erase();
		
		document.all.vc_status.value			= 'Complete o endereço.';
		document.all.vc_endereco.focus();
	}
}
