﻿//! インフォメーションウィンドウ
var isWindow = false;	// 現在開いているか
function onOpenWindow(point, html) {
	map.enableDragging();
	map.openInfoWindowHtml(point, html, null, null, onCloseWindow);
	isWindow = true;
}
function onCloseWindow() {
	map.disableDragging();
	map.recenterOrPanToLatLng(camera.eye);
	isWindow = false;
}

//! メッセージウィンドウ
var Message = Class.create();
Message.prototype = {
	initialize : function() {
		this.timer = 0;
	},
	print : function(txt) {
		$('message').innerHTML = txt;
		this.timer = 60;
	},
	update : function() {
		if (this.timer > 0) if (--this.timer == 0) $('message').innerHTML = '';
	}
}

// デバッグ用プロパティダンプ
function dump(obj) {
    for (var prop in obj) {
    	$debugArea += "obj." + prop + " = " + obj[prop];   
    }
}

//! 16方向正規化（常にプラス）
function norm16(r) {
	return (r < 0) ? (r + 16) : ( (r >= 16) ? (r - 16) : r );
}
//! 16方向差分（プラスマイナス）
function diff16(r0, r1) {
	var r = r0 - r1;
	return (r <= -8) ? (r + 16) : ( (r > 8) ? (r - 16) : r );
}
//! 16方向atan
function atan16(y, x) {
	var r = Math.round(Math.atan2(y, x) * 8 / Math.PI);
	return (r >= 0) ? r : r + 16;
}
//! 16方向sin
function sin16(r) {
	return Math.sin(r * Math.PI / 8);
}
//! 16方向cos
function cos16(r) {
	return Math.cos(r * Math.PI / 8);
}
