// Title:       Scripts.js
// Description: Script Collection
// Author:      Matthias Altherr, VisionOne


tooltip = null;
document.onmousemove = updateTooltip;
fixedTooltip = null;

//returns object by id
function $(id)
{
    return document.getElementById(id);
}

//opens a popup window / tab
function openWindow(URL) 
{
    window.open(URL);
}

//redirects to a different url
function redirect(URL)
{
    window.location.href = URL;
}

//updates the tooltip's position on mouse-move
function updateTooltip(e) 
{   
    if(tooltip != null)
    {   
        x = (document.all) ? window.event.x + document.body.scrollLeft : e.pageX;
        y = (document.all) ? window.event.y + document.body.scrollTop : e.pageY;
        tooltip.style.display = 'block';
        tooltip.style.top = (y + 10) + 'px';
        tooltip.style.left = (x + 10) + 'px';
    }
}

//shows tooltip by id
function showTooltip(id) 
{
    try 
    {
        tooltip = $(id);
        //tooltip.style.display = "block";
    } 
    catch (error) { error = null; } 
}

//hides the tooltip
function hideTooltip() 
{
    try 
    {
        tooltip.style.display = 'none';
        tooltip = null;
    } 
    catch (error) { error = null; } 
}

//returns the x-position of an object
function findPosX(obj)
{
    var curleft = 0;
    if(obj.offsetParent)
        while(1) 
        {
            curleft += obj.offsetLeft;
            if(!obj.offsetParent)
            break;
            obj = obj.offsetParent;
        }
    else if(obj.x)
        curleft += obj.x;
    return curleft;
}

//returns the y-Position of an object
function findPosY(obj)
{
    var curtop = 0;
    if(obj.offsetParent)
        while(1)
        {
          curtop += obj.offsetTop;
          if(!obj.offsetParent)
            break;
          obj = obj.offsetParent;
        }
    else if(obj.y)
        curtop += obj.y;
    return curtop;
}

function TimStatus(message)
{
    window.status=message;
}

function SetStatus(message)
{
    window.status=message;
    setTimeout('TimStatus("'+message+'")',1);
}
