jQuery(function($) {
	$("a.confirmar").click(function() {
		var mensaje = "¿Está seguro que desea "+$(this).attr("title");
		return (confirm(mensaje)) ? true : false;			
	});
	$("#provinciab").change(function() {
		$("#poblacionb option").remove();
		$("#poblacionb").load($("#carga_poblacion").attr("value")+"?anuncio=1&pr="+$(this).attr("value"));				
	});	
	$("#provincia").change(function() {
		$("#poblacion option").remove();
		$("#poblacion").load($("#carga_poblacion").attr("value")+"?pr="+$(this).attr("value"));				
	});	
	$("#ordenacion").change(function() {
		if ($(this).attr("value")>0) {
			$("#ord").attr("value",$(this).attr("value"));
			$("#form_search2").submit();
		}
	});	
	$("a").click(function() {
		if (this.href.indexOf(location.hostname) == -1 || $(this).attr("rel")=="external") {
			abreVentana(this.href);
			return false;
		}
	});	
});

function abreVentana(direccion) {
	if (!(window.open(direccion))) {
		alert("No se ha podido abrir la nueva ventana. Por favor, habilite la apertura de ventanas emergentes en su navegador e inténtelo nuevamente.");
	}
	return false;
}


