var basehtml_head;
var basehtml_tail;
var iframehtml;


function renewHtmlOutputCode(startx, starty, zoom) {

var n_markers = 0;
var n_links = 0;
var n_infowins = 0;
for (var m = markerlist_head; m != null; m = m.next) {
if (m.link != null) {
n_links++;
}
if (m.infowin_html != null) {
n_infowins++;
}
n_markers++;
}

basehtml_head  = "<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\r\n";
basehtml_head += "\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\r\n";
basehtml_head += "<html xmlns=\"http://www.w3.org/1999/xhtml\">\r\n";
basehtml_head += "  <head>\r\n";

basehtml_head += "    <title>" + title + "</title>\r\n";

basehtml_head += "    <script src=\"http://maps.google.com/maps?file=api&v=2&key=" + key + "\"\r\n";
basehtml_head += "        type=\"text/javascript\" charset=\"utf-8\"></script>\r\n";

basehtml_head += "    <script type=\"text/javascript\">\r\n";
basehtml_head += "    //<![CDATA[\r\n";
basehtml_head += "    var map;\r\n";

if (n_markers > 0) {
basehtml_head += "    var markers = new Array(" + n_markers + ");\r\n";
}

basehtml_head += "    function onLoad() {\r\n";

basehtml_head += "      map = new GMap(document.getElementById(\"map\"));\r\n";
basehtml_head += "      map.centerAndZoom(new GPoint(" + startx + "," + starty + ")," + zoom + ");\r\n";

if (glargemapcontrol != null) {
basehtml_head += "      map.addControl(new GLargeMapControl());\r\n";
}
if (gsmallmapcontrol != null) {
basehtml_head += "      map.addControl(new GSmallMapControl());\r\n";
}
if (gsmallzoomcontrol != null) {
basehtml_head += "      map.addControl(new GSmallZoomControl());\r\n";
}
if (gmaptypecontrol != null) {
basehtml_head += "      map.addControl(new GMapTypeControl());\r\n";
}

if (maptype != null) {
basehtml_head += "      map.setMapType(" + maptype + ");\r\n";
}

if (markerlist_head != null) {
basehtml_head += "      var marker = null;\r\n";
basehtml_head += "      var n_markers = 0;\r\n";
for (var m = markerlist_head; m != null; m = m.next) {
if (m.icon != null) {
basehtml_head += "      var icon = new GIcon();\r\n";
basehtml_head += "      icon.image = \"" + m.icon.image + "\";\r\n";
basehtml_head += "      icon.iconSize = new GSize(" + m.icon.iconSize.width + "," + m.icon.iconSize.height + ");\r\n";
basehtml_head += "      icon.iconAnchor = new GPoint(" + m.icon.iconAnchor.x + "," + m.icon.iconAnchor.y + ");\r\n";
basehtml_head += "      marker = new GMarker(new GPoint(" + m.x + "," + m.y + "), icon);\r\n";
if (m.link != null) {
basehtml_head += "      marker.jmplnk = \"" + m.link + "\";\r\n";
}
} else {
basehtml_head += "      marker = new GMarker(new GPoint(" + m.x + "," + m.y + "));\r\n";
}

basehtml_head += "      markers[n_markers] = marker;\r\n";
basehtml_head += "      n_markers++;\r\n";
basehtml_head += "      map.addOverlay(marker);\r\n";
}
}

if (n_links > 0) {
basehtml_head += "      GEvent.addListener(map, 'click', onMapClick);\r\n";
}

basehtml_head += "    }\r\n";

if (n_links > 0) {
basehtml_head += "    function onMapClick(overlay, point) {\r\n";
basehtml_head += "      if (overlay) {\r\n";
basehtml_head += "        for (var i=0; i<" + n_markers + ";" + " i++) {\r\n";
basehtml_head += "          if (overlay == markers[i]) {\r\n";
basehtml_head += "            if (markers[i].jmplnk != null) {\r\n";
basehtml_head += "              location = markers[i].jmplnk;\r\n";
basehtml_head += "            }\r\n";
basehtml_head += "            break;\r\n";
basehtml_head += "          }\r\n";
basehtml_head += "        }\r\n";
basehtml_head += "      }\r\n";
basehtml_head += "    }\r\n";
}


basehtml_tail  = "    //]]>\r\n";
basehtml_tail += "    </script>\r\n";
basehtml_tail += "  </head>\r\n";

basehtml_tail += "  <body onload=\"onLoad()\" style=\"margin:0px; padding:0px;\">\r\n";
basehtml_tail += "    <div id=\"map\" style=\"width:" + width + "px; height:" + height + "px; margin:0px; padding:0px;\"></div>\r\n";
basehtml_tail += "    <div style=\"font-size:10px;text-align:right;\"><a href=\"http://www.geekpage.jp/\">GMapCreator</a></div>\r\n";
basehtml_tail += "  </body>\r\n";
basehtml_tail += "</html>\r\n";


iframehtml = "<iframe src=\"YOURHTMLFILENAME.HTML\" width=\"" + width + "\" height=\"" + height + "\" scrolling=\"NO\" frameborder=\"0\"></iframe>\r\n";

}