var Amesh = {

updateMap: function() {
	var data = this.list[this.index];
	if (this.lastdata != data) {
		this.lastdata = data;

		document.getElementById('MapLoader').style.opacity = '.4';

		var curtime = data.substr(0,4) + '/' + data.substr(4,2) + '/' + data.substr(6,2) + ' ' + data.substr(8,2) + ':' + data.substr(10,2);
		if (this.st) {
			this.st.nodeValue = curtime;
		} else {
			this.st = document.createTextNode(curtime);
			document.getElementById('MapText').appendChild(this.st);
		}

		var imgsrc = 'http://tokyo-ame.jwa.or.jp/mesh/000/' + data + '.gif';
		if (this.img) {
			this.img.setAttribute('src', imgsrc);
		} else {
			this.img = document.createElement('img');
			this.img.setAttribute('src', imgsrc);
			this.img.setAttribute('onload', 'Amesh.onLoadImage()');
			document.getElementById('MapData').appendChild(this.img);
		}
	} else {
		this.onLoadImage();
	}
},

onLoadImage: function() {
	document.getElementById('btPrev').style.opacity = '1';
	document.getElementById('btNext').style.opacity = '1';
	document.getElementById('btRefresh').style.opacity = '1';
	document.getElementById('MapLoader').style.opacity = '0';
},

setIndexList: function(list) {
	this.list = list;
	this.index = 0;
	this.updateMap();
},

showPrev: function() {
	if (this.index < this.list.length - 1) {
		document.getElementById('btPrev').style.opacity = '0.5';
		this.index++;
		this.updateMap();
	}
},

showNext: function() {
	if (this.index > 0) {
		document.getElementById('btNext').style.opacity = '0.5';

		this.index--;
		this.updateMap();
	}
},

initmap: function() {
	document.getElementById('btRefresh').style.opacity = '0.5';

	if (this.script) {
		document.getElementsByTagName('head')[0].removeChild(this.script);
	}
	var script = document.createElement('script');
	script.setAttribute('id', 'meshindex');
	script.setAttribute('type', 'text/javascript');
	script.setAttribute('src', 'http://tokyo-ame.jwa.or.jp/scripts/mesh_index.js?' + (new Date()).getTime());
	this.script = script;
	document.getElementsByTagName('head')[0].appendChild(script);
}
}
