	var form = "";
	var submitted = false;
	var error = false;
	var error_message = "";

	function check_form(form_name) {
	  var crit = "";
	  if (submitted == true) {
		//alert("Este formulario ha sido enviado. Precione Ok y espere a que termine el proceso.");
		return false;
	  }
	
	  error = false;
	  form = form_name;
	  if (form.t_query.value == 'QN') {
	  	error_message = "Debe completar algunos de los campos para búsquedas\n";
		crit = form.autor.value + form.titulo.value + form.descripcion.value;
		if (crit == '') {
			error = true;
		}
	  }
	  
	
	  if (error == true) {
		alert(error_message);
		return false;
	  } else {
		submitted = true;
		return true;
	  }
	}

	function avqueries() {
		var tabla = '';
		tabla = '<table width="100%" border="0" cellpadding="0" cellspacing="0">';
        tabla = tabla + '<!--DWLayoutTable--><tr>';
        tabla = tabla + '<td width="63" height="19" valign="middle">Título:</td>';
        tabla = tabla + '<td width="129" valign="top"><input name="li_titulo" type="text" id="li_titulo" size="22"></td>';
        tabla = tabla + '</tr><tr>';
        tabla = tabla + '<td height="22">Autor:</td>';
        tabla = tabla + '<td><input name="li_autor" type="text" id="li_autor" size="22"></td>';
        tabla = tabla + '</tr>';
        tabla = tabla + '<tr><td height="22">Descripción:</td>';
        tabla = tabla + '<td><input name="li_descripcion" type="text" id="txtofind324" size="22"></td>';
        tabla = tabla + '</tr>';
        tabla = tabla + '<tr><td height="22">Librer&iacute;a:</td><td>';
		tabla = tabla + '<input name="lbr_libreria" type="text" id="txtofind325" size="22"></td>';
        tabla = tabla + '</tr></table>';			
		//document.getElementById('query').innerHTML = '<input name="li_autor" type="text" id="txtofind4" size="32" value="Autor" onFocus="check_in_aut();" onBlur="check_out_aut();"><br><input name="li_titulo" type="text" id="txtofind4" size="32" value="Título"><br><input name="lbr_libreria" type="text" id="txtofind4" size="32" value="Librería">';
		document.getElementById('query').innerHTML = tabla;
		document.getElementById('txquery').innerHTML = '<input name="t_query" type="hidden" id="t_query" value="QA"><a href="#" class="OrderEdit" onclick="norqueries();">B&uacute;squeda simple</a>';

		//document.getElementById('query').innerHTML += '<input name="lbr_libreria" type="text" id="txtofind4" size="32" value="Librería">';
	}
	function norqueries() {
		document.getElementById('query').innerHTML = '<input name="txtofind" type="text" id="txtofind4" size="32">';
		document.getElementById('txquery').innerHTML = '<input name="t_query" type="hidden" id="t_query" value="QN"><a href="#" class="OrderEdit" onclick="avqueries();">B&uacute;squeda Avanzada</a>';
	}
	
	function ch_in_result() {
		if (document.fastquery.in_result.checked == true) {
			document.fastquery.in_result.checked = false;
		} else {
			document.fastquery.in_result.checked = true;
		}
	}
	function fichalibreria(lbr_cod) {
	  window.open("/pop_fichalibreria.php?lbr_cod="+lbr_cod,"Libreria","height=480,width=528,toolbar=no,statusbar=no,scrollbars=yes").focus();
	}
	function condicioneslibreria(lbr_cod) {
	  window.open("/pop_condicioneslibreria.php?lbr_cod="+lbr_cod,"Libreria","height=480,width=528,toolbar=no,statusbar=no,scrollbars=yes").focus();
	}
	
	function send_ordenar() {
		document.orderquery.submit();
	}
	
	function emptyform() {
		document.fastquery.titulo.value = "";
		document.fastquery.autor.value = "";
		document.fastquery.descripcion.value = "";
	}
	
	$(document).ready(function(){
		
		var var_autor = $("#tx_autor").val();
		var var_titulo = $("#tx_titulo").val();
		var total_registros = $("#cnt_result").val();
		if (total_registros < 7) {
			$.get("ajax/inget_fn.php", { accion: "find_sound_autores", tx_autor: var_autor }, function(data) {
				//Aqui los resultados
				if (data != 0) {
					$("#autores_parecidos").html(data);
					$("#tr_sug_autores").fadeIn("slow");
				}
			});

			$.get("ajax/inget_fn.php", { accion: "find_sound_titulos", tx_titulo: var_titulo }, function(data) {
				//Aqui los resultados
				if (data  != 0) {
					$("#libros_parecidos").html(data);
					$("#tr_sug_libros").fadeIn("slow");
				}
			});
			
		}
		
	});
