  // getZoomLevel by Ted Timmons, perljam.net. Please leave this comment
  //  intact, and send modifications/corrections to google-zoom-js at perljam.net.
  //
  //function getZoomLevel(url, maptype) {
  //  var re = /spn=([\d\.]+)\,([\d\.]+)/;                                              
  //  var regexData = re.exec(url);
  //  var y = regexData[2];
  function getZoomLevel(y, maptype) {
    var zoomOffset = 0;
    if (y > 0) {
      zoomOffset = Math.round(Math.log(y*432) / Math.LN2);
      if (zoomOffset < 0) { zoom = 0; }
    }

    var zoom = maptype.getMaximumResolution(0) - zoomOffset;
    return zoom;

  }

  function showMap(lat, lon, spn_x, spn_y, z, type) {
    var map = new GMap2($("map"));
    map.addControl(new GLargeMapControl());
    map.addControl(new GMapTypeControl());
    map.enableDoubleClickZoom();

    var zoom = z ? z : getZoomLevel(spn_y, type);

    map.setCenter(new GLatLng(lat, lon), zoom, type);

  }
