 
function cep_carregar() {
	document.frmCadastro.vc_status.readOnly		= true;
	document.frmCadastro.vc_status.value		= 'Digite o CEP e aguarde.';
}
  
function cep_enable() {
	cep_erase();

	document.frmCadastro.txtEndereco.readOnly	= false;
	document.frmCadastro.txtNumero.readOnly		= false;
	document.frmCadastro.txtBairro.readOnly		= false;
	document.frmCadastro.txtCidade.readOnly		= false;
	document.frmCadastro.txtEstado.readOnly		= false;
}

function cep_readonly() {
	document.frmCadastro.txtEndereco.readOnly	= true;
	document.frmCadastro.txtNumero.readOnly		= true;
	document.frmCadastro.txtBairro.readOnly		= true;
	document.frmCadastro.txtCidade.readOnly		= true;
	document.frmCadastro.txtEstado.readOnly		= true;
	
}

function cep_disabled() {
	document.frmCadastro.txtEndereco.readOnly	= true;
	document.frmCadastro.txtNumero.readOnly		= true;
	document.frmCadastro.txtBairro.readOnly		= true;
	document.frmCadastro.txtCidade.readOnly		= true;
	document.frmCadastro.txtEstado.readOnly		= true;
}

function cep_erase() {
	document.frmCadastro.txtEndereco.value		= '';
	document.frmCadastro.txtNumero.value		= '';
	document.frmCadastro.txtBairro.value		= '';
	document.frmCadastro.txtCidade.value		= '';
	document.frmCadastro.txtEstado.value		= '';
}

function cep_contar() {
	if (document.frmCadastro.txtCep.value.length == 5) {
		document.frmCadastro.txtCep.value			= document.frmCadastro.txtCep.value + '-';
	} else if (document.frmCadastro.txtCep.value.length > 8) {
		document.frmCadastro.vc_status.value	= 'Aguarde! Pesquisando ...';
			
		cep_enviar();
	}
	if(window.event.keyCode == 13) {
		event.keyCode						= 0;
		event.returnValue					= false;
	}
}

function cep_enviar() {
	cep_pesquisar(document.frmCadastro.txtCep.value);
}

function cep_pesquisar(cep) {

	var tempIFrame							= document.createElement('iframe');
	
	tempIFrame.setAttribute('id','iframe_cep');
	tempIFrame.setAttribute('name','iframe_cep');

	tempIFrame.style.border					= '0px';
	tempIFrame.style.width					= '0px';
	tempIFrame.style.height					= '0px';

	tempIFrame.setAttribute('src','http://www.fw5.com.br/correios/CepAsp.asp?cep='+cep+'&url=http://www.cvlink.com.br/ajax/verificarCep.asp');
	
	//http://www.cvlink.com.br/ajax/verificarCep.asp
	IFrameObj								= document.body.appendChild(tempIFrame);
}

function cepPreencher(vc_informacoes) {
	if (vc_informacoes.length > 6) {
		var vc_informacao					= vc_informacoes.split("|");
		 
		
		cep_readonly();
		cep_enable();

		document.frmCadastro.vc_status.value		= "CEP encontrado.";
		document.frmCadastro.txtEndereco.value		= vc_informacao[0];
		document.frmCadastro.txtNumero.value		= '';
		document.frmCadastro.txtBairro.value		= vc_informacao[1];
		document.frmCadastro.txtCidade.value		= vc_informacao[2];
		document.frmCadastro.txtEstado.value		= vc_informacao[3];
		document.frmCadastro.txtNumero.focus();
		
	} else {
		cep_enable();
		
		document.frmCadastro.vc_status.value		= "CEP não encontrado!";
		document.frmCadastro.txtEndereco.focus();

	}
}