// JavaScript Document
	$(function() {
		$("#slider-aluguel").slider({
			range: true,
			min: 1,
			max: 3000,
			step: 100,
			values: [20, 3000],
			slide: function(event, ui) {
				
								if (ui.values[1] >= 3000){
				$("#valor-aluguel").val('R$' + ui.values[0] + ' - Sem limite de valor');
				} else {
				$("#valor-aluguel").val('R$' + ui.values[0] + ' - R$' + ui.values[1]);
				}
				
									document.getElementById('txtvalormin').value= ui.values[0];
						if (ui.values[1] >= 3000){document.getElementById('txtvalormax').value = "sem limite"; } else {document.getElementById('txtvalormax').value= ui.values[1];}
							showPesquisa();
			}
		});
		$("#valor-aluguel").val('R$' + $("#slider-aluguel").slider("values", 0) + ' - R$' + $("#slider-aluguel").slider("values", 1));
	});

	$(function() {
		$("#slider-vendas").slider({
			range: true,
			min: 15000,
			max: 500000,
			step: 5000,
			values: [15000, 500000],
			slide: function(event, ui) {
				if (ui.values[1] >= 500000){
				$("#valor-vendas").val('R$' + ui.values[0] + ' - Sem limite de valor');
				} else {
				$("#valor-vendas").val('R$' + ui.values[0] + ' - R$' + ui.values[1]);
				}
						
						document.getElementById('txtvalormin').value= ui.values[0];
						if (ui.values[1] >= 500000){document.getElementById('txtvalormax').value = "sem limite"; } else {document.getElementById('txtvalormax').value= ui.values[1];}
							showPesquisa();
			}
		});
		$("#valor-vendas").val('R$' + $("#slider-vendas").slider("values", 0) + ' - R$' + $("#slider-vendas").slider("values", 1));
document.getElementById('txtvalormin').value =$("#slider-vendas").slider("values", 0); 
document.getElementById('txtvalormax').value = $("#slider-vendas").slider("values", 1);
	});

function limpacampo (campo, str) {
if (document.getElementById(campo).value == str) {
document.getElementById(campo).value = "";
}
}

function preenchecampo (campo, str) {
if (document.getElementById(campo).value == "") {
document.getElementById(campo).value = str;
}
}
function showValor(selectobj) {

	if (selectobj.selectedIndex == 0) {
			showdiv('aluguel-wrap');
			hidediv('vendas-wrap');
		
//document.getElementById('txtvalormin').value =$("#slider-aluguel").slider("values", 0); 
//document.getElementById('txtvalormax').value = $("#slider-aluguel").slider("values", 1);
	} 
	
	if (selectobj.selectedIndex == 1) {
			showdiv('vendas-wrap');
			hidediv('aluguel-wrap');
		
//document.getElementById('txtvalormin').value =$("#slider-vendas").slider("values", 0); 
//document.getElementById('txtvalormax').value =$("#slider-vendas").slider("values", 1);
	}
		
	
	showPesquisa();
}

var ids=new Array('vendas-wrap','aluguel-wrap');

function switchid(id){	
	hideallids();
	showdiv(id);
}

function hideallids(){
	//loop through the array and hide each element by id
	for (var i=0;i<ids.length;i++){
		hidediv(ids[i]);
	}		  
}

function hidediv(id) {
	//safe function to hide an element with a specified id
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'none';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'none';
		}
		else { // IE 4
			document.all.id.style.display = 'none';
		}
	}
}

function showdiv(id) {
	//safe function to show an element with a specified id
		  
	if (document.getElementById) { // DOM3 = IE5, NS6
		document.getElementById(id).style.display = 'block';
	}
	else {
		if (document.layers) { // Netscape 4
			document.id.display = 'block';
		}
		else { // IE 4
			document.all.id.style.display = 'block';
		}
	}
}

