import java.util.*;
import java.io.*;
import java.lang.*;

public class AuctionHtmlGen
{ 

	 AuctionHtmlGen() {}

	 public void addHtmlHeader(PrintWriter out, String title, String bgColor)
	 {  
		  try
		  {
			   out.println("<HTML> \n <HEAD> \n <TITLE> ");
			   out.println(" </TITLE> \n</HEAD>\n");
			   out.println("\n <BODY bgcolor=\"" + bgColor  + "\">");
			   ProdHtmlGen.linksToPages(out);
			   out.println("<FONT size=\"8\" align=\"center\" color=\"black\"><b>" + title + "</b></font></align>");
			   out.println("<hr>");

		  }

		  catch(Exception ie)
		  { 
			   System.out.println("ie:AuctionHtmlPageGen/addHtmlHeader/");
		  }
	 }


	 public void addGeneralMsg(PrintWriter out, String msg, String msgColor, String msgSize)
	 {
		  try
		  {			   
			   out.println("<font color=" + msgColor + " size=" + msgSize + ">\n");
			   out.println(msg);
			   out.println("</font>\n");
		  }
		  catch(Exception ie)
		  { 
			   System.out.println("ie:AuctionHtmlPageGen/addGeneralMsg/");
		  }

	 }

	 public void  addFormHeader(PrintWriter out, String submitURL, String method)
	 {
		  try
		  {
			   out.println("<form action="+ submitURL +" method=\"" + method  + "\">\n");
		  }
		  catch(Exception ie)
		  {
			   System.out.println("ie:AuctionHtmlPageGen/addFormlHeader/");
		  }
	 }

	 public void addFormTable(PrintWriter out, Vector v, Vector vtype, int border, String formTitle)
	 {
		  int noOfRows = v.size();
		  String fieldName = "";
		  String form = "<table border=" + border + ">\n" ;
		  form += formTitle;
		  //form += "<tr><th><font color=\"blue\">Property</font></th><th><font color=\"blue\">Value</font></th></tr>";		  
		  for (int i=0; i<noOfRows; i++)
		  {
			   fieldName = (String)v.elementAt(i);
			   System.out.println("at pos " + i + "=" + fieldName);
			   if(((String)vtype.elementAt(i)).equalsIgnoreCase("date"))
			   {
					form += "<tr><td>" + fieldName + "</td> <td>" + addDateSelect(fieldName) + "</td></tr>";
					
					//<td><input type=text name=" + fieldName + "></td></tr>\n";
			   }
			   else if(fieldName.equalsIgnoreCase("password"))
			   {
					form += "<tr><td>" + fieldName + "</td> <td><input type=password name=" + fieldName + "></td></tr>\n";
			   }
			   else
			   {
					form += "<tr><td>" + fieldName + "</td> <td><input type=text name=" + fieldName + "></td></tr>\n";
			   }
		  }

		  form += "</table>\n";	
		  try
		  {
			   out.println(form);
			   //out.println(addDateSelect());
		  }
		  catch(Exception ie)
		  {
			   System.out.println("ie:AuctionHtmlPageGen/addFormTable/");
		  }
	 }


	 
/*
 * old working  fn:
 * -----------------
 * 
	 public void addFormTable(PrintWriter out, Vector v, Vector vtype, int border)
	 {
		  int noOfRows = v.size();
		  String fieldName = "";
		  String form = "<table border=" + border + ">\n" ;
		  form += "<tr><th><font color=\"blue\">Property</font></th><th><font color=\"blue\">Value</font></th></tr>";		  
		  for (int i=0; i<noOfRows; i++)
		  {
			   fieldName = (String)v.elementAt(i);
			   System.out.println("at pos " + i + "=" + fieldName);
			   if(((String)vtype.elementAt(i)).equalsIgnoreCase("date"))
			   {
					form += "<tr><td>" + fieldName + "</td> <td>" + addDateSelect(fieldName) + "</td></tr>";
					
					//<td><input type=text name=" + fieldName + "></td></tr>\n";
			   }
			   else if(fieldName.equalsIgnoreCase("password"))
			   {
					form += "<tr><td>" + fieldName + "</td> <td><input type=password name=" + fieldName + "></td></tr>\n";
			   }
			   else
			   {
					form += "<tr><td>" + fieldName + "</td> <td><input type=text name=" + fieldName + "></td></tr>\n";
			   }
		  }

		  form += "</table>\n";	
		  try
		  {
			   out.println(form);
			   //out.println(addDateSelect());
		  }
		  catch(Exception ie)
		  {
			   System.out.println("ie:AuctionHtmlPageGen/addFormTable/");
		  }
	 }
*/
	 public void addFormFooter(PrintWriter out, boolean js)
	 {
		  try
		  {
			   if(js)
			   {
					out.println("<input type=\"button\" name=\"Submit\" value=\"Submit\" onclick=\"validate()\"><input type=reset>\n");
			   }
			   else
			   {
					out.println("<input type=\"Submit\" value=\"Submit\"><input type=reset>\n");
			   }
			   out.println(" </form>\n");
		  }
		  catch(Exception ie)
		  {
			   System.out.println("ie:AuctionHtmlPageGen/addFormFooter/");
		  }

	 }


  
/*
 * old working fn:
 * ----------------
	 public void addFormFooter(PrintWriter out)
	 {
		  try
		  {
			   out.println("<input type=\"button\" name=\"Submit\" value=\"Submit\" onclick=\"validate()\"><input type=reset>\n");
			   out.println(" </form>\n");
		  }
		  catch(Exception ie)
		  {
			   System.out.println("ie:AuctionHtmlPageGen/addFormFooter/");
		  }

	 }
*/
	 public void addHtmlFooter(PrintWriter out)
	 { 
		  try
		  {
			   out.println("\n </BODY> ");
			   out.println("\n </HTML> ");
		  }
		  catch(Exception ie)
		  {
			   System.out.println("ie:AuctionHtmlPageGen/addHtmlFooter/");
		  }
	 }



	 //this require the name of the prefix for the day, month and year field
	 //so that one can distinguish between various type of dates in a single form.
	 public String addDateSelect(String prefix)
	 {
		  String form = "";
		  form += "<select name=" + prefix + "day>\n";
		  for(int d=1; d < 32; d++)
		  {
			   form += "<option value=\"" + d + "\"<b>" + d + "</b></option>\n";			   
		  }		  
		  form += "</select>";

		  form += "<select name=" + prefix  + "month>";
		  form += "<option value=\"1\">Jan </option>";
		  form += "<option value=\"2\">Feb </option>";
		  form += "<option value=\"3\">Mar </option>";
		  form += "<option value=\"4\">Apr </option>";
		  form += "<option value=\"5\">May </option>";
		  form += "<option value=\"6\">Jun </option>";
		  form += "<option value=\"7\">Jul </option>";
		  form += "<option value=\"8\">Aug </option>";
		  form += "<option value=\"9\">Sep </option>";
		  form += "<option value=\"10\">Oct </option>";
		  form += "<option value=\"11\">Nov </option>";
		  form += "<option value=\"12\">Dec </option>";
		  form += "</select>";

		  form += "<select name=" + prefix +"year>";
		  form += "<option value=\"2001\">2001 </option>";
		  form += "<option value=\"2002\">2002 </option>";
		  form += "<option value=\"2003\">2003 </option>";
		  form += "<option value=\"2004\">2004 </option>";
		  form += "</select>";
		  return form;
	 }
}











