$(function () {
	$('input:radio[name=tipo]').change(function() {
		if($('input:radio[name=tipo]:checked').val() == 1){
			$(".busca_categoria_2").hide();
			$(".busca_categoria_1").show();
		} else {
			$(".busca_categoria_1").hide();
			$(".busca_categoria_2").show();
		}
	});
});

//Função que valida o formulário de busca
function validaForm(frm){
var str = "";

if(frm.ref.value !="Referencia..." && frm.ref.value !=""){
	return true;
} else {

	if(frm.categoria_1.value =="" && frm.categoria_2.value ==""){
		str += "Informe o tipo!\n";
	}
	
	if(frm.valor_minimo.value =="" && frm.valor_maximo.value ==""){
		str += "Informe o valor mínimo ou máximo!\n";
	}
	
	if(frm.categoria_1.value =="" && frm.categoria_2.value =="" && frm.categoria_1.value != "4" && frm.categoria_1.value != "5" && frm.categoria_2.value != "4" && frm.categoria_2.value != "5"){
		if(frm.dormitorios.value ==""){
			str += "Informe o número de dormitórios!";
		}
	}

	if(frm.categoria_1.value == "1" || frm.categoria_2.value == "1" || frm.categoria_1.value == "2" || frm.categoria_2.value == "2" || frm.categoria_1.value == "3" || frm.categoria_2.value == "3" || frm.categoria_1.value == "23" || frm.categoria_2.value == "23"){
		if(frm.dormitorios.value ==""){
			str += "Informe o número de dormitórios!";
		}
	}
}

if(str == ""){
	return true;
} else {
	alert(str);
	return false;	
}

}
