function buttonStateHandler(button, enabled) {
 if (button == "book_random_prev") 
 	 //enable ~ disable
   $('book_random_prev').src = enabled ? "images/previous.gif" : "images/first.gif"
 else 
   $('book_random_next').src = enabled ? "images/next.gif" : "images/last.gif"
}

function animHandler(carouselID, status, direction) {
  var region = $(carouselID).down(".carousel-clip-region")
  if (status == "before") {
    Effect.Fade(region, {to: 0.3, queue: { position:'end', scope: "carousel" }, duration: 0.2})
  }
  if (status == "after") {
    Effect.Fade(region, {to: 1, queue: { position:'end', scope: "carousel" }, duration: 0.2})
  }
}

// Show/hide "loading" overlay before and after ajax request
function ajaxHandler(carousel, status) {
  var overlay = $('overlay');
  if (status == "before") {
    if (overlay) {
      overlay.setOpacity(0);
      overlay.show();
      Effect.Fade(overlay, {from: 0, to: 0.5, duration: 0.2})
    }
    else
      new Insertion.Top("ajax-carousel", "<div class='carousel-overlay' id='overlay' ><div>Loading...讀取中</div></div>");
  }
  else 
    Effect.Fade(overlay, {from: 0.5, to: 0.0, duration: 0.2})
}