// JavaScript Document for works
// S&S+ kumagai

$(document).ready(function(){
	var concept = $("a#concept").attr("id");
	var imgNum = $(".thumbnail a").length;
	if(imgNum > 9){
	  $("div.thumbnail").addClass("bgThumbnail");
	}

	if($("#target").length){
		$(".concept").hide();
		$(".thumbnail a").click(function(){
			var src = $(this).attr("href");
			var conceptThumb = $(this).attr("id");
			if(concept){
				if(conceptThumb){
					$("#target").fadeOut("slow",function() {
						$(".concept").fadeIn("slow");
					});
				}else{
					$(".concept").fadeOut("slow",function(){
						$("#target").fadeOut("slow",function() {
							$(this).attr("src",src);
							$(this).fadeIn();
						});
					});
				}
			}else{
				$("#target").fadeOut("slow",function() {
					$(this).attr("src",src);
					$(this).fadeIn();
				});
			}
			return false;
		});

	}

//	if(concept){
//		$("#target").hide();
//	}

	$("#otherWorks").hide();
	$("#btnOthers").click(function () {
	  if ($("#otherWorks").is(":hidden")) {
		$("#otherWorks").slideDown("slow");
	  }
	});
	$(".btnClose").click(function(){
		$("#otherWorks").slideUp("slow");
	});
	$("#otherWorks a").hover(function(){
		var src = $(this).attr("rel");
		if(src){
			$("#otherWorksThumbnail").attr({ src: src });
		} else {
			$("#otherWorksThumbnail").attr({src:"http://www.kyara-arc.com/works/images/noImage.png"});
		}
		return false;
	});
});
