﻿/**********************************************************
* layermenu
*/

//listmod014用
$(document).ready(function(){
	$(".listmod014 img").click(
		function(){
//ボタン画像のオンオフ
//console.log(this.parentNode.lastChild);
//console.log($(this).next());
			this.button = $(this);
			var imgSrc = $(this.button)[0].src;
			var imgSrcSlice = imgSrc.slice(-8,-2);
			if(imgSrcSlice == "_ovr.p"){
				$(this.button)[0].src = imgSrc.replace("_ovr","");
			}else{
				//他のボタンを閉じる処理
				allImg = $(".listmod014 li").find("img");
				for(i=0;i<allImg.length;i++){
					$(allImg)[i].src = $(allImg)[i].src.replace("_ovr","");
				}
				//
				$(this.button)[0].src = imgSrc.replace(".png","_ovr.png");
			};

//console.log(this.button);
			this.target = $(this).next();
			if(this.target.css('display') == 'none'){
				$(".listmod014 li").find("ul").hide();
				$(this.target).css("display","block");
			}else{
				$(".listmod014 li").find("ul").hide();
				$(this.target).css("display","none");
			}
		}
	)
});



//listmod015用
$(document).ready(function(){
	$(".listmod015 li[class^='hasChild']").click(
		function(){
//ボタン画像のオンオフ
			this.button = $(this).find("img");
			allImg = $(".listmod015 li").find("img");
			var len = allImg.length;
			
			/*
			for(var i=0; i<len; i++){
				var imgSrc = allImg[i].src;
				if($(this.button)[0]==allImg[i]){
					if(imgSrc.indexOf("_ovr")<=-1){
						allImg[i].src = imgSrc.replace(".png","_ovr.png");
					}else{
						allImg[i].src = imgSrc.replace("_ovr.png",".png");
					}
				}else{
					if(imgSrc.indexOf("_ovr")>-1){
						allImg[i].src = imgSrc.replace("_ovr.png",".png");
					}
				}
			}
			*/
			
			
			var imgSrc = $(this.button)[0].src;
			var imgSrcSlice = imgSrc.slice(-8,-2);
			if(imgSrcSlice == "_ovr.p"){
				$(this.button)[0].src = imgSrc.replace("_ovr","");
			}else{
				//他のボタンを閉じる処理
				allImg = $(".listmod015 li").find("img");
				for(i=0;i<allImg.length;i++){
					var img = $(allImg)[i].src;
					$(allImg)[i].src = img.replace("_ovr","");
				}
				//
				$(this.button)[0].src = imgSrc.replace(".png","_ovr.png");
			}

			this.target = $(this).find("dl");
			if(this.target.css('display') == 'none'){
				$(".listmod015 li").find("dl").hide();
				var h = $(this.target).height()+50;
				$(".listmod015 ul.list-block").height(h);
				$(this.target).css("display","block");
			}else{
				$(".listmod015 li").find("dl").hide();
				$(this.target).css("display","none");
				$(".listmod015 ul.list-block").height(39);
			}
		}
	)
});
