// for using clossfade gallery
$(function(){
	var image = new Array();
	//予め画像を読み込む
	$("#thumb img").each(function(){
		thumbSRC = $(this).attr("src");
		imgSRC = thumbSRC.replace("_s","");
		//大きい画像を読み込み
		image.push(imgSRC);
		newImage = new Image();
		newImage.src = imgSRC;
	});

	$("#thumb img").hover(function(){
		//サムネイルの画像URLを取得   
		thumbURL = $(this).attr("src");
		//サムネイルの画像URLを大きい画像URLに書き換え

		imgURL = thumbURL.replace("_s","");

		photoURL = $("#photo img").attr("src");
		if(photoURL != imgURL){
			//Loading画像を表示
			//画像をフェードアウト
			$("#photo img").fadeOut("nomal", function() {
				//大きい画像の入れ替え
				$("#photo img").attr("src", imgURL);
				//画像の読み込みが完了したら…
//				$("#photo").load(function () {
					//フェードイン
					$("#photo img").fadeIn(2000);
//				});
			});
		}
	});

	$("#photo img").click(function(){
		
		preSrc = $(this).attr("src");
		imgIndex = $.inArray(preSrc, image);
		imgIndex++;
		if(image[imgIndex]){
			//画像をフェードアウト
			$("#photo img").fadeOut("nomal", function() {
				//大きい画像の入れ替え
				$("#photo img").attr("src", image[imgIndex]);
				//画像の読み込みが完了したら…
//				$("#photo").load(function () {
					//フェードイン
					$("#photo img").fadeIn(2000);
//				});
			});
			return false;
		}
		else{
			return true;
		}
	});
}); 







