    var map;
    var gdir;
    var geocoder = null;
    var addressMarker;

    function initialize() {
      if (GBrowserIsCompatible()) {
	  map = new GMap2(document.getElementById("mapcanvas"),{size:new GSize(640,400)});
	  map.addControl(new GLargeMapControl());
      map.addControl(new GMapTypeControl());
	  var point = new GLatLng(35.926982,139.414374);
      map.setCenter(point, 14);
	  var icon = new GIcon();
      icon.image = "http://www.jp-s.com/wp-content/themes/spacecom01/js/sp_fav.jpg";
      icon.iconSize = new GSize(26, 26);
      icon.iconAnchor = new GPoint(0, 0);
	  var markeropts = new Object();
	  markeropts.icon = icon;
	  var marker = new GMarker(point, markeropts);
	  map.addOverlay(marker);
	  gdir = new GDirections(map, document.getElementById("directions"));
	  GEvent.addListener(gdir, "error", handleErrors);
	  }
	  GEvent.addListener(marker, 'click', function() {
      map.openInfoWindowHtml(map.getCenter(),"<div style='margin:6px;color:#000;'<strong style='font-size:12px;'>スペースコム</strong><p style='margin:6px;font-size:12px;line-height:180%;'>埼玉県鶴ヶ島市松ヶ丘5-1-4<br />TEL：049-279-5115<br />FAX:049-279-3441</div>");
      });
    }
    
    function setDirections(fromAddress, toAddress, locale) {
      gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": locale });
    }

    function handleErrors(){
      if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
        alert("住所もしくは出発点が見つかりませんでした。\nError code: " + gdir.getStatus().code);
      else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
        alert("サーバーエラー\n Error code: " + gdir.getStatus().code);

      else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
        alert("出発点が入力されていません。.\n Error code: " + gdir.getStatus().code);

      else if (gdir.getStatus().code == G_GEO_BAD_KEY)
        alert("所定のキーは無効であるか、それが与えられた領域にマッチしません。\n Error code: " + gdir.getStatus().code);

      else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
        alert("方向要請は、うまく解析されることができませんでした。\n Error code: " + gdir.getStatus().code);

      else alert("原因不明のエラーが起こりました。");

    }
