--- mod_autoindex.c.orig	2007-06-01 14:50:02.058981270 +0800
+++ mod_autoindex.c	2007-06-01 17:10:52.346451938 +0800
@@ -151,8 +151,23 @@
  */
 static void emit_preamble(request_rec *r, int xhtml, const char *title)
 {
-    ap_rvputs(r, xhtml ? DOCTYPE_XHTML_1_0T : DOCTYPE_HTML_3_2,
-              "<html>\n <head>\n  <title>Index of ", title,
+    ap_rvputs(r, "<?xml version=\"1.0\" encoding=\"utf-8\"?>\n", xhtml ? DOCTYPE_XHTML_1_0T : DOCTYPE_HTML_3_2,
+              "<html>\n <head>\n",
+			  "  <style type=\"text/css\">\n",
+			  "    a, a:active {text-decoration: none; color: blue;}\n",
+			  "    a:visited {color: #48468F;}\n",
+			  "    a:hover, a:focus {text-decoration: underline; color: red;}\n",
+			  "    body {background-color: #F5F5F5;}\n",
+			  "    h2 {margin-bottom: 12px;}\n",
+			  "    table {margin-left: 12px;}\n",
+			  "    th, td { font-family: \"Courier New\", Courier, monospace; font-size: 10pt; text-align: left;}\n",
+			  "    th { font-weight: bold; padding-right: 14px; padding-bottom: 3px;}\n",
+			  "    td {padding-right: 14px;}\n",
+			  "    td.s, th.s {text-align: right;}\n",
+			  "    div.list { background-color: white; border-top: 1px solid #646464; border-bottom: 1px solid #646464; padding-top: 10px; padding-bottom: 14px;}\n",
+			  "    div.foot { font-family: \"Courier New\", Courier, monospace; font-size: 10pt; color: #787878; padding-top: 4px;}\n",
+			  "  </style>\n",
+			  "  <title>Index of ", title,
               "</title>\n </head>\n <body>\n", NULL);
 }
 
@@ -1057,7 +1072,7 @@
         emit_preamble(r, emit_xhtml, title);
     }
     if (emit_H1) {
-        ap_rvputs(r, "<h1>Index of ", title, "</h1>\n", NULL);
+        ap_rvputs(r, "<h2>Index of ", title, "</h2>\n", NULL);
     }
     if (rr != NULL) {
         ap_destroy_sub_req(rr);
@@ -1547,7 +1562,7 @@
         ap_rvputs(r, "</th></tr>", breakrow, NULL);
     }
     else if (autoindex_opts & FANCY_INDEXING) {
-        ap_rputs("<pre>", r);
+        ap_rputs("<div class=\"list\">\n<table summary=\"Directory Listing\" cellpadding=\"0\" cellspacing=\"0\">\n<thead><tr><th class=\"n\">", r);
         if (!(autoindex_opts & SUPPRESS_ICON)) {
             if ((tp = find_default_icon(d, "^^BLANKICON^^"))) {
                 ap_rvputs(r, "<img src=\"", ap_escape_html(scratch, tp),
@@ -1571,30 +1586,27 @@
         emit_link(r, "Name", K_NAME, keyid, direction,
                   colargs, static_columns);
         ap_rputs(pad_scratch + 4, r);
+		ap_rputs("</th>", r);
         /*
          * Emit the guaranteed-at-least-one-space-between-columns byte.
          */
-        ap_rputs(" ", r);
+        ap_rputs(" <th class=\"m\">", r);
         if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
             emit_link(r, "Last modified", K_LAST_MOD, keyid, direction,
                       colargs, static_columns);
-            ap_rputs("      ", r);
+            ap_rputs("</th>      <th class=\"s\">", r);
         }
         if (!(autoindex_opts & SUPPRESS_SIZE)) {
             emit_link(r, "Size", K_SIZE, keyid, direction,
                       colargs, static_columns);
-            ap_rputs("  ", r);
+            ap_rputs("</th>  <th class=\"d\">", r);
         }
         if (!(autoindex_opts & SUPPRESS_DESC)) {
             emit_link(r, "Description", K_DESC, keyid, direction,
                       colargs, static_columns);
         }
         if (!(autoindex_opts & SUPPRESS_RULES)) {
-            ap_rputs("<hr", r);
-            if (autoindex_opts & EMIT_XHTML) {
-                ap_rputs(" /", r);
-            }
-            ap_rputs(">", r);
+            ap_rputs("</th></tr></thead>\n<tbody>\n", r);
         }
         else {
             ap_rputc('\n', r);
@@ -1718,7 +1730,7 @@
                     ap_rvputs(r, "<a href=\"", anchor, "\">", NULL);
                 }
                 if ((ar[x]->icon) || d->default_icon) {
-                    ap_rvputs(r, "<img src=\"",
+                    ap_rvputs(r, "<tr><td class=\"n\"><img src=\"",
                               ap_escape_html(scratch,
                                              ar[x]->icon ? ar[x]->icon
                                                          : d->default_icon),
@@ -1758,18 +1770,18 @@
             }
             ap_rvputs(r, "<a href=\"", anchor, "\">",
                       ap_escape_html(scratch, t2),
-                      "</a>", pad_scratch + nwidth, NULL);
+                      "</a></td>", pad_scratch + nwidth, NULL);
             /*
              * The blank before the storm.. er, before the next field.
              */
-            ap_rputs(" ", r);
+            ap_rputs(" <td class=\"m\">", r);
             if (!(autoindex_opts & SUPPRESS_LAST_MOD)) {
                 if (ar[x]->lm != -1) {
                     char time_str[MAX_STRING_LEN];
                     apr_time_exp_t ts;
                     apr_time_exp_lt(&ts, ar[x]->lm);
                     apr_strftime(time_str, &rv, MAX_STRING_LEN,
-                                "%d-%b-%Y %H:%M  ", &ts);
+                                "%d-%b-%Y %H:%M</td>  ", &ts);
                     ap_rputs(time_str, r);
                 }
                 else {
@@ -1779,15 +1791,18 @@
             }
             if (!(autoindex_opts & SUPPRESS_SIZE)) {
                 char buf[5];
+                ap_rputs("<td class=\"s\">", r);
                 ap_rputs(apr_strfsize(ar[x]->size, buf), r);
-                ap_rputs("  ", r);
+                ap_rputs("</td>  ", r);
             }
             if (!(autoindex_opts & SUPPRESS_DESC)) {
+				ap_rputs("<td class=\"d\">", r);
                 if (ar[x]->desc) {
                     ap_rputs(terminate_description(d, ar[x]->desc,
                                                    autoindex_opts,
                                                    desc_width), r);
                 }
+				ap_rputs("</td>  ", r);
             }
             ap_rputc('\n', r);
         }
@@ -1801,11 +1816,7 @@
     }
     else if (autoindex_opts & FANCY_INDEXING) {
         if (!(autoindex_opts & SUPPRESS_RULES)) {
-            ap_rputs("<hr", r);
-            if (autoindex_opts & EMIT_XHTML) {
-                ap_rputs(" /", r);
-            }
-            ap_rputs("></pre>\n", r);
+            ap_rputs("</tbody>\n</table>\n</div>\n", r);
         }
         else {
             ap_rputs("</pre>\n", r);
@@ -1951,7 +1962,7 @@
 #if APR_HAS_UNICODE_FS
     ap_set_content_type(r, "text/html;charset=utf-8");
 #else
-    ap_set_content_type(r, "text/html");
+    ap_set_content_type(r, "text/html;charset=utf-8");
 #endif
     if (autoindex_opts & TRACK_MODIFIED) {
         ap_update_mtime(r, r->finfo.mtime);
