
jQuery(function(){
		//
		//動いてる途中かどうか
	   var nowplaying = false;
	   //現在のサムネイル移動位置
	   var nowThumb = 0;
	   //現在のイメージ移動位置
	   var nowImg = 0;
	   var mainSize = 930;
//	   var bgSize = 940;
	   var easingTime = 500;

	    var _timer = false;
	   var interval = 5000;

		function SetBtnThumb() {
			jQuery(".switchArea ul li").each( function(i){
				jQuery(this).addClass(String(i));
				this.originalSrc = jQuery(this).find("img").attr('src');
				this.rolloverSrc = this.originalSrc.replace(/(\.gif|\.jpg|\.png)$/, "_on"+"$1");
				this.rolloverImg = new Image;
				this.rolloverImg.src = this.rolloverSrc;
			});
			jQuery('.switchArea ul li.0 img').attr('src',jQuery('.switchArea ul li.0')[0].rolloverImg.src);
			jQuery('.switchArea ul li').click(function() {
				clearTimeout(_timer);
				jQuery(".switchArea ul li").each( function(i){
						jQuery('.switchArea ul li:eq('+i+') img').attr('src',jQuery('.switchArea ul li:eq('+i+')')[0].originalSrc);
				});
				jQuery(this).find("img").attr('src',jQuery(this)[0].rolloverImg.src);
				//
				//移動
				var id = jQuery(this).attr("class");
				var px = -(mainSize*id);
				
				jQuery('#slideshow div.slideImg ul').animate({
					marginLeft: px
					}, 1000, "easeInOutExpo");
				nowImg = id;
				
				nextId =  parseInt(id)+1;
				if(nextId >= jQuery('.switchArea ul li').size() ){
					nextId = 0;
				}
				_timer = setTimeout(function(){jQuery('.switchArea ul li.'+nextId).click()}, interval);
			});
			_timer = setTimeout(function(){jQuery('.switchArea ul li.1').click()}, interval);
		}
		SetBtnThumb();
});

