var botellasArray = new Array();
var totalBotellas = 9 ;
var paginas = 0;
var currentPage = 0;

function cargarBotellasVisibles(){
  $('.showcaseFisheyeItem').each(function( i ){
     botellasArray[i] = $(this);
  });
  $('.showcaseFisheyeItem').remove();
  $(botellasArray).each( function(i){
    if(i < totalBotellas){
      $("#visibleCards").append( this );
    }
  });
  paginas =  Math.ceil( botellasArray.length / totalBotellas  ) - 1 ;
}

function  mostrarBotellasPorPagina(  pagina ){
  var lower =  pagina * totalBotellas;
  var higher = lower + totalBotellas;
  var i = 0;
  for( i = lower ; i < higher && i <  botellasArray.length ; i++ ){
      $( botellasArray[i] ).appendTo("#visibleCards");
  }
  restartFishEye();
}

function showMoreLeft(){
   //alert(currentPage < botellasArray.length);
  if( currentPage > 0 ){
    $('.showcaseFisheyeItem').remove();
    currentPage--;
    mostrarBotellasPorPagina( currentPage   );
  }
}


function showMoreRight(){
  //alert(currentPage < botellasArray.length);
  if( currentPage < paginas ){
    $('.showcaseFisheyeItem').remove();
    currentPage++;
    mostrarBotellasPorPagina( currentPage   );
  }
}

$(document).ready(function(){
     cargarBotellasVisibles();
     $('.showcaseFisheyeItem').remove();
     $('.showcaseFisheyeItem').remove();
     currentPage = 2;
     mostrarBotellasPorPagina( currentPage   );

});


function restartFishEye(){
	showcase = new Showcase();
	showcase.initFisheye();
	showcase.finderFilterInit();
	showcase.initCardOverflowButtons();
	showcase.initCardHover();
	finderFilter = new FinderFilter();
	finderFilter.initClickMainFilters();
	finderFilter.initClickSubFilters();
	finderFilter.fixSubFilters();
	finderFilter.doSIFR();
}

