////////////////////////////////////////////////////////////////////////////////
//
// wgu_utils.js
// (c) 2002, SAP AG
//
// WGU Javascript Utilities
//
// created 2002-03-26, tj
//
// 050222  hp  xbrowser func
// 050421  tj  Event handler returns rc of exec func
//
////////////////////////////////////////////////////////////////////////////////


////////////////////////////////////////////////////////////////////////////////
//
// Toolbox
//
////////////////////////////////////////////////////////////////////////////////


function wgu_getAbsolutePosition( in_element )
{
  insidewebguiDynpro = false;
  isIE = false;
  var elem = in_element;
  var pos  = { x: 0, y: 0 };
  while (elem != null) {
  /*alert( "wguutils_getAbsolutePosition()\n\n x = " + pos.x + "\n y = " + pos.y + "\n "
        + elem.outerHTML.substr(0, 80)
        + "\n elem.style.left = " + elem.style.left + "\n elem.style.top = " + elem.style.top
        + "\n\n elem.offsetLeft = " + elem.offsetLeft + "\n elem.offsetTop = " + elem.offsetTop
        + "\n elem.clientLeft = " + elem.clientLeft + "\n elem.clientTop = " + elem.clientTop
        + "\n\n elem.tagName = " + elem.tagName);
   */
    if (elem.clientTop || elem.clientLeft)
    {
      pos.x += elem.offsetLeft + (elem.tagName.toLowerCase() != "body" ? elem.clientLeft : 0);
      pos.y += elem.offsetTop + (elem.tagName.toLowerCase() != "body" ? elem.clientTop : 0);
      isIE = true;
    }
    else
    {
      pos.x += elem.offsetLeft;
      pos.y += elem.offsetTop;
    }
    if (elem.scrollTop)
      pos.y = pos.y - elem.scrollTop;
    if (elem.scrollLeft)
      pos.x = pos.x - elem.scrollLeft;
    if (webguiDynpro && elem==webguiDynpro)
      insidewebguiDynpro = true;

    elem = elem.offsetParent;
  } // while
  if (insidewebguiDynpro && !isIE)
  {
    pos.x = pos.x + 10; // +10 webguidynproborder
    pos.y = pos.y + 10; // +10 webguidynproborder
  }
  //alert( "wguutils_getAbsolutePosition()\n\n RETURN\n x = " + pos.x + "\n y = " + pos.y);
  return pos;
} // wguutils_getAbsolutePosition()



/*********************************************************************
* function wgu_AddStyleSheet(doc, url)
*
*  add stylesheet to page header dynamically
*  works crossbrowser (ie /m moz)
*  he.pi 2005022
*/

function wgu_AddStyleSheet(doc, url){
  if(document.createStyleSheet) {
    //ie
    doc.createStyleSheet(url);
  }
  else {
    //moz
    SS=document.createElement('link');
    SS.rel='stylesheet';
    SS.href='data:text/css,'+escape(url);
    doc.getElementsByTagName("head")[0].appendChild(SS);
  }

}

/*********************************************************************
* Object and constructor function its_accessIframe(iframeName)
*
*  usage:
*    myIframe = new its_accessIframe(iframeName);
*    iframeNode = myIframe.iframe;
*    iframeDoc  = myIframe.doc;
*
*  object, provides:
*    iframe - the node of the iframe
*    doc - the node of the document inside an iframe
*
*  crossbrowser implementation (ie /m moz)
*/

function its_accessIframe ( in_framename )
{
  var rc = false;

  if (in_framename != null)
  {
    if (!document.frames){
       if (document.getElementById( in_framename))
       {
         this.iframe = document.getElementById( in_framename);
         this.doc = this.iframe.contentDocument;
         rc = true;
       }
    } else {
      // IE
      if (document.frames[ in_framename]){
        this.iframe = document.frames[ in_framename];
        this.doc = this.iframe.document;
        rc = true;
      }
    }
  } // if (in_framename)
  return rc;
}

/*********************************************************************
* function wgu_parseWidth/Height(element, value)
*/

function wgu_parseWidth(element, value)
{
  var intValue = parseInt(value);
  if (intValue > 0)
  {
    if (value.indexOf("%") >= 0)
    {
      //unit: percentage
      return parseInt(element.parentNode.clientWidth/100*intValue);
    }
    else
    {
      //unit: pixel
      return intValue;
    }
  }
  else
    return 0;
}

function wgu_parseHeight(element, value)
{
  var intValue = parseInt(value);
  if (intValue > 0)
  {
    if (value.indexOf("%") >= 0){
      //unit: percentage
      return parseInt(element.parentNode.clientHeight/100*intValue);
    }
    else
    {
      //unit: pixel
      return intValue;
    }
  }
  else
    return 0;
}


////////////////////////////////////////////////////////////////////////////////
//
// Cookie routines
//
////////////////////////////////////////////////////////////////////////////////

/*
wguCookieIsEnabled      = itsCookieIsEnabled;
wguObjCookie            = itsObjCookie;
wguObjCookieEnabled     = itsObjCookieEnabled;
wguObjCookieSet         = itsObjCookieSet;
wguObjCookieGet         = itsObjCookieGet;
wguObjCookieDelete      = itsObjCookieDelete;
wguObjCookieEvalExpDays = itsObjCookieEvalExpDays;

wguObjCookie.prototype.IsCookieEnabled  = wguObjCookieEnabled;
wguObjCookie.prototype.Set              = wguObjCookieSet;
wguObjCookie.prototype.Get              = wguObjCookieGet;
wguObjCookie.prototype.Delete           = wguObjCookieDelete;
wguObjCookie.prototype.EvalExpDays      = wguObjCookieEvalExpDays;
*/

////////////////////////////////////////////////////////////////////////////////
//
// User Agent Information
//
// Interface:
//    Functions:    wgu_GetUserAgentType ()
//                  wgu_GetUserAgentVersion ()
//                  wgu_GetUserAgentPlatform ()
//                  wgu_IsUserAgentW3CDOM ()
//
////////////////////////////////////////////////////////////////////////////////


function wgu_GetUserAgentType ()  { return _wguUtil_getUserAgentInfo().type; }
function wgu_GetUserAgentVersion () { return _wguUtil_getUserAgentInfo().version; }
function wgu_GetUserAgentPlatform (){ return _wguUtil_getUserAgentInfo().platform; }
function wgu_IsUserAgentW3CDOM () { return _wguUtil_getUserAgentInfo().W3CDOM; }


// internal function
function _wguUtil_getUserAgentInfo()
{
  if (_wguUtil_getUserAgentInfo.infoRec == 0) {
    var _enum = {
      OTHER   : 0,  MSIE    : 1,  NETSCAPE: 2,  MOZILLA : 2,
      OPERA   : 3,  NOKIA   : 4,  UP      : 5,  ERICSSON: 6,
      MSPIE   : 7,  PALM    : 8,

      OTHER_PLATFORM : 0, NT_PLATFORM    : 1,   WIN_PLATFORM   : 2,
      MAC_PLATFORM   : 3, LINUX_PLATFORM : 4,   WAP_PLATFORM   : 5,
      PDA_PLATFORM   : 6
    } // enum UserAgents

    var lUA   = navigator.userAgent;
    var laMatch = lUA.match( /(Netscape|Gecko|MSIE )([\d|\.|\/]*)/ );

    // initialize record

    _wguUtil_getUserAgentInfo.infoRec = {
      type    : "unknown",
      version   : "0",
      platform  : "unknown",
      W3CDOM    : false
    }

    // determine platform

    if (lUA.indexOf("Win") != -1)
      _wguUtil_getUserAgentInfo.infoRec.platform = (lUA.indexOf("WinNT") != -1 || lUA.indexOf("WindowsNT") != -1)
         ? "WinNT" : "Win";
    else if (lUA.indexOf("Mac") != -1)    _wguUtil_getUserAgentInfo.infoRec.platform = "Mac";
    else if (lUA.indexOf("Linux") != -1)  _wguUtil_getUserAgentInfo.infoRec.platform = "Linux";

    // determine user agent type

    if (window.opera)
      _wguUtil_getUserAgentInfo.infoRec.type = "Opera";
    else if (laMatch.length == 3) {
        switch (laMatch[1]) {
            case "MSIE"     : _wguUtil_getUserAgentInfo.infoRec.type = "IE"; break;
            case "Netscape" :
        case "Gecko"    : _wguUtil_getUserAgentInfo.infoRec.type = "NN"; break;
        default :
          if    (lUA.indexOf("MSIE") != -1)     _wguUtil_getUserAgentInfo.infoRec.type = "IE";
          else if (lUA.indexOf("Opera") != -1)    _wguUtil_getUserAgentInfo.infoRec.type = "Opera";
          else if (lUA.indexOf("Mozilla") != -1)    _wguUtil_getUserAgentInfo.infoRec.type = "Mozilla";
          else if (lUA.indexOf("Lynx") != -1)     _wguUtil_getUserAgentInfo.infoRec.type = "other";
          else if (lUA.indexOf("amaya") != -1)    _wguUtil_getUserAgentInfo.infoRec.type = "other";
          else if (lUA.indexOf("Nokia") != -1)    _wguUtil_getUserAgentInfo.infoRec.type = "Nokia";
          else if (lUA.indexOf("Ericsson") != -1)   _wguUtil_getUserAgentInfo.infoRec.type = "Ericsson";
          else                    _wguUtil_getUserAgentInfo.infoRec.type = "other";
          break;
        }
        _wguUtil_getUserAgentInfo.infoRec.version = parseFloat( laMatch[2]);
    }

    // determine W3C DOM conformity

    if (document.getElementById != null)
      _wguUtil_getUserAgentInfo.infoRec.W3CDOM = true;
  } // if (infoRec == 0)

  return _wguUtil_getUserAgentInfo.infoRec;
} // _wguTool_userAgentInfo()
_wguUtil_getUserAgentInfo.infoRec = 0;
_wguUtil_getUserAgentInfo();

////////////////////////////////////////////////////////////////////////////////
// User Agent Information END
////////////////////////////////////////////////////////////////////////////////









////////////////////////////////////////////////////////////////////////////////
//
// Event Handler Registration
//
// Interface:
//    Constructor:    wguObjEventHandler
//    Functions:      RegisterHandler()
//                    UnregisterHandler()
//                    HandleEvent()
//
////////////////////////////////////////////////////////////////////////////////



   /*********************************************************************
     * Event Handler Object
     * Register, unregister event handler
     * and execute list of event handler
     */

    function _objEventHandlerListElement ( in_handler, in_handlerID, in_priority, in_ahandlerparms )
    {
      var rv = null;
      if (in_handler) {
        this._handler   = in_handler;
        this._handlerID = in_handlerID;

        this._handlerParms = in_ahandlerparms;

        this._priority     = in_priority ? in_priority : 0;

        // this list is implemented as a ring (!)
        this._prev         = this;
        this._next         = this;
        rv = this;
      }
      return rv;
    } // _objEventHandlerListElement()


    _objEventHandlerListElement.prototype.Append = function ( /* _objEventHandlerListElement */ in_listelem )
    {
      in_listelem._next = this._next;
      this._next = in_listelem;
      in_listelem._prev = this;

      return this;
    } // _objEventHandlerListElement.Append()


    _objEventHandlerListElement.prototype.InsertBefore = function ( /*_objEventHandlerListElement */ in_listelem )
    {
      this._prev._next = in_listelem;
      in_listelem._prev = this._prev;
      this._prev = in_listelem;
      in_listelem._next = this;
      return this;
    } // _objEventHandlerListElement.InsertBefore()


    _objEventHandlerListElement.prototype.Find = function ( in_handlerID )
    {
      var rv = null;
      var isfound = false;
      do {

      } while (isfound || el == this);

      return rv;
    } // _objEventHandlerListElement.Find()


    _objEventHandlerListElement.prototype.Unlink = function ()
    {
      this._prev._next = this._next;
      this._next._prev = this._prev;
      // delete this has to be done from outside
    } // _objEventHandlerListElement.Unlink()


    _objEventHandlerListElement.prototype.Delete = function ()
    {
      var el = this;
      if (this._handlerParms)
        delete this._handlerParms;
      delete el;
    } // _objEventHandlerListElement.Delete()


    _objEventHandlerListElement.prototype.Call = function ( in_event )
    {
      var rc      = null;
      var parms   = this._handlerParms;
      var l       = parms ? parms.length : 0;

      if (l == 0) {       // zero parameter -> quick call of event handler
        if (in_event)
          rc = this._handler( in_event);
        else
          rc = this._handler();
      }
      else if (l == 1) {  // one parameter -> quick call of event handler
        if (in_event)
          rc = this._handler( in_event, parms[ 0]);
        else
          rc = this._handler( parms[ 0]);
      }
      else {        // more than one parameter ->  build string
        var i, str, sep;
        str = "this._handler(" + (in_event ? "in_event" : "");
        sep = (in_event ? "," : "");
        for ( i = 0; i < l; i++, sep = ",")
          str += (sep + "parms[" + i + "]");
        str += ")";
        try {
          rc = eval( str);   // call event handler with parameters
        } catch (err) {}
      }
      return rc;
    } // _objEventHandlerListElement.Call()


   /*********************************************************************
    * Help object: Event handler list object
    *  _event       : type of event
    *  _handler     : list of event handler for _event
    *  _handlerParms: list of parameters for _handler
    */
    function _objEventHandlerList( in_event )
    {
      var rv = null;
      if (in_event && typeof in_event == "string") {
        this._event        = in_event.toLowerCase();
        this._handlerList  = null;
        rv = this;
      }
      return rv;
    } // _objEventHandlerList();

    _objEventHandlerList.prototype.Length = function ()
    {
      var rv = 0;
      if (this._handlerList) {
        var firstel = this._handlerList;
        var el      = firstel;
        do {
          rv++;
          el = el._next;
        } while (el != firstel);
      }
      return rv;
    } // _objEventHandlerListElement.Length()




    /* Lookup first element with priority <= in_priority in list
     *  In:      in_priority: value of priority to lookup
     *  Returns: reference to element found in list or null
     */
    _objEventHandlerList.prototype.FindElementByPriority = function ( in_priority )
    {
      var rv = null;
      if (this._handlerList) {
        var el = this._handlerList;
        if (in_priority == 0) {
          if (el._priority != 0) {
            while (el._prev._priority == 0)
              el = el._prev;
            rv = el;
          }
          else
            rv = null;
        }
        else if (in_priority < 0 || in_priority < el._prev._priority)
          rv = null;
        else if (in_priority >= el._priority)
          rv = el;
        else {
          while (in_priority < el._priority)
            el = el._next;
          rv = el;
        }
      }
      return rv;
    } // _objEventHandlerListElement.FindElementByPriority()


    _objEventHandlerList.prototype.AddHandler = function ( in_handler, in_handlerID, in_priority, in_ahandlerparms )
    {
//alert("AddHandler " + in_handlerID + " with priority " + in_priority);
      var rv = null;
      if (in_handler) {
        var prio = (in_priority && (in_priority > 0)) ? in_priority : 0;
        var el   = new _objEventHandlerListElement( in_handler, in_handlerID, prio, in_ahandlerparms);
        if (!this._handlerList)
          this._handlerList = el;
        else {
          var listelem = this.FindElementByPriority( prio - 1);
          if (listelem) {
            listelem.InsertBefore( el);
            if (listelem == this._handlerList && listelem._priority < el._priority)
              this._handlerList = el;
          }
          else
            this._handlerList.InsertBefore( el);
        }
        rv = el;
      }
      return rv;
    } // _objEventHandlerList();


    _objEventHandlerList.prototype.RemoveHandler = function ( in_handler, in_handlerID)
    {
      var rv       = null;
      var firstel  = this._handlerList;
      var el       = firstel;
      var len      = this.Length();
      var el_del;

      if (in_handler || in_handlerID) {

        for (var i = 0; firstel && i < len; i++) {
          el_del = null;

          if (in_handler && !in_handlerID && el._handler == in_handler)             // only reference to handler provided
            el_del = el;
          else if (!in_handler && in_handlerID && el._handlerID == in_handlerID)    // only ID of handler provided
            el_del = el;
          else if (el._handler == in_handler && el._handlerID == in_handlerID)      // both, handler and ID provided
            el_del = el;

          el = el._next;

          if (el_del) {
             el_del.Unlink();
             if (el_del == firstel) {
               if (firstel._next == el_del)     // the only remaining object
                 firstel = this._handlerList = null;
               else
                 firstel = this._handlerList = el;
             }
             el_del.Delete();
          }
        } // for
      }
      return rv;
    } // _objEventHandlerList();


    _objEventHandlerList.prototype.CallHandlerList = function ( in_event )
    {
      var rc = null;
      var firstel = this._handlerList;
      var el      = firstel;
      if (firstel) {
        do {
          rc = el.Call( in_event);
          el = el._next;
        } while (el != firstel && this._handlerList);
      }
    return rc;
    } // _objEventHandlerList.CallHandlerList()


    _objEventHandlerList.prototype.Write = function ()
    {
      var firstel = this._handlerList;
      var el      = firstel;
      if (firstel) {
        document.writeln( "<p style=\"font: normal 7pt sans-serif; border: solid 1px #036; background-color: #CCC;\">");
        document.writeln( "<span style=\"font-weight:bold; font-size: 8pt;\">Event: " + this._event + "</span>");
        document.writeln( "&nbsp;&nbsp;(No of handler: " + this.Length() + ")");
        document.writeln( "<table><tr>");
        do {
          document.writeln( "<td><table style=\"font: normal 7pt sans-serif; color: #036; border: solid 1px #003;\">");
          document.writeln( "<tr><td colspan=\"2\" style=\"border-bottom: 1pt solid #333;\">ID: " + el._handlerID + "</td></tr>");
          document.writeln( "<tr><td colspan=\"2\" style=\"border-bottom: 1pt solid #999;\">Priority: " + el._priority + "</td></tr>");
          document.writeln( "<tr><td>Prev:</td><td>" + el._prev._handlerID + "</td></tr><tr><td>Next:<td>" + el._next._handlerID + "</td></tr>");
          document.writeln( "</table>");
          if (el != el._next && el._next != firstel)
            document.writeln( "<td style=\"white-space: nowrap;\">--></td></td>");
          else
            document.writeln( "</td>");
          el = el._next;
        } while (el != firstel);
        document.writeln( "</tr></table></p>");
      }
    } // _objEventHandlerList.write()



   /*********************************************************************
    *
    */
    function wguObjEventHandler ()
    {
      /* Array of event handler list objects
       */
      this._aHandlerList = null;

      return this;
    } // wguObjEventHandler()


    /* Register event handler to list of handler routines
     * Arguments:
     *   in_handlerid : identifier of registered handler in list
     *   in_handler   : event handler to be registered
     *   ...          : static arguments for event handler
     */
    wguObjEventHandler.prototype.RegisterHandler = function ( in_event, in_handlerID, in_priority, in_handler, in_parm )
    {
      var handlerobj = null;
      var i, l;
      var argparmidx = 4;
      var aParms;
      var handlerel;

      if (in_event && in_handlerID && in_handler) {
        /* For first event the event handler list object
         * must be created
         */
        if (this._aHandlerList == null)
          this._aHandlerList = new Array();

        if (this._aHandlerList) {
          if (typeof this._aHandlerList[ in_event] == "undefined")
            this._aHandlerList[ in_event] = new _objEventHandlerList( in_event);

          handlerobj = this._aHandlerList[ in_event];
          if (handlerobj) {
            // first, copy handler parameters to argument list
            if ((l = arguments.length) > argparmidx) {
              if (aParms = new Array()) {
                for (i = argparmidx; i < l; i++)
                  aParms[ i-argparmidx] = arguments[ i];
              }
            }

            // second, add handler to handler list
            handlerobj.AddHandler( in_handler, in_handlerID, in_priority, aParms);

          } // if (handlerobj)
        } // if (this._aHandlerList)
      } // if (in_event)
      return this;
    } // wguObjEventHandler.RegisterHandler()


    /*
     * IN: in_handler - reference to event handler
     *     in_handlerID
     */
    wguObjEventHandler.prototype.UnregisterHandler = function ( in_event, in_handler, in_handlerID )
    { var i, l;
      if (in_event && this._aHandlerList) {
        var handlerobj = this._aHandlerList[ in_event];
        if (handlerobj) {
          handlerobj.RemoveHandler( in_handler, in_handlerID);
          // also delete event handler object if no handler available
          if (!handlerobj._handlerList) {
            delete handlerobj._event;
            delete handlerobj;
          }
        } // if (handlerobj)
      } // if (args provided)
      return this;
    } // wguObjEventHandler.UnregisterHandler()


    wguObjEventHandler.prototype.HandleEvent = function ( in_evt )
    {
      var rc = null;
      var evt;
      var eventtype;
      if (in_evt) {
        if (typeof in_evt == "string")
          eventtype = in_evt;
        else
          evt = in_evt;
      }
      else
        evt = (window.event) ? window.event : null;

      if (evt)
        eventtype = evt.type;

//alert("HandleEvent( " + in_evt + " )\n eventtype = " + eventtype);

      if (eventtype && this._aHandlerList != null) {
        var handlerobj = this._aHandlerList[ eventtype.toLowerCase()];
        if (handlerobj != null) {
          rc = handlerobj.CallHandlerList();
        }
      }
      return rc;
    } // wguObjEventHandler.HandleEvent()


    wguObjEventHandler.prototype.HandleEvent_withEvent = function ( in_event )
    {
      var rc = null;
      var evt;
      var eventtype;
      if (in_event) {
        if (typeof in_event == "object")
          evt = in_event;
      }
      else
        evt = (window.event) ? window.event : null;

      if (evt)
        eventtype = evt.type;

//alert("HandleEvent_withEvent( " + in_evt + " )\n eventtype = " + eventtype);

      if (eventtype && this._aHandlerList != null) {
        var handlerobj = this._aHandlerList[ eventtype.toLowerCase()];
        if (handlerobj != null) {
          rc = handlerobj.CallHandlerList( evt );
        }
      }
      return rc;
    } // wguObjEventHandler.HandleEvent()


    wguObjEventHandler.prototype.Write = function ()
    {
      var handlerobj;
      for (var ev in this._aHandlerList) {
        handlerobj = this._aHandlerList[ ev];
        if (handlerobj != null) {
          handlerobj.Write();
        }
      }
    } // wguObjEventHandler.HandleEvent()


////////////////////////////////////////////////////////////////////////////////
// Event Handler Registration END
////////////////////////////////////////////////////////////////////////////////










////////////////////////////////////////////////////////////////////////////////
//
// Trace
//
// Interface:
//    Functions:    wgu_Trace ()
//
////////////////////////////////////////////////////////////////////////////////



var __wgu_ringbuffer_static = {
  _dfltMaxEntries : 50
}


function wguObjRingBuffer ( in_maxEntries )
{
  this._buffer    = null;                     // storage
  this._maxEntries  = 0;                      // max no of entries in current ring buffer
  this._defltmax    = _wgu_ringbuffer_static._dfltMaxEntries;   // default max no
  this._idx     = 0;                      // actual index
  this._idxstart    = 0;                      // index of first element

  this.Reset( in_maxEntries);

  return this;
} // wguObjRingBuffer ()


wguObjRingBuffer.prototype.Reset = function ( in_maxEntries ) {
  buffer = null;
  if ( in_maxEntries ) {
    this._maxEntries = in_maxEntries;
    this._buffer = new Array( this._maxEntries);
  }
  else {
    this._maxEntries = this._dfltmax;
    this._buffer = new Array( this._maxEntries);
  }
  this._idx   = 0;
  this._idxstart  = 0;

  return this;
} // wguObjRingBuffer.Reset()


wguObjRingBuffer.prototype.IndexSubtract = function ( in_index, in_operand ) {
  var m = this._maxEntries;
  var i = (in_index - in_operand) % m;
  return (i < 0) ? m + i : i;
} // wguObjRingBuffer.IndexSubtract()


wguObjRingBuffer.prototype.IndexAdd = function ( in_index, in_operand ) {
  return (in_index + in_operand) % this._maxEntries;
} // wguObjRingBuffer.IndexAdd()



wguObjRingBuffer.prototype.GetNoEntries = function () {
  var noEntries = 0;
  var idx1 = this._idx,
    idx0 = this._idxstart;

  if (idx0 >= 0)
    noEntries = (idx1 + (idx1 <= idx0) ? this._maxEntries : 0) - idx0;

  return noEntries;
} // wguObjRingBuffer.GetNoEntries()


// Use ring buffer as queue

wguObjRingBuffer.prototype.Read = function () {
  var data;
  if (this.GetNoEntries() > 0)
    data =  this._buffer[ this._idxstart];
  else
    data = null;

  return data;
} // wguObjRingBuffer.Read()

wguObjRingBuffer.prototype.Dequeue = function () {
  var data;

  if (this.GetNoEntries() > 0) {
    data = this._buffer[ this._idxstart];
    this._buffer[ this._idxstart] = null;
    this._idxstart = (this._idxstart + 1) % this._maxEntries;
  }
  else
    data = null;

  return data;
} // wguObjRingBuffer.Dequeue()

wguObjRingBuffer.prototype.Enqueue = function ( in_data ) {
  this._buffer[ this._idx] = in_data;
  this._idx = (this._idx + 1) % this._maxEntries;
} // wguObjRingBuffer.Enqueue()


// use ring buffer as stack

wguObjRingBuffer.prototype.Pop = function () {
  var data;

  if (this.GetNoEntries() > 0) {
    data = this._buffer[ --this._idx];
    this._buffer[ this._idx] = null;
    this._idxstart = (this._idxstart + 1) % this._maxEntries;
  }
  else
    data = null;

  return data;
} // wguObjRingBuffer.Pop()


wguObjRingBuffer.prototype.Push = function ( in_data ) {
  this.Enqueue( in_data);
} // wguObjRingBuffer.Push()


/*
wguObjRingBuffer.prototype. = function () {

} // wguObjRingBuffer.()


wguObjRingBuffer.prototype. = function () {

} // wguObjRingBuffer.()


wguObjRingBuffer.prototype. = function () {

} // wguObjRingBuffer.()


wguObjRingBuffer.prototype. = function () {

} // wguObjRingBuffer.()


wguObjRingBuffer.prototype. = function () {

} // wguObjRingBuffer.()

*/


function wguObjTrace ()
{
  function setoption ( in_option, in_value, in_default, in_use_default )
  { var obj = new Object();
    obj.value   = in_value;
    obj.deflt   = in_default;
    obj.usedeflt  = in_use_default;
    this._arropts [in_option] = obj;
  } // setoption()

  this._tracewindow   = null;
  this._winname     = "";
  this._accessable    = false;
  this._tempbuf     = new Array();
  this._tempbufidx    = 0;
  this._tempbuffirstidx = 0;

  // options for trace window
  this._arropts = new Array();
  setoption( "title",     null, "WGUTrace", true);
  setoption( "maxentries",  null, "50",   false);

  return this;
} // Constructor wguObjTrace()


wguObjTrace.prototype.GetAccessable = function ()     { return this._accessable; }                // is trace window accessable
wguObjTrace.prototype.SetAccessable = function (in_bool)  { this._accessable = in_bool; return this._accessable; }  // must be called by trace window


wguObjTrace.prototype.ResetOptions = function () {
  var opt;
  for (opt in this._arropts) {
    this._arropts[ opt].value = null;
  } // for (opt)
} // wguObjTrace.ResetOptions()

wguObjTrace.prototype.GetOptions = function () {
  var opt;
  var stropt = "";
  var obj;
  for (opt in this._arropts) {
    obj = this._arropts[ opt];
    if (stropt == "") stropt = "?";
    else stropt = "&";
    stropt =+ stropt + opt;
    if (obj.value != null) stropt += stropt + obj.value;
    else if (obj.usedeflt) stropt += stropt + obj.deflt;
  } // for (opt)
  return stropt;
} // wguObjTrace.GetOptions()

wguObjTrace.prototype.OpenWindow = function () {
  this._winname = "wguwin_trace"; //wgu_NewUniqueWindowName();
  this._tracewindow = window.open( "../page/wgutrace.html",
                                   this._winname,
                                   "location=no,menubar=no,resizable=yes,toolbar=no,titlebar=no");
} // wguObjTrace.OpenWindow()



function _wgu_TraceBuffer ()
{

}


function _wgu_TraceData ()
{

} // _wgu_TraceData()


function _wgu_Trace ( in_str )
{
  var meta;
  var fnregex = /function (\w+\(.*\))/;
  fnregex.exec( _wgu_Trace.caller);

  meta = RegExp.$1;
  if ( in_meta ) meta += ": " + in_meta;

  this._tracewindow = null;
  this._winname   = "";
  this._accessable  = false;
  this._tempbuf   = new Array();
  this._tempbufidx  = 0;
  this._tempbuffirstidx = 0;

  if (this._accessable) {
    //if
    //_wgutrc_append( '', meta, in_str );
  }
  else {
    _
  }
} // wgu_Trace()

wguObjTrace.prototype.Trace = _wgu_Trace;


function _wgutrc_append ( in_time, in_meta, in_str )
{ var div = document.getElementById("wguIDBody").firstChild;
  if (div) {
    var now     = new Date();
    var newdiv    = div.cloneNode( true);
    var strmeta;

    if ( in_time )  strmeta = in_time;
    else      strmeta = now.toGMTString().substr(0,25);
    if ( in_meta ) strmeta = strmeta + "  :  " + in_meta;

    newdiv.firstChild.firstChild.nodeValue = strmeta;
    newdiv.lastChild.firstChild.nodeValue = in_str;

    newdiv.style.display = "block";
    document.getElementById("wguIDBody").insertBefore( newdiv, div);
  } // if (div)
} // _wgutrc_append()

function wguTrace_trace ( in_str, in_meta )
{ var meta;
  var fnregex = /function (\w+\(.*\))/;
  fnregex.exec( wguTrace.caller);

  meta = RegExp.$1;
  if ( in_meta ) meta += ": " + in_meta;
  _wgutrc_append( '', meta, in_str );
} // wguTrace()



////////////////////////////////////////////////////////////////////////////////
// Trace END
////////////////////////////////////////////////////////////////////////////////




function wgudbg_alertEvent( in_event )
{
  var ev;
  var alertstr;

  if (in_event == null) {
    /* MSIE */
    if (typeof window.event != "undefined")
      ev = window.event;
  }
  else
    ev = in_event;

  if (ev != null) {
    alertstr = "Event:\n type = " + ev.type + "\n";
    for (var i in ev) {
      alertstr += " " + i + " = " + ev[ i] + "\n";
      if ((i == "fromElement" || i == "srcElement" || i == "toElement") && ev[ i])
        alertstr += "  " + ev[i].outerHTML.substr( 0, 40) + "\n\n";
    }
    alert( alertstr);
  }
} // alertEvent()



////////////////////////////////////////////////////////////////////////////////

/*******************************************************************************
 *
 * Class <I T S _ U S E R A G E N T>
 *
 * Description: browser independent event class
 * Date       : 2004/11/03
 * Author     : Simon Kruska
 *
 * History    :
 * yyyy/mm/dd id description
 * 2004/11/03 sk initial implementation
 *
 ******************************************************************************/
/** <its_useragent>
  *
  *   constructor for the its_useragent class.
  */
function its_useragent()
{
  var agent = navigator.userAgent.toLowerCase();
  var major = parseInt(navigator.appVersion);
  var minor = parseFloat(navigator.appVersion);

  this.gecko  = (agent.indexOf('gecko') != -1);

  this.ie     = ((agent.indexOf("msie") != -1) &&
                 (agent.indexOf("opera") == -1));
  this.ie3    = (this.ie && (major < 4));
  this.ie4    = (this.ie && (major == 4) && (agent.indexOf("msie 4")!=-1) );
  this.ie5    = (this.ie && (major == 4) && (agent.indexOf("msie 5.0")!=-1) );
  this.ie55   = (this.ie && (major == 4) && (agent.indexOf("msie 5.5") !=-1));
  this.ie55up = (this.ie && !this.ie3 && !this.ie4 && !this.ie5);
  this.ie6    = (this.ie && (major == 4) && (agent.indexOf("msie 6.")!=-1) );
  this.ie6up  = (this.ie && !this.ie3 && !this.ie4 && !this.ie5 && !this.ie55);
}
// </its_useragent>


var its_ua = new its_useragent();

// </I T S _ U S E R A G E N T>


/*******************************************************************************
 *
 * <D O M T O O L S>
 *
 * Description: Several methods for working on a documents DOM
 *
 * Date       : 2004/12/09
 * Author     : Simon Kruska
 *
 * History    :
 * YYYY/MM/DD ID DESCRIPTION
 * 2004/11/22 sk initial implementation
 *
 ******************************************************************************/

// some DOM related constants
DOM_NODE_TYPE_ELEMENT        = 1;
DOM_NODE_TYPE_ATTRIBUTE      = 2;
DOM_NODE_TYPE_TEXT           = 3;
DOM_NODE_TYPE_CDATA_SECTTION = 4;
DOM_NODE_TYPE_COMMENT        = 9;

// DOM attributes that differ with the useragent
DOM_ATTRIBUTE_CLASS = "class";

if (its_ua.gecko)
{

}
else
{
  DOM_ATTRIBUTE_CLASS = "className";
}

/* its_utils */
/** <dom_getChildNodeByAttrAndValue>
  *
  *   get the very next element that has attribute=value
  *
  *   params:
  *   element   - Object - the source element
  *   attribute - String - the attribute to check for
  *   value     - String - the value the attribute must have
  *
  */
function dom_getChildNodeByAttrAndValue(element, attribute, value)
{
  if (element)
  {
    if (element.childNodes.length > 0)
    {
      var i = 0;
      while (i < element.childNodes.length)
      {
        if (element.childNodes[i].nodeType == DOM_NODE_TYPE_ELEMENT)
        {
            v = element.childNodes[i].getAttribute(attribute);
            if (v == value)
            {
              return element.childNodes[i];
            }
        }
        i++
      }
    }
  }
  return null;
}
// </dom_getChildNodeByAttrAndValue>


/** <dom_getChildNodeByNodeName>
  *
  *   get the very next element that has the approriate nodeName
  *
  *   params:
  *   element  - Object - the source element
  *   nodeName - String - the name of the childnode
  *
  */
function dom_getChildNodeByNodeName(element, nodeName)
{
  if (element)
  {
    if (element.childNodes.length > 0)
    {
      var i = 0;
      while (i < element.childNodes.length)
      {
        if (element.childNodes[i].nodeType == DOM_NODE_TYPE_ELEMENT &&
            element.childNodes[i].nodeName == nodeName)
        {
          return element.childNodes[i];
        }
        i++
      }
    }
  }
  return null;
}
// </dom_getChildNodeByNodeName>


/** <dom_getChildNodeByIndex>
  *
  *   get the child node with the appropriate index
  *
  *   params:
  *   node  - Object - the source node
  *   index - Number - the index of the child node
  *
  */
function dom_getChildNodeByIndex(node, index)
{
  var i = -1;
  node = node.childNodes[0];
  while (node && i < index)
  {
    if (node.nodeType == DOM_NODE_TYPE_ELEMENT)
    {
      i++;
    }
    if (i != index)
    {
      node = node.nextSibling;
    }
  }
  return node;
}
// </dom_getChildNodeByIndex>


/** <dom_getParentNodeByNodeName>
  *
  *   get the parent element that has the approriate nodeName
  *
  *   params:
  *   node     - Object - the source node
  *   nodeName - String - the node name of the parent node
  *
  */
function dom_getParentNodeByNodeName(node, nodeName)
{
  if (node)
  {
    node = node.parentNode;
    while (node)
    {
      if (node.nodeType == DOM_NODE_TYPE_ELEMENT &&
          node.nodeName == nodeName)
      {
        return node;
      }
      node = node.parentNode;
    }
  }
  return null;
}
// </dom_getParentNodeByNodeName>


/** <dom_getParentNodeByAttrAndValue>
  *
  *   get the very previous element that has attribute=value
  *
  *   params:
  *   element   - Object - the source element
  *   attribute - String - the attribute to check for
  *   value     - String - the value the attribute must have
  *
  */
function dom_getParentNodeByAttrAndValue(element, attribute, value)
{
  while (element)
  {
    if (element.nodeType == DOM_NODE_TYPE_ELEMENT)
    {
      v = element.getAttribute(attribute);
      if (v == value)
      {
        return element;
      }
    }
    else
    {
      element = element.parentNode;
    }
  }
  return null;
}
// </dom_getParentNodeByAttrAndValue>


/** <dom_contains>
  *
  *   checks whether the parent node is or containes the child node.
  *
  *   params:
  *   parentNode - Object - the node that possibly contains the ...
  *   childNode  - Object - child node that possibly is contained by the
  *                           parentNode or even is the parentNode
  *
  */
function dom_contains(parentNode, childNode)
{
  while (childNode)
  {
    if (childNode == parentNode)
      return true;
    childNode = childNode.parentNode;
  }
  return false;
}
// </dom_contains>


/** <dom_addClass>
  *
  *   add a class to an elements class attribute
  *
  *   params:
  *   className - String - the current class attribute
  *   add       - String - the class to be added to the class attribute
  *
  */
function dom_addClass(className, add)
{
  classes = className.split(" ");
  for (i in classes)
  {
    if (classes[i] == add)
      return className;
  }
  classes.push(add);
  return classes.join(" ");
}
// </dom_addClass>


/** <dom_removeClass>
  *
  *   remove a class from an elements class attribute
  *
  *   params:
  *   className - String - the current class attribute
  *   remove    - String - the class to be remove to the class attribute
  *
  */
function dom_removeClass(className, remove)
{
  classes = className.split(" ");
  newClasses = new Array();
  for (i in classes)
  {
    if (classes[i] != remove)
      newClasses.push(classes[i]);
  }
  return newClasses.join(" ");
}
// </dom_removeClass>


/** <dom_getXPos>
  *
  *   gets the horizontal position of an element on the entire page
  *
  *   params:
  *   obj - Object - the element whose position is to be determined
  *
  */
function dom_getXPos(obj)
{
  var x = 0, parentElement;

  parentElement = obj.offsetParent;
  if (parentElement != null)
  {
    x = dom_getXPos(parentElement);
  }
  if (obj.clientLeft)
  {
    return x + obj.offsetLeft + obj.clientLeft;
  }
  else
  {
    return x + obj.offsetLeft;
  }
}
// </dom_getXPos>


/** <dom_getYPos>
  *
  *   gets the vertical position of an element on the entire page
  *
  *   params:
  *   obj - Object - the element whose position is to be determined
  *
  */
function dom_getYPos(obj)
{
  var y = 0, parentElement;

  parentElement = obj.offsetParent;
  if (parentElement != null)
  {
    y = dom_getYPos(parentElement);
  }
  if (obj.clientTop)
  {
    return y + obj.offsetTop + obj.clientTop;
  }
  else
  {
    return y + obj.offsetTop;
  }
}
// </dom_getYPos>


/** <dom_focus>
  *
  *   Sets the focus to a node and checks whether the node has a focus method
  *   or not. Although this method seemd to be very useless it does really make
  *   sense: .focus() and .select() should not be called directly from within
  *   an event handler but through a window.setTimeout call to prevent scripts
  *   from doing strange unexpected things (see http://www.mozilla.org/access/
  *   keyboard/tabindex.html). Furthermore you will get an javascript error in
  *   "line 0" and "No source code available" error in JS debugger if one
  *   occurs while calling window.setTimeout("focusItem.focus()", 0); for
  *   instance if focusItem does not have a .focus() method. As you have a fix
  *   piece of source code you can set breakpoints and debug.
  *
  *   params:
  *   node - Object - the node to set the focus to
  *
  */
function dom_focus(node)
{
  try
  {
    if (node.focus)
    {
      node.focus();
    }
  }
  catch (error)
  {
  }
}
// </dom_focus>


/** <dom_select>
  *
  *   Selects the node (which should be an something that could be selected, e.
  *   g. an input field) content and checks whether the node has a select method
  *   or not. Although this method seemd to be very useless it does really make
  *   sense: .focus() and .select() should not be called directly from within
  *   an event handler but through a window.setTimeout call to prevent scripts
  *   from doing strange unexpected things (see http://www.mozilla.org/access/
  *   keyboard/tabindex.html). Furthermore you will get an javascript error in
  *   "line 0" and "No source code available" error in JS debugger if one
  *   occurs while calling window.setTimeout("selectItem.select()", 0); for
  *   instance if selectItem does not have a .select() method. As you have a fix
  *   piece of source code you can set breakpoints and debug.
  *
  *   params:
  *   node - Object - the node to set the select to
  *
  */
function dom_select(node)
{
  try
  {
    if (node.select)
    {
      node.select();
    }
  }
  catch (error)
  {
  }
}
// </dom_select>


// </D O M T O O L S>

/*******************************************************************************
 *
 * Class <I T S _ E V E N T>
 *
 * Description: wrapper class for handling events browser independent
 *
 * Date       : 2004/11/03
 * Author     : Simon Kruska
 *
 * History    :
 * yyyy/mm/dd id description
 * 2004/11/03 sk initial implementation
 *
 ******************************************************************************/

// javascript keycode constants
EVT_KEY_TAB    = 9;
EVT_KEY_RETURN = 13;
EVT_KEY_ESCAPE = 27;
EVT_KEY_PGUP   = 33;
EVT_KEY_PGDOWN = 34;
EVT_KEY_END    = 35;
EVT_KEY_POS1   = 36;
EVT_KEY_LEFT   = 37;
EVT_KEY_UP     = 38;
EVT_KEY_RIGHT  = 39;
EVT_KEY_DOWN   = 40;
EVT_KEY_INS    = 45;
EVT_KEY_DEL    = 46;
EVT_KEY_F1     = 112;
EVT_KEY_F2     = 113;
EVT_KEY_F3     = 114;
EVT_KEY_F4     = 115;
EVT_KEY_F5     = 116;
EVT_KEY_F6     = 117;
EVT_KEY_F7     = 118;
EVT_KEY_F8     = 119;
EVT_KEY_F9     = 120;
EVT_KEY_F10    = 121;

// javascript mouse button constants
EVT_MB_INVALID = -1;
EVT_MB_LEFT = 1;
EVT_MB_RIGHT = 2;
EVT_MB_MIDDLE = 4;
if (its_ua.gecko)
{
  ITS_EVENT_GLOBAL_RECEIVER = window;
}
else if (its_ua.ie55up)
{
  ITS_EVENT_GLOBAL_RECEIVER = document;
}

/** <its_event>
  *
  *   constructor for the its_event class.
  *
  *   params:
  *     browserEvent - Object(Event) - for mozilla only; the event
  */
function its_event(browserEvent)
{
  if (typeof event == "undefined" && !browserEvent)
  {
    // no event, no processing
    return null;
  }

  // get useragent information
  its_ua = new its_useragent();

  // browser dependent initialization
  if (its_ua.gecko)
  {
    this.event   = browserEvent;
    this.target  = browserEvent.target;
    this.offsetX = null;
    this.offsetY = null;
    this.pageX   = browserEvent.pageX;
    this.pageY   = browserEvent.pageY;
    this.currentTarget = browserEvent.currentTarget;
    this.relatedTarget = browserEvent.relatedTarget;
    if (browserEvent.type == "mousedown" || browserEvent.type == "mouseup")
    {
      switch (browserEvent.button)
      {
        case 0:
          this.button = EVT_MB_LEFT;
          break;
        case 1:
          this.button = EVT_MB_MIDDLE;
          break;
        case 2:
          this.button = EVT_MB_RIGHT;
          break;
        default:
          this.button = EVT_MB_INVALID;
          break;
      }
    }
  }
  if (its_ua.ie55up)
  {
    this.event   = browserEvent = event;
    this.target  = browserEvent.srcElement;
    this.offsetX = browserEvent.offsetX;
    this.offsetY = browserEvent.offsetY;
    this.button  = browserEvent.button;
  }

  // browser independent initialization
  this.altKey       = browserEvent.altKey;
  this.ctrlKey      = browserEvent.ctrlKey;
  this.cancelBubble = browserEvent.cancelBubble;
  this.clientX      = browserEvent.clientX;
  this.clientY      = browserEvent.clientY;
  this.keyCode      = browserEvent.keyCode;
  this.screenX      = browserEvent.screenX;
  this.screenY      = browserEvent.screenY;
  this.pageX        = browserEvent.clientX;
  this.pageY        = browserEvent.clientY;
  this.shiftKey     = browserEvent.shiftKey;
  this.type         = browserEvent.type;
}
// </its_event>

/** <provideOffsetXY>
  *
  *   calculates offsetX and offsetY from clientX and clientY minus its sibling
  *   and parent elements for gecko browsers.
  *
  */
its_event.prototype.provideOffsetXY = function()
{
  if (its_ua.gecko)
  {
    var x = this.clientX;
    var y = this.clientY;
    var element = this.target;

    // find the first element node
    while (element.nodeType != 1)
    {
      element = element.previousSibling;
    }

    // substract the sibling elements widths (e. g. TDs in a table)
    while (element.previousSibling)
    {
      if (element.previousSibling.nodeType == 1)
      {
        x -= element.previousSibling.offsetWidth;
      }
      element = element.previousSibling;
    }

    // substract the parent elements widths (e. g. DIVs)
    while (element.parentNode && element.tagName != "BODY")
    {
      x -= element.parentNode.offsetLeft;
      y -= element.parentNode.offsetTop;
      element = element.parentNode;
    }
    this.offsetX = x + 1;
    this.offsetY = y + 1;
  }
}
// </provideOffsetXY>


/** <preventDefault>
  *
  *   prevents the event bubbeling from executing its default action, i. g.
  *   prevent the browsers context menu on a right mouse click.
  *
  */
its_event.prototype.preventDefault = function()
{
  if (its_ua.gecko)
  {
    this.event.preventDefault();
  }
  else if (its_ua.ie55up)
  {
    this.event.returnValue = false;
  }
}
// </preventDefault>


/** <stopPropagation>
  *
  *   stop the propagation of the current event.
  *
  *
  */
its_event.prototype.stopPropagation = function()
{
  if (its_ua.gecko)
  {
    this.event.stopPropagation();
  }
  else if (its_ua.ie55up)
  {
    this.event.cancelBubble = true;
  }
}
// </stopPropagation>


/** <cancel>
  *
  *   cancel the entire event, including stopPropagation and preventDefault.
  *
  *
  */
its_event.prototype.cancel = function()
{
  this.stopPropagation();
  this.preventDefault();
}
// </cancel>


/** <getGlobalEventReceiver>
  *
  *   returns the upper event receiver, for mozilla it#s the window object, for
  *   internet explorer it#s the document
  *
  */
its_event.prototype.getGlobalEventReceiver = function()
{
  if (its_ua.gecko)
  {
    return window;
  }
  else if (its_ua.ie55up)
  {
    return document;
  }
}
// </getGlobalEventReceiver>


/** <dump>
  *
  *   dump the event data as alert window or within a table in the document
  *
  *   params:
  *     asAlert - Bool - when true, the dump is displayed in an alert window,
  *                      when false, the dump is displayed wihtin a table in the
  *                      document
  */
its_event.prototype.dump = function(asAlert)
{
  this.provideOffsetXY();
  eventArray = new Array();
  eventArray["ALTKEY"] = this.altKey;
  eventArray["CANCELBUBBLE"] = this.cancelBubble;
  eventArray["CLIENTX"] = this.clientX;
  eventArray["CLIENTY"] = this.clientY;
  eventArray["KEYCODE"] = this.keyCode;
  eventArray["SCREENX"] = this.screenX;
  eventArray["SCREENY"] = this.screenY;
  eventArray["SHIFTKEY"] = this.shiftKey;
  eventArray["TYPE"] = this.type;
  eventArray["OFFSETX"] = this.offsetX;
  eventArray["OFFSETY"] = this.offsetY;
  eventArray["TARGET"] = this.target.tagName;

  if (asAlert)
  {
    var eventString = "";
    for (var i in eventArray)
    {
      eventString += i + " = " + eventArray[i] + "\n";
    }
    alert("EVENT FROM its_event:\n\n" + eventString);
  }
  else
  {
    var table = document.getElementById("its_eventDump");
    if (!table)
    {
      var body = document.getElementsByTagName("body")[0];
      table = document.createElement("table");
      table.setAttribute("id", "its_eventDump");
      body.appendChild(table);
    }
    else
    {
      while (table.childNodes.length > 0)
      {
        table.removeChild(table.childNodes[0]);
      }
    }
    var tbody = document.createElement("tbody");
    table.appendChild(tbody);
    for (var i in eventArray)
    {
      var tr = document.createElement("tr");
      tr.style.height = "20px";
      tbody.appendChild(tr);
      var td1 = document.createElement("td");
      var td2 = document.createElement("td");
      td1.innerHTML = i;
      td2.innerHTML = eventArray[i];
      tr.appendChild(td1);
      tr.appendChild(td2);
    }
  }
}
// </dump>
// </I T S _ E V E N T>

/*******************************************************************************
 *
 * Class <I T S _ E V E N T M A N A G E R>
 *
 * Description: register and unregister events for html elements browser
 *              independent
 * Date       : 2004/11/03
 * Author     : Simon Kruska
 *
 * History    :
 * yyyy/mm/dd id description
 * 2004/11/03 sk initial implementation
 *
 ******************************************************************************/
/** <its_eventManager>
  *
  *   constructor for the its_eventManager class.
  *
  */
function its_eventManager()
{
}
// </its_eventManager>

/** <registerEvent>
  *
  *   register an event for a html element
  *
  *   params:
  *     in_element   : the element on which the event should be registered
  *     in_evtName   : name of the event to be registered (e. g. "click" or
  *                    "mouseover")
  *     in_evtHandler: a function that is to be called on the appropriate event
  *
  */
its_eventManager.prototype.registerEvent = function(in_element, in_evtName, in_evtHandler)
{
    if (its_ua.gecko)
    {
        in_element.addEventListener(in_evtName, in_evtHandler, false);
    }
    else if (its_ua.ie55up)
    {
        in_element.attachEvent("on" + in_evtName, in_evtHandler);
    }
}
// </registerEvent>

/** <unregisterEvent>
  *
  *   unregister an event for a html element
  *
  *   params:
  *     in_element   : the element on which the event should be unregistered
  *     in_evtName   : name of the event to be unregistered (e. g. "click" or
  *                    "mouseover")
  *     in_evtHandler: a function that is to be called on the appropriate event
  *
  */
its_eventManager.prototype.unregisterEvent = function(in_element, in_evtName, in_evtHandler)
{
    if (its_ua.gecko)
    {
        in_element.removeEventListener(in_evtName, in_evtHandler, false);
    }
    else if (its_ua.ie55up)
    {
        in_element.detachEvent("on" + in_evtName, in_evtHandler);
    }
}
// </unregisterEvent>

/* global instance */
var its_eMgr = new its_eventManager();

// </I T S _ E V E N T M A N A G E R>


