// href のパスをハッシュに変える
function replacePath2Hash(){
    setTimeout(function(){
        $("#header a, #footer_list a, div.tooltips a, div.sub_footer a, div.sub_footer p a").each(function(){
            var setHref = $(this).attr("href").replace("./", "#");
            $(this).attr({href:setHref})
        });
    },
    200);
}
        
function dispControl() {
    setTimeout(function(){
        // navi_mat の表示位置決め
        var off = $('#navi_container').offset();
        $("#navi_mat").css("top", off.top + border_weight);
        // リンクをクリックした後に点線がつかないようにする
        $("a").focus( function () { $(this).blur()});
        // メニューを非表示に
        $("#navi_container ul .sub, #navi_mat").fadeOut("fast");
        // ツールチップを非表示に
        $("div.tooltip").fadeOut("fast");
        $("div.tooltip_privinf").fadeOut("fast");
        $("div.tooltip_facebook").fadeOut("fast");
        // IE6用透過処理
        setAlphafilter();
    },
    200);
}
        
// URLのハッシュから該当するファイルを読み込む
function loadFileFromHash(){
    var hashValue = window.location.hash;
	// hashの値がない（初期表示の）場合と、hashありの場合で読み込むファイルを分ける
    if ( hashValue == "" ) {  // 初期表示の場合
        $("#main").load("./top.html");
        $("#header_img").css("display", "none");
        $("#top_link").css("display", "");
        $("#footer_dot_border").css("visibility", "hidden");
        // 表示調整
        dispControl();
        // href のパスをハッシュに変える
        replacePath2Hash();
	} else { // hash の値による画面遷移の場合
        var setHash = hashValue.replace('#', './');
        if ( setHash == "./none" ) { 
            return false;
        // トップの場合とそれ以外の場合で表示項目を変える
        } else if ( setHash == "./top.html" ) { 
            $("#header_img").css("display", "none");
            $("#top_link").css("display", "");
            $("#footer_dot_border").css("visibility", "hidden");
        } else {
            $("#header_img").css("display", "");
            $("#top_link").css("display", "none");
            $("#footer_dot_border").css("visibility", "visible");
        }
        // hashに応じたファイルを読み込む
        $("#main").load(setHash);
        // 表示調整
        dispControl();
        // href のパスをハッシュに変える
        replacePath2Hash();
        // ページトップへ戻る
        javascript:scrollTo(0,0);
    }
}
        
// IE6において透過pngを表示
function setAlphafilter(){
    // // IE6 の場合
    if(_ua.ltIE6){
        $(".top_left_gray").addClass("alphafilter");
        $(".top_center_gray").addClass("alphafilter");
        $(".top_right_gray").addClass("alphafilter");
        $("#phil_list").addClass("alphafilter");
        $(".top_left").addClass("alphafilter");
        $(".top_center").addClass("alphafilter");
        $(".top_right").addClass("alphafilter");
        $(".mid_left").addClass("alphafilter");
        $(".mid_right").addClass("alphafilter");
        $(".bottom_left").addClass("alphafilter")
                         .append("&nbsp;");
        $(".bottom_center").addClass("alphafilter")
                         .append("&nbsp;");
        $(".bottom_right").addClass("alphafilter")
                         .append("&nbsp;");
        alphaFunc();
    }
}
        
// ブラウザを判別
function brouserCheck(){
    return {
    ltIE6:typeof window.addEventListener == "undefined" && typeof document.documentElement.style.maxHeight == "undefined",
    ltIE7:typeof window.addEventListener == "undefined" && typeof document.querySelectorAll == "undefined",
    ltIE8:typeof window.addEventListener == "undefined" && typeof document.getElementsByClassName == "undefined",
    ie:document.uniqueID,
    firefox:window.globalStorage,
    opera:window.opera,
    webkit:!document.uniqueID && !window.opera && !window.globalStorage && window.localStorage,
    mobile:/android|iphone|ipad|ipod/i.test(navigator.userAgent.toLowerCase())
    }
}

