﻿// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// 各種パラメータ
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


var width = 600 / 3;  // 表示マップの一画面の幅
var height = 390 / 3;// 表示マップの一画面の高さ
dragObj = new Object ();
dragWhole = new Object ();
var scale = 5000;  // 縮尺
var lat = 35.08014;      // 緯度
var lon = 137.15944;     // 経度
var clickLat = 0;        // クリック箇所の緯度
var clickLon = 0;        // クリック箇所の経度
var startX = 0; // ドラッグ開始座標
var startY = 0; // ドラッグ開始座標
var moveX = 0;  // 移動座標
var moveY = 0;  // 移動座標
var east = 0;   // 東移動
var west = 0;   // 西移動
var south = 0;  // 南移動
var north = 0;  // 北移動
var tmpE = 0;   // 東移動
var tmpW = 0;   // 西移動
var tmpS = 0;   // 南移動
var tmpN = 0;   // 北移動
var areaE = 0;   // 移動座標 (東移動)
var areaW = 0;   // 移動座標 (西移動)
var areaS = 0;   // 移動座標 (南移動)
var areaN = 0;   // 移動座標 (北移動)
var top = 0;        // 表示画像の位置（初期値は中心を指定高さ分表示するように設定）
var right = width;  // 表示画像の位置（初期値は中心を指定幅分表示するように設定）
var bottom = height;// 表示画像の位置（初期値は中心を指定高さ分表示するように設定）
var left = 0;       // 表示画像の位置（初期値は中心を指定幅分表示するように設定）
var whole_top = 0;        // 表示画像の位置
var whole_left = 0;       // 表示画像の位置
var dragFlag = false;                         // ドラッグ中かどうかのフラグ変数
var moveFlag = false;                         // 移動したかどうかのフラグ変数
var openFlag = false;                         // 表示開始時のフラグ変数
var zoomFlag = false;                         // 縮尺変更をしたかどうかのフラグ変数
var menuFlag = false;                         // メニューフラグ
var menuOpenFlag = false;                     // メニューフラグ(使用判定)
var wholeFlag = true;                         // 全域図表示フラグ
var wholeActFlag = false;                     // 全域図表示フラグ
var lineFlag = false;                     // ラインフラグ（openMap時）
var lineParams = new Array (1);           // ライン描画用パラメータ（openMap時）
var polylineFlag = false;                     // 連続ラインフラグ（openMap時）
var polylineParams = new Array (1);           // 連続ライン描画用パラメータ（openMap時）
var ellipseFlag = false;                     // 楕円フラグ（openMap時）
var ellipseParams = new Array (1);           // 楕円描画用パラメータ（openMap時）
var fillellipseFlag = false;                     // 楕円（塗りつぶし）フラグ（openMap時）
var fillellipseParams = new Array (1);           // 楕円（塗りつぶし）描画用パラメータ（openMap時）
var rectFlag = false;                     // 矩形フラグ（openMap時）
var rectParams = new Array (1);           // 矩形描画用パラメータ（openMap時）
var iconX = new Array (1);       // アイコンの表示座標
var iconY = new Array (1);       // アイコンの表示座標
var iconUrl = new Array (1);     // アイコンのアドレス
var iconWidth = new Array (1);   // アイコンの幅
var iconHeight = new Array (1);  // アイコンの高さ
var iconFlag = new Array (1);    // アイコンの表示判断
var iconMsg = new Array (1);     // アイコンの吹き出し内容
var mouseX = 0;                 // クリックしたX位置情報（移動）
var mouseY = 0;                 // クリックしたY位置情報（移動）
var clickX = 0;                 // クリックしたX位置情報（クリック縮尺変更）
var clickY = 0;                 // クリックしたY位置情報（クリック縮尺変更）
var menuValues = "";            // メニュー上に表示する文字列
var menuWidth = 0;   // メニューの幅
var menuHeight = 0;  // メニューの高さ
var zoomList = new Array (9);    // 縮尺一覧
var zoomRule = new Array (9);    // 縮尺表示
var around = 40;                 // 地図の文字切れ対応用の表示領域
zoomList [0] = 200000;
zoomList [1] = 150000;
zoomList [2] = 100000;
zoomList [3] = 50000;
zoomList [4] = 25000;
zoomList [5] = 15000;
zoomList [6] = 10000;
zoomList [7] = 5000;
zoomList [8] = 2500;
zoomRule [0] = "4km";
zoomRule [1] = "3km";
zoomRule [2] = "2km";
zoomRule [3] = "1km";
zoomRule [4] = "500m";
zoomRule [5] = "300m";
zoomRule [6] = "200m";
zoomRule [7] = "100m";
zoomRule [8] = "50m";


// ##################################################################################
// クリック箇所のクリック箇所の緯度を取得
// ##################################################################################
function getClickLat () {
    return clickLat;
}


// ##################################################################################
// クリック箇所のクリック箇所の経度を取得
// ##################################################################################
function getClickLon () {
    return clickLon;
}


// ##################################################################################
// クリック箇所のクリック箇所の緯度・緯度を計算
// ==================================================================================
// event : イベントオブジェクト
// ##################################################################################
function setCoordinate (event) {
    var target = "";
    if (window.createPopup) {
        //IE
        target = event.srcElement.id;
    } else {
        //その他
        target = event.target.id;
    }
    if (target.indexOf ("imgmap_") < 0) return;        // マップ画像が表示されていない場合はなにもしない
    if (document.all) {
        //IE
        clickX = event.offsetX;
        clickY = event.offsetY;
    } else {
        //その他
        clickX = event.layerX;
        clickY = event.layerY;
    }
    // 中心座標を算出
    var file = $(target).name;
    var tmp = file.substring (file.lastIndexOf ("/") + 1, file.length).replace (".png", "").split ("_");
    var tmpLon = floor (parseFloat (tmp [10]) - (tmp [12] / 2.0), 10);
    var tmpLat = floor (parseFloat (tmp [9]) + (tmp [11] / 2.0), 10);
    var pixelX = floor (parseFloat (tmp [12]) / parseFloat (width), 10);
    var pixelY = floor (parseFloat (tmp [11]) / parseFloat (height), 10);
    // 中心座標を算出
    clickLat = floor (parseFloat (tmpLat) - (pixelY * parseFloat (clickY - (around / 2) ) ), 10);
    clickLon = floor (parseFloat (tmpLon) + (pixelX * parseFloat (clickX - (around / 2) ) ), 10);
}


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// 各種パラメータ
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// ##################################################################################
// ##################################################################################
// ##################################################################################
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// ドラッグの操作
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// ##################################################################################
// ドラッグ開始処理（マップ）
// ##################################################################################
dragObj.dragStart = function () {
    if (dragFlag) return;   // ドラック中は更新しない
    if (zoomFlag) return;   // 縮尺変更中は更新しない
    // マウスポインタ変更
    $("map").style.cursor = "move";
    startX = 0;
    startY = 0;
    moveX = 0;
    moveY = 0;
    dragFlag = true;
    return false;
}


// ##################################################################################
// ドラッグ終了処理（マップ）
// ##################################################################################
dragObj.dragEnd = function (event) {
    if (!dragFlag) return;  // ドラッグ中で無い場合は更新しない
    var target = "";
    if (window.createPopup) {
        //IE
        event = window.event;
        target = event.srcElement.id;
    } else {
        //その他
        target = event.target.id;
    }

    // マウスポインタ変更
    $("map").style.cursor = "pointer";
    // 移動した場合
    top -= moveY;
    left += moveX
    if (dragFlag && moveFlag) {
        // 移動分を計算
        tmpE = parseInt (Math.abs (left / width) + 0.5);      // 東移動
        tmpW = tmpE;                                          // 西移動
        tmpS = parseInt (Math.abs (top / height) + 0.5);      // 南移動
        tmpN = tmpS;                                          // 北移動
        if (left <= 0) {
            tmpE = tmpE * -1;
        } else {
            tmpW = tmpW * -1;
        }
        if (top <= 0) {
            tmpS = tmpS * -1;
        } else {
            tmpN = tmpN * -1;
        }
        // マップファイル切り替え
        if (east != tmpE
        || west != tmpW
        || south != tmpS
        || north != tmpN) {
            // 中心マップファイル名
            var tmpFile = "";
            east = tmpE;
            west = tmpW;
            south = tmpS;
            north = tmpN;
            createMap (east, west, south, north, 1);
            upLayer ();
            // 余剰分のマップを削除
            var nodeLists = $("map").childNodes;
            for (i = nodeLists.length - 1; i >= 0; i--) {
                var nodeVal = nodeLists.item (i);
                if (nodeVal.attributes != null && nodeVal.nodeName == "DIV") {
                    // 近隣３エリア以外は削除
                    var tmp = nodeVal.attributes.getNamedItem ('id').nodeValue.split ("_");
                    if (tmp [6] <= east - 9 || east + 9 <= tmp [6]
                    || tmp [8] <= south - 9 || south + 9 <= tmp [8]) {
                        if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null)    $("map").removeChild (nodeVal);
                    }
                    // 縮尺と中心の違うマップは削除
                    if (nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_") == 0
                    && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_") < 0) {
                        if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null)    $("map").removeChild (nodeVal);
                    }
                }
            }
            // 全体図の矩形
            setWhole ();
            // 縮尺距離
            ruleChange ();
        }
    }
    startX = 0;
    startY = 0;
    moveX = 0;
    moveY = 0;
    dragFlag = false;
}


// ##################################################################################
// ドラッグアウト処理（マップ）
// ##################################################################################
dragObj.dragOut = function (event) {
    if (!dragFlag) return;  // ドラッグ中で無い場合は更新しない
    var target = "";
    if (window.createPopup) {
        //IE
        event = window.event;
        target = event.srcElement.id;
    } else {
        //その他
        target = event.target.id;
    }
    // 指定のレイヤの場合のみドラッグ終了処理
    if (target.indexOf ("scale") >= 0
    || target.indexOf ("whole") >= 0
    || target.indexOf ("switch") >= 0
    || target.indexOf ("pasco") >= 0) {
        dragObj.dragEnd (event);
    }
    return false;
}


// ##################################################################################
// ドラッグ中の処理（マップ）
// ==================================================================================
// event : イベントオブジェクト
// ##################################################################################
dragObj.dragProc = function (event) {
    if (!dragFlag) return;  // ドラッグ中で無い場合は更新しない
    if (zoomFlag) return;   // 縮尺変更中は更新しない
    var target = "";
    if (window.createPopup) {
        //IE
        target = event.srcElement.id;
    } else {
        //その他
        target = event.target.id;
    }

    // 縮尺と中心の違うマップは更新しない
    if (target.indexOf ("imgmap_" + lat + "_" + lon + "_" + scale + "_") != 0) {
        dragFlag = false;
        return;
    }
    var tempX = moveX;
    var tempY = moveY;
    if (window.createPopup) {
        // IE
        if (startX != 0
        || startY != 0) {
            // 移動地点を設定
            moveX = (Event.pointerX (event) - startX) * -1;  // 地図の座標とカーソルの移動座標の変化が逆転しているため正負を逆にする
            moveY = Event.pointerY (event) - startY;
        } else {
            // 開始地点を設定
            startX = Event.pointerX (event);
            startY = Event.pointerY (event);
        }
    } else {
        // その他
        if (startX != 0
        || startY != 0) {
            // 移動地点を設定
            moveX = (event.pageX - startX) * -1;            // 地図の座標とカーソルの移動座標の変化が逆転しているため正負を逆にする
            moveY = event.pageY - startY;
        } else {
            //開始地点を設定
            startX = event.pageX;
            startY = event.pageY;
        }
    }

    movement ((left + moveX) * -1, (top - moveY) * -1);
    // 移動したかどうか判定
    if (tempX != moveX || tempY != moveY) {
        moveFlag = true;
    }

    //IEの場合は移動時には読み込まないようにする
    var f = true;
    if (window.createPopup) {
        f = false;
    }
    if (dragFlag && moveFlag && f) {
        // 移動分を計算
        tmpE = parseInt (Math.abs ( (left + moveX) / width) + 0.5);      // 東移動
        tmpW = tmpE;                                                    // 西移動
        tmpS = parseInt (Math.abs ( (top + moveY) / height) + 0.5);      // 南移動
        tmpN = tmpS;                                                    // 北移動
        if ( (left + moveX) <= 0) {
            tmpE = tmpE * -1;
        } else {
            tmpW = tmpW * -1;
        }
        if ( (top + moveY) <= 0) {
            tmpS = tmpS * -1;
        } else {
            tmpN = tmpN * -1;
        }
        // マップファイル切り替え
        if (east != tmpE
        || west != tmpW
        || south != tmpS
        || north != tmpN) {
            if (areaE != tmpE
            || areaW != tmpW
            || areaS != tmpS
            || areaN != tmpN) {
                areaE = tmpE;
                areaW = tmpW;
                areaS = tmpS;
                areaN = tmpN;
                createMap (tmpE, tmpW, tmpS, tmpN, 2);
                //upLayer ();
                // 全体図の矩形
                //setWhole ();
            }
        }
    }

    // 枠外への移動時の処理
    if (moveFlag) {
        var offsetX = 0;
        var offsetY = 0;
        if (document.all) {
            // IE
            offsetX = event.offsetX;
            offsetY = event.offsetY;
        } else {
            // その他
            offsetX = event.layerX;
            offsetY = event.layerY;
        }
        var tmp = target.split ("_");
        var tmpX = 0;
        var tmpY = 0;
        if ( (tmp [6] < 0 && east < 0)
        || ( (tmp [6] > 0 && east > 0) ) ) {
            tmpX = Math.abs (east - tmp [6]);
        } else {
            tmpX = Math.abs (east) + Math.abs (tmp [6]);
        }
        if ( (tmp [8] < 0 && south < 0)
        || ( (tmp [8] > 0 && south > 0) ) ) {
            tmpY = Math.abs (south - tmp [8]);
        } else {
            tmpY = Math.abs (south) + Math.abs (tmp [8]);
        }
        tmpX *= tmp [6] <= east ? 1 : -1;
        tmpY *= tmp [8] <= south ? 1 : -1;
        var pointX = (Math.abs (tmpX - 1) * width) - (left - (east * width) ) + offsetX + (moveX * -1) - (around / 2);
        var pointY = (Math.abs (tmpY - 1) * height) - (top - (south * height) ) + offsetY + moveY - (around / 2);
        if (pointX <= 0 || pointY <= 0
        || pointX >= (width * 3) || pointY >= (height * 3) ) {
            dragObj.dragEnd (event);
            return false;
        }
        // スケールバー
        if (10 <= pointX && pointX <= 10 + 23
        && 10 <= pointY && pointY <= 10 + 19 + 18 + (18 * 9)) {
            dragObj.dragEnd (event);
            return false;
        }
        // パスコロゴ
        if (0 <= pointX && pointX <= 113
        && (height * 3) - 15 <= pointY && pointY <= (height * 3)) {
            dragObj.dragEnd (event);
            return false;
        }
        // パスコロゴ
        if (10 <= pointX && pointX <= 105
        && (height * 3) - 15 - 20 <= pointY && pointY <= (height * 3) - 20) {
            dragObj.dragEnd (event);
            return false;
        }
        // 全域図
        if (wholeFlag
        && (width * 3) - 138 <= pointX && pointX <= (width * 3)
        && (height * 3) - 100 <= pointY && pointY <= (height * 3)) {
            dragObj.dragEnd (event);
            return false;
        }
        // 全域図表示／非表示
        if (!wholeFlag
        && (width * 3) - 15 <= pointX && pointX <= (width * 3)
        && (height * 3) - 15 <= pointY && pointY <= (height * 3)) {
            dragObj.dragEnd (event);
            return false;
        }
    }

    return false;
}





// ##################################################################################
// ドラッグ開始処理（全域図）
// ##################################################################################
dragWhole.dragStart = function () {
    if (wholeActFlag) return;  // 全域図ドラック中は更新しない
    if (dragFlag) return;   // ドラック中は更新しない
    if (zoomFlag) return;   // 縮尺変更中は更新しない
    // マウスポインタ変更
    $("rect_whole").style.cursor = "move";
    whole_top = parseInt ($("area_whole").style.top);
    whole_left = parseInt ($("area_whole").style.left);
    startX = 0;
    startY = 0;
    moveX = 0;
    moveY = 0;
    dragFlag = true;
    wholeActFlag = true;
    return false;
}


// ##################################################################################
// ドラッグ終了処理（全域図）
// ##################################################################################
dragWhole.dragEnd = function () {
    if (!dragFlag) return;  // ドラッグ中で無い場合は更新しない
    if (!wholeActFlag) return;  // 全域図動作中で無い場合は更新しない
    // マウスポインタ変更
    $("rect_whole").style.cursor = "pointer";
    if (dragFlag && moveFlag) {
        // マップの各項目を設定
        var tmpLon = floor (137.04341863390334, 10);
        var tmpLat = floor (34.98532390804601, 10);
        var pixelX = floor (0.53963482573016 / parseFloat (138), 10);
        var pixelY = floor (0.304755240026874 / parseFloat (100), 10);
        // 中心座標を算出
        lat = floor (parseFloat (tmpLat) + (pixelY * parseFloat (100 - whole_top - parseInt ($("rect_whole").style.top) - (parseInt ($("area_whole").style.height) / 2) ) ), 10);
        lon = floor (parseFloat (tmpLon) + (pixelX * parseFloat (whole_left + parseInt ($("rect_whole").style.left) + (parseInt ($("area_whole").style.width) / 2) ) ), 10);
        startX = 0;
        startY = 0;
        moveX = 0;
        moveY = 0;
        east = 0;
        west = 0;
        south = 0;
        north = 0;
        top = 0;
        left = 0;
        //$("map").style.top = top + "px";
        //$("map").style.left = left + "px";
        // アイコンの位置を修正
        clearAllIcon ();
        //resetIcon ();
        // メニューを閉じる
        closeMenu ();
        // 再描画設定
        presetDraw ();
        // マップ画像削除
        deleteMap ();
        movement (left, top);
        createMap (east, west, south, north, 1);
    }
    whole_top = 0;
    whole_left = 0;
    startX = 0;
    startY = 0;
    moveX = 0;
    moveY = 0;
    dragFlag = false;
}


// ##################################################################################
// ドラッグアウト処理（全域図）
// ##################################################################################
dragWhole.dragOut = function (event) {
    if (!dragFlag) return;  // ドラッグ中で無い場合は更新しない
    if (!wholeActFlag) return;  // 全域図動作中で無い場合は更新しない
    var target = "";
    if (window.createPopup) {
        //IE
        event = window.event;
        target = event.srcElement.id;
    } else {
        //その他
        target = event.target.id;
    }
    // 指定のレイヤ以外の場合のみドラッグ終了処理
    if (target.indexOf ("whole") < 0) {
        dragWhole.dragEnd ();
    }
    return false;
}


// ##################################################################################
// ドラッグ中の処理（全域図）
// ==================================================================================
// event : イベントオブジェクト
// ##################################################################################
dragWhole.dragProc = function (event) {
    if (!wholeActFlag) return;  // 全域図動作中で無い場合は更新しない
    if (!dragFlag) return;  // ドラッグ中で無い場合は更新しない
    if (zoomFlag) return;   // 縮尺変更中は更新しない
    var target = "";
    if (window.createPopup) {
        //IE
        target = event.srcElement.id;
    } else {
        //その他
        target = event.target.id;
    }

    var tempX = moveX;
    var tempY = moveY;
    if (window.createPopup) {
        // IE
        if (startX != 0
        || startY != 0) {
            // 移動地点を設定
            moveX = (Event.pointerX (event) - startX) * -1;  // 地図の座標とカーソルの移動座標の変化が逆転しているため正負を逆にする
            moveY = Event.pointerY (event) - startY;
        } else {
            // 開始地点を設定
            startX = Event.pointerX (event);
            startY = Event.pointerY (event);
        }
    } else {
        // その他
        if (startX != 0
        || startY != 0) {
            // 移動地点を設定
            moveX = (event.pageX - startX) * -1;            // 地図の座標とカーソルの移動座標の変化が逆転しているため正負を逆にする
            moveY = event.pageY - startY;
        } else {
            //開始地点を設定
            startX = event.pageX;
            startY = event.pageY;
        }
    }
    // 移動したかどうか判定
    if (tempX != moveX || tempY != moveY) {
        moveFlag = true;
    }
    $("rect_whole").style.top = (-moveY) * -1 + "px";
    $("rect_whole").style.left = (moveX) * -1 + "px";

    // 枠外への移動時の処理
    if (moveFlag) {
        var pointX = parseInt ($("area_whole").style.left) + (moveX * -1);
        var pointY = parseInt ($("area_whole").style.top) + moveY;
        if (pointX <= -1 || pointY <= -1
        || (moveX != 0 && (pointX + parseInt ($("area_whole").style.width) ) >= 138)
        || (moveY != 0 && (pointY + parseInt ($("area_whole").style.height) ) >= 100) ) {
            dragWhole.dragEnd ();
            return false;
        }
        // 全域図表示／非表示
        if (138 - 15 <= (pointX + parseInt ($("area_whole").style.width) ) && (pointX + parseInt ($("area_whole").style.width) ) <= 138
        && 100 - 15 <= (pointY + parseInt ($("area_whole").style.height) ) && (pointY + parseInt ($("area_whole").style.height) ) <= 100) {
            dragWhole.dragEnd ();
            return false;
        }
    }

    return false;
}

// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// ドラッグの操作
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// ##################################################################################
// ##################################################################################
// ##################################################################################
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// マップの操作
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// ##################################################################################
// マップを開く
// ==================================================================================
// w : マップの幅
// h : マップの高さ
// s : マップの縮尺
// x : マップの表示座標
// y : マップの表示座標
// ##################################################################################
function openMap (w, h, s, x, y) {
    openMap (w, h, s, x, y, -1)
}


// ##################################################################################
// マップを開く
// ==================================================================================
// w : マップの幅
// h : マップの高さ
// s : マップの縮尺
// x : マップの表示座標
// y : マップの表示座標
// no : 表示したい吹き出し番号（0より小さい場合何もしない）
// ##################################################################################
function openMap (w, h, s, x, y, no) {
    $("panelMap").oncontextmenu = nonRightClick;
    openFlag = true;
    width = w / 3;
    height = h / 3;
    scale = s;
    lon = floor (x, 10);
    lat = floor (y, 10);
    startX = 0;
    startY = 0;
    moveX = 0;
    moveY = 0;
    east = 0;
    west = 0;
    south = 0;
    north = 0;
    top = 0;
    left = 0;
    movement (left, top);
    deleteMap ();
    clearAllIcon ();
    closeMenu ();
    presetDraw ();
    zoomBar ();
    createMap (0, 0, 0, 0, 1, no);

    $("map").onmousedown = dragObj.dragStart;
    $("map").onmouseup = dragObj.dragEnd;
    //$("map").onmouseout = dragObj.dragEnd;
    //$("map").onmouseout = dragObj.dragOut;
    Event.observe ("map", "mousemove", dragObj.dragProc, false);
}


// ##################################################################################
// マップの作成と表示
// ==================================================================================
// e : 東
// w : 西
// s : 南
// n : 北
// c : 範囲
// ##################################################################################
function createMap (e, w, s, n, c) {
    createMap (e, w, s, n, c, -1);
}


// ##################################################################################
// マップの作成と表示
// ==================================================================================
// e : 東
// w : 西
// s : 南
// n : 北
// c : 範囲
// no : 表示したい吹き出し番号（0より小さい場合何もしない）
// ##################################################################################
function createMap (e, w, s, n, c, no) {
    // マップファイル移動を検出
    var flag = openFlag;    // 表示開始時はtrue
    if ($("map_" + lat + "_" + lon + "_" + scale + "_" + width + "_" + height + "_" + e + "_" + w + "_" + s + "_" + n + "_") == null)  flag = true;
    for (var ns = 0; !flag && ns <= 4; ns++) {
        for (var ew = 0; !flag && ew <= 4; ew++) {
            // 中心は作成済み
            if (ns == 0 && ew == 0) {
                continue;
            }
            if (ew == 0) {
                if ($("map_" + lat + "_" + lon + "_" + scale + "_" + width + "_" + height + "_" + e + "_" + w + "_" + (s - ns) + "_" + (n + ns) + "_") == null)    flag = true;
                if ($("map_" + lat + "_" + lon + "_" + scale + "_" + width + "_" + height + "_" + e + "_" + w + "_" + (s + ns) + "_" + (n - ns) + "_") == null)    flag = true;
            } else if (ns == 0) {
                if ($("map_" + lat + "_" + lon + "_" + scale + "_" + width + "_" + height + "_" + (e + ew) + "_" + (w - ew) + "_" + s + "_" + n + "_") == null)    flag = true;
                if ($("map_" + lat + "_" + lon + "_" + scale + "_" + width + "_" + height + "_" + (e - ew) + "_" + (w + ew) + "_" + s + "_" + n + "_") == null)    flag = true;
            } else {
                if ($("map_" + lat + "_" + lon + "_" + scale + "_" + width + "_" + height + "_" + (e + ew) + "_" + (w - ew) + "_" + (s + ns) + "_" + (n - ns) + "_") == null)  flag = true;
                if ($("map_" + lat + "_" + lon + "_" + scale + "_" + width + "_" + height + "_" + (e - ew) + "_" + (w + ew) + "_" + (s + ns) + "_" + (n - ns) + "_") == null)  flag = true;
                if ($("map_" + lat + "_" + lon + "_" + scale + "_" + width + "_" + height + "_" + (e + ew) + "_" + (w - ew) + "_" + (s - ns) + "_" + (n + ns) + "_") == null)  flag = true;
                if ($("map_" + lat + "_" + lon + "_" + scale + "_" + width + "_" + height + "_" + (e - ew) + "_" + (w + ew) + "_" + (s - ns) + "_" + (n + ns) + "_") == null)  flag = true;
            }
        }
    }

    // マップの読み込みが発生した場合のみ作成用Ajaxを呼び出す
    if (flag) {
        var url = "/maps/MapCreate?"
                + "initlat=" + lat
                + "&initlon=" + lon
                + "&mps=" + scale
                + "&mpw=" + width
                + "&mph=" + height
                + "&bar=0"
                + "&e=" + e
                + "&w=" + w
                + "&s=" + s
                + "&n=" + n
                + "&cnt=" + c
                + "&no=" + no
                + "&cache=" + (new Date () ).getTime ();
        var tmpNo = no;
        // マップファイル作成
        new Ajax.Request (url, { method: "get", onComplete: function (returnObj) {
            var res = returnObj.responseText.split ("+");

            // 縮尺が違う場合は更新しない
            if (res.length > 1) {
                var tmp = res [1].replace (".png", "").split ("_");
                if (tmp [2] != scale) {
                    return false;
                }
            }

            // マップファイル表示
            for (var i = 1; i < res.length; i++) {
                var tmp = res [i].replace (".png", "").split ("_");
                var area = "map_" + tmp [0] + "_" + tmp [1] + "_" + tmp [2] + "_" + tmp [3] + "_" + tmp [4] + "_" + tmp [5] + "_" + tmp [6] + "_" + tmp [7] + "_" + tmp [8] + "_";
                setMap (res [i], area, res [0]);

                // 周辺を表示
                if (i == 1
                && tmp [2] == scale) {
                    if (c == 1) {
                        // 全体図の矩形
                        setWhole ();
                        // 縮尺距離
                        ruleChange ();
                        // 表示開始終了
                        openFlag = false;
                        // 再描画設定
                        presetDraw ();
                        // 再描画
                        resetDraw ();
                    }
                    if (c < 2) {
                        createMap (e, w, s, n, c + 1);
                    }
                }
            }
            // 縮尺変更終了
            if (tmp [2] == scale) {
                zoomFlag = false;
            }
            // 全域図動作終了
            if (c == 1) {
                wholeActFlag = false;
            }

        }});

    }

}


// ##################################################################################
// マップの作成と表示 (再実行)
// ==================================================================================
// file : ファイル名
// area : マップ表示領域ID
// ##################################################################################
function createMapAgain (file, area) {
    var tmp = area.split ("_");
    var url = "/maps/MapCreateAgain?"
            + "initlat=" + lat
            + "&initlon=" + lon
            + "&mps=" + scale
            + "&mpw=" + width
            + "&mph=" + height
            + "&bar=0"
            + "&e=" + tmp [4]
            + "&w=" + tmp [5]
            + "&s=" + tmp [6]
            + "&n=" + tmp [7]
            + "&fn=" + file
            + "&area=" + area
            + "&cache=" + (new Date () ).getTime ();
    // マップファイル作成
    new Ajax.Request (url, { method: "get", onComplete: function (returnObj) {
        var res = returnObj.responseText.split ("+");
        // マップ
        setMap (res [0], res [1]);
    }});
}


// ##################################################################################
// マップファイルを取得する
// ==================================================================================
// file : ファイル名
// area : マップ表示領域ID
// ##################################################################################
function setMap (file, area) {
    setMap (file, area, -1);
}

// ##################################################################################
// マップファイルを取得する
// ==================================================================================
// file : ファイル名
// area : マップ表示領域ID
// no : 表示したい吹き出し番号（0より小さい場合何もしない）
// ##################################################################################
function setMap (file, area, no) {
    // 既に表示されている場合と縮尺が違う場合はなにもしない
    if (openFlag
    || ($(area) == null
    && area.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_" + width + "_" + height + "_") >= 0) ) {
        var tmp = file.replace (".png", "").split ("_");
        var mapUrl = "http://www2.wagamachi-guide.com/getmapimage/getmapimage.asp"
                   + "?mpw=" + (parseInt (tmp [3]) + around)
                   + "&amp;mph=" + (parseInt (tmp [4]) + around)
                   + "&amp;mpy=" + tmp [9]
                   + "&amp;mpx=" + tmp [10]
                   + "&amp;mps=" + tmp [2]
                   + "&amp;bar=" + 0
                   + "&amp;ity=" + 2
                   + "&amp;cri=" + 0;
        var element = document.createElement ('div');
        element.id = area;
        element.style.top = (tmp [7] * height) + height + "px";
        element.style.left = (tmp [5] * width) + width + "px";
        element.style.width = width + "px";
        element.style.height = height + "px";
        element.style.position = "absolute";
        element.style.overflow = "hidden";
        element.innerHTML = "<img id=\"img" + area + "\" name=\"" + file + "\" src=\"" + mapUrl + "\" style=\"top: -" + (around / 2) + "px; left: -" + (around / 2) + "px; position: absolute\">";
        $("map").appendChild (element);
        // アイコンを表示
        setIcon (file, no);
    }
}


// ##################################################################################
// 全マップファイルを削除する
// ##################################################################################
function deleteMap () {
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        if (nodeVal.attributes != null
        && nodeVal.nodeName == "DIV"
        && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_") == 0) {
            if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null)    $("map").removeChild (nodeVal);
        }
    }
}


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// マップの操作
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// ##################################################################################
// ##################################################################################
// ##################################################################################
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// 表示の操作
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// ##################################################################################
// 指定した座標に移動
//
// ==================================================================================
// t : 初期top
// l : 初期left
// x : 移動量（left）
// y : 移動量（top）
// end : 終了条件
// ##################################################################################
function movement (x, y) {
    $("map").style.top = y + "px";
    $("map").style.left = x + "px";
}


// ##################################################################################
// クリックしたアイコンを中心になるように移動
// ==================================================================================
// no : アイコンの表示番号（添字）
// ##################################################################################
function iconCenter (no) {
    var tmpTop = top;
    var tmpLeft = left;
    top = parseInt ($("icon" + no).style.top) + (iconHeight [no] / 2) - height - (height / 2);
    left = parseInt ($("icon" + no).style.left) + (iconWidth [no] / 2) - width - (width / 2);

    var splitX = 0;
    var splitY = 0;
    if ( (tmpTop < 0 && top < 0)
    || ( (tmpTop > 0 && top > 0) ) ) {
        splitY = Math.abs (top - tmpTop);
    } else {
        splitY = Math.abs (top) + Math.abs (tmpTop);
    }
    if ( (tmpLeft < 0 && left < 0)
    || ( (tmpLeft > 0 && left > 0) ) ) {
        splitX = Math.abs (left - tmpLeft);
    } else {
        splitX = Math.abs (left) + Math.abs (tmpLeft);
    }
    splitX *= tmpLeft <= left ? 1 : -1;
    splitY *= tmpTop <= top ? 1 : -1;
    splitX /= 10;
    splitY /= 10;
    for (var i = 0; i < 10; i++) {
        tmpTop += splitY;
        tmpLeft += splitX;
        setTimeout ("movement(" + parseInt (tmpLeft * -1) + ", " + parseInt (tmpTop * -1) + ")", 50 * i);
    }
    setTimeout ("movement(" + (left * -1) + ", " + (top * -1) + ")", 500);

    // 移動分を計算
    tmpE = parseInt (Math.abs (left / width) + 0.5);      // 東移動
    tmpW = tmpE;                                          // 西移動
    tmpS = parseInt (Math.abs (top / height) + 0.5);      // 南移動
    tmpN = tmpS;                                          // 北移動
    if (left <= 0) {
        tmpE = tmpE * -1;
    } else {
        tmpW = tmpW * -1;
    }
    if (top <= 0) {
        tmpS = tmpS * -1;
    } else {
        tmpN = tmpN * -1;
    }
    // マップファイル切り替え
    if (east != tmpE
    || west != tmpW
    || south != tmpS
    || north != tmpN) {
        // 中心マップファイル名
        var tmpFile = "";
        east = tmpE;
        west = tmpW;
        south = tmpS;
        north = tmpN;
        createMap (east, west, south, north, 1);
        upLayer ();
        // 余剰分のマップを削除
        var nodeLists = $("map").childNodes;
        for (i = nodeLists.length - 1; i >= 0; i--) {
            var nodeVal = nodeLists.item (i);
            if (nodeVal.attributes != null && nodeVal.nodeName == "DIV") {
                // 近隣３エリア以外は削除
                var tmp = nodeVal.attributes.getNamedItem ('id').nodeValue.split ("_");
                if (tmp [6] <= east - 9 || east + 9 <= tmp [6]
                || tmp [8] <= south - 9 || south + 9 <= tmp [8]) {
                    if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null)    $("map").removeChild (nodeVal);
                }
                // 縮尺と中心の違うマップは削除
                if (nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_") == 0
                && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_") < 0) {
                    if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null)    $("map").removeChild (nodeVal);
                }
            }
        }
        // 全体図の矩形
        setWhole ();
        // 縮尺距離
        ruleChange ();
    }
}


// ##################################################################################
// クリック地点に移動
// ==================================================================================
// event : イベントオブジェクト
// ##################################################################################
function clickCenter (event) {
    if (moveFlag) return; // ドラックした場合はなにもしない
    var target = "";
    if (window.createPopup) {
        //IE
        target = event.srcElement.id;
    } else {
        //その他
        target = event.target.id;
    }
    if (target.indexOf ("imgmap_") < 0) return;        // マップ画像が表示されていない場合はなにもしない
    if (document.all) {
        //IE
        clickX = event.offsetX;
        clickY = event.offsetY;
    } else {
        //その他
        clickX = event.layerX;
        clickY = event.layerY;
    }
    var tmp = target.split ("_");

    var tmpTop = top;
    var tmpLeft = left;
    top = (tmp [8] * height) + clickY - (height / 2);
    left = (tmp [6] * width) + clickX - (width / 2);

    var splitX = 0;
    var splitY = 0;
    if ( (tmpTop < 0 && top < 0)
    || ( (tmpTop > 0 && top > 0) ) ) {
        splitY = Math.abs (top - tmpTop);
    } else {
        splitY = Math.abs (top) + Math.abs (tmpTop);
    }
    if ( (tmpLeft < 0 && left < 0)
    || ( (tmpLeft > 0 && left > 0) ) ) {
        splitX = Math.abs (left - tmpLeft);
    } else {
        splitX = Math.abs (left) + Math.abs (tmpLeft);
    }
    splitX *= tmpLeft <= left ? 1 : -1;
    splitY *= tmpTop <= top ? 1 : -1;
    splitX /= 10;
    splitY /= 10;
    for (var i = 0; i < 10; i++) {
        tmpTop += splitY;
        tmpLeft += splitX;
        setTimeout ("movement(" + parseInt (tmpLeft * -1) + ", " + parseInt (tmpTop * -1) + ")", 50 * i);
    }
    setTimeout ("movement(" + (left * -1) + ", " + (top * -1) + ")", 500);

    // 移動分を計算
    tmpE = parseInt (Math.abs (left / width) + 0.5);      // 東移動
    tmpW = tmpE;                                          // 西移動
    tmpS = parseInt (Math.abs (top / height) + 0.5);      // 南移動
    tmpN = tmpS;                                          // 北移動
    if (left <= 0) {
        tmpE = tmpE * -1;
    } else {
        tmpW = tmpW * -1;
    }
    if (top <= 0) {
        tmpS = tmpS * -1;
    } else {
        tmpN = tmpN * -1;
    }
    // マップファイル切り替え
    if (east != tmpE
    || west != tmpW
    || south != tmpS
    || north != tmpN) {
        // 中心マップファイル名
        var tmpFile = "";
        east = tmpE;
        west = tmpW;
        south = tmpS;
        north = tmpN;
        createMap (east, west, south, north, 1);
        upLayer ();
        // 余剰分のマップを削除
        var nodeLists = $("map").childNodes;
        for (i = nodeLists.length - 1; i >= 0; i--) {
            var nodeVal = nodeLists.item (i);
            if (nodeVal.attributes != null && nodeVal.nodeName == "DIV") {
                // 近隣３エリア以外は削除
                var tmp = nodeVal.attributes.getNamedItem ('id').nodeValue.split ("_");
                if (tmp [6] <= east - 9 || east + 9 <= tmp [6]
                || tmp [8] <= south - 9 || south + 9 <= tmp [8]) {
                    if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null)    $("map").removeChild (nodeVal);
                }
                // 縮尺と中心の違うマップは削除
                if (nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_") == 0
                && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_") < 0) {
                    if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null)    $("map").removeChild (nodeVal);
                }
            }
        }
        // 全体図の矩形
        setWhole ();
        // 縮尺距離
        ruleChange ();
    }
}


// ##################################################################################
// クリック地点に移動
// （移動時に拡大）
// ==================================================================================
// event : イベントオブジェクト
// ##################################################################################
function clickZoom (event) {
    var size = scale;
    for (var i = zoomList.length - 2; i >= 0; i--) {
        if (zoomList [i] == scale) {
            size = zoomList [i + 1];
            break;
        }
    }
    if (scale == size) {
        clickCenter (event);
        return;
    }
    var target = "";
    if (window.createPopup) {
        //IE
        target = event.srcElement.id;
    } else {
        //その他
        target = event.target.id;
    }
    if (target.indexOf ("imgmap_") < 0) return;        // マップ画像が表示されていない場合はなにもしない
    if (document.all) {
        //IE
        clickX = event.offsetX;
        clickY = event.offsetY;
    } else {
        //その他
        clickX = event.layerX;
        clickY = event.layerY;
    }
    var tmp = target.split ("_");
    var tmpX = 0;
    var tmpY = 0;
    if ( (tmp [6] < 0 && east < 0)
    || ( (tmp [6] > 0 && east > 0) ) ) {
        tmpX = Math.abs (east - tmp [6]);
    } else {
        tmpX = Math.abs (east) + Math.abs (tmp [6]);
    }
    if ( (tmp [8] < 0 && south < 0)
    || ( (tmp [8] > 0 && south > 0) ) ) {
        tmpY = Math.abs (south - tmp [8]);
    } else {
        tmpY = Math.abs (south) + Math.abs (tmp [8]);
    }
    tmpX *= tmp [6] <= east ? 1 : -1;
    tmpY *= tmp [8] <= south ? 1 : -1;
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        // マップ画像を検出
        if (nodeVal.attributes != null
        && nodeVal.nodeName == "DIV"
        && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_") == 0) {
            if (nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_") == 0) {
                var tmp = nodeVal.attributes.getNamedItem ('id').nodeValue.split ("_");
                $(nodeVal.attributes.getNamedItem ('id').nodeValue).style.top = (tmp [8] * height + height) - clickY + (height / 2) + (height * tmpY) + "px";
                $(nodeVal.attributes.getNamedItem ('id').nodeValue).style.left = (tmp [6] * width + width) - clickX + (width / 2) + (width * tmpX) + "px";
            } else {
                if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null)    $("map").removeChild ($(nodeVal.attributes.getNamedItem ('id').nodeValue) );
            }
        }
    }
    var tmp = target.split ("_");
    top = (tmp [8] * height) + clickY - (height / 2);
    left = (tmp [6] * width) + clickX - (width / 2);
    zoomChange (size);
}


// ##################################################################################
// 拡大縮小
// ==================================================================================
// size : 縮尺
// ##################################################################################
function zoomChange (size) {
    if (zoomFlag) return;                       // 縮尺変更中はなにもしない
    // 中心マップを検出
    var target = "";
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        // マップ画像を検出
        if (nodeVal.attributes != null
        && nodeVal.nodeName == "DIV"
        && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_") == 0) {
            if (nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_") == 0
            && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("_" + width + "_" + height + "_" + east + "_" + west + "_" + south + "_" + north + "_") > 0) {
                target = nodeVal.attributes.getNamedItem ('id').nodeValue;
                break;
            }
        }
    }
    if (target.length == 0 || $(target) == null) return;     // 中心マップが無い場合はなにもしない
    zoomFlag = true;
    // 表示中の縮尺のサイズを変更して擬似的に縮尺を変更する（マップ画像が読み込まれるまでの間に合わせ）
    var ratio = scale / size;
    var rX = (width - (width * ratio) ) / 2;
    var rY = (height - (height * ratio) ) / 2;
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        if (nodeVal.attributes != null
        && nodeVal.nodeName == "DIV"
        && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_") == 0) {
            // 縮尺の違うマップ画像は削除（中心座標計算に必要なマップ画像以外）
            if (nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_") != 0) {
                if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null && $(nodeVal.attributes.getNamedItem ('id').nodeValue) != target)    $("map").removeChild (nodeVal);
                continue;
            }
            // 近隣１エリア対象
            var tmp = nodeVal.attributes.getNamedItem ('id').nodeValue.split ("_");
            var range = 3;
            if (east - range <= tmp [6] && tmp [6] <= east + range
            && south - range <= tmp [8] && tmp [8] <= south + range) {
                var tmpX = 0;
                var tmpY = 0;
                if ( (tmp [6] < 0 && east < 0)
                || ( (tmp [6] > 0 && east > 0) ) ) {
                    tmpX = Math.abs (east - tmp [6]);
                } else {
                    tmpX = Math.abs (east) + Math.abs (tmp [6]);
                }
                if ( (tmp [8] < 0 && south < 0)
                || ( (tmp [8] > 0 && south > 0) ) ) {
                    tmpY = Math.abs (south - tmp [8]);
                } else {
                    tmpY = Math.abs (south) + Math.abs (tmp [8]);
                }

                var valueX = rX;
                valueX -= left * ratio;
                valueX += tmpX * width * ratio * (tmp [6] <= east ? -1 : 1);
                valueX += width * ratio * east;
                valueX += width;
                // 中心点が移動した時
                $(nodeVal.attributes.getNamedItem ('id').nodeValue).style.left = parseInt (valueX) + "px";
                var valueY = rY;
                valueY -= top * ratio;
                valueY += tmpY * height * ratio * (tmp [8] <= south ? -1 : 1);
                valueY += height * ratio * south;
                valueY += height;
                // 中心点が移動した時
                $(nodeVal.attributes.getNamedItem ('id').nodeValue).style.top = parseInt (valueY) + "px";

                $(nodeVal.attributes.getNamedItem ('id').nodeValue).style.width = parseInt (width * ratio + (around / 2) * ratio) + "px";
                $(nodeVal.attributes.getNamedItem ('id').nodeValue).style.height = parseInt (height * ratio + (around / 2) * ratio) + "px";

                if ($("img" + nodeVal.attributes.getNamedItem ('id').nodeValue) != null) {
                    $("img" + nodeVal.attributes.getNamedItem ('id').nodeValue).style.top = parseInt ((around / 2) * ratio * -1) + "px";
                    $("img" + nodeVal.attributes.getNamedItem ('id').nodeValue).style.left = parseInt ((around / 2) * ratio * -1) + "px";
                    $("img" + nodeVal.attributes.getNamedItem ('id').nodeValue).style.width = (parseInt (width * ratio) + parseInt (around * ratio)) + "px";
                    $("img" + nodeVal.attributes.getNamedItem ('id').nodeValue).style.height = (parseInt (height * ratio) + parseInt (around * ratio)) + "px";
                }

            } else {
                if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null)    $("map").removeChild (nodeVal);
                continue;
            }
        }
    }
    // 中心座標を算出
    scale = size;
    if ($(target) == null) return;     // 中心マップが無い場合はなにもしない
    var nodeLists = $(target).childNodes;
    //var nodeLists = $("map_" + lat + "_" + lon + "_" + scale + "_" + width + "_" + height + "_" + east + "_" + west + "_" + south + "_" + north + "_").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        if (nodeVal.attributes != null && nodeVal.nodeName == "IMG") {
            var file = nodeVal.attributes.getNamedItem ('name').nodeValue;

            var tmp = file.substring (file.lastIndexOf ("/") + 1, file.length).replace (".png", "").split ("_");
            var tmpLon = floor (parseFloat (tmp [10]) - (tmp [12] / 2.0), 10);
            var tmpLat = floor (parseFloat (tmp [9]) + (tmp [11] / 2.0), 10);
            var pixelX = floor (parseFloat (tmp [12]) / parseFloat (width), 10);
            var pixelY = floor (parseFloat (tmp [11]) / parseFloat (height), 10);
            var tmpTop = Math.abs (tmp [8] * height) - Math.abs (top);
            var tmpLeft = Math.abs (tmp [5] * width) - Math.abs (left);
            tmpTop = top <= 0 ? tmpTop : tmpTop * -1;
            tmpLeft = left <= 0 ? tmpLeft : tmpLeft * -1;
            // 中心座標を算出
            lat = floor (parseFloat (tmpLat) - (pixelY * parseFloat (tmpTop + (height / 2) ) ), 10);
            lon = floor (parseFloat (tmpLon) + (pixelX * parseFloat (tmpLeft + (width / 2) ) ), 10);
        }
    }
    startX = 0;
    startY = 0;
    moveX = 0;
    moveY = 0;
    east = 0;
    west = 0;
    south = 0;
    north = 0;
    top = 0;
    left = 0;
    movement (left, top);
    // アイコンの位置を修正
    clearAllIcon ();
    // メニューを閉じる
    closeMenu ();
    // 再描画設定
    presetDraw ();
    createMap (east, west, south, north, 1);
    zoomBar ();
    //zoomFlag = false;
}


// ##################################################################################
// 縮尺拡大
// ##################################################################################
function zoomPlus () {
    var size = 0;
    for (var i = zoomList.length - 2; i >= 0; i--) {
        if (zoomList [i] == scale) {
            size = zoomList [i + 1];
            break;
        }
    }
    if (size > 0) {
        zoomChange (size);
    }
}


// ##################################################################################
// 縮尺縮小
// ##################################################################################
function zoomMinus () {
    var size = 0;
    for (var i = 1; i < zoomList.length; i++) {
        if (zoomList [i] == scale) {
            size = zoomList [i - 1];
            break;
        }
    }
    if (size > 0) {
        zoomChange (size);
    }
}


// ##################################################################################
// 縮尺バー表示設定
// ##################################################################################
function zoomBar () {
    for (var i = 0; i < zoomList.length; i++) {
        if (zoomList [i] == scale) {
            $("scale" + zoomList [i]).src = "/maps/img/scaler_handle.gif";
        } else {
            $("scale" + zoomList [i]).src = "/maps/img/scaler_base.gif";
        }
    }
}


// ##################################################################################
// 縮尺距離表示設定
// ##################################################################################
function ruleChange () {
    if ($("rule") == null) return;
    for (var i = 0; i < zoomList.length; i++) {
        if (zoomList [i] == scale) {
            $("rule").innerHTML = zoomRule [i];
        }
    }

    // 以下は可変用
/*
    // 中心マップを検出
    var target = "";
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        // マップ画像を検出
        if (nodeVal.attributes != null
        && nodeVal.nodeName == "DIV"
        && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_") == 0) {
            if (nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_") == 0
            && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("_" + width + "_" + height + "_" + east + "_" + west + "_" + south + "_" + north + "_") > 0) {
                target = nodeVal.attributes.getNamedItem ('id').nodeValue;
                break;
            }
        }
    }
    if (target.length == 0 || $(target) == null) return;     // 中心マップが無い場合はなにもしない
    var nodeLists = $(target).childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        if (nodeVal.attributes != null && nodeVal.nodeName == "IMG") {
            var file = nodeVal.attributes.getNamedItem ('name').nodeValue;
            var tmp = file.substring (file.lastIndexOf ("/") + 1, file.length).replace (".png", "").split ("_");
            var pixelX = floor ( ( parseFloat (tmp [12]) / parseFloat (width) ) * 3600 * 1000 / 45, 10);
            //var pixelY = floor ( ( parseFloat (tmp [11]) / parseFloat (height) ) * 3600 / 30, 10);
            $("rule").innerHTML = floor ( pixelX * 90, 1) + " m";
            //$("rule").style.width = "90px";
        }
    }
*/
}


// ##################################################################################
// 下になってはいけないレイヤを上に移動させる
// （アイコン・吹き出し・縮尺バー・描画系など）
// ##################################################################################
function upLayer () {
    var max = $("map").childNodes.length;
    if ($("pasco") != null) {
        $("pasco").style.zIndex = max + 1;
    }
    if ($("rule") != null) {
        $("rule").style.zIndex = max + 1;
    }
    if ($("workmenue") != null) {
        $("workmenue").style.zIndex = max + 1;
    }
    if ($("scale") != null) {
        $("scale").style.zIndex = max + 1;
    }
    if ($("whole") != null) {
        if (wholeFlag) {
            $("whole").style.zIndex = max + 1;
        } else {
            $("whole").style.zIndex = 0;
        }
    }
    if ($("switch") != null) {
        $("switch").style.zIndex = max + 1;
    }
    if ($("line") != null) {
        $("line").style.zIndex = max - 2;
    }
    if ($("ellipse") != null) {
        $("ellipse").style.zIndex = max - 2;
    }
    if ($("fillellipse") != null) {
        $("fillellipse").style.zIndex = max - 2;
    }
    if ($("polyline") != null) {
        $("polyline").style.zIndex = max - 2;
    }
    if ($("rect") != null) {
        $("rect").style.zIndex = max - 2;
    }
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        if (nodeVal.attributes != null && nodeVal.nodeName == "DIV") {
            if (nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("icon") >= 0) {
                $(nodeVal.attributes.getNamedItem ('id').nodeValue).style.zIndex = max - 1;
            }
            if (nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("balloon") >= 0) {
                $(nodeVal.attributes.getNamedItem ('id').nodeValue).style.zIndex = max;
            }
        }
    }
}


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// 表示の操作
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// ##################################################################################
// ##################################################################################
// ##################################################################################
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// 全域図の操作
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// ##################################################################################
// 矩形を表示（全域図）
// ##################################################################################
function setWhole () {

    // マップの各項目を設定
    var tmpLon = floor (137.04341863390334, 10);
    var tmpLat = floor (34.98532390804601, 10);
    var pixelX = floor (0.53963482573016 / parseFloat (138), 10);
    var pixelY = floor (0.304755240026874 / parseFloat (100), 10);
    var border = 2;
    // 矩形の幅と高さを調べる
    var file = "";
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        // マップ画像を検出
        if (nodeVal.attributes != null
        && nodeVal.nodeName == "DIV"
        && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_" + width + "_" + height + "_" + east + "_" + west + "_" + south + "_" + north + "_") == 0) {
            // マップのファイル名を取得
            var nodeLists2 = $(nodeVal.attributes.getNamedItem ('id').nodeValue).childNodes;
            for (j = 0; j < nodeLists2.length; j++) {
                var nodeVal2 = nodeLists2.item (j);
                if (nodeVal2.attributes != null
                && nodeVal2.nodeName == "IMG"
                && nodeVal2.attributes.getNamedItem ('id').nodeValue.indexOf ("img") >= 0
                && nodeVal2.attributes.getNamedItem ('name').nodeValue.length > 0) {
                    file = nodeVal2.attributes.getNamedItem ('name').nodeValue;
                }
            }
        }
        if (file.length > 0) break;
    }
    if (file.length == 0) return;   // 中心ファイルが作成されていない場合は処理をしない

    // 削除
    clearWhole ();

    var tmp = file.substring (file.lastIndexOf ("/") + 1, file.length).replace (".png", "").split ("_");
    var w = parseInt ( (tmp [12] * 3) / pixelX + 0.5);
    var h = parseInt ( (tmp [11] * 3) / pixelY + 0.5);
    var x = floor (parseFloat (tmp [10]), 10);
    var y = floor (parseFloat (tmp [9]), 10);
    // 位置座標を測定
    var pointX = (x - tmpLon) / pixelX;
    var pointY = 100 - ( (y - tmpLat) / pixelY);
    // 矩形の幅と高さを考慮
    pointX -= w / 2;
    pointY -= h / 2;
    // ライン幅を考慮
    pointX -= border / 2;
    pointY -= border / 2;
    if (pointX < 0) {
        w += pointX;
        pointX = 0;
    }
    if (pointY < 0) {
        h += pointY;
        pointY = 0;
    }
    // 枠内に入るよう微調整
    w = pointX <= 138 - w - border ? w : 138 - pointX;
    h = pointY <= 100 - h - border ? h : 100 - pointY;
    w = w >= 5 ? w : 5;
    h = h >= 5 ? h : 5;
    pointX = pointX < 138 - w - border ? pointX : 138 - w - border;
    pointY = pointY < 100 - h - border ? pointY : 100 - h - border;
    // 矩形表示用領域作成
    if ($("rect_whole") == null) {
        var element = document.createElement ('div');
        element.id = "rect_whole";
        element.style.left = "0px";
        element.style.top = "0px";
        element.style.position = "absolute";
        element.style.zIndex = $("whole").childNodes.length;
        $("whole").appendChild (element);

        $("rect_whole").onmousedown = dragWhole.dragStart;
        $("rect_whole").onmouseup = dragWhole.dragEnd;
        $("rect_whole").onmouseout = dragWhole.dragEnd;
        //$("rect_whole").onmouseout = dragWhole.dragOut;
        Event.observe ("rect_whole", "mousemove", dragWhole.dragProc, false);
        //upLayer ();
    }
    // 矩形を描画
    var jg = new jsGraphics ("rect_whole");    // 矩形等記入用
    jg.setColor ("#ff0000");
    jg.setStroke (border);
    jg.drawRect (parseInt (pointX + 0.5), parseInt (pointY + 0.5), w, h);
    jg.paint ();
    $("rect_whole").innerHTML += "<img id=\"area_whole\" src=\"/maps/img/rect_whole.gif\" style=\"width: " + parseInt (w + border) + "px; height: " + parseInt (h + border) + "px; top: " + parseInt (pointY + 0.5) + "px; left: " + parseInt (pointX + 0.5) + "px; position:absolute; filter:Alpha(opacity=20); -moz-opacity:0.2; opacity:0.20\">";
}


// ##################################################################################
// 矩形を削除（全域図）
// ##################################################################################
function clearWhole () {
    if ($("rect_whole") != null)    $("whole").removeChild ($("rect_whole") );
    if ($("area_whole") != null)    $("rect_whole").removeChild ($("area_whole") );
}


// ##################################################################################
// クリック地点に移動（全域図）
// ==================================================================================
// event : イベントオブジェクト
// ##################################################################################
function clickWhole (event) {
    if (wholeActFlag) return;  // 全域図ドラック中は更新しない
    var target = "";
    if (window.createPopup) {
        //IE
        target = event.srcElement.id;
    } else {
        //その他
        target = event.target.id;
    }
    if (target != "img_whole") return;
    wholeActFlag = true;
    var x = 0;
    var y = 0;
    if (document.all) {
        //IE
        x = event.offsetX;
        y = event.offsetY;
    } else {
        //その他
        x = event.layerX;
        y = event.layerY;
    }
    // マップの各項目を設定
    var tmpLon = floor (137.04341863390334, 10);
    var tmpLat = floor (34.98532390804601, 10);
    var pixelX = floor (0.53963482573016 / parseFloat (138), 10);
    var pixelY = floor (0.304755240026874 / parseFloat (100), 10);
    // 中心座標を算出
    lat = floor (parseFloat (tmpLat) + (pixelY * parseFloat (100 - y) ), 10);
    lon = floor (parseFloat (tmpLon) + (pixelX * parseFloat (x) ), 10);
    startX = 0;
    startY = 0;
    moveX = 0;
    moveY = 0;
    east = 0;
    west = 0;
    south = 0;
    north = 0;
    top = 0;
    left = 0;
    // アイコンの位置を修正
    clearAllIcon ();
    // メニューを閉じる
    closeMenu ();
    // 再描画設定
    presetDraw ();
    createMap (east, west, south, north, 1);
    // 余剰分のマップを削除
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        if (nodeVal.attributes != null && nodeVal.nodeName == "DIV") {
            // 近隣３エリア以外は削除
            var tmp = nodeVal.attributes.getNamedItem ('id').nodeValue.split ("_");
            if (tmp [6] <= east - 9 || east + 9 <= tmp [6]
            || tmp [8] <= south - 9 || south + 9 <= tmp [8]) {
                if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null)    $("map").removeChild (nodeVal);
            }
            // 縮尺と中心の違うマップは削除
            if (nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_") == 0
            && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_") < 0) {
                if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null)    $("map").removeChild (nodeVal);
            }
        }
    }
}


// ##################################################################################
// 全域図表示／非表示
// ##################################################################################
function switchWhole () {
    if (wholeFlag) {
        wholeFlag = false;
        $("imgswitch").src = "/maps/img/open.gif";
        $("whole").style.visibility = "hidden";
    } else {
        wholeFlag = true;
        $("imgswitch").src = "/maps/img/close.gif";
        $("whole").style.visibility = "visible";
        setWhole ();
    }
    upLayer ();
}


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// 全域図の操作
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// ##################################################################################
// ##################################################################################
// ##################################################################################
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// アイコンの操作
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// ##################################################################################
// アイコンのデータを初期化
// ==================================================================================
// params : アイコンデータ保持クラス
// ##################################################################################
function initIcon (params) {
    var size = params.iconX.length;
    iconX = new Array (size);       // アイコンの表示座標
    iconY = new Array (size);       // アイコンの表示座標
    iconUrl = new Array (size);     // アイコンのアドレス
    iconWidth = new Array (size);   // アイコンの幅
    iconHeight = new Array (size);  // アイコンの高さ
    iconFlag = new Array (size);    // アイコンの表示判定
    iconMsg = new Array (size);     // アイコンの吹き出し内容
    for (var i = 0; i < size; i++) {
        iconX [i] = params.iconX [i];
        iconY [i] = params.iconY [i];
        iconUrl [i] = params.iconUrl [i];
        iconWidth [i] = params.iconWidth [i];
        iconHeight [i] = params.iconHeight [i];
        iconFlag [i] = false;
        iconMsg [i] = params.iconMsg [i];
    }
}


// ##################################################################################
// アイコンの吹き出し内容を設定
// ==================================================================================
// no : アイコンの表示番号（添字）
// value : メニューの内容（タグ使用可）
// ##################################################################################
function menuIcon (no, msg) {
    iconMsg [no] = msg;
}


// ##################################################################################
// アイコンデータ保持クラス
// ==================================================================================
// size : アイコンの表示数
// ##################################################################################
function iconData (size) {
    this.iconX = new Array (size);       // アイコンの表示座標
    this.iconY = new Array (size);       // アイコンの表示座標
    this.iconUrl = new Array (size);     // アイコンのアドレス
    this.iconWidth = new Array (size);   // アイコンの幅
    this.iconHeight = new Array (size);  // アイコンの高さ
    this.iconFlag = new Array (size);    // アイコンの表示判定
    this.iconMsg = new Array (size);     // アイコンの吹き出し内容
    this.setParams = setParams;
}


// ##################################################################################
// アイコン用クラスへデータ挿入
// ==================================================================================
// no : 表示番号（0から開始）
// x : アイコンの表示座標
// y : アイコンの表示座標
// url : アイコンのアドレス
// width : アイコンの幅
// height : アイコンの高さ
// msg : アイコンの吹き出し（タグ使用可）
// ##################################################################################
function setParams (no, x, y, url, width, height, msg) {
    this.iconX [no] = x;            // アイコンの表示座標
    this.iconY [no] = y;            // アイコンの表示座標
    this.iconUrl [no] = url;        // アイコンのアドレス
    this.iconWidth [no] = width;    // アイコンの幅
    this.iconHeight [no] = height;  // アイコンの高さ
    this.iconMsg [no] = msg;        // アイコンの吹き出し内容
}


// ##################################################################################
// アイコンを表示
// ==================================================================================
// file : ファイル名
// ##################################################################################
function setIcon (file) {
    setIcon (file, -1);
}

// ##################################################################################
// アイコンを表示
// ==================================================================================
// file : ファイル名
// no : 表示したい吹き出し番号（0より小さい場合何もしない）
// ##################################################################################
function setIcon (file, no) {

    var tmp = file.substring (file.lastIndexOf ("/") + 1, file.length).replace (".png", "").split ("_");
    if (tmp.length < 13) return;    // ファイル名に不備がある場合
    var tmpLon = floor (parseFloat (tmp [10]) - (tmp [12] / 2.0), 10);
    var tmpLat = floor (parseFloat (tmp [9]) - (tmp [11] / 2.0), 10);
    var pixelX = floor (parseFloat (tmp [12]) / parseFloat (width), 10);
    var pixelY = floor (parseFloat (tmp [11]) / parseFloat (height), 10);
    for (var i = 0; i < iconX.length; i++) {
        // 既にアイコンを表示している場合
        if ($("icon" + i) != null) continue;
        // 表示マップ内かどうか判別
        if (tmpLon <= iconX [i] && iconX [i] <= (parseFloat (tmpLon) + parseFloat (tmp [12]) )
        && tmpLat <= iconY [i] && iconY [i] <= (parseFloat (tmpLat) + parseFloat (tmp [11]) ) ) {
            // アイコンの位置座標を測定
            var marginX = (iconX [i] - tmpLon) / pixelX;
            var marginY = height - ( (iconY [i] - tmpLat) / pixelY);
            // マップの位置座標を測定
            marginX += parseFloat (tmp [5] * width);
            marginY += parseFloat (tmp [7] * height);
            // アイコンの幅を考慮
            marginX -= iconWidth [i] / 2;
            marginY -= iconHeight [i] / 2;
            // アイコンを作成
            var element = document.createElement ('div');
            element.id = "icon" + i;
            element.style.top = parseInt (marginY + 0.5) + height + "px";
            element.style.left = parseInt (marginX + 0.5) + width + "px";
            element.style.position = "absolute";
            element.style.zIndex = $("map").childNodes.length;
            element.innerHTML = "<img src=\"" + iconUrl [i] + "\" width=\"" + iconWidth [i] + "\" height=\"" + iconHeight [i] + "\" onclick=\"openBalloon (" + i + ") \">";
            $("map").appendChild (element);
            upLayer ();
            // 表示判定
            iconFlag [i] = true;
            // 吹き出しの表示の指定がある場合
            if (no == i) {
                openBalloon (no);
            }
        }
    }
}


// ##################################################################################
// すべてのアイコンを再表示
// ##################################################################################
function resetIcon () {
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        // マップ画像を検出
        if (nodeVal.attributes != null
        && nodeVal.nodeName == "DIV"
        && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_") == 0) {
            // マップのファイル名を取得
            var nodeLists2 = $(nodeVal.attributes.getNamedItem ('id').nodeValue).childNodes;
            for (j = 0; j < nodeLists2.length; j++) {
                var nodeVal2 = nodeLists2.item (j);
                if (nodeVal2.attributes != null
                && nodeVal2.nodeName == "IMG"
                && nodeVal2.attributes.getNamedItem ('id').nodeValue.indexOf ("img") >= 0
                && nodeVal2.attributes.getNamedItem ('name').nodeValue.length > 0) {
                    // アイコンを表示
                    setIcon (nodeVal2.attributes.getNamedItem ('name').nodeValue);
                }
            }
        }
    }
}


// ##################################################################################
// アイコンを削除
// ==================================================================================
// no : アイコンの表示番号（添字）
// ##################################################################################
function clearIcon (no) {
    if ($("icon" + no) != null) $("map").removeChild ($("icon" + no) );
    // 表示判定
    iconFlag [no] = false;
    // 吹き出しも削除
    clearBalloon (no);
}


// ##################################################################################
// すべてのアイコンを削除
// ##################################################################################
function clearAllIcon () {
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        if (nodeVal.attributes != null && nodeVal.nodeName == "DIV") {
            if (nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("icon") >= 0) {
                if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null)    $("map").removeChild (nodeVal);
                // 表示判定
                iconFlag [nodeVal.attributes.getNamedItem ('id').nodeValue.substring (4)] = false;
            }
        }
    }
    // 吹き出しも削除
    clearAllBalloon ();
}


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// アイコンの操作
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// ##################################################################################
// ##################################################################################
// ##################################################################################
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// 吹き出しの操作
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// ##################################################################################
// アイコンの吹き出しを表示
// 幅と高さはメニューで指定した値を使用する
// ==================================================================================
// no : アイコンの表示番号（添字）
// event : イベントオブジェクト
// ##################################################################################
function openBalloon (no) {
    iconCenter (no);
    // アイコンが表示されていない場合
    if ($("icon" + no) == null) return;
    // 既に吹き出しを表示している場合
    if ($("balloon" + no) != null) return;
    var element = document.createElement ('div');
    element.id = "balloon" + no;
    element.style.bottom = (height * 3) - parseInt ($("icon" + no).style.top) + "px";
    element.style.left = (parseInt ($("icon" + no).style.left) + (iconWidth [no] / 2) - 12) + "px";
    element.style.position = "absolute";
    if (menuWidth > 0) {
        element.style.width = menuWidth + "px";
    }
    if (menuHeight > 0) {
        element.style.height = menuHeight + "px";
    }
    element.style.zIndex = $("map").childNodes.length;

    element.innerHTML = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td><img src=\"/maps/img/fuki_lt.gif\"></td><td background=\"/maps/img/fuki_t.gif\" style=\"background-repeat: repeat-x;\"></td><td background=\"/maps/img/fuki_rt.gif\" align=\"center\" style=\"background-repeat: no-repeat;\"><img src=\"/maps/img/fuki_close.gif\" onClick=\"clearBalloon (" + no + ") \"></td></tr><tr><td background=\"/maps/img/fuki_l.gif\" style=\"background-repeat: repeat-y;\"></td><td bgcolor=\"#FFFFFF\">" + iconMsg [no] + "</td><td background=\"/maps/img/fuki_r.gif\" style=\"background-repeat: repeat-y;\"></td></tr><tr><td><img src=\"/maps/img/fuki_lb.gif\"></td><td background=\"/maps/img/fuki_b.gif\" style=\"background-repeat: repeat-x;\"></td><td><img src=\"/maps/img/fuki_rb.gif\"></td></tr></table>";
    $("map").appendChild (element);
    upLayer ();
}


// ##################################################################################
// アイコンの吹き出しを削除
// ==================================================================================
// no : アイコンの表示番号（添字）
// ##################################################################################
function clearBalloon (no) {
    if ($("balloon" + no) != null)  $("map").removeChild ($("balloon" + no) );
}


// ##################################################################################
// すべてのアイコンの吹き出しを削除
// ##################################################################################
function clearAllBalloon () {
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        if (nodeVal.attributes != null && nodeVal.nodeName == "DIV") {
            if (nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("balloon") >= 0) {
                if ($(nodeVal.attributes.getNamedItem ('id').nodeValue) != null)    $("map").removeChild (nodeVal);
            }
        }
    }
}


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// 吹き出しの操作
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// ##################################################################################
// ##################################################################################
// ##################################################################################
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// メニューの操作
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// ##################################################################################
// メニューを開く
// ==================================================================================
// event : イベントオブジェクト
// ##################################################################################
function openMenu (event) {
    if (moveFlag) {                     // ドラックした場合は作業しない
        moveFlag = false;
        return;
    }
    //if (event.button != 2) return;              // 右クリック以外は作業しない
    if (!menuOpenFlag) return;              // メニューを使用しない場合は作業しない
    var target = "";
    if (window.createPopup) {
        //IE
        target = event.srcElement.id;
    } else {
        //その他
        target = event.target.id;
    }
    if (menuFlag
    && target.length > 0) {
        $(target).focus();
    }
    if (target.indexOf ("imgmap_") < 0) return;        // マップ画像が表示されていない場合はなにもしない
    // メニューを開いているときはメニューを開き直す
    if (menuFlag) {
        menuFlag = false;
        closeMenu ();
    }
    if (zoomFlag) return;                       // 縮尺変更中はなにもしない
    menuFlag = true;
    if (document.all) {
        //IE
        mouseX = event.offsetX;
        mouseY = event.offsetY;
    } else {
        //その他
        mouseX = event.layerX;
        mouseY = event.layerY;
    }
    // マップの座標を取得
    var tmp = target.split ("_");
    mouseX += tmp [6] * width;
    mouseY += tmp [8] * height;
    // メニューを追加
    var element = document.createElement ('div');
    element.id = "workmenue";
    element.style.bottom = (height * 3) - (mouseY + height) + 15 + "px";
    element.style.left = (mouseX + width) - 30 + "px";
    element.style.position = "absolute";
    if (menuWidth > 0) {
        element.style.width = menuWidth + "px";
    }
    if (menuHeight > 0) {
        element.style.height = menuHeight + "px";
    }
    element.style.zIndex = $("map").childNodes.length;
    element.innerHTML = "<table border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><tr><td id=\"workmenue_lt\"><img src=\"/maps/img/fuki_lt.gif\"></td><td background=\"/maps/img/fuki_t.gif\" style=\"background-repeat: repeat-x;\" id=\"workmenue_t\"></td><td background=\"/maps/img/fuki_rt.gif\" align=\"center\" style=\"background-repeat: no-repeat;\" id=\"workmenue_rt\"><img src=\"/maps/img/fuki_close.gif\" onClick=\"closeMenu () \"></td></tr><tr><td background=\"/maps/img/fuki_l.gif\" style=\"background-repeat: repeat-y;\" id=\"workmenue_l\"></td><td bgcolor=\"#FFFFFF\" id=\"workmenue_c\">" + menuValues + "</td><td background=\"/maps/img/fuki_r.gif\" style=\"background-repeat: repeat-y;\" id=\"workmenue_r\"></td></tr><tr><td id=\"workmenue_lb\"><img src=\"/maps/img/fuki_lb.gif\"></td><td background=\"/maps/img/fuki_b.gif\" style=\"background-repeat: repeat-x;\" id=\"workmenue_b\"></td><td id=\"workmenue_rb\"><img src=\"/maps/img/fuki_rb.gif\"></td></tr></table>";

    $("map").appendChild (element);
    upLayer ();

}


// ##################################################################################
// メニューを閉じる
// ##################################################################################
function closeMenu () {
    if ($("workmenue") != null) $("map").removeChild ($("workmenue") );
    menuFlag = false;
}


// ##################################################################################
// メニューのデータを初期化
// ==================================================================================
// w : 幅（0の場合は指定なし／吹き出しと共通とする）
// h : 高さ（0の場合は指定なし／吹き出しと共通とする）
// value : メニューの内容（タグ使用可）
// ##################################################################################
function initMenu (w, h, m) {
    menuWidth = w;    // メニューの幅
    menuHeight = h;  // メニューの高さ
    menuValues = m; // メニューの内容
    menuOpenFlag = true;
}


// ##################################################################################
// メニューの内容を取得
// ##################################################################################
function getMenu () {
    return menuValues;
}


// ##################################################################################
// メニューの内容を設定
// ==================================================================================
// value : メニューの内容（タグ使用可）
// ##################################################################################
function setMenu (value) {
    menuValues = value;
}


// ##################################################################################
// メニューの内容を設定
// ==================================================================================
// value : メニューの内容（タグ使用可）
// ##################################################################################
function setMenuPlus (value) {
    menuValues += value;
}


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// メニューの操作
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// ##################################################################################
// ##################################################################################
// ##################################################################################
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// 描画の操作
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// ##################################################################################
// ラインをマップ表示時に描画
// ==================================================================================
// x1 : 開始X座標
// y1 : 開始Y座標
// x2 : 終了X座標
// y2 : 終了Y座標
// color : ラインの色
// border : ラインの幅
// ##################################################################################
function presetLine (x1, y1, x2, y2, color, border) {
    lineParams = new Array (6);
    lineParams [0] = x1;
    lineParams [1] = y1;
    lineParams [2] = x2;
    lineParams [3] = y2;
    lineParams [4] = color;
    lineParams [5] = border;
    lineFlag = true;
}


// ##################################################################################
// ラインを表示
// ==================================================================================
// x1 : 開始X座標
// y1 : 開始Y座標
// x2 : 終了X座標
// y2 : 終了Y座標
// color : ラインの色
// border : ラインの幅
// ##################################################################################
function setLine (x1, y1, x2, y2, color, border) {
    if ($("line") != null) return;
    lineParams = new Array (6);
    lineParams [0] = x1;
    lineParams [1] = y1;
    lineParams [2] = x2;
    lineParams [3] = y2;
    lineParams [4] = color;
    lineParams [5] = border;
    lineFlag = true;
    var file = "";
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        // マップ画像を検出
        if (nodeVal.attributes != null
        && nodeVal.nodeName == "DIV"
        && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_") == 0) {
            // マップのファイル名を取得
            var nodeLists2 = $(nodeVal.attributes.getNamedItem ('id').nodeValue).childNodes;
            for (j = 0; j < nodeLists2.length; j++) {
                var nodeVal2 = nodeLists2.item (j);
                if (nodeVal2.attributes != null
                && nodeVal2.nodeName == "IMG"
                && nodeVal2.attributes.getNamedItem ('id').nodeValue.indexOf ("img") >= 0
                && nodeVal2.attributes.getNamedItem ('name').nodeValue.length > 0) {
                    file = nodeVal2.attributes.getNamedItem ('name').nodeValue;
                }
            }
        }
        if (file.length > 0) break;
    }
    // 参照マップから計算に必要な項目を取得
    var tmp = file.substring (file.lastIndexOf ("/") + 1, file.length).replace (".png", "").split ("_");
    //if (tmp.length < 13) return;    // ファイル名に不備がある場合
    var tmpLon = floor (parseFloat (tmp [10]) - (tmp [12] / 2.0), 10);
    var tmpLat = floor (parseFloat (tmp [9]) - (tmp [11] / 2.0), 10);
    var pixelX = floor (parseFloat (tmp [12]) / parseFloat (width), 10);
    var pixelY = floor (parseFloat (tmp [11]) / parseFloat (height), 10);
    // 開始位置座標を測定
    var startX = (x1 - tmpLon) / pixelX;
    var startY = height - ( (y1 - tmpLat) / pixelY);
    // マップの位置座標を測定
    startX += parseFloat (tmp [5] * width);
    startY += parseFloat (tmp [7] * height);
    // ライン幅を考慮
    startX -= border / 2;
    startY -= border / 2;
    // 表示位置を考慮
    startX += width;
    startY += height;
    // 到着位置座標を測定
    var stopX = (x2 - tmpLon) / pixelX;
    var stopY = height - ( (y2 - tmpLat) / pixelY);
    // マップの位置座標を測定
    stopX += parseFloat (tmp [5] * width);
    stopY += parseFloat (tmp [7] * height);
    // ライン幅を考慮
    stopX -= border / 2;
    stopY -= border / 2;
    // 表示位置を考慮
    stopX += width;
    stopY += height;
    // ライン表示用領域作成
    if ($("line") == null) {
        var element = document.createElement ('div');
        element.id = "line";
        element.style.position = "absolute";
        element.style.zIndex = $("map").childNodes.length;
        $("map").appendChild (element);
        upLayer ();
    }
    // ラインを描画
    var jg = new jsGraphics ("line");    // ライン等記入用
    jg.setColor (color);
    jg.setStroke (border);
    jg.drawLine (parseInt (startX + 0.5), parseInt (startY + 0.5), parseInt (stopX + 0.5), parseInt (stopY + 0.5) );
    jg.paint ();
}


// ##################################################################################
// ラインを削除
// ##################################################################################
function clearLine () {
    if ($("line") != null)  $("map").removeChild ($("line") );
    lineFlag = false;
}


// ##################################################################################
// 連続ラインをマップ表示時に描画
// ==================================================================================
// x : X座標（Array型）
// y : Y座標（Array型）
// color : ラインの色
// border : ラインの幅
// ##################################################################################
function presetPolyLine (x, y, color, border) {
    polylineParams = new Array (4);
    polylineParams [0] = x;
    polylineParams [1] = y;
    polylineParams [2] = color;
    polylineParams [3] = border;
    polylineFlag = true;
}


// ##################################################################################
// 連続ラインを表示
// [color]と[border]の最後は表示には使用しない
// [border]の最後は計算で使用するため１つ前の値と同じにすること
// ==================================================================================
// x : X座標（Array型）
// y : Y座標（Array型）
// color : ラインの色（Array型）
// border : ラインの幅（Array型）
// ##################################################################################
function setPolyLine (x, y, color, border) {
    if ($("polyline") != null) return;
    polylineParams = new Array (4);
    polylineParams [0] = x;
    polylineParams [1] = y;
    polylineParams [2] = color;
    polylineParams [3] = border;
    polylineFlag = true;
    var file = "";
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        // マップ画像を検出
        if (nodeVal.attributes != null
        && nodeVal.nodeName == "DIV"
        && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_") == 0) {
            // マップのファイル名を取得
            var nodeLists2 = $(nodeVal.attributes.getNamedItem ('id').nodeValue).childNodes;
            for (j = 0; j < nodeLists2.length; j++) {
                var nodeVal2 = nodeLists2.item (j);
                if (nodeVal2.attributes != null
                && nodeVal2.nodeName == "IMG"
                && nodeVal2.attributes.getNamedItem ('id').nodeValue.indexOf ("img") >= 0
                && nodeVal2.attributes.getNamedItem ('name').nodeValue.length > 0) {
                    file = nodeVal2.attributes.getNamedItem ('name').nodeValue;
                }
            }
        }
        if (file.length > 0) break;
    }
    // 参照マップから計算に必要な項目を取得
    var tmp = file.substring (file.lastIndexOf ("/") + 1, file.length).replace (".png", "").split ("_");
    //if (tmp.length < 13) return;    // ファイル名に不備がある場合
    var tmpLon = floor (parseFloat (tmp [10]) - (tmp [12] / 2.0), 10);
    var tmpLat = floor (parseFloat (tmp [9]) - (tmp [11] / 2.0), 10);
    var pixelX = floor (parseFloat (tmp [12]) / parseFloat (width), 10);
    var pixelY = floor (parseFloat (tmp [11]) / parseFloat (height), 10);
    // 位置座標を測定
    var arrayX = new Array (x.length);
    var arrayY = new Array (y.length);
    for (var i = 0; i < x.length; i++) {
        arrayX [i] = (x [i] - tmpLon) / pixelX;
        arrayY [i] = height - ( (y [i] - tmpLat) / pixelY);
        // マップの位置座標を測定
        arrayX [i] += parseFloat (tmp [5] * width);
        arrayY [i] += parseFloat (tmp [7] * height);
        // 連続ライン幅を考慮
        arrayX [i] -= border [i] / 2;
        arrayY [i] -= border [i] / 2;
        // 小数点以下四捨五入
        arrayX [i] = parseInt (arrayX [i] + 0.5);
        arrayY [i] = parseInt (arrayY [i] + 0.5);
        // 表示位置を考慮
        arrayX [i] += width;
        arrayY [i] += height;
    }
    // 連続ライン表示用領域作成
    if ($("polyline") == null) {
        var element = document.createElement ('div');
        element.id = "polyline";
        element.style.position = "absolute";
        element.style.zIndex = $("map").childNodes.length;
        $("map").appendChild (element);
        upLayer ();
    }
    // 連続ラインを描画
    var jg = new jsGraphics ("polyline");    // ライン等記入用
    for (var i = 0; i + 1 < arrayX.length; i++) {
        jg.setColor (color [i]);
        jg.setStroke (border [i]);
        jg.drawLine (arrayX [i], arrayY [i], arrayX [i + 1], arrayY [i + 1] );
    }
    jg.paint ();
}


// ##################################################################################
// 連続ラインを削除
// ##################################################################################
function clearPolyLine () {
    if ($("polyline") != null)  $("map").removeChild ($("polyline") );
    polylineFlag = false;
}


// ##################################################################################
// 楕円をマップ表示時に描画
// ==================================================================================
// x : 中心X座標
// y : 中心Y座標
// w : 円の幅（直径）
// h : 円の高さ（直径）
// color : ラインの色
// border : ラインの幅
// ##################################################################################
function presetEllipse (x, y, w, h, color, border) {
    ellipseParams = new Array (6);
    ellipseParams [0] = x;
    ellipseParams [1] = y;
    ellipseParams [2] = w;
    ellipseParams [3] = h;
    ellipseParams [4] = color;
    ellipseParams [5] = border;
    ellipseFlag = true;
}


// ##################################################################################
// 楕円を表示
// ==================================================================================
// x : 中心X座標
// y : 中心Y座標
// w : 円の幅（直径）
// h : 円の高さ（直径）
// color : ラインの色
// border : ラインの幅
// ##################################################################################
function setEllipse (x, y, w, h, color, border) {
    if ($("ellipse") != null) return;
    ellipseParams = new Array (6);
    ellipseParams [0] = x;
    ellipseParams [1] = y;
    ellipseParams [2] = w;
    ellipseParams [3] = h;
    ellipseParams [4] = color;
    ellipseParams [5] = border;
    ellipseFlag = true;
    var file = "";
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        // マップ画像を検出
        if (nodeVal.attributes != null
        && nodeVal.nodeName == "DIV"
        && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_") == 0) {
            // マップのファイル名を取得
            var nodeLists2 = $(nodeVal.attributes.getNamedItem ('id').nodeValue).childNodes;
            for (j = 0; j < nodeLists2.length; j++) {
                var nodeVal2 = nodeLists2.item (j);
                if (nodeVal2.attributes != null
                && nodeVal2.nodeName == "IMG"
                && nodeVal2.attributes.getNamedItem ('id').nodeValue.indexOf ("img") >= 0
                && nodeVal2.attributes.getNamedItem ('name').nodeValue.length > 0) {
                    file = nodeVal2.attributes.getNamedItem ('name').nodeValue;
                }
            }
        }
        if (file.length > 0) break;
    }
    // 参照マップから計算に必要な項目を取得
    var tmp = file.substring (file.lastIndexOf ("/") + 1, file.length).replace (".png", "").split ("_");
    //if (tmp.length < 13) return;    // ファイル名に不備がある場合
    var tmpLon = floor (parseFloat (tmp [10]) - (tmp [12] / 2.0), 10);
    var tmpLat = floor (parseFloat (tmp [9]) - (tmp [11] / 2.0), 10);
    var pixelX = floor (parseFloat (tmp [12]) / parseFloat (width), 10);
    var pixelY = floor (parseFloat (tmp [11]) / parseFloat (height), 10);
    // 位置座標を測定
    var pointX = (x - tmpLon) / pixelX;
    var pointY = height - ( (y - tmpLat) / pixelY);
    // マップの位置座標を測定
    pointX += parseFloat (tmp [5] * width);
    pointY += parseFloat (tmp [7] * height);
    // 楕円の幅と高さを考慮
    pointX -= w / 2;
    pointY -= h / 2;
    // ライン幅を考慮
    pointX -= border / 2;
    pointY -= border / 2;
    // 表示位置を考慮
    pointX += width;
    pointY += height;
    // 楕円表示用領域作成
    if ($("ellipse") == null) {
        var element = document.createElement ('div');
        element.id = "ellipse";
        element.style.position = "absolute";
        element.style.zIndex = $("map").childNodes.length;
        $("map").appendChild (element);
        upLayer ();
    }
    // 楕円を描画
    var jg = new jsGraphics ("ellipse");    // 楕円等記入用
    jg.setColor (color);
    jg.setStroke (border);
    jg.drawEllipse (parseInt (pointX + 0.5), parseInt (pointY + 0.5), w, h);
    jg.paint ();
}


// ##################################################################################
// 楕円を削除
// ##################################################################################
function clearEllipse () {
    if ($("ellipse") != null)   $("map").removeChild ($("ellipse") );
    ellipseFlag = false;
}


// ##################################################################################
// 楕円（塗りつぶし）をマップ表示時に描画
// ==================================================================================
// x : 中心X座標
// y : 中心Y座標
// w : 円の幅（直径）
// h : 円の高さ（直径）
// color : 円の色
// ##################################################################################
function presetFillEllipse (x, y, w, h, color) {
    fillellipseParams = new Array (5);
    fillellipseParams [0] = x;
    fillellipseParams [1] = y;
    fillellipseParams [2] = w;
    fillellipseParams [3] = h;
    fillellipseParams [4] = color;
    fillellipseFlag = true;
}


// ##################################################################################
// 楕円（塗りつぶし）を表示
// ==================================================================================
// x : 中心X座標
// y : 中心Y座標
// w : 円の幅（直径）
// h : 円の高さ（直径）
// color : 円の色
// ##################################################################################
function setFillEllipse (x, y, w, h, color) {
    if ($("fillellipse") != null) return;
    fillellipseParams = new Array (5);
    fillellipseParams [0] = x;
    fillellipseParams [1] = y;
    fillellipseParams [2] = w;
    fillellipseParams [3] = h;
    fillellipseParams [4] = color;
    fillellipseFlag = true;
    var file = "";
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        // マップ画像を検出
        if (nodeVal.attributes != null
        && nodeVal.nodeName == "DIV"
        && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_") == 0) {
            // マップのファイル名を取得
            var nodeLists2 = $(nodeVal.attributes.getNamedItem ('id').nodeValue).childNodes;
            for (j = 0; j < nodeLists2.length; j++) {
                var nodeVal2 = nodeLists2.item (j);
                if (nodeVal2.attributes != null
                && nodeVal2.nodeName == "IMG"
                && nodeVal2.attributes.getNamedItem ('id').nodeValue.indexOf ("img") >= 0
                && nodeVal2.attributes.getNamedItem ('name').nodeValue.length > 0) {
                    file = nodeVal2.attributes.getNamedItem ('name').nodeValue;
                }
            }
        }
        if (file.length > 0) break;
    }
    // 参照マップから計算に必要な項目を取得
    var tmp = file.substring (file.lastIndexOf ("/") + 1, file.length).replace (".png", "").split ("_");
    //if (tmp.length < 13) return;    // ファイル名に不備がある場合
    var tmpLon = floor (parseFloat (tmp [10]) - (tmp [12] / 2.0), 10);
    var tmpLat = floor (parseFloat (tmp [9]) - (tmp [11] / 2.0), 10);
    var pixelX = floor (parseFloat (tmp [12]) / parseFloat (width), 10);
    var pixelY = floor (parseFloat (tmp [11]) / parseFloat (height), 10);
    // 位置座標を測定
    var pointX = (x - tmpLon) / pixelX;
    var pointY = height - ( (y - tmpLat) / pixelY);
    // マップの位置座標を測定
    pointX += parseFloat (tmp [5] * width);
    pointY += parseFloat (tmp [7] * height);
    // 楕円（塗りつぶし）の幅と高さを考慮
    pointX -= w / 2;
    pointY -= h / 2;
    // 表示位置を考慮
    pointX += width;
    pointY += height;
    // 楕円（塗りつぶし）表示用領域作成
    if ($("fillellipse") == null) {
        var element = document.createElement ('div');
        element.id = "fillellipse";
        element.style.position = "absolute";
        element.style.zIndex = $("map").childNodes.length;
        $("map").appendChild (element);
        upLayer ();
    }
    // 楕円（塗りつぶし）を描画
    var jg = new jsGraphics ("fillellipse");    // 楕円（塗りつぶし）等記入用
    jg.setColor (color);
    jg.setStroke (1);
    jg.fillEllipse (parseInt (pointX + 0.5), parseInt (pointY + 0.5), w, h);
    jg.paint ();
}


// ##################################################################################
// 楕円（塗りつぶし）を削除
// ##################################################################################
function clearFillEllipse () {
    if ($("fillellipse") != null)   $("map").removeChild ($("fillellipse") );
    fillellipseFlag = false;
}


// ##################################################################################
// 矩形をマップ表示時に描画
// ==================================================================================
// x : 中心X座標
// y : 中心Y座標
// w : 円の幅（直径）
// h : 円の高さ（直径）
// color : ラインの色
// border : ラインの幅
// ##################################################################################
function presetRect (x, y, w, h, color, border) {
    rectParams = new Array (6);
    rectParams [0] = x;
    rectParams [1] = y;
    rectParams [2] = w;
    rectParams [3] = h;
    rectParams [4] = color;
    rectParams [5] = border;
    rectFlag = true;
}


// ##################################################################################
// 矩形を表示
// ==================================================================================
// x : 中心X座標
// y : 中心Y座標
// w : 円の幅（直径）
// h : 円の高さ（直径）
// color : ラインの色
// border : ラインの幅
// ##################################################################################
function setRect (x, y, w, h, color, border) {
    if ($("rect") != null) return;
    rectParams = new Array (6);
    rectParams [0] = x;
    rectParams [1] = y;
    rectParams [2] = w;
    rectParams [3] = h;
    rectParams [4] = color;
    rectParams [5] = border;
    rectFlag = true;
    var file = "";
    var nodeLists = $("map").childNodes;
    for (i = nodeLists.length - 1; i >= 0; i--) {
        var nodeVal = nodeLists.item (i);
        // マップ画像を検出
        if (nodeVal.attributes != null
        && nodeVal.nodeName == "DIV"
        && nodeVal.attributes.getNamedItem ('id').nodeValue.indexOf ("map_" + lat + "_" + lon + "_" + scale + "_") == 0) {
            // マップのファイル名を取得
            var nodeLists2 = $(nodeVal.attributes.getNamedItem ('id').nodeValue).childNodes;
            for (j = 0; j < nodeLists2.length; j++) {
                var nodeVal2 = nodeLists2.item (j);
                if (nodeVal2.attributes != null
                && nodeVal2.nodeName == "IMG"
                && nodeVal2.attributes.getNamedItem ('id').nodeValue.indexOf ("img") >= 0
                && nodeVal2.attributes.getNamedItem ('name').nodeValue.length > 0) {
                    file = nodeVal2.attributes.getNamedItem ('name').nodeValue;
                }
            }
        }
        if (file.length > 0) break;
    }
    // 参照マップから計算に必要な項目を取得
    var tmp = file.substring (file.lastIndexOf ("/") + 1, file.length).replace (".png", "").split ("_");
    //if (tmp.length < 13) return;    // ファイル名に不備がある場合
    var tmpLon = floor (parseFloat (tmp [10]) - (tmp [12] / 2.0), 10);
    var tmpLat = floor (parseFloat (tmp [9]) - (tmp [11] / 2.0), 10);
    var pixelX = floor (parseFloat (tmp [12]) / parseFloat (width), 10);
    var pixelY = floor (parseFloat (tmp [11]) / parseFloat (height), 10);
    // 位置座標を測定
    var pointX = (x - tmpLon) / pixelX;
    var pointY = height - ( (y - tmpLat) / pixelY);
    // マップの位置座標を測定
    pointX += parseFloat (tmp [5] * width);
    pointY += parseFloat (tmp [7] * height);
    // 矩形の幅と高さを考慮
    pointX -= w / 2;
    pointY -= h / 2;
    // ライン幅を考慮
    pointX -= border / 2;
    pointY -= border / 2;
    // 表示位置を考慮
    pointX += width;
    pointY += height;
    // 矩形表示用領域作成
    if ($("rect") == null) {
        var element = document.createElement ('div');
        element.id = "rect";
        element.style.position = "absolute";
        element.style.zIndex = $("map").childNodes.length;
        $("map").appendChild (element);
        upLayer ();
    }
    // 矩形を描画
    var jg = new jsGraphics ("rect");    // 矩形等記入用
    jg.setColor (color);
    jg.setStroke (border);
    jg.drawRect (parseInt (pointX + 0.5), parseInt (pointY + 0.5), w, h);
    jg.paint ();
}


// ##################################################################################
// 矩形を削除
// ##################################################################################
function clearRect () {
    if ($("rect") != null)  $("map").removeChild ($("rect") );
    rectFlag = false;
}


// ##################################################################################
// すべての描画を再描画
// ##################################################################################
function resetDraw () {
    // ライン
    if (lineFlag) {
        setLine (lineParams [0], lineParams [1], lineParams [2], lineParams [3], lineParams [4], lineParams [5]);
    }
    // 連続ライン
    if (polylineFlag) {
        setPolyLine (polylineParams [0], polylineParams [1], polylineParams [2], polylineParams [3]);
    }
    // 楕円
    if (ellipseFlag) {
        setEllipseLine (ellipseParams [0], ellipseParams [1], ellipseParams [2], ellipseParams [3], ellipseParams [4], ellipseParams [5]);
    }
    // 楕円（塗りつぶし）
    if (fillellipseFlag) {
        setFillEllipse (fillellipseParams [0], fillellipseParams [1], fillellipseParams [2], fillellipseParams [3], fillellipseParams [4]);
    }
    // 矩形
    if (rectFlag) {
        setRect (rectParams [0], rectParams [1], rectParams [2], rectParams [3], rectParams [4], rectParams [5]);
    }
}


// ##################################################################################
// すべての描画をマップ表示時に再描画
// ##################################################################################
function presetDraw () {
    // ライン
    if (lineFlag) {
        clearLine ();
        presetLine (lineParams [0], lineParams [1], lineParams [2], lineParams [3], lineParams [4], lineParams [5]);
    }
    // 連続ライン
    if (polylineFlag) {
        clearPolyLine ();
        presetPolyLine (polylineParams [0], polylineParams [1], polylineParams [2], polylineParams [3]);
    }
    // 楕円
    if (ellipseFlag) {
        clearEllipse ();
        presetEllipseLine (ellipseParams [0], ellipseParams [1], ellipseParams [2], ellipseParams [3], ellipseParams [4], ellipseParams [5]);
    }
    // 楕円（塗りつぶし）
    if (fillellipseFlag) {
        clearFillEllipse ();
        presetFillEllipse (fillellipseParams [0], fillellipseParams [1], fillellipseParams [2], fillellipseParams [3], fillellipseParams [4]);
    }
    // 矩形
    if (rectFlag) {
        clearRect ();
        presetRect (rectParams [0], rectParams [1], rectParams [2], rectParams [3], rectParams [4], rectParams [5]);
    }
}


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// 描画の操作
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// ##################################################################################
// ##################################################################################
// ##################################################################################
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
// その他の操作
// >>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>


// ##################################################################################
// 右クリック禁止
// ##################################################################################
function nonRightClick (event) {
    if (event.button == 2) return false;
}


// ##################################################################################
// 指定した小数点以下を切り捨て
// ==================================================================================
// value : 数値
// no : 切捨てる小数点
// ##################################################################################
function floor (value, no) {
    var tmpVal = parseInt (value * Math.pow (no, 10) );
    return tmpVal / Math.pow (no, 10);
}


// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
// その他の操作
// <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
