
function ct(checkData){
	if (typeof(checkData) == "number") alert('type is num');
	if (typeof(checkData) == "string") alert('type is str');
	if (typeof(checkData) == "function") alert('type is func');
}


jQuery(function(){
	if($('#scrollable').length){

	var kazu = $('#itemBox a img').length; // 画像の数を取得
	var imgHaba = 160 + 16; //１個の画像エリアサイズ（width+margin-right）
	var itemHaba = kazu * imgHaba; // itemBoxの適正サイズを計算
	var naka = 1;
	if (kazu % 2 == 0) { // 偶数の場合、中央に位置する画像位置がズレてるため調整値を設定
		//alert('偶数');
		var imgHalfMove = 80; // 偶数の場合（※画像widthの半分）
	} else {
		//alert('奇数');
		var imgHalfMove =  0; // 奇数の場合
	}

	// スライダーエリアサイズ計算メソッド
	function itemBoxMove(){
		var centrize = Math.floor( ($('#scrollable').width()) / 2) - (imgHaba * 1.5); // itemBoxを中央移動させる位置を計算
		//ct(imgHalfMove);

		$('#itemBox').css({
			width: itemHaba + 'px',
			position: 'absolute',
			top: '0',
			left: centrize + 'px'
		});
	};

	itemBoxMove();

	// window size が変更された場合も動作させる
	$(window).resize(function(){
		itemBoxMove();
	});

	// 中央 ３画像の特定
	function tgtElem(){
		$('#itemBox').undelegate( '.centerImage', 'hover' );//イベント削除
		$('#itemBox a').removeClass('centerImage');
		$('#itemBox a:eq(' + (naka)  + ')').addClass('centerImage');
		$('#itemBox a:eq(' + (naka-1)  + ')').addClass('centerImage');
		$('#itemBox a:eq(' + (naka+1)  + ')').addClass('centerImage');

		// 商品画像hover時に 情報を表示するイベント登録
		$('#itemBox').delegate(
			'.centerImage',
			'mouseenter',
			function(){
				$(this).children('div').fadeIn('fast');
				/*
				$(this).children('div').animate({
					left:'176px'
					});
				*/
			}
		);
		$('#itemBox').delegate(
			'.centerImage',
			'mouseleave',
			function(){
				$(this).children('div').hide();
			}
		);

	}

	tgtElem();

	// （右）ボタンクリック時の動作～１回のみ
/*
	$('.forward').one('click', function(){
		$('.back').show();
	});
*/


	// （右）ボタンクリック時の動作
	$('.forward').click( function(){
		if(naka < kazu-2){
			naka++;
			tgtElem();
			var itemBoxPosition = $('#itemBox').css('left').replace('px','') - 0;
			$('#itemBox').animate({
				left: itemBoxPosition - imgHaba
			});
			if(1 !== naka){
				$('.back').show();
			};
		};
	});

	/* （左）ボタンクリック時の動作 */
	$('.back').click( function(){
		if(1 < naka){
			--naka;
			tgtElem();
			var itemBoxPosition = $('#itemBox').css('left').replace('px','') - 0;
			$('#itemBox').animate({
				left: itemBoxPosition + imgHaba
			});
			if(1 == naka){
				$('.back').fadeOut();
			};
		};
	});

	}
});


