// JavaScript Document
  $(document).ready(function(){			
	theRotator();							 
	//Menu desplegable
	$("#menu ul li ul").hide();	
	$("#menu ul li span.current").addClass("open").next("ul").show();
	$("#menu ul li span").click(function(){	
		$(this).next("ul").slideToggle("slow").parent("li").siblings("li").find("ul:visible").slideUp("slow");
		$("#menu ul li").find("span").removeClass("open");
		$(this).addClass("open");
	});
	
	
	$("a.switch_thumb").toggle(function(){
	  $(this).addClass("swap"); 
	  $("ul.display").fadeOut("fast", function() {
	  	$(this).fadeIn("fast").addClass("thumb_view"); 
		 });
	  }, function () {
      $(this).removeClass("swap");
	  $("ul.display").fadeOut("fast", function() {
	  	$(this).fadeIn("fast").removeClass("thumb_view");
		});
	}); 

$('.loading').show();
        pagina(5,'Fecha',1);

}); 	
 
 
function theRotator() {
	$('div#rotatorder ul li').css({opacity: 0.0});
	$('div#rotatorder ul li:first').css({opacity: 1.0});
	setInterval('rotate()',10000);
}
function rotate() {	
	var current = ($('div#rotatorder ul li.show')?  $('div#rotatorder ul li.show') : $('div#rotatorer ul li:first'));
	var next = ((current.next().length) ? ((current.next().hasClass('show')) ? $('div#rotatorder ul li:first') :current.next()) : $('div#rotatorder ul li:first'));	
	next.css({opacity: 0.0})
	.addClass('show')
	.animate({opacity: 1.0}, 1000);
	current.animate({opacity: 0.0}, 1000)
	.removeClass('show');
};
	
     function pagina(cat,ord1,page_id){
        var first = (page_id*10)+1, second = (page_id*10)+10;
		$('#resj').hide();
		$('.loading').show();
        $.ajax({
        type:'GET',
        url:'pagina.php',
        data:'q2=5&ord2='+ord1+'&pag='+page_id,
        success:function(msg) {
		$('.loading').hide();
		$('#resj').fadeIn('slow');		
			$('#resj').html(msg);
        }
        });
    }
	
$(function() {
	$(".pag").click(function() {
	var name = this.text;
	pagina(5,name,1);
							 })
return false;
	}); 
