var active = 0; view domo
$('.btn').click(function() {
var $btn = $(this);
var $box = $('#area-wrap').find('.box');
$box.eq(active).slideUp(function() {
if ($btn.hasClass('next')) {
if (active == $box.length - 1) {
active = 0;
}
else {
active ++;
}
}
else {
if (active == 0) {
active = $box.length - 1;
}
else {
active --;
}
}
$box.eq(active).delay(500).slideDown();
});
});