
// ============================================================
// Klasse Dialog
// ============================================================
//
// Objekthierarchie:
// -----------------
//   Object
//     |-- Dialog
//
// Konstruktor:
// ------------
//   - Dialog()
//
// Eigenschaften:
// --------------
//   + title : String (readonly)
//   + subtitle : String (readonly)
//   + callback : Function (readonly)
//   + _inputList : Array (readonly)
//   + _inputRegister : ass. Array (readonly)
//   + _hasResults : boolean (readonly)
//
// Methoden:
// ---------
//   + setTitle(str:String) : void
//   + setSubtitle(str:String) : void
//   + setCallback(f:Function) : void
//   + addInput(obj:DialogInput) : void
//   + readInput() : void
//   + hasResults() : boolean
//   + getInputValue(str:name) : Object
//
// Beschreibung:
// -------------
//   ...
//

// ------------------------------------------------------------
// Konstruktor
// ------------------------------------------------------------

function Dialog() {
  if (arguments.length>0) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  // Attribute
  this.title;
  this.subtitle;
  this._inputList = [];
  this._inputRegister = {};
  this._hasResults = false;
}

// toString()
Dialog.prototype.toString = function() {
  return "\n[Dialog]\n";
}

// ------------------------------------------------------------
// Private Klasseneigenschaften
// ------------------------------------------------------------

Dialog._activeDialog;
Dialog._activeWindow;

// ------------------------------------------------------------
// Zugriffsmethoden
// ------------------------------------------------------------

// --------
// setTitle
// --------
Dialog.prototype.setTitle = function(str) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    throw new Error("Argument ist nicht vom Typ string!");
  }
  this.title = str;
}

// -----------
// setSubtitle
// -----------
Dialog.prototype.setSubtitle = function(str) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    throw new Error("Argument ist nicht vom Typ string!");
  }
  this.subtitle = str;
}

// -----------
// setCallback
// -----------
Dialog.prototype.setCallback = function(f) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (! (f instanceof Function)) {
    throw new Error("Argument ist nicht vom Typ Function!");
  }
  this.callback = f;
}

// --------
// addInput
// --------
Dialog.prototype.addInput = function(input) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (! (input instanceof DialogInput)) {
    throw new Error("Argument ist nicht vom Typ DialogInput!");
  }
  var name = input.name;
  if (!name) {
    throw new Error("No valid name in Input");
  }
  if (name in this._inputRegister) {
    throw new Error("Input-Name ist bereits vorhanden: " + name);
  }
  this._inputRegister[name] = input;
  this._inputList.push(input);
}

// ----------
// hasResults
// ----------
Dialog.prototype.hasResults = function() {
  return this._hasResults;
}

// ------------------------------------------------------------
// Öffentliche Instanzmethoden
// ------------------------------------------------------------

// ---------
// readInput
// ---------
Dialog.prototype.readInput = function() {
  if (! this.callback) {
    throw new Error("Callback ist nicht definiert!");
  }
  this._open();
}

// -------------
// getInputValue
// -------------
Dialog.prototype.getInputValue = function(name) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof name != "string") {
    throw new Error("Argument ist nicht vom Typ string!");
  }
  if (!this.hasResults()) {
    throw new Error("Es ist kein Ergebnis vorhanden");
  }
  if (! (name in this._inputRegister)) {
    throw new Error("Input-Name ist nicht vorhanden: " + name);
  }
  return this._inputRegister[name].value;
}

// ------------------------------------------------------------
// Private Instanzmethoden
// ------------------------------------------------------------

// -----
// _open
// -----
Dialog.prototype._open = function() {
  if (Dialog._activeDialog) {
    Dialog._activeDialog._abort();
  }
  Dialog._activeDialog = this;
  var html = this._getHTML();
  var win = window.open("", "Dialog", "resizeable,status,width=600,height=400");
  Dialog._activeWindow = win;
  var doc = win.document;
  doc.write(html);
  doc.close();
}

// ------
// _close
// ------
Dialog.prototype._close = function() {
  if (Dialog._activeDialog) {
    Dialog._activeDialog = null;
  }
  if (Dialog._activeWindow) {
    Dialog._activeWindow.close();
    Dialog._activeWindow = null;
  }
}

// ------
// _abort
// ------
Dialog.prototype._abort = function() {
  this._close();
  Dialog._activeDialog = null;
  this._hasResults = false;
}

// -------
// _submit
// -------
Dialog.prototype._submit = function() {
  Dialog._activeDialog = this;
  // !!! ACHTUNG:
  // "_activeWindow" ist nur notwendig, wenn mit echten windows
  // gearbeitet wird - bei Layer-Lösung entfernen.
  var form = Dialog._activeWindow.document.forms["input-dialog"];
  for (var i=0; i<this._inputList.length; i++) {
    var input = this._inputList[i];
    if (input && !input.hidden) {
      var value = input._readFormValue(form[input.name]);
      if (!input.setValue(value)) {
        return;
      }
    }
  }
  this._hasResults = true;
  this._close();
  this.callback.call(null, this);
}

// --------
// _getHTML
// --------
Dialog.prototype._getHTML = function() {
  var html = "";
  html += '<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"\n';
  html += '"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">\n';
  html += '<html xmlns="http://www.w3.org/1999/xhtml">\n';
  html += '<head>\n';
  html += '<title>Editor\'s Office - Dateneingabe</title>\n';
  html += '<link href="' + DialogTemplates._htmlRoot + '/resource/css/xdoc.css" type="text/css" media="all" rel="stylesheet">';
  html += '<script>window.focus();</script>\n';
  html += '</head>\n';
  html += '<body class="dialog">\n';

  
  html += '<div class="dialog-page">\n';
  html += '<div class="dialog-title">\n';
  html += this.title + '<br/>\n';
  html += '</div>\n';
  if (this.subtitle){
    html += '<div class="dialog-subtitle">\n';
    html +=  this.subtitle + '<br/>\n';
    html += '</div>\n';
  }
  html += '<div class="dialog-content">\n';
  html += '<form name="input-dialog">\n';
  if (this._inputList.length>0){
    html += '<div class="dialog-form">\n';
    for (var i=0; i<this._inputList.length; i++) {
      if (this._inputList[i]._getHTML() != ''){
      html += this._inputList[i]._getHTML();
      }
    }
    html += '<div class="xdoc-formular-element">\n';
    html += '<div class="xdoc-formular-element-label">\n';
    html += '<br />\n';
    html += '</div>\n';
    html += '<div class="xdoc-formular-element-value">\n';
    html += '<input type="button" name="OK" value="OK" class="dialog-formular-button" onclick="opener.Dialog._submitActiveDialog();"/>';
    html += '<input type="button" name="Cancel" value="Cancel" class="dialog-formular-button" onclick="opener.Dialog._abortActiveDialog();"/><br/>\n';
    html += '</div>\n';
    html += '<div class="float-aufheben"><br /></div>\n';
    html += '</div>\n';
    html += '</div>\n';
  }
  html += '</form>\n';
  html += '</div>\n';
  html += '</div>\n';
  html += '</body>\n';
  html += '</html>\n';
  return html;
}

// ------------------------------------------------------------
// Private Klassenmethoden
// ------------------------------------------------------------

// -------------------
// _submitActiveDialog
// -------------------
Dialog._submitActiveDialog = function() {
  if (!Dialog._activeDialog) {
    throw new Error("Kein aktiver Dialog!");
  }
  Dialog._activeDialog._submit();
}

// ------------------
// _abortActiveDialog
// ------------------
Dialog._abortActiveDialog = function() {
  if (!Dialog._activeDialog) {
    throw new Error("Kein aktiver Dialog!");
  }
  Dialog._activeDialog._abort();
}

// ============================================================
// Klasse DialogInput
// ============================================================
//
// Objekthierarchie:
// -----------------
//   Object
//     |-- DialogInput
//
// Konstruktor:
// ------------
//   - DialogInput()
//
// Eigenschaften:
// --------------
//   + name : String (readonly)
//   + value : String (readonly)
//   + label : String (readonly)
//   + description : String (readonly)
//   + required : boolean (readonly)
//   + hidden : String (readonly)
//
// Methoden:
// ---------
//   + setName(str:String) : void
//   + setLabel(str:String) : void
//   + setDescription(str:String) : void
//   + setRequired(b:boolean) : void
//   + setHidden(b:boolean) : void
//
// Beschreibung:
// -------------
//   Wird nicht direkt instanziert
//

// ------------------------------------------------------------
// Konstruktor
// ------------------------------------------------------------

function DialogInput(name) {
  // leerer Konstruktor
  if (arguments.length==0) {
    return;
  }
  if (arguments.length>1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof name != "string") {
    throw new Error("Argument ist nicht vom Typ string!");
  }
  // Attribute
  this.name = name;
  this.value;
  this.label;
  this.description;
  this.required = false;
  this.hidden = false;
}

// toString()
DialogInput.prototype.toString = function() {
  return "\n[DialogInput]\n";
}

// ------------------------------------------------------------
// Zugriffsmethoden
// ------------------------------------------------------------

// --------
// setLabel
// --------
DialogInput.prototype.setLabel = function(str) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    throw new Error("Argument ist nicht vom Typ string!");
  }
  this.label = str;
}

// --------------
// setDescription
// --------------
DialogInput.prototype.setDescription = function(str) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof str != "string") {
    throw new Error("Argument ist nicht vom Typ string!");
  }
  this.description = str;
}

// -----------
// setRequired
// -----------
DialogInput.prototype.setRequired = function(b) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof b != "boolean") {
    throw new Error("Argument ist nicht vom Typ boolean!");
  }
  this.label = b;
}

// ---------
// setHidden
// ---------
DialogInput.prototype.setHidden = function(b) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof b != "boolean") {
    throw new Error("Argument ist nicht vom Typ boolean!");
  }
  this.hidden = b;
}

// ============================================================
// Klasse DialogTextInput
// ============================================================
//
// Objekthierarchie:
// -----------------
//   Object
//     |-- DialogInput
//           |-- DialogTextInput
//
// Konstruktor:
// ------------
//   + DialogTextInput(name:string)
//
// Eigenschaften:
// --------------
//   + multiline : boolean
//
// Methoden:
// ---------
//   + setValue(str:String) : void
//   + setMultiline(b:boolean) : void
//
// Beschreibung:
// -------------
//   ...
//

// ------------------------------------------------------------
// Konstruktor
// ------------------------------------------------------------

function DialogTextInput(name) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  // Konstruktor der Superklasse
  DialogInput.call(this, name);
  // Attribute
  this.defaultValue = "";
  this.multiline = false;
}

// Objekthierarchie
DialogTextInput.prototype = new DialogInput;

// toString()
DialogTextInput.prototype.toString = function() {
  return "\n[DialogTextInput - name: " + this.name + "]\n";
}

// ------------------------------------------------------------
// Öffentliche Instanzmethoden
// ------------------------------------------------------------

// ---------------
// setDefaultValue
// ---------------
DialogTextInput.prototype.setDefaultValue = function(v) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  this.defaultValue = this._checkValue(v);
  return true;
}

// --------
// setValue
// --------
DialogTextInput.prototype.setValue = function(v) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  this.value = this._checkValue(v);
  return true;
}

// ------------
// setMultiline
// ------------
DialogTextInput.prototype.setMultiline = function(b) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof b != "boolean") {
    throw new Error("Argument ist nicht vom Typ boolean!");
  }
  this.multiline = b;
}

// ------------------------------------------------------------
// Private Instanzmethoden
// ------------------------------------------------------------

// --------
// _getHTML
// --------
DialogTextInput.prototype._getHTML = function() {
  if (this.hidden) {
    return "";
  }
  var html = "";
  var outputDescription = '';
  if (this.description!=undefined){
    outputDescription =  '(' + this.description + ')';
  }

  if (outputDescription.length){
    outputDescription = outputDescription + '<br />';
  }
  
  html += '<div class="dialog-formular-element">\n';
  html += '<div class="dialog-formular-element-label">\n';
  html += '<label for="' + this.name + '">\n';
  html += this.label + '\n';
  html += '</label><br/>\n';
  html += '</div>\n';
  html += '<div class="dialog-formular-element-value">\n';
  html += '<input type="text" class="dialog-formular-einzeilig" name="' + this.name + '" value="' + this.defaultValue + '"/><br/>\n' + outputDescription;
  html += '</div>\n';
  html += '<div class="float-aufheben"><br /></div>\n';
  html += '</div>\n';

  return html;
}

// -----------
// _checkValue
// -----------
DialogTextInput.prototype._checkValue = function(v) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  // !!! => Wert prüfen und umwandeln, sonst bestehenden DefaultValue zurückgeben
  return v;
}

// --------------
// _readFormValue
// --------------
DialogTextInput.prototype._readFormValue = function(formElement) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  return formElement.value;
}

// ============================================================
// Klasse DialogIntegerInput
// ============================================================
//
// Objekthierarchie:
// -----------------
//   Object
//     |-- DialogInput
//           |-- DialogTextInput
//
// Konstruktor:
// ------------
//   + DialogTextInput(name:string)
//
// Eigenschaften:
// --------------
//   + defaultValue : String (readonly)
//   + min : number
//   + max : number
//
// Methoden:
// ---------
//   + setValue(n:number) : void
//   + setMin(n:number) : void
//   + setMax(n:number) : void
//
// Beschreibung:
// -------------
//   ...
//

// ------------------------------------------------------------
// Konstruktor
// ------------------------------------------------------------

function DialogIntegerInput(name) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  // Konstruktor der Superklasse
  DialogInput.call(this, name);
  // Attribute
  this.defaultValue = 0;
  this.min = Number.NEGATIVE_INFINITY;
  this.max = Number.POSITIVE_INFINITY;
}

// Objekthierarchie
DialogIntegerInput.prototype = new DialogInput;

// toString()
DialogIntegerInput.prototype.toString = function() {
  return "\n[DialogIntegerInput - name: " + this.name + "]\n";
}

// ------------------------------------------------------------
// Öffentliche Instanzmethoden
// ------------------------------------------------------------

// ---------------
// setDefaultValue
// ---------------
DialogIntegerInput.prototype.setDefaultValue = function(v) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  this.defaultValue = this._checkValue(v);
  return true;
}

// --------
// setValue
// --------
DialogIntegerInput.prototype.setValue = function(v) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  this.value = this._checkValue(v);
  return true;
}

// ------
// setMin
// ------
DialogIntegerInput.prototype.setMin = function(n) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof n != "number") {
    throw new Error("Argument ist nicht vom Typ number!");
  }
  this.min = n;
}

// ------
// setMax
// ------
DialogIntegerInput.prototype.setMax = function(n) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (typeof n != "number") {
    throw new Error("Argument ist nicht vom Typ number!");
  }
  this.max = n;
}

// ------------------------------------------------------------
// Private Instanzmethoden
// ------------------------------------------------------------

// --------
// _getHTML
// --------
DialogIntegerInput.prototype._getHTML = function() {
  if (this.hidden) {
    return "";
  }
  var html = "";
  var outputDescription = '';
  if (this.description!=undefined){
    outputDescription =  '(' + this.description + ')';
  }

  if (outputDescription.length){
    outputDescription = outputDescription + '<br />';
  }
  
  html += '<div class="dialog-formular-element">\n';
  html += '<div class="dialog-formular-element-label">\n';
  html += '<label for="' + this.name + '">\n';
  html += this.label + '\n';
  html += '</label><br/>\n';
  html += '</div>\n';
  html += '<div class="dialog-formular-element-value">\n';
  html += '<input type="text" class="dialog-formular-einzeilig-short" name="' + this.name + '" value="' + this.defaultValue + '"/><br/>\n' + outputDescription;
  html += '</div>\n';
  html += '<div class="float-aufheben"><br /></div>\n';
  html += '</div>\n';
  
  return html;
}

// -----------
// _checkValue
// -----------
DialogIntegerInput.prototype._checkValue = function(v) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  // !!! => Wert prüfen und umwandeln, sonst bestehenden DefaultValue zurückgeben
  return v;
}

// --------------
// _readFormValue
// --------------
DialogIntegerInput.prototype._readFormValue = function(formElement) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  return formElement.value;
}

// ============================================================
// Klasse DialogBooleanInput
// ============================================================
//
// Objekthierarchie:
// -----------------
//   Object
//     |-- DialogInput
//           |-- DialogBooleanInput
//
// Konstruktor:
// ------------
//   + DialogBooleanInput(name:string)
//
// Eigenschaften:
// --------------
//   + defaultValue : String (readonly)
//
// Methoden:
// ---------
//   + setValue(n:number) : void
//
// Beschreibung:
// -------------
//   ...
//

// ------------------------------------------------------------
// Konstruktor
// ------------------------------------------------------------

function DialogBooleanInput(name) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  // Konstruktor der Superklasse
  DialogInput.call(this, name);
  // Attribute
  this.defaultValue = false;
}

// Objekthierarchie
DialogBooleanInput.prototype = new DialogInput;

// toString()
DialogBooleanInput.prototype.toString = function() {
  return "\n[DialogBooleanInput - name: " + this.name + "]\n";
}

// ------------------------------------------------------------
// Öffentliche Instanzmethoden
// ------------------------------------------------------------

// ---------------
// setDefaultValue
// ---------------
DialogBooleanInput.prototype.setDefaultValue = function(v) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  this.defaultValue = this._checkValue(v);
  return true;
}

// --------
// setValue
// --------
DialogBooleanInput.prototype.setValue = function(v) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  this.value = this._checkValue(v);
  return true;
}

// ------------------------------------------------------------
// Private Instanzmethoden
// ------------------------------------------------------------

// --------
// _getHTML
// --------
DialogBooleanInput.prototype._getHTML = function() {
  if (this.hidden) {
    return "";
  }
  var outputDescription = '';
  if (this.description!=undefined){
    outputDescription =  '(' + this.description + ')';
  }
  
  var html = "";
  
  html += '<div class="dialog-formular-element">\n';
  html += '<div class="dialog-formular-element-label">\n';
  html += '<label for="' + this.name + '">\n';
  html += this.label + '\n';
  html += '</label><br/>\n';
  html += '</div>\n';
  html += '<div class="dialog-formular-element-value">\n';
  html += '<input type="checkbox" name="' + this.name + '" value="' + this.defaultValue + '" '+ (this.defaultValue ? " checked" : "") +'/> '+ outputDescription +'<br />\n';
  html += '</div>\n';
  html += '<div class="float-aufheben"><br /></div>\n';
  html += '</div>\n';
  
  return html;
}

// -----------
// _checkValue
// -----------
DialogBooleanInput.prototype._checkValue = function(v) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  // !!! => Wert prüfen und umwandeln, sonst bestehenden DefaultValue zurückgeben
  return v;
}

// --------------
// _readFormValue
// --------------
DialogBooleanInput.prototype._readFormValue = function(formElement) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  if (formElement.checked) {
    return true;
  }
  return false;
}

// ============================================================
// Klasse DialogListInput
// ============================================================
//
// Objekthierarchie:
// -----------------
//   Object
//     |-- DialogInput
//           |-- DialogListInput
//
// Konstruktor:
// ------------
//   + DialogListInput(name:string)
//
// Eigenschaften:
// --------------
//   + defaultValue : String (readonly)
//   + options : Array
//
// Methoden:
// ---------
//   + setValue(n:number) : void
//   + addOption(o:Object) : void
//
// Beschreibung:
// -------------
//   ...
//

// ------------------------------------------------------------
// Konstruktor
// ------------------------------------------------------------

function DialogListInput(name) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  // Konstruktor der Superklasse
  DialogInput.call(this, name);
  // Attribute
  this.defaultValue = 0;
  this.options = [];
}

// Objekthierarchie
DialogListInput.prototype = new DialogInput;

// toString()
DialogListInput.prototype.toString = function() {
  return "\n[DialogListInput - name: " + this.name + "]\n";
}

// ------------------------------------------------------------
// Öffentliche Instanzmethoden
// ------------------------------------------------------------

// ---------------
// setDefaultValue
// ---------------
DialogListInput.prototype.setDefaultValue = function(v) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  this.defaultValue = this._checkValue(v);
  return true;
}

// --------
// setValue
// --------
DialogListInput.prototype.setValue = function(v) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  this.value = this._checkValue(v);
  return true;
}

// ---------
// addOption
// ---------
DialogListInput.prototype.addOption = function(v) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  this.options.push(v);
}

// ------------------------------------------------------------
// Private Instanzmethoden
// ------------------------------------------------------------

// --------
// _getHTML
// --------
DialogListInput.prototype._getHTML = function() {
  if (this.hidden) {
    return "";
  }
  var html = "";
  
  html += '<div class="dialog-formular-element">\n';
  html += '<div class="dialog-formular-element-label">\n';
  html += '<label for="' + this.name + '">\n';
  html += this.label + '\n';
  html += '</label><br/>\n';
  html += '</div>\n';
  html += '<div class="dialog-formular-element-value">\n';
  html += '<select name="'+ this.name +'" class="dialog-formular-select">\n';
  html += "<option value='" + this.defaultValue + "'>Bitte wählen...</option>\n";
  for (var i=0; i<this.options.length; i++) {
    html += "<option value='" + this.options[i] + "'" + (this.options[i] == this.defaultValue ? " selected" : "") + ">" + this.options[i] + "</option>\n";
  }
  html += '</select><br />\n';
  var outputDescription = '';
  if (this.description!=undefined){
    outputDescription =  '(' + this.description + ')<br/>\n';
  }
  html += outputDescription;
  html += '</div>\n';
  html += '<div class="float-aufheben"><br /></div>\n';
  html += '</div>\n';

  return html;
}

// -----------
// _checkValue
// -----------
DialogListInput.prototype._checkValue = function(v) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  var found = false;
  for (var i=0; i<this.options.length; i++) {
    if (this.options[i] == v) {
      var found = true;
      break;
    }
  }
  if (found) {
    return v;
  }
  return this.defaultValue;
}

// --------------
// _readFormValue
// --------------
DialogListInput.prototype._readFormValue = function(formElement) {
  if (arguments.length!=1) {
    throw new Error("Falsche Anzahl von Argumenten!");
  }
  return formElement.options[formElement.selectedIndex].value;
}



