import java.io.*;
import java.util.Vector;
class NavTemplate extends Template {

  String linkStyle=" STYLE='font-size:12pt;font-weight:bold;color:#707070;text-decoration:none;font-family:\"Trebuchet MS\",\"Verdana\",\"Arial\",\"sans-serif\"'";
  String thisLinkStyle=" STYLE='font-size:12pt;font-weight:bold;color:#000000;text-decoration:none;font-family:\"Trebuchet MS\",\"Verdana\",\"Arial\",\"sans-serif\"'";

  Template parent;
  Vector pictures;
  String current;
  boolean rhsPadding;
  


  NavTemplate(Template parent, Vector pictures, String current) {
    this.parent = parent;
    this.pictures = pictures;
    this.current = current;
  }

  NavTemplate(Template parent, Vector pictures, String current, boolean rhsPadding) {
    this.parent = parent;
    this.pictures = pictures;
    this.current = current;
    this.rhsPadding = true;
  }

  void prefix(PrintStream o, int depth) {
    if (parent == null) super.prefix(o, depth); else parent.prefix(o, depth);
    o.println("<table><tr><td valign=top>");
    // Navigation bar, such as it is
    for (int i = 0; i < pictures.size(); i++) {
      AbstractPage p = ((AbstractPage) (pictures.elementAt(i)));
      String s = p.title;
      // Problem -- this gets invoked in different places, and thus
      // needs to be made relative (or not).
      String h = dotDotSlash(depth)+p.pageName();
      o.println("<br><a href=\""+h+"\""+(s.equals(current) ? thisLinkStyle : linkStyle)+">"+s+"</a>&nbsp;&nbsp;<br>");
    }
    o.println("</td><td background=\""+dotDotSlash(depth)+"ColorCodeBlur.png\"><img border=\"0\" src=\""+dotDotSlash(depth)+"transparent16by16.png\"></td>");
    o.println(
      (rhsPadding ? "<td><img src=\""+dotDotSlash(depth)+"transparent16by16.png\"></td><td valign=\"top\"" : "<td valign=\"top\"") +
      (bodyStyle != null ? " " + bodyStyle : "") + ">"
    );
  }

  void suffix(PrintStream o, int depth) {
    o.println("</td></tr></table>");
    if (parent == null) super.suffix(o, depth); else parent.suffix(o, depth);
  }

}
