
// グローバル変数

var mapPath;
var moveBaseRect;
var info;

var Zoom = new Object();
Zoom.TOP_LEFT = 1;
Zoom.TOP_RIGHT = 2;
Zoom.BOTTOM_LEFT = 3;
Zoom.BOTTOM_RIGHT = 4;

// ブラウザ判別
var agt = navigator.userAgent.toLowerCase();
var is_major = parseInt(navigator.appVersion);
var is_minor = parseFloat(navigator.appVersion);
var is_ie      = ((agt.indexOf("msie") != -1) && (agt.indexOf("opera") == -1));
var is_ie3     = (is_ie && (is_major < 4));
var is_ie4     = (is_ie && (is_major == 4) && (agt.indexOf("msie 4")!=-1) );
var is_ie4up   = (is_ie && (is_major >= 4));
var is_ie5     = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.0")!=-1) );
var is_ie5_5   = (is_ie && (is_major == 4) && (agt.indexOf("msie 5.5") !=-1));
var is_ie5up   = (is_ie && !is_ie3 && !is_ie4);
var is_ie5_5up = (is_ie && !is_ie3 && !is_ie4 && !is_ie5);
var is_ie6     = (is_ie && (is_major == 4) && (agt.indexOf("msie 6.")!=-1) );
var is_ie6up   = (is_ie && !is_ie3 && !is_ie4 && !is_ie5 && !is_ie5_5);

// 共通関数

function openPrintWindow(fname) {

	var win = window.open(fname, "prnWnd", "top=" + window.screenTop + ",left=" + window.screenLeft + ",height=650,width=650,menubar,toolbar,scrollbars,location,resizable");
	win.focus();
}

function createGuideElem() {

	var infoWin = createWindowElem("infoWindow", 140, 140);
	infoWin.style.visibility = "hidden";

	// 案内文
	var txt = document.createElement("div");
	txt.id = "infoText";
	txt.style.position = "absolute";
	txt.style.width = "140px";
	txt.style.height = "100px";
	txt.style.top = "12px";
	txt.style.left = "0px";
	txt.style.padding = "5px 8px 8px 8px";
	txt.style.fontSize = "10pt";
	txt.style.color = "#333333";
	txt.style.border = "0px solid red";
	txt.style.lineHeight = "normal";
	infoWin.appendChild(txt);

	// 矢印テキスト
	var txt = document.createElement("div");
	txt.id = "infoArrowText";
	txt.style.position = "absolute";
	txt.style.width = "60px";
	txt.style.height = "60px";
	txt.style.top = "65px";
	txt.style.left = "75px";
	txt.style.paddingLeft = "3px";
	txt.style.fontSize = "7pt";
	txt.style.color = "#F65527";
	txt.style.border = "0px solid green";
	txt.style.lineHeight = "normal";
	txt.appendChild(document.createTextNode("矢印をクリックして進みます。"));
	infoWin.appendChild(txt);

	// 矢印
	var arrow = document.createElement("v:shape");
	arrow.id = "infoArrow";
	arrow.style.position = "absolute";
	arrow.style.width = "40px";
	arrow.style.height = "40px";
	arrow.style.top = "90px";
	arrow.style.left = "83px";
	arrow.style.cursor = "pointer";
	arrow.style.border = "0px solid green";
	arrow.coordsize = "100,100";
	arrow.coordorigin = "-50,-50";
	arrow.filled = "true";
	arrow.path = "m -38,-12 l 12,-12 12,-38 50,0 12,38 12,12 -38,12 x e";
	var fill = document.createElement("v:fill");
	fill.color = "#F87B58";
	fill.opacity = "0.8";
	arrow.appendChild(fill);
	var stroke = document.createElement("v:stroke");
	stroke.color = "#F65527";
	stroke.weight = "1";
	arrow.appendChild(stroke);
	infoWin.appendChild(arrow);

	// 写真
	var imgWin = createWindowElem("imgWindow", 56, 67);
	imgWin.style.top = "63px";
	imgWin.style.left = "8px";
	var image = document.createElement("img");
	//image.id = "infoImage";
	image.id = "imgWindowImage";
	image.style.position = "absolute";
	image.style.width = "50px";
	image.style.height = "50px";
	image.style.top = "12px";
	image.style.left = "0px";
	image.style.margin = "3px";
	image.style.cursor = "pointer";
	imgWin.appendChild(image);
	infoWin.appendChild(imgWin);

	var imgWin = createWindowElem("imgWindow2", 56, 67);
	imgWin.style.top = "63px";
	imgWin.style.left = "72px";
	imgWin.style.visibility = "hidden";
	var image = document.createElement("img");
	image.id = "imgWindow2Image";
	image.style.position = "absolute";
	image.style.width = "50px";
	image.style.height = "50px";
	image.style.top = "12px";
	image.style.left = "0px";
	image.style.margin = "3px";
	image.style.cursor = "pointer";
	imgWin.appendChild(image);
	infoWin.appendChild(imgWin);

	return infoWin;
}

function createWindowElem(id, width, height) {

	var elem = document.createElement("div");
	elem.id = id;
	elem.style.position = "absolute";
	elem.style.width = width + "px";
	elem.style.height = height + "px";

	var bg = document.createElement("v:roundrect");
	bg.id = id + "Bg";
	bg.style.position = "absolute";
	bg.style.width = width + "px";
	bg.style.height = height + "px";
	bg.style.top = "0px";
	bg.style.left = "0px";
	bg.arcsize = "0.02";
	var fill = document.createElement("v:fill");
	fill.color = "#F7F8F8";
	bg.appendChild(fill);
	var stroke = document.createElement("v:stroke");
	stroke.color = "#8B9898";
	bg.appendChild(stroke);
	var shadow = document.createElement("v:shadow");
	shadow.on = "true";
	shadow.opacity = "0.5";
	shadow.offset = "3pt,3pt";
	bg.appendChild(shadow);
	elem.appendChild(bg);

	var bar = document.createElement("v:roundrect");
	bar.id = id + "Bar";
	bar.style.position = "absolute";
	bar.style.width = width + "px";
	bar.style.height = "12px";
	bar.style.top = "0px";
	bar.style.left = "0px";
	bar.arcsize = "0.02";
	bar.stroked = "false";
	bar.onmouseover = function() { this.style.cursor = 'move'; }
	var fill = document.createElement("v:fill");
	fill.color = "#0E22AF";
	bar.appendChild(fill);
	elem.appendChild(bar);

	return elem;
}

function createLabelElem(top, left, width, height, text, strokeColor) {

	var elem = document.createElement("div");
	elem.style.position = "absolute";
	elem.style.top = top + "px";
	elem.style.left = left + "px";

	var rect = document.createElement("v:rect");
	rect.style.position = "absolute";
	rect.style.top = "0px";
	rect.style.left = "0px";
	rect.style.width = width + "px";
	rect.style.height = height + "px";
	var fill = document.createElement("v:fill");
	fill.color = "#FFFFCC";
	rect.appendChild(fill);
	var stroke = document.createElement("v:stroke");
	stroke.color = strokeColor;
	stroke.weight = "1";
	rect.appendChild(stroke);
	var shadow = document.createElement("v:shadow");
	shadow.on = "true";
	shadow.opacity = "0.7";
	rect.appendChild(shadow);
	elem.appendChild(rect);

	var textElem = document.createElement("div");
	textElem.style.position = "absolute";
	textElem.style.top = "0px";
	textElem.style.left = "0px";
	textElem.style.fontSize = "9pt";
	textElem.style.color = "#333333";
	textElem.style.padding = "5px";
	textElem.style.lineHeight = "normal";
	textElem.innerHTML = text;
	elem.appendChild(textElem);

	return elem;
}

function createMarkerElem(top, left, fillColor, strokeColor) {

	var elem = document.createElement("v:roundrect");
	elem.style.position = "absolute";
	elem.style.width = "15px";
	elem.style.height = "15px";
	elem.style.top = top + "px";
	elem.style.left = left + "px";
	elem.arcsize = "0.2";
	var fill = document.createElement("v:fill");
	fill.color = fillColor;
	fill.opacity = "1.0";
	elem.appendChild(fill);
	var stroke = document.createElement("v:stroke");
	stroke.color = strokeColor;
	elem.appendChild(stroke);
	var shadow = document.createElement("v:shadow");
	shadow.on = "true";
	shadow.offset = "15%,12%";
	shadow.opacity = "0.7";
	elem.appendChild(shadow);

	return elem;
}

// ユーティリティ

function HDOMElement(elem) {
	this.elem = elem;
}

HDOMElement.getWidth = function(elem) {
	return parseInt(elem.style.width);
}

HDOMElement.setWidth = function(elem, value) {
	elem.style.width = value + "px";

}

HDOMElement.addWidth = function(elem, value) {
	HDOMElement.setWidth(elem, HDOMElement.getWidth(elem) + value);
}

HDOMElement.subWidth = function(elem, value) {
	HDOMElement.setWidth(elem, HDOMElement.getWidth(elem) - value);
}

HDOMElement.getHeight = function(elem) {
	return parseInt(elem.style.height);
}

HDOMElement.setHeight = function(elem, value) {
	elem.style.height = value + "px";
}

HDOMElement.addHeight = function(elem, value) {
	HDOMElement.setHeight(elem, HDOMElement.getHeight(elem) + value);
}

HDOMElement.subHeight = function(elem, value) {
	HDOMElement.setHeight(elem, HDOMElement.getHeight(elem) - value);
}

HDOMElement.getTop = function(elem) {
	return parseInt(elem.style.top);
}

HDOMElement.setTop = function(elem, value) {
	elem.style.top = value + "px";
}

HDOMElement.addTop = function(elem, value) {
	HDOMElement.setTop(elem, HDOMElement.getTop(elem) + value);
}

HDOMElement.subTop = function(elem, value) {
	HDOMElement.setTop(elem, HDOMElement.getTop(elem) - value);
}

HDOMElement.getLeft = function(elem) {
	return parseInt(elem.style.left);
}

HDOMElement.setLeft = function(elem, value) {
	elem.style.left = value + "px";
}

HDOMElement.addLeft = function(elem, value) {
	HDOMElement.setLeft(elem, HDOMElement.getLeft(elem) + value);
}

HDOMElement.subLeft = function(elem, value) {
	HDOMElement.setLeft(elem, HDOMElement.getLeft(elem) - value);
}

HDOMElement.getVisibility = function(elem) {
	return elem.style.visibility;
}

HDOMElement.setVisibility = function(elem, value) {
	elem.style.visibility = value;
}

/*
 * Object Properties
 */
HDOMElement.prototype.getWidth = function() {
	return HDOMElement.getWidth(this.elem);
}

HDOMElement.prototype.setWidth = function(value) {
	HDOMElement.setWidth(this.elem, value);
}

HDOMElement.prototype.getHeight = function() {
	return HDOMElement.getHeight(this.elem);
}

HDOMElement.prototype.setHeight = function(value) {
	HDOMElement.setHeight(this.elem, value);
}

HDOMElement.prototype.getTop = function() {
	return HDOMElement.getTop(this.elem);
}

HDOMElement.prototype.setTop = function(value) {
	HDOMElement.setTop(this.elem, value);
}

HDOMElement.prototype.getLeft = function() {
	return HDOMElement.getLeft(this.elem);
}

HDOMElement.prototype.setLeft = function(value) {
	HDOMElement.setLeft(this.elem, value);
}

