/**
 * 設定
 */
// インデックスファイル再読み込み間隔（ミリ秒）
// 例）300000:5分、150000:2分30秒、60000:1分
var readIndexInterval = 150000;

// インデックスファイルキャッシュ時間（ミリ秒）
var indexCacheTime    = 150000;

// 注警報キャッシュ時間（ミリ秒）
var worningCacheTime  = 150000;

// お知らせキャッシュ時間（ミリ秒）
var telopCacheTime       = 60 * 60 * 1000;

// お知らせ一覧キャッシュ時間（ミリ秒）
var informationCacheTime = 60 * 60 * 1000;

// アニメーション間隔（ミリ秒）
var animationInterval = 1000;
// 
/**
 * 各オブジェクト作成
 */
// 動的スクリプト読み込みオブジェクト作成
dynamicloadScript = new DynamicloadScript().setProperties({
	url : toRootUrl + "/scripts/mesh_index.js",
	interval : readIndexInterval,
	cacheTime : indexCacheTime//,
});

// ドラッグする地図レイヤーのオブジェクト作成
var dragLayer = new DragLayer().setProperties({
	contentId : "meshMapArea",
	posX : 0 - (3080 - 770) / 2,
	posY : 0 - (1920 - 480) / 2//,
});

// 右下のクリッカブルマップの黄色い四角オブジェクト作成
var magnifyMap     = [1403, 689];
var navigationMap  = [ 156,  82];
var boundaryOffset = [  70,  60];
var areaBoundary = new DragLayer().setProperties({
	posX : -81,
	posY : -52,
	contentId : "area_boundary",
	enableDrag : false//,
});
areaBoundary.clickMapId = "use_navi_map";
areaBoundary.retioX = magnifyMap[0] / navigationMap[0];
areaBoundary.retioY = magnifyMap[1] / navigationMap[1];
areaBoundary.offsetX = 70;
areaBoundary.offsetY = 60;

// スライダーオブジェクト作成
var slider = new SlideController().setProperties({
	targetId   : "recordSelectSlider",
	useDefauleLane : false,
	offsetX : 4,
	offsetY : 1,
	width  : sliderWidth + 11,
	points : 25,
	imageBase : languageBaseFolder + "/images/time_panel",
	images : {
		knobImage  : "time_panel_knob_blink.gif",// ノブ通常
		knobLatest : "time_panel_knob.gif",// ノブ通常(最新時)
		knobPoint  : "time_panel_knob_click.gif" // ノブクリック時
	}//,
});

// アニメーションオブジェクト作成
var animation = new JSAnimation().setProperties({
	interval : animationInterval//,
});

// 一定期間ごとにリロードするiframeのHTML
var reloadContent = new ReloadContent().setProperties({
	contentList :[
		{id : "information_telop", cacheTime : telopCacheTime,
			url : languageBaseFolder + "/info/info.html"},
		{id : "information_list", cacheTime : informationCacheTime,
			url : languageBaseFolder + "/info/info_list.html"},
		{id : "warning_list", cacheTime : worningCacheTime,
			url : languageBaseFolder + "/info/warn.html"}//,
	]//,
});

// 拡張ボタンクラス設定
ButtonExtensionPlus.setRoleSuffix({
	enabled   : '',// 使用可能画像
	disabled  : '_off',// 使用不可画像
	selected  : '_on',// 選択済画像
	mouseOver : '_on',// マウスオーバー画像
	mouseDown : '_on'//,// マウスダウン画像
});
// オブジェクト作成
var amesh = new Amesh().setProperties({
	meshImagePath : toRootUrl + "/mesh",
//	meshImagePath : "/cgi-bin/get_image.pl/2",
	fixedMapPath  : toRootUrl + "/map",
	errorImage    : languageBaseFolder + "/images/spacer.gif",

	explanationId  : "explanation",
	meshImageId    : "rainfallMesh",
	backgroundId   : "backgroundMap",
	frontLayerId   : "foregroundMap",
	datetimeId     : "datetime",
	nowLoadingId   : "now_loading",
	errorDisplayId : "error_display",

	localizeDateStrings : localizeDateStrings,
	regionMap     : regionMap,
	areaMap       : areaMap,
	buttons : {
		recordBack : new ButtonExtensionPlus("recordBack"),
		recordNext : new ButtonExtensionPlus("recordNext"),
		moviePlay  : new ButtonExtensionPlus("moviePlay"),
		moviePause : new ButtonExtensionPlus("moviePause"),
		movieStop  : new ButtonExtensionPlus("movieStop"),

		recordList : new ButtonExtensionPlus("recordList"),
		wholeMap   : new ButtonExtensionPlus("wholeMap"),
		magnifyMap : new ButtonExtensionPlus("magnifyMap")//,
	},
	dynamicloadScript : dynamicloadScript,
	dragLayer : dragLayer,
	slider    : slider,
	animation : animation,
	areaBoundary : areaBoundary,
	reloadContent : reloadContent//,
}).addOnloadListener();// オンロード後に実行

// Netscape6.X なら「Now Loadding...」しない
if (IsGeckoRevisionLessThan(1)) {
	amesh.enableLoadingStatus = false;
}
// JSONP用関数
Amesh.setIndexList = function (list) {
//console.log("Index first line: [" + list[0] + "] length: [" + list.length + "]");
	amesh.imageList = list;
	amesh.changeImage();
	amesh.reloadContent.load();
};

// MM_***用
function changeArea(code) {
	amesh.changeArea(code);
}

function getCookieParamaters() {
	if (Cookie.get("index")) {
		amesh.index = parseInt(Cookie.get("index"));
	}
	Cookie.set("index", "0", null, "/");

	if (Cookie.get("area")) {
		amesh.area = Cookie.get("area");
	}
	Cookie.set("area", "000", null, "/");
}
