	
	/************************************************************************************************************
	(C) www.dhtmlgoodies.com, October 2005
	
	This is a script from www.dhtmlgoodies.com. You will find this and a lot of other scripts at our website.	
	
	Terms of use:
	You are free to use this script as long as the copyright message is kept intact. However, you may not
	redistribute, sell or repost it without our permission.
	
	Thank you!
	
	www.dhtmlgoodies.com
	Alf Magne Kalleland
	
	************************************************************************************************************/	

	
	var activeMenuItem = new Array();
	
	function isUlInArray(inputObj,ulObj){
		while(inputObj && inputObj.id!='dhtmlgoodies_listMenu'){
			if(inputObj==ulObj)return true;
			inputObj = inputObj.parentNode;			
		}		
		return false;
	}
	
	function showHideSub(e,inputObj)
	{
		

		if(!inputObj)inputObj=this;
		var parentObj = inputObj.parentNode;
		var ul = parentObj.getElementsByTagName('UL')[0];
//		if(activeMenuItem.length > 0){
//			for(var no=0; no<activeMenuItem.length; no++){
//				if(!isUlInArray(ul,activeMenuItem[0]) && !isUlInArray(activeMenuItem[0],ul)){
//				//別なカテゴリを開いたときクリックしたカテゴリ以外を閉じる処理
//					activeMenuItem[no].style.display='none';
//					activeMenuItem.splice(no,1);
//					no--;
//				}
//			}			
//		}
		
		//offsetHeightはULの縦幅を見ている。
		//カテゴリを開いていない場合は0となる
		if(ul.offsetHeight == 0){
			//カテゴリを開く
			ul.style.display='block';
			activeMenuItem.push(ul);
		}else{
			//カテゴリを閉じる
			ul.style.display='none';
		}
//		var str = getOpenUl();
//		window.alert(str);
	}
	
	function showHidePath(inputObj)
	{
		var startTag = inputObj;
		//window.alert("aaa");
		//showHideSub(false,inputObj);
		//window.alert("bbb");
		//子カテゴリを開く処理
		inputObj = inputObj.parentNode;
		while(inputObj){
			inputObj = inputObj.parentNode;
			if(inputObj.tagName=='LI')showHideSub(false,inputObj.getElementsByTagName('A')[0]);
			if(inputObj.id=='dhtmlgoodies_listMenu')inputObj=false;	
		}		
	}
	function openMenu(pCategoryIndex1, pCategoryIndex2 ){
		var obj = document.getElementById('dhtmlgoodies_listMenu');
		
		if(obj != null){
			var uls = obj.getElementsByTagName('UL');
			if(pCategoryIndex1 == 99){
				//どこも開いていない状態
			}else{
				if (pCategoryIndex1 != 0) {
					var num = 0;
					//+3は男性用,女性用,共用をすっ飛ばす用
					num = pCategoryIndex1 + 3;
					uls[num].style.display = "block";
				}
				else {
					//0が唯一サブサブカテゴリのある親カテゴリのため
					uls[0].style.display = "block";
					//+1はジャンル２と整合性を取るため その他だけサブサブカテゴリは無いため除外する
					if (pCategoryIndex2 < 3) {
						uls[pCategoryIndex2 + 1].style.display = "block";
					}
				}
			}
		}
	}
	function getOpenUl()
	{
		var obj = document.getElementById('dhtmlgoodies_listMenu');
		var aTags = obj.getElementsByTagName('A');
		window.alert("adca");
		var openCntStr = "ZZ:";
		var openCnt = 0;
		
		var uls = obj.getElementsByTagName('UL');
		for(var no=0; no<uls.length; no++){
			if(uls[no].style.display == 'block'){
				openCntStr = openCntStr + no + "/";
			}
		}
		
		/*
		for(var no=0; no<aTags.length; no++){
			
			if(aTags[no].id > 0)
			{
				//UL判定
				
				var parentObj = aTags[no].parentNode;
				window.alert("name22");
				var ul = parentObj.getElementsByTagName('UL')[0];
				window.alert("ul:"+ul);
				window.alert("display:"+ul.style.display);
				if(ul.style.display == 'block'){
					openCntStr = openCntStr + no + "/";
					openCnt++;
				}
				
			}
			
		}
		*/
		
		
		return "AAAA";
	}
	
	function initMenu()
	{
		var linkCounter=0;
		var activeMenuItem = false;
		var activeMenuLink = false;
		var thisLocationArray = location.href.split(/\//);
		var fileNameThis = thisLocationArray[thisLocationArray.length-1];
		if(fileNameThis.indexOf('?')>0)fileNameThis = fileNameThis.substr(0,fileNameThis.indexOf('?'));
		if(fileNameThis.indexOf('#')>0)fileNameThis = fileNameThis.substr(0,fileNameThis.indexOf('#'));

		var obj = document.getElementById('dhtmlgoodies_listMenu');
		if(obj != null){
			var aTags = obj.getElementsByTagName('A');
			for(var no=0; no<aTags.length; no++){
				var parent = aTags[no].parentNode;
				var subs = parent.getElementsByTagName('UL');
				if(subs.length > 0){
					//ULタグの場合のみshowHideSubを登録
					aTags[no].onclick = showHideSub;	
					linkCounter++;
					//UL つまり子カテゴリがあるカテゴリのみidが挿入される
					//aTags[no].id = 'aLink' + linkCounter;
					aTags[no].id = linkCounter;
				}else{
					aTags[no].id = 0;
				}
				if(aTags[no].href.indexOf(fileNameThis)>=0 && aTags[no].href.charAt(aTags[no].href.length-1)!='#'){				
					if(aTags[no].parentNode.parentNode){								
						var parentObj = aTags[no].parentNode.parentNode.parentNode;
						var a = parentObj.getElementsByTagName('A')[0];
						if(a.id && !activeMenuLink){
							//window.alert(aTags[no]);
							//メニューが青くなる(アパレルだけ？)
							activeMenuLink = aTags[no];
							activeMenuItem = a.id;
						}
					}
				}
			}
	//cssで停止中となっているためいらない
			if(activeMenuLink){
				activeMenuLink.className='activeMenuLink';
			}
			if(activeMenuItem){
				if(document.getElementById(activeMenuItem)){
					showHidePath(document.getElementById(activeMenuItem));	
				}
			}
		}		
		
	}
	//window.onload = initMenu;
