<!--
//***************************************************************************
//   Empower Mobility LLC, Essex Junction, Vermont 05452
//   Copyright © 2001-06, All Rights Reserved.
//***************************************************************************
//
// FILE:        emWeb_tools.js
// AUTHOR:      Tom Jaros
// NOTICE:      Copyright Notice
//
//              This software, 'emWeb_tools.js', is provided 'AS-IS' and without any express or 
//              implied warranty.  In no event will the author or Empower Mobility LLC
//              be held liable for any damages arising from the use of this software.
//              
//              This software must not be modified or redistributed without prior written 
//              approval by the author or an authorized agent of Empower Mobility LLC.  All
//              bug fixes or enhancements will be performed by Empower Mobility LLC unless
//              otherwise noted.
//
//              Usage is also subject to the following conditions:
//
//              1. The origin of this software must not be misrepresented; you must not
//                 claim that you wrote the original software. 
//
//              2. This notice may not be removed or altered from any source distribution.
//
//***************************************************************************
var gA              = navigator.userAgent;
var ns4             = document.layers;
var ns6             = document.getElementById&&!document.all;
var ie4             = document.all;
var ieCE            = gA.indexOf("Windows CE");
//***************************************************************************
function WebToolsGetObject(s)
{
    var obj;

    if (ns6)
    {
        obj = document.getElementById(s);
    }
    else if (ns4)
    {
        obj = document.layers(s);
    }
    else if (ieCE > -1)
    {
        obj = eval(s);
    }
    else
    {
        obj = document.all(s);
    }

    return(obj);
}
//***************************************************************************
function WebToolsGetRealLeft(obj)
{
    var xPos;

    if (obj == null)
    {
        // bah
    }
    else if (ns4)
    {
        xPos = obj.x;
    }
    else
    {
        var tempObj;
        
        tempObj = obj;
        xPos = 0;

        while (tempObj != null)
        {
            xPos += tempObj.offsetLeft;
            tempObj = tempObj.offsetParent;
        }
    }

    return(xPos);
}
//**************************************************************
function WebToolsGetRealRight(obj)
{
    var xPos;

    if (obj == null)
    {
        // bah
    }
    else if (ns4)
    {
        xPos = obj.x;
    }
    else
    {
        var tempObj;
        
        tempObj = obj;
        xPos = tempObj.offsetWidth;

        while (tempObj != null)
        {
            xPos += tempObj.offsetLeft;
            tempObj = tempObj.offsetParent;
        }
    }

    return(xPos);
}
//***************************************************************
function WebToolsGetRealTop(obj)
{
    var yPos;

    if (obj == null)
    {
        // bah
    }
    else if (ns4)
    {
        yPos = obj.y;
    }
    else
    {
        var tempObj;

        tempObj = obj;
        yPos = 0;

        while (tempObj != null)
        {
            yPos += tempObj.offsetTop;
            tempObj = tempObj.offsetParent;
        }
    }

    return(yPos);
}
//***************************************************************
function WebToolsGetRealBottom(obj)
{
    var yPos;

    if (obj == null)
    {
        // bah
    }
    else if (ns4)
    {
        yPos = obj.y;
    }
    else
    {
        var tempObj;
        
        tempObj = obj;
        yPos = tempObj.offsetHeight;

        while (tempObj != null)
        {
            yPos += tempObj.offsetTop;
            tempObj = tempObj.offsetParent;
        }
    }

    return(yPos);
}
//***************************************************************
function WebToolsMoveLayerTo(obj, newX, newY)
{
    var objStyle;

    if (ns6)
    {
        objStyle = obj.style;
        if (newX != -1)
        {
            objStyle.left = String(newX) + 'px';
        }

        if (newY != -1)
        {
            objStyle.top = String(newY) + 'px';
        }
    }
    else if (ns4)
    {
        obj.moveTo(newX, newY);
    }
    else if (ie4)
    {
        objStyle = obj.style;
        if (newX != -1)
        {
            objStyle.pixelLeft = newX;
        }

        if (newY != -1)
        {
            objStyle.pixelTop = newY;
        }
    }
}
//***************************************************************
function WebToolsMoveLayerBy(obj, xOffset, yOffset)
{
    var objStyle;

    if (obj == null)
    {
        // bah
    }
    else if (ns6)
    {
        objStyle = obj.style;
        objStyle.left = String(parseInt(sty.left) + xOffset) + 'px';
        objStyle.top = String(parseInt(sty.top) + yOffset) + 'px';
    }
    else if (ns4)
    {
        obj.moveBy(xOffset, yOffset);
    }
    else if (ie4)
    {
        objStyle = obj.style;
        objStyle.pixelLeft = obj.offsetLeft + xOffset;
        objStyle.pixelTop = obj.offsetTop + yOffset;
    }
}
//***************************************************************
function WebToolsSizeLayerTo(obj, newX, newY)
{
    var objStyle;

    if (obj == null)
    {
        // bah
    }
    else if (ns6)
    {
        objStyle = obj.style;
        objStyle.width = String(newX) + 'px';
        objStyle.height = String(newY) + 'px';
    }
    else if (ns4)
    {
        obj.sizeTo(newX, newY);
    }
    else if (ie4)
    {
        objStyle = obj.style;
        objStyle.pixelWidth = newX;
        objStyle.pixelHeight = newY;
    }
}
//***************************************************************
function WebToolsSizeLayerBy(obj, xOffset, yOffset)
{
    var objStyle;

    if (obj == null)
    {
        // bah
    }
    else if (ns6)
    {
        objStyle = obj.style;
        objStyle.width = String(parseInt(objStyle.left) + xOffset) + 'px';
        objStyle.height = String(parseInt(objStyle.top) + yOffset) + 'px';
    }
    else if (ns4)
    {
        obj.sizeTo(xOffset, yOffset);
    }
    else if (ie4)
    {
        objStyle = obj.style;
        objStyle.pixelWidth = obj.clientWidth + xOffset;
        objStyle.pixelHeight = obj.clientHeight + yOffset;
    }
}
//*************************************************************
-->
