function get(id)
{
	return document.getElementById(id);
}

function verFoto(codigo, local)
{
	window.open('foto.php?cod='+codigo+'&local='+local, 'foto', 'directories=0,left=20,location=0,menubar=0,scrollbars=0,status=0,titlebar=0,toolbar=0,top=20');
}

function mouseHover(id)
{
	var atual = get(id).src;
	var er ='.*-hover\.jpg$';
	
	if (atual.match(er))
		get(id).src = atual.replace("-hover","");
	else
		get(id).src = atual.replace(".jpg","-hover.jpg");
}

function ativaOpc(id)
{
	var outra = id == "opc-maisInfo" ? "opc-descricao" : "opc-maisInfo";
	
	get(outra).className = 'aba-inativo';
	get(outra.replace("opc-","")).style.display = 'none';
	
	get(id).className = 'aba-ativo';
	get(id.replace("opc-","")).style.display = 'block';
}

function trocaImagem(obj)
{
	var srcTMP = get('fotoGrande').src;
	var altTMP = get('fotoGrande').alt;
	
	get('fotoGrande').src = obj.src.replace("_p","_g");
	get('fotoGrande').alt = obj.alt;
	get('fotoGrande').title = obj.title;
	
	obj.src = srcTMP.replace("_g","_p");
	obj.alt = altTMP
	obj.title = altTMP
}

function validaBusca()
{
	var msg = '';
	if (!get('tipoImovel').value)
		msg += "Um Tipo de Imóvel deve ser selecionado.\n";
		
	if (msg)
	{
		alert("Os seguintes erros foram encontrados:\n\n" + msg);
		return false;
	}
	else
		return true;
}

function limpa(obj, opc)
{
	if (obj.value == opc)
		obj.value = '';
	else if (obj.value == '')
		obj.value = opc;
}

function muda()
{
	if(get('adicionar').style.display == 'none')
	{
		get('fotos').style.display = 'none';
		get('adicionar').style.display = 'block';
		get('mudar').value = 'Fotos Cadastradas';
	}
	else
	{
		get('fotos').style.display = 'block';
		get('adicionar').style.display = 'none';
		get('mudar').value = 'Adicionar Fotos';
	}
}

