/*
 * The contents of this file are subject to the Mozilla Public License Version 1.1
 * (the "License"); you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at <http://www.mozilla.org/MPL/>.
 * 
 * Software distributed under the License is distributed on an "AS IS" basis, WITHOUT
 * WARRANTY OF ANY KIND, either express or implied. See the License for the specific
 * language governing rights and limitations under the License.
 * 
 * The Original Code is the Venice Web Community System.
 * 
 * The Initial Developer of the Original Code is Eric J. Bowersox <erbo@silcom.com>,
 * for Silverwrist Design Studios.  Portions created by Eric J. Bowersox are
 * Copyright (C) 2001 Eric J. Bowersox/Silverwrist Design Studios.  All Rights Reserved.
 * 
 * Contributor(s): 
 */
package com.silverwrist.venice.servlets.format;

import com.silverwrist.util.StringUtil;
import com.silverwrist.venice.except.ValidationException;
import com.silverwrist.venice.servlets.Variables;

public class LoginDialog extends ContentDialog
{
  /*--------------------------------------------------------------------------------
   * Constructors
   *--------------------------------------------------------------------------------
   */

  public LoginDialog()
  {
    super("Log In",null,"loginform","account");
    setHiddenField("cmd","L");
    setHiddenField("tgt","");
    addFormField(new CDVeniceIDFormField("user","User name",null,false,32,64));
    addFormField(new CDPasswordFormFieldCommand("pass","Password",null,false,32,128,
						new CDImageButton("remind","bn_reminder.gif","Reminder",
								  80,24)));
    addFormField(new CDCheckBoxFormField("saveme","Remember me for next time so I can log in automatically",
    					 null,"Y"));
    addCommandButton(new CDImageButton("login","bn_log_in.gif","Log In",80,24));
    addCommandButton(new CDImageButton("cancel","bn_cancel.gif","Cancel",80,24));

  } // end constructor

  protected LoginDialog(LoginDialog other)
  {
    super(other);

  } // end constructor

  /*--------------------------------------------------------------------------------
   * External operations
   *--------------------------------------------------------------------------------
   */

  public void setTarget(String target)
  {
    setHiddenField("tgt",target);

  } // end setTarget

  public void setupNew(String target)
  {
    setHiddenField("tgt",target);

  } // end setupNew

  public void resetOnError(String message)
  {
    setErrorMessage(message);
    setFieldValue("pass",null);

  } // end resetOnError

  public Object clone()
  {
    return new LoginDialog(this);

  } // end clone

} // end class LoginDialog
