func mapDetailHandler(w http.ResponseWriter, r *http.Request, m *vc.Map) {
	fmt.Fprintf(w, "<html><head><title>Map %s</title>\n", m.Name)
	io.WriteString(w, "<style>table, th, td {border: 1px solid black;};</style>")
	io.WriteString(w, "</head><body>\n")
	fmt.Fprintf(w, "<h1>%s</h1>\n%s", m.Name, m.StartMsg)
	fmt.Fprintf(w, "<p><a href=\"/maps/%d/WIKI\">Wiki Formatted</a></p>", m.Id)
	io.WriteString(w, "<div>\n")
	io.WriteString(w, "<table><thead><tr>\n")
	io.WriteString(w, "<th>No</th><th>Name</th><th>Long Name</th><th>Start</th><th>End</th><th>Story</th><th>Boss Start</th><th>Boss End</th>\n")
	io.WriteString(w, "</tr></thead>\n")
	io.WriteString(w, "<tbody>\n")
	for _, e := range m.Areas(VcData) {
		fmt.Fprintf(w, "<tr><td>%d</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td><td>%s</td></tr>",
			e.AreaNo,
			e.Name,
			e.LongName,
			e.Start,
			e.End,
			e.Story,
			e.BossStart,
			e.BossEnd,
		)
	}
	io.WriteString(w, "</tbody></table></div></body></html>")
}
func mapDetailWikiHandler(w http.ResponseWriter, r *http.Request, m *vc.Map) {
	fmt.Fprintf(w, "<html><head><title>Map %s</title>\n", m.Name)
	io.WriteString(w, "<style>table, th, td {border: 1px solid black;};</style>")
	io.WriteString(w, "</head><body>\n")
	fmt.Fprintf(w, `<h1>%s</h1>
<p><a href="../%d/WIKI">prev</a> &nbsp; <a href="../%d/WIKI">next</a></p>
<p>%s</p>`,
		m.Name,
		m.Id-1,
		m.Id+1,
		m.StartMsg,
	)
	io.WriteString(w, "<div>\n")
	io.WriteString(w, "<textarea style=\"width:800px;height:760px\">\n")
	fmt.Fprintf(w, `{{#tag:gallery|
Banner {{#titleparts:{{PAGENAME}}|1}}.png
AreaMap %s.png
BattleBG %d.png
|type="slider"
|widths="680"
|position="left"
|captionposition="within"
|captionalign="center"
|captionsize="small"
|bordersize="none"
|bordercolor="transparent"
|hideaddbutton="true"
|spacing="small"
}}

{| border="0" cellpadding="1" cellspacing="1" class="article-table wikitable" style="width:680px;" 
|-
! scope="col" style="width:120px;" |Area
! scope="col"|Dialogue
`,
		m.Name,
		0,
	)

	if m.StartMsg != "" {
		fmt.Fprintf(w, "|-\n| align=\"center\" |%s\n|%s\n", m.Name, html.EscapeString(strings.Replace(m.StartMsg, "\n", " ", -1)))
	}

	for _, e := range m.Areas(VcData) {
		if e.Story != "" || e.Start != "" || e.End != "" || e.BossStart != "" || e.BossEnd != "" {
			fmt.Fprintf(w, "|-\n| align=\"center\" |%s\n|\n", e.LongName)

			if e.Story != "" {
				fmt.Fprintf(w, "; Prologue\n: %s\n", html.EscapeString(strings.Replace(e.Story, "\n", " ", -1)))
				if e.Start != "" || e.End != "" || e.BossStart != "" || e.BossEnd != "" {
					io.WriteString(w, "----\n\n")
				}
			}

			if e.Start != "" || e.End != "" {
				io.WriteString(w, "; Guide Dialogue")
				if e.Start != "" {
					fmt.Fprintf(w, "\n: ''%s''",
						html.EscapeString(strings.Replace(e.Start, "\n", " ", -1)))
					if e.End != "" {
						io.WriteString(w, "<br />&amp;nbsp;<br />")
					}
				}
				if e.End != "" {
					fmt.Fprintf(w, "\n: ''%s''\n",
						html.EscapeString(strings.Replace(e.End, "\n", " ", -1)))
				} else {
					io.WriteString(w, "\n")
				}
				if e.BossStart != "" || e.BossEnd != "" {
					io.WriteString(w, "----\n\n")
				}
			}

			if e.BossStart != "" || e.BossEnd != "" {
				fmt.Fprintf(w, "; Boss Dialogue")
				if e.BossStart != "" {
					fmt.Fprintf(w, "\n: %s",
						html.EscapeString(strings.Replace(e.BossStart, "\n", " ", -1)))
					if e.BossEnd != "" {
						io.WriteString(w, "<br />&amp;nbsp;<br />")
					}
				}
				if e.BossEnd != "" {
					fmt.Fprintf(w, "\n: %s\n",
						html.EscapeString(strings.Replace(e.BossEnd, "\n", " ", -1)))
				} else {
					io.WriteString(w, "\n")
				}
			}
		}
	}
	io.WriteString(w, "|}\n[[Category:Story]]\n</textarea></div></body></html>")
}