$(document).ready(function(){
            var alturafb;
            alturafb= $("body").height()-100;
            $("#galeria").easySlider({
    				auto: true, 
    				continuous: true,
                    pause: 10000,
                    controlsShow: false,
                    nextId: "nextimg",
                    prevId: "previmg"
                });            
            /* $("#nextimg").click(function(){
                n = parseInt($("#nimg").html())+1;
                if(n > parseInt($("#ntotal").html())) n = 1;
                
                $("#nimg").html(n);
             });
             $("#previmg").click(function(){
                n = parseInt($("#nimg").html())-1;
                if(n == 0) n = parseInt($("#ntotal").html())
                $("#nimg").html(n);
             });
             */
              $(".box .boxdesple, .headesple").toggle(function(){
                    $(this).nextAll("ul").slideDown(500)
              },
                function(){
                    $(this).nextAll("ul").slideUp(500);
                }
              )
              $(".construccion").fancybox({'width' :   600});
              $(".box a.grouped_elements").fancybox({
        		'speedIn'		:	600, 
        		'speedOut'		:	200, 
        		'overlayShow'	:	true,
                'width'         :   550,
                'height'        :  600,
                'scrolling'     : 'no',
                'autoDimensions':   false,              
                'padding'       :   5,
                'type'          :   'ajax',
                'onComplete'    :   function(){
                enlace = $(this).attr("href");       
                   $("a.imgfancy").fancybox();
                   $("#reserve-now").click(function(){
                        $(".box a[href='"+enlace+"'].grouped_elements").trigger("click")
                   });
                  $('#fancybox-content').children("div").jScrollPane({showArrows : true, scrollbarWidth: 10, reinitialiseOnImageLoad : true});
                },
	       });
            //$('#fancybox-outer').append('<a id="reserve-now" href="javascript:void(0);">Volver</a>'); 
            
        // NOTICIAS BANNER IZQUIERDO
        var nnew = 0;
        var numnoti = 8
        $("#nextnew").click(function(){
            $("#ultimasnews").html("<li>Cargando...</li>");           
                $.post("ajax/side-noticias.php", {'nnew' : nnew+(numnoti*2)}, function(data){                
                    if(data == "") $("#nextnew").hide();
                    $("#ultimasnews").load("ajax/side-noticias.php", {'nnew' : nnew+numnoti}, function(data){                
                        nnew+=numnoti;
                    });
                });
            
            $("#prevnew").show();
        });
        $("#prevnew").click(function(){
            if((nnew-numnoti) >= 0){
                nnew-=numnoti;
                $("#ultimasnews").html("Cargando...");
                $("#ultimasnews").load("ajax/side-noticias.php", {'nnew' : nnew}, function(data){                
                     
                });
                if(nnew == 0) $("#prevnew").hide();
            }
            $("#nextnew").show();
        });             
});
