$(function() {
	/*
	 * heightの最大値を取得
	 */
	/*var maxheight = 0;
	$(".accordion-list").each(function() {
		$(".accordion-list-item", this).each(function(index) {
			var $this = $(this);
			var thischild = $this.children("ul");
			if(thischild.length > 0) {
				if(maxheight < thischild.height()) {
					maxheight = thischild.height();
				}
			}
		});
	});*/

	/*
	 * maxheightまで広がるアコーディオン
	 */
	$(".accordion-list").each(function() {
		$(".accordion-list-item", this).each(function(index) {
			var $this = $(this);
			var params = {height:'toggle'};

			//$this.children("ul").hide();
			if($this.children("ul").is(":hidden")) {
				$this.children("strong a").click(
					function(){
						if($this.find("ul").is(":hidden")) {
							$this.find(".sidenavi-arrow").text('ー');
							$this.children("strong").addClass("accordion-hover");
							$this.siblings().children("ul:visible").slideUp("slow");
							$this.siblings().children("strong").removeClass("accordion-hover");
							if($this.siblings().children("ul").is(":visible")) {
								$this.siblings().find(".sidenavi-arrow").text('＋');
							}
							//$this.children("ul").slideDown("normal");
							$this.children("ul").animate(params, {duration:"slow"});
							return false;
						}
					}
				);

				$this.hover(
					function () {
						$this.children("strong").addClass("accordion-hover");
						$this.css("cursor","pointer"); 
						//$this.children("strong a").append('<a class="open-arrow">▼</a>');
							
					},
					function () {
						$this.children("strong").removeClass("accordion-hover");
						$(this).css("cursor","default"); 
						//$this.find(".open-arrow").remove();

					}
				);
			}

		});
	});
});


