// ----------------------------------------------
// Author: (c) Andreas 'decoman' Fay
// ----------------------------------------------
// Version:    1.4.3
// ----------------------------------------------
// Functionindex
// ----------------------------------------------
// v0.1 - checkBoxPosition
// v0.2 - close
// v0.2 - getPointerPosition
// v0.2 - open
// ----------------------------------------------


function infobox(strInfobox)
{
    // Attributes -------------------------------
    var blnOpen                                  =  false;
    var strInfoboxId                             =  strInfobox;


    // ------------------------------------------
    // Method (privileged)
    // ------------------------------------------
    // Name:        checkBoxPosition
    // Description: Places box to pointer
    // Input:       MouseMovement-Event
    // Output:
    // ------------------------------------------
    // Version:     0.1
    // ------------------------------------------
    // ChangeLog
    // ------------------------------------------
    // v0.1 (06.01.2007)
    // ------------------------------------------
    this.checkBoxPosition                        =  function(mousemove)
    {
        if (blnOpen)
        {
            if (!mousemove)
                mousemove                        =  window.event;

            arrPointer                           =  getPointerPosition(mousemove);

            objMenu                              =  document.getElementById(strInfoboxId);
            objMenu.style.left                   =  arrPointer["x"] + 15 + "px";
            objMenu.style.top                    =  arrPointer["y"] + 5 + "px";
        }
    }


    // ------------------------------------------
    // Method (privileged)
    // ------------------------------------------
    // Name:        close
    // Description:
    // Input:
    // Output:
    // ------------------------------------------
    // Version:     0.2
    // ------------------------------------------
    // ChangeLog
    // ------------------------------------------
    // v0.1 (06.01.2007)
    // v0.2 (19.05.2007)
    // ------------------------------------------
    this.close                                   =  function()
    {
        if (blnOpen)
        {
            objMenu                              =  document.getElementById(strInfoboxId);
            objMenu.style.visibility             =  "hidden";
            objMenu.style.zIndex                 =  -1;

            blnOpen                              =  false;
        }
    }


    // ------------------------------------------
    // Method (private)
    // ------------------------------------------
    // Name:        getPointerPosition
    // Description:
    // Input:       MouseMovement-Event
    // Output:      Coordinates of pointer
    // ------------------------------------------
    // Version:     0.2
    // ------------------------------------------
    // ChangeLog
    // ------------------------------------------
    // v0.1 (06.01.2007)
    // v0.2 (20.10.2007)
    // ------------------------------------------
    getPointerPosition                           =  function(mousemove)
    {
        if (!mousemove)
            mousemove                            =  window.event;

        arrPointer                               =  new Array();

        if (self.pageYOffset) // all except Explorer
        {
            x                                    =  self.pageXOffset;
            y                                    =  self.pageYOffset;
        }
        else if (document.documentElement && document.documentElement.scrollTop) // Explorer 6 Strict
        {
            x                                    =  document.documentElement.scrollLeft;
            y                                    =  document.documentElement.scrollTop;
        }
        else if (document.body) // all other Explorers
        {
            x                                    =  document.body.scrollLeft;
            y                                    =  document.body.scrollTop;
        }

        arrPointer["x"]                          =  mousemove.clientX+x;
        arrPointer["y"]                          =  mousemove.clientY+y;
        
        
        // Check if box position is to close at borders
        arrDimension                             =  getInnerDimensions();
        if (arrDimension['x'] - arrPointer['x'] < 300)
            arrPointer['x']                      =  arrPointer['x']-300;
        

        return arrPointer;
    }


    // ------------------------------------------
    // Method (privileged)
    // ------------------------------------------
    // Name:        open
    // Description:
    // Input:       Text
    // Output:
    // ------------------------------------------
    // Version:     0.2
    // ------------------------------------------
    // ChangeLog
    // ------------------------------------------
    // v0.1 (06.01.2007)
    // v0.2 (19.05.2007)
    // ------------------------------------------
    this.open                                    =  function(text)
    {
        if (text.length > 0)
        {
            blnOpen                              =  true;

            objMenu                              =  document.getElementById(strInfoboxId);
            objMenu.innerHTML                    =  text;
            objMenu.style.zIndex                 =  2;
            objMenu.style.visibility             =  "visible";
        }
    }
}
