//TreeMenu
f = 1;
function setEvent () {
    if(!document.getElementById) return;
    var arrayB = document.getElementsByTagName("DIV");
    for(i = 0; i < arrayB.length; i++) {
        if(arrayB[i].parentNode.tagName == "LI") {
            arrayB[i].onclick = expandMenu;
        }
    }
}

function expandMenu (e) {
     if(window.event) e = window.event;
     var b = null;
     if(e.srcElement) b = e.srcElement;
     else if(e.currentTarget) b = e.currentTarget;
     var ul = b.nextSibling;
     while(ul) {
         if(ul.nodeType == 1 && ul.tagName == "UL")
            break;
         ul = ul.nextSibling;
     }
     if(ul) {
         if(ul.style.display == "block")
             ul.style.display = "none";
         else ul.style.display = "block";
     }
}

if(document.getElementById) {
    document.write("<style type='text/css'>" +
                   "ul ul { display: none; }" +
                   "</style>");
}

//PopupMenu

var ie  = navigator.userAgent.indexOf("MSIE ");
var verIE = 0, winIE = -1;
if(ie >= 0) {
    verIE = parseFloat(navigator.userAgent.substr(ie + 5));
    winIE = navigator.userAgent.indexOf("Windows");
}

function getElemLeft (elem) {
    var x = elem.offsetLeft;
    var pa = elem.offsetParent;
    while(pa) {
        if(pa.offsetLeft) x += pa.offsetLeft;
        pa = pa.offsetParent;
    }
    return x;
}
function getElemTop (elem) {
    var y = elem.offsetTop;
    var pa = elem.offsetParent;
    while(pa) {
        if(pa.offsetTop) y += pa.offsetTop;
        pa = pa.offsetParent;
    }
    return y;
}

var currentId = "";
function showMenu (e, id) {
    if(!document.getElementById) return;
    if(currentId == id) return;
    closeMenu();
    var obj = document.getElementById(id);
    var x, y;
    var elm;
    if(e.srcElement) elem = e.srcElement;
    else elem = e.currentTarget;
    if(elem.offsetParent && !(verIE > 0 && winIE < 0)) {
        x = getElemLeft(elem)-20;
        y = getElemTop(elem) + elem.offsetHeight;
    }
    else {
        var x = e.clientX + scrollLeft();
        var y = e.clientY + scrollTop();
        x -= 60; y += 16;
    }
    obj.style.left = x + "px";
    obj.style.top = y + "px";
    obj.style.visibility = "visible";
    currentId = id;
}
function closeMenu () {
    if(!document.getElementById) return;
    if(!currentId) return;
    var obj = document.getElementById(currentId);
    obj.style.visibility = "hidden";
    currentId = "";
}
function bodyClick (e) {
    closeMenu();
}
if(document.getElementById)
    document.onclick = bodyClick;

function scrollLeft () {
    if(window.pageXOffset)
        return window.pageXOffset;
    if(document.compatMode == "CSS1Compat")
        return document.body.parentNode.scrollLeft;
    if(document.body.scrollLeft)
        return document.body.scrollLeft;
    return 0;
}
function scrollTop () {
    if(window.pageYOffset)
        return window.pageYOffset;
    if(document.compatMode == "CSS1Compat")
        return document.body.parentNode.scrollTop;
    if(document.body.scrollTop)
        return document.body.scrollTop;
    return 0;
}

//ShowhideMenu

function showHide(obj) {
    if(!document.getElementById) return;
    var style = document.getElementById(obj).style;
    if(style.display == "block") style.display = "none";
    else { style.display = "block"; }
}
if(document.getElementById) {
    document.write("<style type='text/css'>");
    document.write("div#div1, div#div2, div#div3, div#div4 , div#div5, div#div6, div#div7, div#div8, div#div9, div#div10{ display: none;}");
    document.write("</style>");
}

function showHide2(obj) {
    if(!document.getElementById) return;
    var style = document.getElementById(obj).style;
    if(style.display == "none") style.display = "block";
    else { style.display = "none"; }
}
//ホームページに登録
function setHome (obj) {
    if(verIE >= 5.0 && winIE >= 0)
        obj.setHomepage(location.href);
    else
        alert("このブラウザーではホームページに設定できません。");
}
//お気に入りに登録
function addFav () {
    if(verIE >= 5.0 && winIE >= 0)
        window.external.AddFavorite(location.href,
            document.title);
    else
        alert("このブラウザーでは追加できません。");
}

//SHOW MSG
isIE4 = (navigator.appVersion.charAt(0)>=4 && (navigator.appVersion).indexOf("MSIE") != -1)
isNN4 = (navigator.appVersion.charAt(0)>=4 && (navigator.appName).indexOf("Netscape")!=-1);

function link_info(m) {
  if(m==null)  m = ""; 
  if(isIE4) {
    el = document.all("msg"); 
    el.innerHTML = m;
}
else if(isNN4) {
    lay = document.layers["link"].document.layers["msg"];
    lay.document.open();
    lay.document.write("<font style='font-size:10pt' color='#C0C0C0'>"+ m +"</font>");
    lay.document.close(); 
   }
}

function popupCenter(url, name, width, height) {
    var left = (screen.width - width) / 2;
    var top  = (screen.height - height) / 2;
    var options = "left=" + left + ",top=" + top + 
       ",width=" + width + ",height=" + height;
    window.open(url, name, options);
}

//右クリック禁止
var message="";
function clickIE() {if (document.all) {(message);return false;}}
function clickNS(e) {if 
(document.layers||(document.getElementById&&!document.all)) {
if (e.which==2||e.which==3) {(message);return false;}}}
if (document.layers) 
{document.captureEvents(Event.MOUSEDOWN);document.onmousedown=clickNS;}
else{document.onmouseup=clickNS;document.oncontextmenu=clickIE;}
document.oncontextmenu=new Function("return false")
