@tools.dpuser

function fixpgplot, current {
    fixpgplot = stringarray(0)
    n = 1
    while (strpos(current[n], "<table CELLSPACING=0") == -1) {
        fixpgplot += current[n]
        n++
    }
    n += 2
    fixpgplot += "<h1 class=\"declaration\">" + current[n] + "</h1>"
    n += 2
    while (n <= nelements(current)) {
        fixpgplot += current[n]
        n++
    }
}

files = ["index.html","history.html","syntax.html","operators.html","ifandloop.html","variables.html","plotting.html","fitsfiles.html","bridges.html","category.html","functions.html","procedures.html","pgplot.html","examples.html"]
curdir = pwd()
cd ".."
files += dir("function_*.html")
files += dir("procedure_*.html")
files += dir("pgplot_*.html")
cd curdir

style = import("style.html", /text);

for n=1, nelements(files) {
    print files[n]
    content = import("../" + files[n], /text)
    if (strpos(files[n], "pgplot_") != -1) content = fixpgplot(content)
    output = stringarray(0)
    j = 1
    while (strpos(content[j], "</head>") == -1) {
        output += content[j]
        j++
    }
    output += style
    while (strpos(content[j], "<h1") == -1) {
        output += content[j]
        j++
    }
    output += menu(html_header(), files[n])
    while (strpos(content[j], "</body>") == -1) {
        output += content[j]
        j++
    }
    output += footer()
    while (j <= nelements(content)) {
        output += content[j]
        j++
    }
    export files[n], output
}

exec "cp ../*.png ."

output = stringarray(0)
output += "<html>"
output += "<head>"
output += "<title>DPUSER Search Results</title>"
output += style
output += "<link rel=\"shortcut icon\" href=\"dpuser.ico\" type=\"image/xicon\">"
output += "</head>"
output += "<body>"
output += menu(html_header(), "nix.html")
output += "<h1>Search Results</h1>"
output += "<hr>"

output += "<script src=\"index.js\">"
output += "</script>"

output += "This search was created by &copy Satadip Dutta 1997"
output += "<hr>"
output += footer()
output += "</body>"
output += "</html>"
export "search.html", output
