
window.onload = function() {

// 非アクティブでウィンドウを閉じる場合
//    window.onblur = function() { if (this.opener) { this.close();} };

/*** 閉じるボタンを表示する ***/
    var strAddHTML = '<input type="button" id="cbutton" style="position:absolute;bottom:0px;right:0px;width:50px;height:20px;border-width:1px;background-color:#ccc;"'
    if (this.opener) {
        this.document.body.innerHTML += strAddHTML + ' onClick="window.close();" value="閉じる">';
    } else {
        this.document.body.innerHTML += strAddHTML + ' onClick="top.location.href=\'./index.html\';" value="HOME">';
    }

/*** ボタン動き ***/
/*
    var e = this.document.getElementById("cbutton");
    if (typeof e == "undefined" || e == null) { return; }
    this.cbutton = e;
    this.document.body.onmousemove = function(event) {
        if (typeof event == "undefined") { event = window.event; }

        if (window.document.body.scrollTop != 0) {
            window.cbutton.style.bottom = "";
            window.cbutton.style.top = (window.document.body.scrollTop + event.clientY - 10) + "px";
        } else {
            window.cbutton.style.top = "";
            window.cbutton.style.bottom = "0px";
        }
        if (window.document.body.scrollLeft != 0) {
            window.cbutton.style.right = "";
            window.cbutton.style.left = (window.document.body.scrollLeft + event.clientX - 10) + "px";
        } else {
            window.cbutton.style.left = "";
            window.cbutton.style.right = "0px";
        }
    };
*/
    var e = this.document.getElementById("cbutton");
    if (typeof e == "undefined" || e == null) { return; }
    this.cbutton = e;
    this.document.body.onscroll = function(event) {

        if (window.document.body.scrollTop != 0) {
            window.cbutton.style.bottom = "";
            window.cbutton.style.top = (window.document.body.offsetHeight + window.document.body.scrollTop - window.cbutton.offsetHeight - 10) + "px";
        } else {
            window.cbutton.style.top = "";
            window.cbutton.style.bottom = "0px";
        }
        if (window.document.body.scrollLeft != 0) {
            window.cbutton.style.right = "";
            window.cbutton.style.left = (window.document.body.scrollLeft + 10) + "px";
        } else {
            window.cbutton.style.left = "";
            window.cbutton.style.right = "0px";
        }
    };

};


