$(function(){ 
	//プリセット
	var acc = $("#accordion");
	var det = acc.find(".detail");
	var h2 = $("h2");
	var count = 500;
	
	h2.css("cursor", "pointer");
	det.css("display", "none");
	$(".detail > li:last-child").css("margin-bottom","2em");
	$(".detail:last").delay(count).slideDown("slow");//delayメソッド：jQuery1.4以上
	setTimeout(function(){$("h2:last").addClass("open");}, count);
	
	// 個別に開閉するボタン
	h2.click(function () {
		var indexcode = h2.index(this);
		
		if($(this).nextAll(".detail").css("display") == "none") {// display:noneだったら表示
			$(this).nextAll(".detail").slideDown("slow");
			$(this).addClass("open");
			// $(this).find("img").attr("src", $(this).find("img").attr("src").replace("_cl", "_op"));
		}
		else if($(this).nextAll(".detail").css("display") == "block") {// display:blockだったら非表示
			$(this).nextAll(".detail").slideUp("slow");
			$(this).removeClass("open");
			//$(this).find("img").attr("src", $(this).find("img").attr("src").replace("_op", "_cl"));
		}
	});
});
