function repintar_resenias(){
	
				xmlhttp=GetXmlHttpObject();
				if (xmlhttp==null)
				  {
				  alert ("Browser does not support HTTP Request");
				  return;
				  }
				  
				  var indice = document.form_resenia.selector_resenia.selectedIndex;
		
				patron_busqueda = document.form_resenia.selector_resenia.options[indice].value ;
				  
				var url="ajax_resenia.php";
				
				url=url+"?valor="+patron_busqueda;
				
				url=url+"&sid="+Math.random();
			
				xmlhttp.onreadystatechange=stateChanged88;
				xmlhttp.open("GET",url,true);
				xmlhttp.send(null);	
}

function agregar(valor){
				xmlhttp=GetXmlHttpObject();
				if (xmlhttp==null)
				  {
				  alert ("Browser does not support HTTP Request");
				  return;
				  }
				  
				var url="ajax_nuevolibro.php";
				
				url=url+"?valor="+valor;
				
				url=url+"&sid="+Math.random();
			
				xmlhttp.onreadystatechange=stateChanged99;
				xmlhttp.open("GET",url,true);
				xmlhttp.send(null);
}


function actualizar_eventos(fecha){
	
		
				xmlhttp=GetXmlHttpObject();
				if (xmlhttp==null)
				  {
				  alert ("Browser does not support HTTP Request");
				  return;
				  }
				  
				var url="ajax_eventos.php";
				
				url=url+"?fecha="+fecha;
				
				url=url+"&sid="+Math.random();
			
				xmlhttp.onreadystatechange=stateChanged3;
				xmlhttp.open("GET",url,true);
				xmlhttp.send(null);


}

function buscar_texto(tipo, valor){
		var patron_busqueda="";

	if(tipo==1){
		patron_busqueda = document.getElementById('patron_busqueda_texto').value;
	}
	
	if(tipo==2){
		patron_busqueda = valor;
	}
	
	if(tipo==3){
		patron_busqueda = valor;
	}
	
	if(tipo==4){
		var indice = document.fomul.id_autor.selectedIndex;
		
		patron_busqueda = document.fomul.id_autor.options[indice].text ;
	}
	
	if(tipo==5){
		patron_busqueda = document.getElementById('patron_busqueda_texto').value;
		url = "catalogo.php?&patron_busqueda="+patron_busqueda;
		location.href='./'+url;
	}
		
		
				xmlhttp=GetXmlHttpObject();
				if (xmlhttp==null)
				  {
				  alert ("Browser does not support HTTP Request");
				  return;
				  }
				  
				var url="ajax_busqueda.php";
				
				url=url+"?tipo="+tipo;
				url=url+"&patron="+patron_busqueda;
				
				url=url+"&sid="+Math.random();
				
				xmlhttp.onreadystatechange=stateChanged;
				

				
				xmlhttp.open("GET",url,true);
				xmlhttp.send(null);
	
		
	}
	
function actualiza_calendario(){
	
		var indice = document.formu_calenda.fecha_calendario.selectedIndex;
		
		patron_busqueda = document.formu_calenda.fecha_calendario.options[indice].value ;
	
		
				xmlhttp=GetXmlHttpObject();
				if (xmlhttp==null)
				  {
				  alert ("Browser does not support HTTP Request");
				  return;
				  }
				  
				var url="ajax_calendario.php";
				
				url=url+"?patron="+patron_busqueda;
				
				url=url+"&sid="+Math.random();
			
				xmlhttp.onreadystatechange=stateChanged2;
				xmlhttp.open("GET",url,true);
				xmlhttp.send(null);
	
		
	}
	

function stateChanged88()
{
	if(xmlhttp.readyState==1){
                        //modificamos el estilo de la div, mostrando una imagen de fondo
						document.getElementById('contenedor_resenias').innerHTML="<p>&nbsp;</p><p>&nbsp;</p>";
                        document.getElementById('contenedor_resenias').style.background = "url('img/103.gif') no-repeat"; 

	} else if (xmlhttp.readyState==4)
		{
			document.getElementById('contenedor_resenias').style.background="";	
			document.getElementById('contenedor_resenias').innerHTML=xmlhttp.responseText;
		}
}

function stateChanged()
{
	if(xmlhttp.readyState==1){
                        //modificamos el estilo de la div, mostrando una imagen de fondo
						document.getElementById('gran_contenedor').innerHTML="<p>&nbsp;</p>";
                        document.getElementById('gran_contenedor').style.background = "url('img/103.gif') no-repeat"; 

	} else if (xmlhttp.readyState==4)
		{
			document.getElementById('gran_contenedor').style.background="";	
			document.getElementById('gran_contenedor').innerHTML=xmlhttp.responseText;
		}
}

function stateChanged2()
{
if(xmlhttp.readyState==1){
                        //modificamos el estilo de la div, mostrando una imagen de fondo
						document.getElementById('calendario_pintado').innerHTML="<p>&nbsp;</p>";
                        document.getElementById('calendario_pintado').style.background = "url('img/103.gif') no-repeat"; 

	} else if (xmlhttp.readyState==4)
		{
			document.getElementById('calendario_pintado').style.background="";	
			document.getElementById('calendario_pintado').innerHTML=xmlhttp.responseText;
		}
		

}

function stateChanged3()
{
if(xmlhttp.readyState==1){
                        //modificamos el estilo de la div, mostrando una imagen de fondo
						document.getElementById('contenido_agenda').innerHTML="<p>&nbsp;</p>";
                        document.getElementById('contenido_agenda').style.background = "url('img/103.gif') no-repeat"; 

	} else if (xmlhttp.readyState==4)
		{
			document.getElementById('contenido_agenda').style.background="";	
			document.getElementById('contenido_agenda').innerHTML=xmlhttp.responseText;
			myLightbox.updateImageList();
			initLightbox();
		}
		

}

function stateChanged99()
{
	 if (xmlhttp.readyState==4)
		{
			
			location.href='http://www.edicionesatlantis.com/comprar.php';
		}	

}
	
function GetXmlHttpObject()
{
if (window.XMLHttpRequest)
  {
  // code for IE7+, Firefox, Chrome, Opera, Safari
  return new XMLHttpRequest();
  }
if (window.ActiveXObject)
  {
  // code for IE6, IE5
  return new ActiveXObject("Microsoft.XMLHTTP");
  }
return null;
}

function ver(mostrar,cantidad){
	i=1;
	
	while(i<=cantidad){
		valor = 'contenedor_' + i;
		vinculo = "vinculo_" + i;
		document.getElementById(valor).style.display = 'none';
		document.getElementById(vinculo).className = '';
		i = i+1;
	}
	document.getElementById(mostrar).style.display = 'block';
	numero = mostrar.split('_');
	vinculo = "vinculo_" + numero[1];
	document.getElementById(vinculo).className = 'paginado_active';
	window.scrollTo(0,0);
}



 $(document).ready(function(){
							
   $("#enviar").click(function(event){
		mensaje = "";
		if($("#nombre").val()==""){
			$("#nombre").css({ background: "#F5A783" });
			mensaje = "Necesitamos que rellene su nombre";
		}
		if($("#telefono").val()==""){
			$("#telefono").css({ background: "#F5A783" });
			if(mensaje!=""){
				mensaje = mensaje + " y su telefono para poder ponernos en contacto con usted.";
			}else{
				mensaje = "Necesitamos que rellene su telefono para poder ponernos en contacto con usted";
			}
		}
		
		if(mensaje!=""){
			jAlert(mensaje);
		}else{
			$("#formulario").submit();
		}
   });
 });

