num=1;

function MudarBanner(banner) {
	document.getElementById('banner_0').className = 'banner-exibir-inativo';
	document.getElementById('banner_1').className = 'banner-exibir-inativo';
	document.getElementById('banner_2').className = 'banner-exibir-inativo';
	document.getElementById('banner_3').className = 'banner-exibir-inativo';
	document.getElementById('banner_'+banner+'').className = 'banner-exibir-ativo';
	document.getElementById('banner-exibir').innerHTML = ar[banner];
	num++;
}

function atualiza(){
	MudarBanner(num);
	if (num == ar.length){
		num = 0;
	}
}

setInterval("atualiza()","6500");

function numerico(campo) {
	var string = campo.value;
	var string = string.replace(/([a-z])/g, '');
	campo.value = string;
}

function mostrar(id) {
	document.getElementById(id).style.display ='';
}
function ocultar(id) {
	document.getElementById(id).style.display ='none';
}

function abrirAnuncio() {
		
	largura = screen.width*0.7;
	altura = screen.height*0.6;
	
	windowTop = screen.height/2 - altura/2;
	windowLeft = screen.width/2 - largura/2;
	
	window.open('anuncio.html','popup','width='+largura+',height='+altura+',scrolling=yes,resizable=yes,scrollbars=yes,top='+windowTop+',left='+windowLeft+''); 

}

function AlterarTipo(finalidade) {
	if(finalidade == '2') {
		document.getElementById('tipo').disabled = false;
		document.getElementById('bairro').disabled = false;
		var total = document.getElementById('tipo').options.length; for (var i = 0; i <= total; i++) { document.getElementById('tipo').options[0] = null; }
		document.getElementById('tipo').options[document.getElementById('tipo').options.length] = new Option (' ', '', true, true);
		document.getElementById('tipo').options[document.getElementById('tipo').options.length] = new Option ('Apartamento', '1', true, false);
		document.getElementById('tipo').options[document.getElementById('tipo').options.length] = new Option ('Casa', '3', true, false);
		document.getElementById('tipo').options[document.getElementById('tipo').options.length] = new Option ('Comercial', '2', true, false);
		document.getElementById('tipo').options[document.getElementById('tipo').options.length] = new Option ('Terreno', '4', true, false);
		document.getElementById('tipo').options[document.getElementById('tipo').options.length] = new Option ('Alto Padrão', '6', true, false);
		document.getElementById('tipo').options[document.getElementById('tipo').options.length] = new Option ('Outros', '5', true, false);
	}
	
	if(finalidade == '1') {
		document.getElementById('tipo').disabled = false;
		document.getElementById('bairro').disabled = false;
		var total = document.getElementById('tipo').options.length; for (var i = 0; i <= total; i++) { document.getElementById('tipo').options[0] = null; }
		document.getElementById('tipo').options[document.getElementById('tipo').options.length] = new Option (' ', '', true, true);
		document.getElementById('tipo').options[document.getElementById('tipo').options.length] = new Option ('Apartamento', '1', true, false);
		document.getElementById('tipo').options[document.getElementById('tipo').options.length] = new Option ('Casa', '3', true, false);
		document.getElementById('tipo').options[document.getElementById('tipo').options.length] = new Option ('Comercial', '2', true, false);
		document.getElementById('tipo').options[document.getElementById('tipo').options.length] = new Option ('Alto Padrão', '6', true, false);
		document.getElementById('tipo').options[document.getElementById('tipo').options.length] = new Option ('Outros', '5', true, false);
	}
	
	if(finalidade != '1' && finalidade != '2') {
		document.getElementById('tipo').disabled = true;
		document.getElementById('bairro').disabled = true;
	}
	
}

function Verificar() {
	if(document.getElementById('finalidade').value == '' || document.getElementById('tipo').value == '') { 
		alert('Você deve escolher a finalidade e o tipo do imóvel.');
		return false; 
	}
}

function closeObj(id, method)
{
	obj = document.getElementById(id);

	if(method == 'display')
		obj.style.display = 'none';
	else
		obj.style.visibility = 'hidden';

}

function openObj(id, method)
{
	obj = document.getElementById(id);

	if(method == 'display')
		obj.style.display = 'block';
	else
		obj.style.visibility = 'visible';

}

function ExibirFotoImovel(foto) {
	if(foto == '') {
		document.getElementById('foto-maior').style.display='none';
		document.getElementById('mapa_google').style.display='block';
		document.getElementById('titulo-detalhes').innerHTML = 'Localização do Imóvel';
	}else{
		document.getElementById('foto-maior').innerHTML='<img src="http://www.pecini.com.br/imoveis/'+foto+'" width="320" height="240" />';
		document.getElementById('foto-maior').style.display='block';
		document.getElementById('mapa_google').style.display='none';
		document.getElementById('titulo-detalhes').innerHTML = 'Foto Ampliada';
	}
}

function Empreendimentos(theURL,winName,features) {
  window.open(theURL,winName,features);
}
