var timer = null;
var offset = 5000;
var index = 0;
function slideImage(A) {
    var B = "image_" + target[A];
    $("#" + B).animate({ opacity: 1 },
1100,
function () {
    $(this).find(".word").animate({ height: "show" }, "slow")
}).show().siblings(":visible").find(".word").animate({ height: "hide" },
"fast",
function () {
    $(this).parent().animate({ opacity: 0 }, 1100).hide()
})
} function hookThumb() {
    $("#thumbs li a").bind("click", function () {
        if (timer) {
            clearTimeout(timer)
        } var A = this.id;
        index = getIndex(A.substr(11));
        rechange(index);
        slideImage(index);
        timer = window.setTimeout(auto, offset);
        this.blur();
        return false
    })
} 
function hookBtn() {
    $("#thumbs li img").filter("#play_prev,#play_next").bind("click",
  function () {
      if (timer) {
          clearTimeout(timer)
      } var A = this.id;
      if (A == "play_prev") {
          index--; if (index < 0) {
              index = 11
          }
      } else {
          index++; if (index > 11) {
              index = 0 
          }
      } rechange(index);
      slideImage(index);
      timer = window.setTimeout(auto, offset)
  })
}
 function getIndex(A) {
    for (var B = 0; B < target.length; B++) {
        if (target[B] == A) {
            return B
        }
    }
}
function rechange(A) {
    var B = "thumb_" + target[A];
    $("#thumbs li a.current").removeClass("current");
    $("#" + B).addClass("current")
} 
      function auto() {
    index++; if (index > 11) { index = 0 } rechange(index); slideImage(index); timer = window.setTimeout(auto, offset)
};
