/********************************************************************
 *  Oracle JDeveloper
 *  Copyright (c) 1997, 1999, Oracle Corporation. All rights reserved.
 ********************************************************************/


package oracle.jdeveloper.html;

import java.io.PrintWriter;
import java.util.Vector;


/**
 *
 *	This class represents and HTML DIV element.
 *
 * @author  Juan Oropeza
 * @version PUBLIC
 */

public class HTMLDiv extends HTMLElementContainer
{
   protected   String theID = null;
   protected   String theClickHandler = null;
   
   public HTMLDiv()
   {
      setCSSClassName("csDiv");
      theID = "divId";
   }
   
   /**
   *	@param sClass	the CSS class name for this DIV
   *	@param sID		the ID of this DIV
   */
   public HTMLDiv(String sClass , String sID)
   {
      setCSSClassName(sClass);
      theID = sID;
   }

   /**
   *	Sets the name of the JavaScript function that will be called when the DIV receives a mouse click.
   */
   public void setClickHandler(String sClickHandler)
   {
      theClickHandler = sClickHandler;
   }

   /**
   *	Inserts a line break BR tag nTimes.
   *
   *  @param nTimes Number of times to insert  aline break
   */
   public void skipLine(int nTimes)
   {
      for(int i = 0; i < nTimes ; i++)
         addElement(new HTMLTextElement("<BR>"));            
   }
   
   protected void renderContainerHeader(PrintWriter out)
   {
      if(theClickHandler == null)
         out.println("\n<DIV CLASS=\"" + getCSSClassName() + "\" ID=\"" + theID +"\">");
      else
         out.println("\n<DIV CLASS=\"" + getCSSClassName() + "\" ID=\"" + theID +"\" ONCLICK=\"" + theClickHandler + "\">");
   }
   
   protected void renderContainerFooter(PrintWriter out)
   {
      out.println("</DIV>\n");
   }

}

