function getEndereco() {

	if( document.getElementById( "cep" ).value.length == 8 ){
		
		document.getElementById( "cepLoader" ).style.display = "inline";
	 
		$.getScript("http://cep.republicavirtual.com.br/web_cep.php?formato=javascript&cep="+$("#cep").val(), function(){
			if(resultadoCEP["resultado"] != 0 ){
				
				var msg = "";
				msg = "O seguinte endereço foi encontrado para o CEP informado:\n\n";
				msg += " - Logradouro: " + unescape(resultadoCEP["tipo_logradouro"]) + " " + unescape(resultadoCEP["logradouro"]) + "\n";
				msg += " - Bairro: " + unescape(resultadoCEP["bairro"]) + "\n";
				msg += " - Cidade/Estado: " + unescape(resultadoCEP["cidade"]) + " - " + unescape(resultadoCEP["uf"]) + "\n\n";
				msg += "Deseja utilizá-lo? (clique em Cancelar para preencher manualmente)";
				
				if( confirm( msg ) ){
				
					$("#endereco").val(unescape(resultadoCEP["tipo_logradouro"]) + " " + unescape(resultadoCEP["logradouro"]));
					$("#bairro").val(unescape(resultadoCEP["bairro"]));
					$("#cidade").val(unescape(resultadoCEP["cidade"]));
					$("#estado").val(unescape(resultadoCEP["uf"]));
					$("#pais").val("Brasil");
					document.getElementById( "cepLoader" ).style.display = "none";
					document.getElementById( "numero" ).focus();
					
				} else{
					
					limpaEndereco( false );
					habilitaEndereco( false );
					document.getElementById( "cepLoader" ).style.display = "none";
					document.getElementById( "endereco" ).focus();
					
				}
				
			} else{
				
				document.getElementById( "cepLoader" ).style.display = "none";
				alert( "Endereço não encontrado. Por favor, preencha manualmente." );
				limpaEndereco( false );
				habilitaEndereco( false );
				
			}
		});
		
	}			
}

function insSwf(Caminho, Largura, Altura) {
	var obj='<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,0,0" width="'+Largura+'" height="'+Altura+'">';
	obj+='<param name="movie" value="'+Caminho+'" />';
	obj+='<param name="quality" value="high" />';
	obj+='<param name="menu" value="false" />';
	obj+='<param name="wmode" value="transparent" />';
	obj+='<embed src="'+Caminho+'" quality="high" wmode="transparent" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" menu="false" width="'+Largura+'" height="'+Altura+'"></embed></object>';
	return obj;
}

function insereSwf( arquivo, largura, altura ) {
	document.write( insSwf( arquivo, largura, altura ) );
}

function abreCategoria( cat ){
			
	var m;
	
	m = document.getElementById( "menuCAT" + cat );
	m.style.display = ( m.style.display == "none" ? "block" : "none" );

	m = null;

}
			
function abreSubcategoria( cat, subcat ){

	var m;
	
	m = document.getElementById( "menuCAT" + cat + "SUB" + subcat );
	m.style.display = ( m.style.display == "none" ? "block" : "none" );

	m = null;

}	

function aumentaFonte(){	
		var o = document.getElementById( "subtxt" );
		var t = o.style.fontSize.replace( "px", "" ) ;
		
		if( t < 18 ){ // limite máximo: 18px
			t++;
			o.style.fontSize = t + "px";
		}
		
		o = null;
		t = null;
	}
	
	function diminuiFonte(){
		var o = document.getElementById( "subtxt" );
		var t = o.style.fontSize.replace( "px", "" );
		
		if( t > 9 ){ // limite mínimo: 9px
			t--;
			o.style.fontSize = t + "px";
		}
		
		o = null;
		t = null;
	}
function AbreForm(vfnURL, vfnLargura, vfnAltura){
	var vT;
	var vL;
	var vNome;
	var vVetor;
	vT = (window.screen.height/2) - (vfnAltura/2);
	vT = (vT-40);
	vL = (window.screen.width/2) - (vfnLargura/2);	
	window.open(vfnURL, '_blank', 'width='+ vfnLargura +'px, height='+ vfnAltura +'px, left='+ vL +'px, top='+vT+'px' );
}


