
//==================================================================================
//==================================================================================
// 
// POPUP-MODUL HAUPTPROGRAMM
// OO-PROGRAMMIERUNG
// AUTOR: DF
// ERSTELLT: 05.04.2005
//
//==================================================================================
//==================================================================================


// ============================================================
// Globale Deklarationen
// ============================================================

// den undefinierten Wert deklarieren
var undefined;


/////////////////////////////////////////////////////////////////////////////////////////////////////////////


// ============================================================
// Klasse ElementPopup
// ============================================================

// ------------------------------------------------------------
// Konstruktor
// ------------------------------------------------------------

// ---------------------------------------
// ElementPopup()
// ---------------------------------------
//
// Beschreibung:
// -------------
// Konstruiert ein ElementPopup Objekt.
//
// Beispiel:
// ---------
// 

function ElementPopup() {  
  // Attribute
  this._id = undefined;
  this._height = undefined;
  this._width = undefined;  
  this._x = undefined;  
  this._y = undefined;  
  this._html = undefined;  
  this._targetElementID = undefined;  
  this._visibility = undefined;  
  // Initialisierungen
  this.id();
  this.height();
  this.width();
  this.X();
  this.Y(); 
  this.html(); 
  this.targetElementID(); 
  this.visibility(); 
}

// ------------------------------------------------------------
// Zugriffsfunktionen
// ------------------------------------------------------------

// -----------
// id(string)
// -----------
//
// Beschreibung:
// -------------
//

ElementPopup.prototype.id = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("ArgumentError:noString!");
    }
    this._id = str;
  }
  return this._id;
}

// -----------
// height(string)
// -----------
//
// Beschreibung:
// -------------
//

ElementPopup.prototype.height = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("ArgumentError:noString!");
    }
    this._height = str;
  }
  return this._height;
}

// -----------
// width(string)
// -----------
//
// Beschreibung:
// -------------
//

ElementPopup.prototype.width = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("ArgumentError:noString!");
    }
    this._width = str;
  }
  return this._width;
}

// -----------
// X(string)
// -----------
//
// Beschreibung:
// -------------
//

ElementPopup.prototype.X = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("ArgumentError:noString!");
    }
    this._x = str;
  }
  return this._x;
}

// -----------
// Y(string)
// -----------
//
// Beschreibung:
// -------------
//

ElementPopup.prototype.Y = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("ArgumentError:noString!");
    }
    this._y = str;
  }
  return this._y;
}

// -----------
// html(string)
// -----------
//
// Beschreibung:
// -------------
//

ElementPopup.prototype.html = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("ArgumentError:noString!");
    }
    this._html = str;
  }
  return this._html;
}

// -----------
// targetElementID(string)
// -----------
//
// Beschreibung:
// -------------
//

ElementPopup.prototype.targetElementID = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("ArgumentError:noString!");
    }
    this._targetElementID = str;
  }
  return this._targetElementID;
}

// -----------
// visibility(string)
// -----------
//
// Beschreibung:
// -------------
//

ElementPopup.prototype.visibility = function(str) {
  if (arguments.length) {
    if (typeof str != "string") {
      focus();
      throw new Error("ArgumentError:noString!");
    }
    this._visibility = str;
  }
  return this._visibility;
}

// ------------------------------------------------------------
// Öffentliche Instanzmethoden
// ------------------------------------------------------------

// -------------------------------------------
// setID()
// -------------------------------------------
//
// Beschreibung:
// -------------

// Beispiel:
// ---------
// setID();
//

ElementPopup.prototype.setID = function(str) {
  this.id(str);
}

// -------------------------------------------
// setTargetElementID()
// -------------------------------------------
//
// Beschreibung:
// -------------

// Beispiel:
// ---------
// setTargetElementID();
//

ElementPopup.prototype.setTargetElementID = function(str) {
  this.targetElementID(str);
}

// -------------------------------------------
// setHeight()
// -------------------------------------------
//
// Beschreibung:
// -------------

// Beispiel:
// ---------
// setID();
//

ElementPopup.prototype.setHeight = function(str) {
  this.height(str);
}

// -------------------------------------------
// setWidth()
// -------------------------------------------
//
// Beschreibung:
// -------------

// Beispiel:
// ---------
// setWidth();
//

ElementPopup.prototype.setWidth = function(str) {
  this.height(str);
}

// -------------------------------------------
// setX()
// -------------------------------------------
//
// Beschreibung:
// -------------

// Beispiel:
// ---------
// setX();
//

ElementPopup.prototype.setX = function(str) {
  this.X(str);
}

// -------------------------------------------
// setY()
// -------------------------------------------
//
// Beschreibung:
// -------------

// Beispiel:
// ---------
// setY();
//

ElementPopup.prototype.setY = function(str) {
  this.Y(str);
}

// -------------------------------------------
// setHTML()
// -------------------------------------------
//
// Beschreibung:
// -------------

// Beispiel:
// ---------
// setHTML();
//

ElementPopup.prototype.setHTML = function(str) {
  this.html(str);
}

// -------------------------------------------
// getTargetElementID()
// -------------------------------------------
//
// Beschreibung:
// -------------

// Beispiel:
// ---------
// setTargetElementID();
//

ElementPopup.prototype.getTargetElementID = function(str) {
  return this.targetElementID();
}

// -------------------------------------------
// open()
// -------------------------------------------
//
// Beschreibung:
// -------------

// Beispiel:
// ---------
// open();
//

ElementPopup.prototype.open = function() {
  if (!document.getElementById(this.id())){
    var elem = document.createElement("div");
    elem.id = this.id();
    document.getElementById('pageBody').appendChild(elem);
  }
  document.getElementById(this.id()).style.display = 'block';
  document.getElementById(this.id()).style.position = 'absolute';
  document.getElementById(this.id()).style.zIndex = 1000000;
  document.getElementById(this.id()).style.top = this.X();
  document.getElementById(this.id()).style.left = this.Y();
  document.getElementById(this.id()).innerHTML = this.html();
}

// -------------------------------------------
// close()
// -------------------------------------------
//
// Beschreibung:
// -------------

// Beispiel:
// ---------
// close();
//

ElementPopup.prototype.close = function() {
  if (document.getElementById(this.id())){
    this.setTargetElementID('_CLOSED_' + this.targetElementID());
    document.getElementById(this.id()).style.display = 'none';
  }
}

// ------------------------------------------------------------
// Private Instanzmethoden
// ------------------------------------------------------------

// ------------------------------------------------------------
// Private Klasseneigenschaften
// ------------------------------------------------------------

// ------------------------------------------------------------
// Öffentliche Klasseneigenschaften
// ------------------------------------------------------------

ElementPopup.instance = undefined;

// ------------------------------------------------------------
// Private Klassenmethoden
// ------------------------------------------------------------

// ------------------------------------------------------------
// Öffentliche Klassenmethoden
// ------------------------------------------------------------

// -------------------------------------------
// ElementPopup.throwValue()
// -------------------------------------------
//
// Beschreibung:
// -------------
//   ...
//
// Beispiel:
// ---------
// ElementPopup.throwValue();
//

ElementPopup.throwValue = function(value) { 
  if (document.getElementById(ElementPopup.getInstance().targetElementID())){
    document.getElementById(ElementPopup.getInstance().targetElementID()).value = value;
  }
}

// -------------------------------------------
// ElementPopup.setInstance()
// -------------------------------------------
//
// Beschreibung:
// -------------
//   ...
//
// Beispiel:
// ---------
// ElementPopup.setInstance();
//

ElementPopup.setInstance = function(obj) { 
  if (arguments.length) {
    if (! obj instanceof Eintrag) {
      focus();
      throw new Error("ArgumentError:noObjectFromClassEintrag!");
    }
    ElementPopup.instance = obj;
  }
  ElementPopup.instance;
}

// -------------------------------------------
// ElementPopup.getInstance()
// -------------------------------------------
//
// Beschreibung:
// -------------
//   ...
//
// Beispiel:
// ---------
// ElementPopup.getInstance();
//

ElementPopup.getInstance = function() { 
  return ElementPopup.instance;
}


// -------------------------------------------
// ElementPopup.createInstance()
// -------------------------------------------
//
// Beschreibung:
// -------------
//   ...
//
// Beispiel:
// ---------
// ElementPopup.createInstance();
//

ElementPopup.createInstance = function() {  
  // defaultArguments
  ElementPopup.setInstance(new ElementPopup());
  return ElementPopup.getInstance();
}

// ------------------------------------------------------------
// toString()
// ------------------------------------------------------------

ElementPopup.prototype.toString = function() {
  // zunaechst an Methode der Basisklasse weiterleiten
  return Object.prototype.toString.apply(this);
}