/*
 * El formulario se envía con un enlace (por diseño)
 */
var buscar = function(boton){
	$("div#contenido form.buscar").submit()
}


$(function(){
	/*
	 * Mostrar o ocultar la explicación de los campos del buscador
	 */
	var txtInput = "Texto libre";
	$("div#contenido form.buscar input, div#contenido form.buscar select").each(function(){
		$(this).addClass("por-defecto");
	});
	$("div#contenido form.buscar input").each(function(){
		$(this).val(txtInput);
	});
	$("div#contenido form.buscar input").focus(function(){
		$(this).removeClass("por-defecto");
		if( $(this).val()==txtInput ){
			$(this).val("");
		}
	}).blur(function(){
		if( $(this).val()=="" ){
			$(this).val(txtInput);
		}

		if( $(this).val()==txtInput ){
			$(this).addClass("por-defecto")
		}
	});
	$("div#contenido form.buscar select").focus(function(){
		$(this).removeClass("por-defecto");
	}).blur(function(){
		if( this.selectedIndex==0 ){
			$(this).addClass("por-defecto")
		}
	});

	// Borramos el texto de relleno al enviar el formulario
	$("div#contenido form.buscar").submit(function(){
		$(this).find("input").each(function(){
			if( $(this).val()==txtInput ){
				$(this).val("");
			}
		});
	});
});

