var mes;
var anio;
var mes_a; //mes anterior
var mes_s; //mes siguiente
var anio_a; //anio anterior
var anio_s; //anio siguiente

function calculaLinks(){
 switch(mes){ //Calculamos el movimiento entre meses y anios
  case 1: 
					mes_s  = 2													
				  mes_a  = 12													
					anio_s = anio						  					
					anio_a = anio - 1										
					break;
	case 12:
					mes_s  = 1													
				  mes_a  = 11													
					anio_s = anio + 1						  			
					anio_a = anio												
					break;
	default:
					mes_s = mes+1												
				  mes_a = mes-1												
					anio_s = anio_a = anio							
 }	
}

$(document).ready(function() {
		$('#eventos2').hide().load('lista_eventos.php?anio='+anio+'&mes='+mes+'&lang='+idioma+'&'+Math.random(),function() {
			$(this).fadeIn();			
		});							   
		$('#fecha').hide().load('fechatit.php?anio='+anio+'&mes='+mes+'&lang='+idioma+'&r='+Math.random(),function() {
			$(this).fadeIn();			
		});
		$('#eventos').hide().load('calendario.php?anio='+anio+'&mes='+mes+'&lang='+idioma+'&'+Math.random(),function() {
			$(this).fadeIn();			
		});	
});

$(document).ready(function() {
		$('#anterior a').click(function() {	
				calculaLinks();														
				anio = anio_a;
				mes = mes_a;
				$('#eventos2').hide().load('lista_eventos.php?anio='+anio+'&mes='+mes+'&lang='+idioma+'&'+Math.random(),function() {
					$(this).fadeIn();			
				});					
				$('#fecha').hide().load('fechatit.php?anio='+anio+'&mes='+mes+'&lang='+idioma+'&r='+Math.random(),function() {
					$(this).fadeIn();			
				});
				$('#eventos').hide().load('calendario.php?anio='+anio+'&mes='+mes+'&lang='+idioma+'&'+Math.random(),function() {
					$(this).fadeIn();					
			  	});
		});
  });

$(document).ready(function() {
		$('#siguiente a').click(function() {										
				calculaLinks();																		 
					anio = anio_s;
					mes = mes_s;					
					$('#eventos2').hide().load('lista_eventos.php?anio='+anio+'&mes='+mes+'&lang='+idioma+'&'+Math.random(),function() {
						$(this).fadeIn();			
					});						
					$('#fecha').hide().load('fechatit.php?anio='+anio+'&mes='+mes+'&lang='+idioma+'&r='+Math.random(),function() {
						$(this).fadeIn();			
					});	
					$('#eventos').hide().load('calendario.php?anio='+anio+'&mes='+mes+'&lang='+idioma+'&'+Math.random(),function() {
						$(this).fadeIn();
				  	});														
		});
  });

$(document).ready(function() {
		$('#eventos a').click(function() {												
					$('#eventos').hide().load('calendario.php?anio='+(anio+1)+'&mes='+mes+'&lang='+idioma+'&'+Math.random(),function() {
						$(this).fadeIn();
		  	});														
		});
  });