function Popup(t, l, w, h)
{
    if(!document.body) return alert('Funktion kann erst nach dem laden aufgerufen werden');
    if(!w ) w = Popup.defaultWidth;
    if(!h ) h = Popup.defaultHeight;

    function myPopup()
    {
         var self = this;
         // Elemente erzeugen
         var _popup = new CreateElement();
         var _panel = new CreateElement('p');
         var _titel = new CreateElement('h1');
         var _closeButton = new CreateElement();

         // Zugriffsfunktionen
         this.isOpen = true;
         this.close = function() { _popup.setStyle({display:'none'}); this.isOpen = false;}
         this.open = function() { _popup.setStyle({ display: ''}); this.isOpen  = true;}
         this.titel = function(text) { _titel.setContent(text); }
         this.text = function(text) { _panel.setContent(text); }

         // Elemente einfügen
         _popup.obj().appendChild( _titel.obj() );
         _popup.obj().appendChild( _panel.obj() );
         _popup.obj().appendChild( _closeButton.obj() );

         // einige Zuweisungen
         _popup.obj().className = 'popup';
         _popup.setStyle(
         {
             width:   w  + 'px',
             height: h + 'px',
             top:    (t || 0) + 'px',
             left:   (l || 0)  + 'px'
         }
         );
         _closeButton.obj().onmousedown = function(e) { this.style.borderStyle = 'inset';  };
         _closeButton.obj().onmouseup = _closeButton.obj().onmouseout = function(e) { this.style.borderStyle = 'outset';  };
         _closeButton.obj().onclick = function(e) { self.close(); };
         _closeButton.setContent('X');

         // und zum Dokumentenbaum
         document.body.appendChild( _popup.obj() );

         this.titel('[unbekannt]');
         var offset = 2;
         var size = ( _titel.obj().offsetHeight - 2 * offset);
         _closeButton.setStyle(
         { // Style
              fontFamiliy: 'Arial',
              fontSize: size +'px',
              fontWeight: 'bold',
              position: 'absolute',
              right: offset + 'px',
              top: offset + 'px',
              width: size + 'px',
              cursor: 'pointer',
              color: '#000',
              backgroundColor: '#c0c0c0',
              textAlign: 'center',
              border: offset +'px outset #fff',
              padding:0
         }
         );
         _titel.setStyle( {
         padding: (offset*2) + 'px',
         height: '1em',
         overflow: 'hidden'

         } );
         _panel.setStyle(
         {
              height: (_popup.obj().offsetHeight - _titel.obj().offsetHeight - (offset * 2) ) + 'px',
              overflow: 'auto'
         }
         );
         // Drag ini()
         this.ini(_titel.obj(), _popup.obj() );
    }
    myPopup.prototype = new DragObject();
    myPopup.prototype.constructor = myPopup;
    return new myPopup();
}
Popup.defaultWidth = 150;
Popup.defaultHeight = 100;

function CreateElement(tag, style)
{
    if(!tag) tag = 'div';
    var obj = document.createElement(tag);

    this.obj = function() { return obj;};
    this.setStyle = function( style) { for(var attribut in style) obj.style[attribut] = style[attribut];};
    this.setContent = function( content ) { obj.innerHTML = content; };
    this.setStyle( style);
}

