// JavaScript Document

function imprimirFicha(ficha, html)
{

	window.open("index.php?pag=ficha_imprimir&id="+ficha,"imprimirf","width=600, height=500, scrollbars=YES");
	
}

function ActivarTextoBuscador()
{
	
	document.getElementById("buscador_mini_texto").style.display = 'block';	
	document.getElementById("buscador_mini_imagen").style.display = 'none';	
}
function DesactivaTextoBuscador()
{
	
	document.getElementById("buscador_mini_texto").style.display = 'none';	
	document.getElementById("buscador_mini_imagen").style.display = 'block';	
}


function BuscadorMini(html)
{
	
	// Mostrar: cuadro de texto
	var pTitulo = document.getElementById('titulo');
	var pISBN   = document.getElementById('isbn');
	var texto	= document.getElementById('txt_buscador_mini').value;
	
	var Titulo	= "";
	var ISBN	= "";
	
	var BT		= "NO";
	
	if (pISBN.checked==true) ISBN = texto; else Titulo = texto;
	if (pISBN.checked!=true&&pTitulo.checked!=true) BT = "SI";

	var x=document.body.clientWidth;
	var y=document.body.clientHeight;
	
	var anchoForm = 925;
	var altoForm = 550;
	
	document.getElementById("Buscador").style.width=anchoForm+"px"; 
	document.getElementById("Buscador").style.height=altoForm+"px"; 

	
	var xini = (x/2)-(anchoForm/2);
	var yini = (y/2)-(altoForm/2);
	
	document.getElementById("Buscador").style.left=xini+"px";
	document.getElementById("Buscador").style.top=yini+"px";

	// Recuperar Datos:
	
	fbuscar(Titulo,ISBN,"","","","","","","",BT);

	document.getElementById("Buscador").style.display = 'block';
	
}

function mostrarFormalizar()
{

	document.getElementById("DivFormalizar").style.display = 'block';
	
}


function mostrar(esto, html)
{
	
	if (html=="html_ga") html="html_gal";
	
	var anchoForm=460; 
	var altoForm=470;

	var x=document.body.clientWidth;
	var y=document.body.clientHeight;

	document.getElementById("Buscador").style.width=anchoForm+"px";
	document.getElementById("Buscador").style.height=altoForm+"px";	

	var xini = (x/2)-(anchoForm/2);
	var yini = (y/2)-(altoForm/2);
	
	document.getElementById("Buscador").style.left=xini+"px";
	document.getElementById("Buscador").style.top=yini+"px";

	var txt = getDataServer("/"+html+"/formulario_buscador.html");
	document.getElementById('Buscador').innerHTML = txt;


	document.getElementById(esto).style.display = 'block';
	
}

function ocultar(esto)
{
	document.getElementById(esto).style.display = 'none';
}
function ver(esto)
{
	document.getElementById(esto).style.display = 'block';
}


/*
 *	 EVENTOS DE LA AGENDA
 *
*/

function VerEvento(id)
{
	/*ver(esto);
	document.getElementById(esto2).innerHTML="ocultar";
	document.getElementById(esto2).href="javascript:OcultarEvento('"+esto+"', '"+esto2+"');";*/


	
	var txt = getDataServer("/ds/eventos_ver.php?id="+id);

	document.getElementById('eventoampliado').innerHTML=txt;	
	
	
}



/*function OcultarEvento(esto, esto2)
{
	ocultar(esto);
	document.getElementById(esto2).innerHTML="ver";
	document.getElementById(esto2).href="javascript:VerEvento('"+esto+"', '"+esto2+"');";
}*/

/* ---- */


function ocultarBuscador()
{
	var anchoForm=460; 
	var altoForm=400;

	var x=document.body.clientWidth;
	var y=document.body.clientHeight;
	
	var xini = (x/2)-(anchoForm/2);
	var yini = (y/2)-(altoForm/2);
	
	document.getElementById("Buscador").style.left=xini+"px";
	document.getElementById("Buscador").style.top=yini+"px";

	document.getElementById('Buscador').style.display = 'none';

}



function datos()
{
	
	var x=document.body.clientWidth;
	var y=document.body.clientHeight;
	
	var anchoForm = 925;
	var altoForm = 550;
	
	document.getElementById("Buscador").style.width=anchoForm+"px"; 
	document.getElementById("Buscador").style.height=altoForm+"px"; 

	
	var xini = (x/2)-(anchoForm/2);
	var yini = (y/2)-(altoForm/2);
	
	document.getElementById("Buscador").style.left=xini+"px";
	document.getElementById("Buscador").style.top=yini+"px";


	// Recuperar Datos:
	
	var Titulo = document.getElementById("ftitulo").value;
	var ISBN = document.getElementById("fisbn").value;
	var Autor = document.getElementById("fautor").value;
	var Idioma = document.getElementById("fidioma").value;
	var Texto = document.getElementById("ftexto").value;
	var Keyword = document.getElementById("keyword").value;
	var MasVendidos="";
	var Recomendado="";
	var Disponible="";
	var Novedad="";

	if (document.getElementById("fmasvendidos").checked==true) MasVendidos="si";
	if (document.getElementById("frecomendado").checked==true) Recomendado="si";
	if (document.getElementById("fdisponibilidad").checked==true) Disponible="si";
	if (document.getElementById("fnovedad").checked==true) Novedad="si";
	
	fbuscar(Titulo,ISBN,Autor,Idioma,Texto,Keyword,MasVendidos,Recomendado,Disponible,Novedad,"");

	/*document.getElementById('Buscador').innerHTML = "<br/>Datos de b&uacute;squeda<br/><br/>";
	document.getElementById('Buscador').innerHTML += "<br/>Titulo: "+Titulo;	
	document.getElementById('Buscador').innerHTML += "<br/>Autor: "+Autor;	
	document.getElementById('Buscador').innerHTML += "<br/>Idioma: "+Idioma;		
	document.getElementById('Buscador').innerHTML += "<br/>Texto: "+Texto;		
	document.getElementById('Buscador').innerHTML += "<br/>MasVendidos: "+MasVendidos;		
	document.getElementById('Buscador').innerHTML += "<br/>Recomendado: "+Recomendado;
	document.getElementById('Buscador').innerHTML += "<br/>Disponible: "+Disponible;
	document.getElementById('Buscador').innerHTML += "<br/>Novedad: "+Novedad;*/
}



function getDataServer(url){
     var xml = null;
     try{
         xml = new ActiveXObject("Microsoft.XMLHTTP");
     }catch(expeption){
         xml = new XMLHttpRequest();
     }
     xml.open("GET",url, false);
     xml.send(null);
     if(xml.status == 404) alert("Url no valida");
     return xml.responseText;
}



function fbuscar(Titulo,ISBN,Autor,Idioma,Texto,Keyword,MasVendidos,Recomendado,Disponible,Novedad,BT)
{
	if(BT=="SI") {
			
			var txt = getDataServer("/php/fbuscador.php?bt=si&txt="+Titulo);
		
	}
	
	else {
		
		var txt = getDataServer("/php/fbuscador.php?titulo="+Titulo+"&isbn="+ISBN+"&autor="+Autor
								+"&idioma="+Idioma+"&texto="+Texto+"&keyword="+Keyword+"&masvendidos="+MasVendidos
								+"&recomendados="+Recomendado+"&disponible="+Disponible
								+"&novedad="+Novedad);
		
	}

	document.getElementById('Buscador').innerHTML = txt;

}


function BorraInfoCatalogo()
{
	document.getElementById('infoCuadrosCat').innerHTML = "";	
}
function MuestraInfoCatalogo(txt)
{
	
	document.getElementById('infoCuadrosCat').innerHTML = txt;	
}



