// JavaScript Document
var basePath = "/navi/";
var largeMapPath = "/map/map.php";
var placeJSPath = "/map/place.js.php";
var zoomLevel = 2;
var icon = {
  image:"/map/icons/small_icon.png",
  shadow:"/map/icons/small_shadow.png",
  height:20,
  width:22,
  center:6};
var genreTable = {gr:1,be:2,ss:3,sc:4,le:5,ht:6,hs:7};
var GAPIKey = "ABQIAAAAUKlLEM7O76RBazhLbd6YoxSYx-iahpXh5ISYquzKvds1rfA3CBQJZEDpihYZHbRgDrWFlHGviAcPUw";
var shop = getShopData();
var largeMapURL = largeMapPath+"?g="+shop.gid+"&name="+shop.name;
var point = null;

document.write('<script src="http://maps.google.co.jp/maps?file=api&v=2&key='+GAPIKey+'" type="text/javascript" charset="utf-8"></script>');
document.write('<script src="'+placeJSPath+'?g='+shop.gid+'&name='+shop.name+'" type="text/javascript"></script>');

function getShopData() {
  var a = location.pathname;
  var reg =  new RegExp(basePath+"([a-zA-Z0-9_.\-]+)/([a-zA-Z0-9_.\-]+)/");
  if (reg.exec(a)) {
    return {gid:genreTable[RegExp.$1],name:RegExp.$2};
  }
  else {
    return null;
  }
}

function openLargeMap() {
  window.open(largeMapURL , "_blank");
}

function goLargeMap() {
  location.href = largeMapURL;
}

function startMap() {
if (point != null) {
  var gp = new GPoint(point.lng, point.lat);
  var map = new GMap(document.getElementById("map"));
  map.addControl(new GSmallMapControl());
  map.centerAndZoom(gp, zoomLevel);
  var gi = new GIcon();
  gi.image = icon.image;
  gi.shadow = icon.shadow;
  gi.iconSize = new GSize(icon.width, icon.height);
  gi.shadowSize = new GSize(icon.width, icon.height);
  gi.iconAnchor = new GPoint(icon.center, icon.height);
  gm = new GMarker(gp, gi);
//  GEvent.addListener(gm, "click", function(){openLargeMap();});
  map.addOverlay(gm);
}
}
