﻿

$(function(){
    // 自分のディレクトリを dir に入れる処理。

    // はじめにディレクトリを全て列記
    var dirs = "profile|history|office|head|sisya-kanto|s-kimitsu|eigyo-tokyo|eigyo-kansai|s-himeji|s-aso|eigyo-ooita|s-nobeoka|sisya-nagasaki"; // "|" ← "OR" の意味
    var dir = null;
	
// if(document.URL.match("http://[^/]+/("+dirs+")")){ // ← 本番用
if(document.URL.match("/("+dirs+")")){ // デバッグ用
        var dir = RegExp.$1;
        if(document.URL.match("/")){ // 2階層以上のときの処理。
            dir = dir.substring(dir.lastIndexOf("/") + 1); 
			// 最後のスラッシュ以降を取得
        }
    }

	
    // ↓ 該当メニューの色変え処理
    if(dir != null){
        /*$("#"+dir).css("background","#AAF");*/
		$("#"+dir).addClass("BG-Rever");
	}
    // メニュークリック時に自動遷移 htmlにて AccordionPanelContent に autojump を追加
    $(".autojump").bind('click',function(){
        // alert( $("li a" ,$(this).siblings(".AccordionPanelContent")).attr("href")  );
        // 20090302 topath 修正
        //var topath = $("li a" ,$(this).siblings(".AccordionPanelContent")).attr("href");
        var topath = $(this).children("a").attr("href");
        var basedir = document.URL.substring(0,document.URL.lastIndexOf("#"));
        if(basedir.match("\.html$")){
            basedir = basedir.substring(0,basedir.lastIndexOf("/") + 1); 
        }
        //alert($(this).siblings(".AccordionPanelContent").css("display")); // block none
        //alert($(this).siblings(".AccordionPanelContent").css("height")); // 0px or 999px
        if ($(this).siblings(".AccordionPanelContent").css("display") == 'none' ||
            $(this).siblings(".AccordionPanelContent").css("height") == '0px'){
            location.href = basedir + topath;
        }
	});;	
	
}); 
