/********************************************/
// Name : topImage.js
// Title : topImage Loading Script
// Site : www.jillbyjillstuart.jp
// Function : 
// 1.topImageエリアのアニメーション処理およびページング効果追加
// 
// Version : 0.90
// 
// Change History :
// 2011.06.30 新規作成 T.Sato
// 
// 
/********************************************/
var tId;

function ctrTimer(){
  var tmpId = setInterval(topImagethumb_click,10000);
  return tmpId;
}

function topImagethumb_click(){
  var currentNode = $(".topVisualli:visible");
  var tmpBtn = $(".topVisualThumBtn").filter(".btn_on");
  try{
    var clickedNode = $(this);
    var btnindex = clickedNode.attr("id").substring(clickedNode.attr("id").length-1, clickedNode.attr("id").length);
    //window.alert(clickedNode.attr("id").substring(clickedNode.attr("id").length-1, clickedNode.attr("id").length));
    var nextNode = $(".topVisualli:eq("+eval(btnindex-1)+")");
    var tmpNextBtn = $(".topVisualThumBtn:eq("+eval(btnindex-1)+")");
  }catch(e){
    var nextNode = currentNode.next();
    var tmpNextBtn = tmpBtn.next();
  }
  //window.alert(clickedNode.attr("id").substring(clickedNode.attr("id").length-1, clickedNode.attr("id").length));
  if(nextNode.size() == 0){
    nextNode = $(".topVisualli:first");
  }
  currentNode.fadeOut(1000,function () {
    if(tmpNextBtn.size() == 0){
      tmpNextBtn = $(".topVisualThumBtn:first");
    }
    tmpBtn.removeClass("btn_on");
    tmpNextBtn.addClass("btn_on"); 
    nextNode.fadeIn(1000);
    clearInterval(tId);
    tId = ctrTimer();
  });
}

