
function point(numX,numY) {
    this.x = numX;
    this.y = numY;
}

function rect( x1, y1, x2, y2 ) {
    var m_dblLeft;
    var m_dblBottom;
    var m_dblRight;
    var m_dblTop;

    var dblX1 = parseFloat(x1);
    var dblY1 = parseFloat(y1);
    var dblX2 = parseFloat(x2);
    var dblY2 = parseFloat(y2);

    if (dblX1 < dblX2) {
        m_dblLeft  = dblX1;
        m_dblRight = dblX2;
    }
    else  {
        m_dblLeft  = dblX2;
        m_dblRight = dblX1;
    }

    if (dblY1 < dblY2) {
        m_dblBottom = dblY1;
        m_dblTop    = dblY2;
    }
    else {
        m_dblBottom = dblY2;
        m_dblTop    = dblY1;
    }

    // methods
    this.getLeft   = getLeft;
    this.getBottom = getBottom;
    this.getRight  = getRight;
    this.getTop    = getTop;
    this.getCenter = getCenter;
    this.getWidth  = getWidth;
    this.getHeight = getHeight;
    this.scale     = scale;

    // ------- Public Methods -------

    function getLeft()   { return m_dblLeft; }
    function getBottom() { return m_dblBottom; }
    function getRight()  { return m_dblRight; }
    function getTop()    { return m_dblTop; }
    function getWidth()  { return (this.getRight() - this.getLeft()); }
    function getHeight() { return (this.getTop() - this.getBottom()); }

    function scale( factor ) {
        makeFromCenter(this.getCenter(), this.getWidth() * factor, this.getHeight() * factor);
    }

    function getCenter() {
        var dblCenterX = this.getLeft() + (this.getWidth() / 2);
        var dblCenterY = this.getBottom() + (this.getHeight() / 2);
        return new point(dblCenterX, dblCenterY);
    }

    // ------ Private Functions -----

    function makeFromCenter( center, width, height ) {
        m_dblLeft   = center.x - (width  / 2);
        m_dblRight  = center.x + (width  / 2);
        m_dblBottom = center.y - (height / 2);
        m_dblTop    = center.y + (height / 2);
    }
}
