<html>
  <head>
    <script type="text/javascript">
        // Parse query string and set variables
        var url = location.href;
        var queryStringPos = url.indexOf("?");
        if( queryStringPos != -1 )
        {
            url = url.substring(queryStringPos + 1);
            var variables = url.split ("&");
            for (i = 0; i < variables.length; i++)
            {
                if( !variables[i] )
                    continue;
                var keyValue = variables[i].split("=");
                eval ('var '+keyValue[0].toLowerCase()+'="'+keyValue[1]+'"');
            }
        }
        else
        {
            dump("YWMS ERROR: no queryString\n");
        }
    </script>
    <script type="text/javascript" src="http://api.maps.yahoo.com/ajaxymap?v=3.8&appid=z7qRk3_V34HAbY_SkC7u7GAgG5nDTblw.cuL1OS5LWGwkIIUeGjg4qsnJDPpmhoF"></script>
  </head>

  <body style="margin: 0px">
    <div id="map"></div>
    <script type="text/javascript">
      if( !bbox || !width || !height)
      {
          alert("YWMS ERROR: invalid parameters\n");
      }
      else
      {
        // Resize map container to parameter dimension
        var mapDiv = document.getElementById("map");

        // Get the bounding box
        var coords = bbox.split(",");
        var tllon  = Number(coords[0]), tllat = Number(coords[1]);
        var brlon  = Number(coords[2]), brlat = Number(coords[3]);

        var points = new Array();
        points[0] = new YGeoPoint(tllat, tllon);
        points[1] = new YGeoPoint(brlat, brlon);

        // other map types work as well but only satellite allowed for use with OSM!
        var map = new YMap(document.getElementById("map"), YAHOO_MAP_SAT, new YSize(width, height));
        map.removeZoomScale();
        var zac = map.getBestZoomAndCenter(points);
        var level = zac.zoomLevel-1;
        var levels = map.getZoomValidLevels();
        if(levels[0] > level)
          level = levels[0];

        map.drawZoomAndCenter(zac.YGeoPoint,level);

        // Get the on-screen coordinates of the points
        xy0 = map.convertLatLonXY(points[0]);
        xy1 = map.convertLatLonXY(points[1]);

        // Recenter the stuff to have exact edges
        cx = map.convertXYLatLon(new YCoordPoint((xy0.x+xy1.x)/2.0, (xy0.y+xy1.y)/2.0));
        map.drawZoomAndCenter(cx,level)

        // Create a new size for the map. This makes the need of clipping the image unnecessary.
        new_width  = Math.abs( xy0.x - xy1.x);
        new_height = Math.abs( xy0.y - xy1.y);

        // Apply the new width-height
        map.resizeTo( new YSize(new_width, new_height));
        mapDiv.style.width  = new_width;
        mapDiv.style.height = new_height;
        window.moveTo(0,0);
        window.resizeTo(new_width, new_height);
      }
    </script>
  </body>
</html>