var cur = 1;
function next() {
  if (cur < 2) {
    if (cur == 1 && ($('next1').html() == null)) {
      // append default products to body
      $('body').append('<div id="next1" class="hidden">'+$("#archiveproducts").html()+'</div>');
    }
    cur++;
    $('#archiveproducts').fadeOut(300, 
    function() {
      $('#archiveproducts').html($('#next'+cur).html());
      $('#archiveproducts').fadeIn(300);  
      if (cur == 2) {
        $("#next").html('next');
      }
    });
    $("#prev").html('<a href="#" onclick="prev()">prev</a>');
  }
}
  
function prev() {
  if (cur > 1) {
    cur--;
    $('#archiveproducts').fadeOut(300, 
    function() {
      $('#archiveproducts').html($('#next'+cur).html());
      $('#archiveproducts').fadeIn(300);  
      if (cur == 1) {
        $("#prev").html('prev');
      }
    });
    $("#next").html('<a href="#" onclick="next()">next</a>');
  }
}