function alreadyin, list, token {
rv = 0
for i=1, nelements(list) {
if (list[i] == token) {
rv = 1
}
}
alreadyin = rv
}

function unify, input {
list = input
replace list, "\.", " "
replace list, ",", " "
replace list, "\"", " "
list = lower(list)
list = simplifywhitespace(list)
list = strsplit(list)
rv = stringarray(0)
rv += list[1]
for i=2, nelements(list) {
bla = list[i]
if (alreadyin(rv, bla) == 0) {
rv += bla
}
}
unify = rv[1]
for i=2, nelements(rv) {
if (strlen(rv[i]) > 2) {
unify += " " + rv[i]
}
}
replace unify, "  ", " "
}

function menu, header, current {
 rv = stringarray(0)
 for i=1, nelements(header) {
  if (strpos(header[i], current) == -1) {
   rv += header[i]
  } else {
   rv += "<li><a class=\"current\"" + header[i][7:strlen(header[i])]
  }
 }
 menu = rv
}

function html_header {
html_header = stringarray(0)
html_header += "<div id=\"header\">DPUSER - The Next Generation</div>"
html_header += "<div id=\"menu\">"
html_header += "<ul>"
html_header += "<li><a href=\"index.html\">Introduction</a></li>"
//html_header += "<li><a href=\"installing.html\">Installation</a></li>"
html_header += "<li><a href=\"history.html\">History</a></li>"
html_header += "<li><a href=\"syntax.html\">Syntax</a></li>"
html_header += "<li><a href=\"operators.html\">Operators</a></li>"
html_header += "<li><a href=\"ifandloop.html\">Structural commands</a></li>"
html_header += "<li><a href=\"variables.html\">Data types</a></li>"
html_header += "<li><a href=\"plotting.html\">Graphics</a></li>"
html_header += "<li><a href=\"fitsfiles.html\">Fits files</a></li>"
html_header += "<li><a href=\"bridges.html\">Calling PYTHON/GDL</a></li>"
html_header += "<li><a href=\"category.html\">Category index</a></li>"
html_header += "<li><a href=\"functions.html\">Function index</a></li>"
html_header += "<li><a href=\"procedures.html\">Procedure index</a></li>"
html_header += "<li><a href=\"pgplot.html\">Pgplot index</a></li>"
html_header += "<li><a href=\"examples.html\">Examples</a></li>"
html_header += "<hr>"
html_header += "<li><a href=\"qfitsview.html\">QFitsView documentation</a></li>"
html_header += "<hr>"
html_header += "</ul>"
html_header += "<form method=\"GET\" action=\"search.html\">"
html_header += "<input type=\"text\" size=15 name=\"keywords\">"
html_header += "<input type=\"submit\" value=\"Search\">"
html_header += "</form>"
html_header += "</div>"
html_header += "<div id=\"content\">"
}

function footer {
footer = stringarray(0)
footer += "</div>"
footer += "<div id=\"footer\">"
footer += version()
footer += " - <a href=\"http://www.mpe.mpg.de/impressum\">Imprint</a> - <a href=\"http://www.mpe.mpg.de/data-protection\">Privacy Policy</a>"
footer += "</div>"
}

function nohtml, input {
nohtml = stringarray(0)
i = 1
while (strpos(input[i], "<h1") == -1) i++
//print i
while (i < nelements(input)) {
line = input[i]
replace line, "<h1>", ""
replace line, "<[^>]+>", ""
replace line, "<div[^>]+>", ""
nohtml += line
i++
}
}

