//<![CDATA[
var geocoder;
var map;

//MTから住所・緯度経度を読み込み

//プロフィール : 住所
var profileAddress = "〒807-1144<br />福岡県北九州市八幡西区真名子2-14-14";

//プロフィール住所
var accessAddress = "福岡県中間市七重町32-10";

var mapLatLon = "33.801994,130.720907";


var inputLat;
var inputLon;

//Google Maps読み込み

function googleMapsLoadInit(){
  
  if(mapLatLon != ""){
	var mapLatLonAry = mapLatLon.split(",");
	inputLat = mapLatLonAry[0];
	inputLon = mapLatLonAry[1];
	
	inputLat = inputLat.replace("\s", "");
	inputLat = inputLat.replace("　", "");
	inputLon = inputLon.replace("\s", "");
	inputLon = inputLon.replace("　", "");
	
	showLatLon(inputLat, inputLon);
	
  }else if(accessAddress != ""){
	showAddress(accessAddress);
	
  }else if(profileAddress != ""){
	showAddress(profileAddress);
	
  }
}
if (window.addEventListener) { //for W3C DOM
	window.addEventListener("load", googleMapsLoadInit, false);
} else if (window.attachEvent) { //for IE
	window.attachEvent("onload", googleMapsLoadInit);
}

////////// 緯度経度でマーカーを表示 //////////
function showLatLon(lat, lon) {
  
  var latlng = new google.maps.LatLng(lat, lon);
  var myOptions = {
	zoom: 15,
	center: latlng,
	mapTypeId: google.maps.MapTypeId.ROADMAP
  };
  var map = new google.maps.Map(
	document.getElementById("googleMapsArea"),
	myOptions
  );
  var marker = new google.maps.Marker({
	map: map, 
	position: latlng
  });
}
////////// 地名でマーカーを表示 //////////
function showAddress(address) {
  geocoder = new google.maps.Geocoder();
  if (geocoder) {
	geocoder.geocode( { 'address': address}, function(results, status) {
	  if (status == google.maps.GeocoderStatus.OK) {

		var myOptions = {
		  zoom: 15,
		  center: results[0].geometry.location,
		  mapTypeId: google.maps.MapTypeId.ROADMAP
		};
		var map = new google.maps.Map(
		  document.getElementById("googleMapsArea"),
		  myOptions
		);
		var marker = new google.maps.Marker({
		  map: map, 
		  position: results[0].geometry.location
		});
	  }
	});
  }
}

//]]>

