function ConstructObject( containerId, stepLength, timeOut)
  { container     = document.getElementById(containerId); 
    container.style.position = 'relative';

    // kreiere DIV mit position: absolute innerhalb des Containers, setze position absolute
    // und verschiebe alle Kindknoten vom Container in das innere DIV
    var scrollcontent = document.createElement('div');
    scrollcontent.style.position = 'absolute';
    while ( container.hasChildNodes() )
      { scrollcontent.appendChild(container.firstChild.cloneNode(true));
        container.removeChild(container.firstChild);
      }
    container.appendChild(scrollcontent);
    this.el       = scrollcontent;
        
    this.down     = function ()
                      { if ( this.y > - this.el.offsetHeight + this.el.parentNode.offsetHeight )
                          { this.MoveArea(0, this.y - this.stepLength );
                            if ( this.loop ) { var obj = this; setTimeout(function() { obj.down(); }, this.timeOut ); } 
                          } 
                      }
    this.up     = function ()
                      { if ( this.y < 0)
                          { this.MoveArea(0, this.y + this.stepLength ); 
                            if ( this.loop ) { var obj = this; setTimeout(function() { obj.up(); }, this.timeOut ); } 
                          } 
                      } 
    this.MoveArea = function(x,y) { this.x = x; this.y = y; this.el.style.left = this.x+'px'; this.el.style.top  = this.y+'px'; };
     
    this.loop       = false;
    this.timeOut    = timeOut;
    this.stepLength = stepLength;

    this.MoveArea(0,0);

    return this 
  } 
 
function InitialiseScrollableArea( upId, downId, containerId, stepLength, timeOut )
  { if ( document.getElementById )
      { var objScroller=new ConstructObject( containerId, stepLength, timeOut); 
        
        var upControl = document.getElementById(upId);
		//alert('Höhe: ' + objScroller.el.offsetHeight + ' Platz: ' + document.getElementById(containerId).offsetHeight);
        if ( objScroller.el.offsetHeight > document.getElementById(containerId).offsetHeight )
          { upControl.style.display = 'block';
        	upControl.onmousedown = function() { this.className='down'; objScroller.loop=true; objScroller.up(); };
            upControl.onmouseup  = function() { this.className=''; objScroller.loop=false; };
          }

        var downControl = document.getElementById(downId);
        if ( objScroller.el.offsetHeight > document.getElementById(containerId).offsetHeight )
          { downControl.style.display = 'block';
            downControl.onmousedown = function() { this.className='down'; objScroller.loop=true; objScroller.down(); };
            downControl.onmouseup  = function() { this.className=''; objScroller.loop=false; };
          }  
      } 
  } 

window.onload = function() { InitialiseScrollableArea('up','down','marg_inhalt',7,50); }
