﻿/* グリッドロケータ to Map S.Yoshikawa 2008/07/29 */
//<![CDATA[
function load() {
    if (GBrowserIsCompatible()) {
	var NS=34.9;
	var EW=137.1;
        map = new GMap2(document.getElementById("gmap"));
/*	map.addControl(new GSmallMapControl()); */
        map.addControl(new GLargeMapControl());
	map.addControl(new GMapTypeControl());
	map.addControl(new GScaleControl());
	map.setCenter(new GLatLng(NS, EW), 9);
    }
}

function GLcalc(){
	CODE = document.GL2.CODE.value.toUpperCase();		/* 大文字変換 */
	if(CODE.length < 4) {alert("GLcode short"); return false;}
	if(isNaN(CODE.charAt(0)) != 1) {alert("1st = A to R"); return false;}
	if(isNaN(CODE.charAt(1)) != 1) {alert("2nd = A to R"); return false;}
	if(isNaN(CODE.charAt(2)) == 1) {alert("3rd = 0 to 9"); return false;}
	if(isNaN(CODE.charAt(3)) == 1) {alert("4th = 0 to 9"); return false;}

	var EW = (CODE.charCodeAt(0)-65)*20 + (parseInt(CODE.charAt(2)))*2;	/* 緯度 */
	var NS = (CODE.charCodeAt(1)-65)*10 + parseInt(CODE.charAt(3));		/* 経度 */

	Code4 = CODE.charCodeAt(4);
	if(Code4 > 64 && Code4 < 89){
		EW = EW + (Code4 -65)/12 +0.0416667;	/* 2度を24分割 */
		EW = EW.toFixed(6);
	}else{
		EW = EW +1;				/* センター */
	}

	Code5 = CODE.charCodeAt(5);
	if(Code5 > 64 && Code5 < 89){
		NS = NS + (Code5 -65)/24 +0.0208333;	/* 1度を24分割 */
		NS = NS.toFixed(6);
	}else{
		NS = NS + 0.5;				/* センター */
	}

	EW = EW -180;
	NS = NS -90;
/*	document.write(NS," ",EW); */
	var ITI = NS +" / "+ EW;
	document.GL2.DISP1.value = (ITI);

        map.setCenter(new GLatLng(NS, EW));
/*	map.panTo(new GLatLng(NS, EW));		*/
}
//]]>
