// JScript File


//----------------------------------------------------------------------------------------------------
//    TRACK OBJECTS
//----------------------------------------------------------------------------------------------------
   
var TRACK_ACTION_S            = 1;
var TRACK_ACTION_E            = 2;
var TRACK_ACTION_SE           = 3;
var TRACK_ACTION_LINE_START   = 4;
var TRACK_ACTION_LINE_END     = 5;
function trackRectEllipse(p) {
    var me = this;
    this.parent = p;
    this.coords = null;
    this.edit = true;

    this.run = function(event) {
        switch (me.action(event)) {
            case TRACK_ACTION_S:
                browser.cursor.nResize();
                break;

            case TRACK_ACTION_E:
                browser.cursor.eResize();
                break;

            case TRACK_ACTION_SE:
                browser.cursor.nwResize();
                break;
        }
        return (browser.block(event));
    };

    this.action = function(event) {
        if (!me.edit) { return (0); }
        me.coords = me.parent.coords(event);

        h = me.parent.draw.height;
        w = me.parent.draw.width;

        //window.status = "offset(x:" + me.coords.x + ",y:" + me.coords.y + ") size(h:" + h + ",w:" + w + ")";

        if ((me.coords.x + me.coords.y) > ((h + w) - 5)) {
            return (TRACK_ACTION_SE);
        }
        else if (me.coords.x > (w - 3)) {
            return (TRACK_ACTION_E);
        }
        else if (me.coords.y > (h - 3)) {
            return (TRACK_ACTION_S);
        }
        return (0);
    };
}

function trackLine(p) {
    var me = this;
    this.parent = p;
    this.coords = null;
    this.edit = true;

    this.run = function(event) {
        switch (me.action(event)) {
            case TRACK_ACTION_LINE_START:
                browser.cursor.crosshair();
                break;

            case TRACK_ACTION_LINE_END:
                browser.cursor.crosshair();
                break;
        }
        return (browser.block(event));
    };

    this.action = function(event) {
        if (!me.edit) { return (0); }
        me.coords = me.parent.coords(event);

        var x1 = me.parent.draw.x1;
        var y1 = me.parent.draw.y1;
        var x2 = me.parent.draw.x2;
        var y2 = me.parent.draw.y2;

        var sw = me.parent.draw.stroke.width;
        if (sw == null) { sw = 0; }


        offset = { x: (me.coords.x - 400), y: (me.coords.y - 400) };
        if ((Math.abs(offset.x - (x1 - 400)) < (5 + sw)) && (Math.abs(offset.y - (y1 - 400)) < (5 + sw))) {
            //window.status = "LINE START";
            return (TRACK_ACTION_LINE_START);
        }
        else if ((Math.abs(offset.x - (x2 - 400)) < (5 + sw)) && (Math.abs(offset.y - (y2 - 400)) < (5 + sw))) {
            //window.status = "LINE END";
            return (TRACK_ACTION_LINE_END);
        }
        //window.status = "sw(" + sw + ") offset(" + offset.x + "," + offset.y + ") start(" + (x1-400) + "," + (y1-400) + ") end(" + (x2-400) + "," + (y2-400) + ")";
    };
}

function trackImage(p) {
    var me = this;
    this.parent = p;
    this.coords = null;
    this.edit = true;

    this.run = function(event) {
        switch (me.action(event)) {
            case TRACK_ACTION_S:
                browser.cursor.nResize();
                break;

            case TRACK_ACTION_E:
                browser.cursor.eResize();
                break;

            case TRACK_ACTION_SE:
                browser.cursor.nwResize();
                break;
        }
        return (browser.block(event));
    };

    this.action = function(event) {
        if (!me.edit) { return (0); }
        me.coords = me.parent.coords(event);

        switch (browser.type) {
            case MSIE:
                h = parseInt(me.parent.draw.img.height);
                w = parseInt(me.parent.draw.img.width);
                break;

            case FOX:
            case SAFARI:
            case OPERA:
            case BLACKBERRY:
            case CHROME:
            case ANDROID:
                h = parseInt(me.parent.draw.img.style.height);
                w = parseInt(me.parent.draw.img.style.width);
                break;
        }

        //   window.status = "offset(x:" + me.coords.x + ",y:" + me.coords.y + ") size(h:" + h + ",w:" + w + ")";

        if ((me.coords.x + me.coords.y) > ((h + w) - 5)) {
            return (TRACK_ACTION_SE);
        }
        else if (me.coords.x > (w - 3)) {
            return (TRACK_ACTION_E);
        }
        else if (me.coords.y > (h - 3)) {
            return (TRACK_ACTION_S);
        }
        return (0);
    };
}

function trackDataPoint(p) {
    var me = this;
    this.parent = p;
    this.coords = null;
    this.edit = true;

    this.run = function(event) {

        if (me.parent.type == OBJ_TYPE_LABEL) { return; }
        switch (me.action(event)) {
            case TRACK_ACTION_E:
                browser.cursor.eResize();
                break;
        }
        return (browser.block(event));
    };

    this.action = function(event) {
        me.coords = me.parent.coords(event);

        h = me.parent.draw.height;
        w = me.parent.draw.width;

        //      window.status = "offset(x:" + me.coords.x + ",y:" + me.coords.y + ") size(h:" + h + ",w:" + w + ")";

        if (me.coords.x > (w - 1)) {
            return (TRACK_ACTION_E);
        }
        return (0);
    };
}

//----------------------------------------------------------------------------------------------------
//    RESIZE OBJECTS
//----------------------------------------------------------------------------------------------------
function resizeRectEllipse(p) {
    var me = this;
    this.parent = p;
    this.resizeEventType = null;
    this.callBackOverride = null;
    this.delayStartTimer = null;

    this.delayStart = function(event) {
        me.parent.div.clearEvents();
        me.delayStartTimer = setTimeout(me.start, 100);
        me.resizeEventType = me.parent.track.action(event);
        browser.attachEvent('onmouseup', me.cancelStart);
        //browser.attachEvent('onmousemove', me.cancelStart);
        return (browser.block(event));
    };

    this.cancelStart = function(event) {
        me.parent.div.setEvents();
        clearTimeout(me.delayStartTimer);
        me.resizeEventType = null;
        return;
    };

    this.start = function(event) {
        browser.detachEvent('onmouseup', me.cancelStart);
        //browser.detachEvent('onmousemove', me.cancelStart);
        browser.attachEvent('onmousemove', me.run);
        browser.attachEvent('onmouseup', me.stop);
        return;
    };

    this.stop = function(event) {
        setTimeout(me.parent.div.setEvents, 50);
        browser.detachEvent('onmousemove', me.run);
        browser.detachEvent('onmouseup', me.stop);
        browser.cursor.none();
        me.parent.state = null;

        if (me.callBackOverride) {
            me.callBackOverride();
            me.callBackOverride = null;
        }
        else {
            me.parent.saveSize();
        }
        return (browser.block(event));
    };

    this.run = function(event) {
        coords = me.parent.coords(event);
        switch (me.resizeEventType) {
            case TRACK_ACTION_S:
                browser.cursor.nResize();
                //me.parent.draw.height = coords.y;
                me.parent.draw.set.height(coords.y);
                break;

            case TRACK_ACTION_E:
                browser.cursor.eResize();
                //me.parent.draw.width = coords.x;
                me.parent.draw.set.width(coords.x);
                break;

            case TRACK_ACTION_SE:
                browser.cursor.nwResize();
                //me.parent.draw.height = coords.y;
                //me.parent.draw.width = coords.x;
                me.parent.draw.set.height(coords.y);
                me.parent.draw.set.width(coords.x);
                break;
        }
        me.parent.draw.run();
        me.parent.div.clearEvents();
        return (browser.block(event));
    }
}

function resizeLine(p) {
    var me = this;
    this.parent = p;
    this.resizeEventType = null;
    this.callBackOverride = null;
    this.delayStartTimer = null;

    this.delayStart = function(event) {
        me.parent.div.clearEvents();
        me.delayStartTimer = setTimeout(me.start, 100);
        me.resizeEventType = me.parent.track.action(event);
        browser.attachEvent('onmouseup', me.cancelStart);
        //browser.attachEvent('onmousemove', me.cancelStart);
        return (browser.block(event));
    };

    this.cancelStart = function(event) {
        me.parent.div.setEvents();
        clearTimeout(me.delayStartTimer);
        me.resizeEventType = null;
        return;
    };

    this.start = function(event) {
        browser.detachEvent('onmouseup', me.cancelStart);
        //browser.detachEvent('onmousemove', me.cancelStart);
        browser.attachEvent('onmousemove', me.run);
        browser.attachEvent('onmouseup', me.stop);
        return;
    };

    this.stop = function(event) {
        setTimeout(me.parent.div.setEvents, 50);
        browser.detachEvent('onmousemove', me.run);
        browser.detachEvent('onmouseup', me.stop);
        browser.cursor.none();
        me.parent.state = null;
        if (me.callBackOverride) {
            me.callBackOverride();
            me.callBackOverride = null;
        }
        else {
            me.parent.saveLineSize();
        }
        return (browser.block(event));
    };

    this.run = function(event) {
        var d = me.parent.draw;

        coords = me.parent.coords(event);
        switch (me.resizeEventType) {
            case TRACK_ACTION_LINE_START:
                d.x1 = coords.x;
                d.y1 = coords.y;
                break;

            case TRACK_ACTION_LINE_END:
                browser.cursor.eResize();
                d.x2 = coords.x;
                d.y2 = coords.y;
                break;
        }


        //      m = Math.abs((d.y2-d.y1)/(d.x2-d.x1));
        //      window.status = "slope:" + m;


        if (Math.abs(d.x1 - d.x2) < 3) {
            if (me.resizeEventType == TRACK_ACTION_LINE_END) {
                d.x2 = d.x1;
            }
            else {
                d.x1 = d.x2;
            }
        }
        if (Math.abs(d.y1 - d.y2) < 3) {
            if (me.resizeEventType == TRACK_ACTION_LINE_END) {
                d.y2 = d.y1;
            }
            else {
                d.y1 = d.y2;
            }
        }

            window.status = "x1:" + d.x1 + ",y1:" + d.y1 + ",x2:" + d.x2 + ",y2:" + d.y2;

        me.parent.draw.run();
        browser.cursor.crosshair();
        return (browser.block(event));
    }
}

function resizeImage(p) {
    var me = this;
    this.parent = p;
    this.callBackOverride = null;
    this.resizeEventType = null;
    this.delayStartTimer = null;

    this.delayStart = function(event) {
        me.parent.div.clearEvents();
        me.delayStartTimer = setTimeout(me.start, 100);
        me.resizeEventType = me.parent.track.action(event);
        browser.attachEvent('onmouseup', me.cancelStart);
        //browser.attachEvent('onmousemove', me.cancelStart);
        return (browser.block(event));
    };

    this.cancelStart = function(event) {
        me.parent.div.setEvents();
        clearTimeout(me.delayStartTimer);
        me.resizeEventType = null;
        return;
    };

    this.start = function(event) {
        browser.detachEvent('onmouseup', me.cancelStart);
        //browser.detachEvent('onmousemove', me.cancelStart);
        browser.attachEvent('onmousemove', me.run);
        browser.attachEvent('onmouseup', me.stop);
        return;
    };

    this.stop = function(event) {
        setTimeout(me.parent.div.setEvents, 50);
        browser.detachEvent('onmousemove', me.run);
        browser.detachEvent('onmouseup', me.stop);
        browser.cursor.none();
        me.parent.state = null;
        if (me.callBackOverride) {
            me.callBackOverride();
            me.callBackOverride = null;
        }
        else {
            me.parent.saveImageSize();
           // me.parent.parent.saveObjectsByXML();
        }
        return (browser.block(event));
    };

    this.run = function(event) {
        coords = me.parent.coords(event);

        switch (me.resizeEventType) {
            case TRACK_ACTION_SE:
                browser.cursor.nwResize();
                me.parent.draw.set.height(coords.y);
                me.parent.draw.set.width(coords.x);
                break;

            case TRACK_ACTION_S:
                browser.cursor.nResize();
                me.parent.draw.set.height(coords.y);
                break;

            case TRACK_ACTION_E:
                browser.cursor.eResize();
                me.parent.draw.set.width(coords.x);
                break;
        }
        var d = me.parent.div.get();
        d.style.height = me.parent.draw.get.height() + "px";
        d.style.width = me.parent.draw.get.width() + "px";
        return (browser.block(event));
    }
}

function resizeDataPoint(p) {
    var me = this;
    this.parent = p;
    this.resizeEventType = null;
    this.delayStartTimer = null;

    this.delayStart = function(event) {
        me.parent.div.clearEvents();
        me.delayStartTimer = setTimeout(me.start, 100);
        me.resizeEventType = me.parent.track.action(event);
        browser.attachEvent('onmouseup', me.cancelStart);
        //browser.attachEvent('onmousemove', me.cancelStart);
        return (browser.block(event));
    };

    this.cancelStart = function(event) {
        me.parent.div.setEvents();
        clearTimeout(me.delayStartTimer);
        me.resizeEventType = null;
        return;
    };

    this.start = function(event) {
        browser.detachEvent('onmouseup', me.cancelStart);
        //browser.detachEvent('onmousemove', me.cancelStart);
        browser.attachEvent('onmousemove', me.run);
        browser.attachEvent('onmouseup', me.stop);
        return;
    };

    this.stop = function(event) {
        setTimeout(me.parent.div.setEvents, 50);
        browser.detachEvent('onmousemove', me.run);
        browser.detachEvent('onmouseup', me.stop);
        browser.cursor.none();
        me.parent.state = null;
        me.parent.saveInt("width", me.parent.draw.width);
        return (browser.block(event));
    };

    this.run = function(event) {
        coords = me.parent.coords(event);
        switch (me.resizeEventType) {
            case TRACK_ACTION_E:
                browser.cursor.eResize();
                me.parent.draw.width = coords.x;
                break;
        }
        me.parent.draw.run();
        me.parent.div.clearEvents();
        return (browser.block(event));
    }
}

//----------------------------------------------------------------------------------------------------
//    CLICK DRAG SELECTION BOX
//----------------------------------------------------------------------------------------------------
function clsClickDragSelect(p) {
    var me = this;
    this.parent = p;
    this.div = null;
    this.delayStartTimer = null;
    this.delayHideTimer = null;

    this.coordsStart = null;

    this.coords = function(event) {
        var c = browser.coords(event);
        var s = browser.scroll(event);
        var o = { x: me.parent.canvas.x, y: me.parent.canvas.y };
        return { x: (c.x + s.x - o.x), y: (c.y + s.y - o.y) };
    };


    this.delayStart = function(event) {
        me.hide();
        me.coordsStart = me.coords(event);
        me.delayStartTimer = setTimeout(me.start, 10);
        browser.attachEvent('onmouseup', me.cancelStart);
        return (browser.block(event));
    };

    this.cancelStart = function(event) {
        clearTimeout(me.delayStartTimer);
        return;
    };

    this.start = function(event) {
        me.coordsStart = me.coords(event);
        browser.attachEvent('onmouseup', me.delayStop);
        browser.attachEvent('onmousemove', me.run);

        me.div = document.createElement("div");
        me.div.id = "multiSelectBox";
        me.div.style.zIndex = 10;
        me.div.style.border = "1px dashed black";
        me.div.style.position = "absolute";
        me.div.style.left = me.coordsStart.x + "px";
        me.div.style.top = me.coordsStart.y + "px";
        me.div.style.height = "1px";
        me.div.style.width = "1px";

        me.parent.canvas.node.appendChild(me.div);
        return (browser.block(event));
    };

    this.hide = function() {
        me.coordsStart = null;
        browser.detachEvent('onmouseup', me.delayStop);
        browser.detachEvent('onmousemove', me.run);
        if (me.div) {
            me.div.parentNode.removeChild(me.div);
        }
        browser.html.remove("multiSelectBox");
        me.div = null;
    };

    this.delayStop = function(event) {
        browser.detachEvent('onmouseup', me.delayStop);
        browser.detachEvent('onmousemove', me.run);
        me.delayStartTimer = setTimeout(me.stop, 25);
    };

    this.stop = function(event) {
        if (me.div) {
            var pos = { x: parseInt(me.div.style.left), y: parseInt(me.div.style.top) };
            var size = { w: parseInt(me.div.style.width), h: parseInt(me.div.style.height) };

            me.parent.selectObjectsByLocation(pos, size);
        }
        me.hide();
        return;
        return (browser.block(event));
    };

    this.run = function(event) {
        var c = me.coords(event);
        w = c.x - me.coordsStart.x;
        h = c.y - me.coordsStart.y;

        if ((h < 0) && (w < 0)) {
            me.div.style.left = (me.coordsStart.x + w) + "px";
            me.div.style.top = (me.coordsStart.y + h) + "px";
            me.div.style.height = Math.abs(h) + "px";
            me.div.style.width = Math.abs(w) + "px";
        }
        else if ((h < 0) && (w > 0)) {
            me.div.style.left = (me.coordsStart.x) + "px";
            me.div.style.top = (me.coordsStart.y + h) + "px";
            me.div.style.height = Math.abs(h) + "px";
            me.div.style.width = Math.abs(w) + "px";
        }
        else if ((h > 0) && (w < 0)) {
            me.div.style.left = (me.coordsStart.x + w) + "px";
            me.div.style.top = (me.coordsStart.y) + "px";
            me.div.style.height = Math.abs(h) + "px";
            me.div.style.width = Math.abs(w) + "px";
        }
        else {
            me.div.style.left = me.coordsStart.x + "px";
            me.div.style.top = me.coordsStart.y + "px";
            me.div.style.height = Math.abs(h) + "px";
            me.div.style.width = Math.abs(w) + "px";
        }


        return (browser.block(event));
    };
}


//----------------------------------------------------------------------------------------------------
//    DRAW OBJECTS
//----------------------------------------------------------------------------------------------------
function drawRect(p) {
    var me = this;
    this.parent = p;
    this.initialized = false;

    this.opacity;
    this.fillColor;
    this.height;
    this.width;
    this.stroke;
    this.title;
    this.visible;
    this.lockRatio;
    this.ratio;



    this.getRatio = function() {
        if (me.lockRatio) { return (me.ratio); }
        me.ratio = parseFloat(me.height / me.width);
        return (me.ratio);
    };


    this.updateXML = function() {
        var n = me.parent.node;

        n.setAttribute("opacity", me.opacity);
        n.setAttribute("fillColor", me.fillColor);
        n.setAttribute("height", me.height);
        n.setAttribute("width", me.width);
        n.setAttribute("strokeWidth", me.stroke.width);
        n.setAttribute("strokeColor", me.stroke.color);
        n.setAttribute("visibility", (me.visible ? 1 : 0));
        n.setAttribute("xLeft", me.parent.div.coords.x);
        n.setAttribute("yTop", me.parent.div.coords.y);
        return;
    };

    this.run = function() {
        me.parent.div.remove();
        var d = me.parent.div.get();

        if (!me.initialized) {
            me.opacity = me.parent.get.int("opacity", me.parent.showState, 100);
            me.fillColor = me.parent.get.string("fillColor", me.parent.showState, "LIME");
            me.height = me.parent.get.int("height", me.parent.showState, 1);
            me.width = me.parent.get.int("width", me.parent.showState, 1);
            me.stroke = { color: me.parent.get.string("strokeColor", me.parent.showState, "BLACK"), width: me.parent.get.int("strokeWidth", me.parent.showState, 2) };
            me.title = me.parent.get.string("description", me.parent.showState, "");
            me.visible = (me.parent.get.int("visibility", me.parent.showState, 1) ? true : false);

            me.lockRatio = false;
            me.ratio = null;
            me.initialized = true;
        }


        d.title = me.title;
        var j = new jsGraphics(d);


        if (!me.visible) {
            d.style.opacity = .3;
            d.style.filter = "alpha(opacity=30);";
            d.style.backgroundColor = "white";
            d.style.visibility = "visible";
            d.style.height = me.height + "px";
            d.style.width = me.width + "px";
            d.style.border = "2px dotted black";
            d.style.color = "blue";
            return;
        }

        me.getRatio();
        me.lockRatio = (me.parent.get.int("lockRatio", me.parent.showState, 1) ? true : false);

        //Set Opacity
        j.setOpacity(me.opacity);

        //Set fill color
        j.setColor(me.fillColor);

        //fill backgound
        j.fillRect(1, 1, me.width, me.height);

        //Do the stroke
        if ((me.stroke.color.length) && me.stroke.width) {
            j.setColor(me.stroke.color);
            j.setStroke(me.stroke.width);
            j.drawRect(1, 1, me.width - me.stroke.width, me.height - me.stroke.width);
        }


        j.paint();
        j = null;
        return;
    };
    this.setWidth = function(w, flag) {
        if (!w) { return; }
        if (w < 0) { return; }
        me.width = w;
        if (!flag) {
            me.set.height(parseInt(w * me.getRatio()), true);
        }
        return;
    };
    this.setHeight = function(h, flag) {
        if (!h) { return; }
        if (h < 0) { return; }
        me.height = h;
        if (!flag) {
            me.set.width(parseInt(h / me.getRatio()), true);
        }
        return;
    };
    this.set = { height: me.setHeight, width: me.setWidth };
}



function drawEllipse(p) {
    var me = this;
    this.parent = p;
    this.initialized = false;

    this.opacity;
    this.fillColor;
    this.height;
    this.width;
    this.stroke;
    this.visible;
    this.lockRatio;
    this.ratio;

    this.getRatio = function() {
        if (me.lockRatio) { return (me.ratio); }
        me.ratio = parseFloat(me.height / me.width);
        return (me.ratio);
    };

    this.updateXML = function() {
        var n = me.parent.node;

        n.setAttribute("opacity", me.opacity);
        n.setAttribute("fillColor", me.fillColor);
        n.setAttribute("height", me.height);
        n.setAttribute("width", me.width);
        n.setAttribute("strokeWidth", me.stroke.width);
        n.setAttribute("strokeColor", me.stroke.color);
        n.setAttribute("visibility", (me.visible ? 1 : 0));
        n.setAttribute("xLeft", me.parent.div.coords.x);
        n.setAttribute("yTop", me.parent.div.coords.y);
        return;
    };

    this.run = function() {
        me.parent.div.remove();
        var j = new jsGraphics(me.parent.div.get());

        if (!me.initialized) {
            me.opacity = me.parent.get.int("opacity", me.parent.showState, 100);
            me.fillColor = me.parent.get.string("fillColor", me.parent.showState, "LIME");
            me.height = me.parent.get.int("height", me.parent.showState, 1);
            me.width = me.parent.get.int("width", me.parent.showState, 1);
            me.stroke = { color: me.parent.get.string("strokeColor", me.parent.showState, "BLACK"), width: me.parent.get.int("strokeWidth", me.parent.showState, 2) };
            me.visible = (me.parent.get.int("visibility", me.parent.showState, 1) ? true : false);

            me.lockRatio = false;
            me.ratio = null;
            me.getRatio();
            me.lockRatio = (me.parent.get.int("lockRatio", me.parent.showState, 1) ? true : false);
            me.initialized = true;
        }



        if (!me.visible) {
            //Set Opacity
            j.setOpacity(30);

            //Set fill color
            j.setColor("white");

            //fill backgound
            j.fillEllipse(1, 1, me.width, me.height);

            //Do the stroke
            j.setColor("black");
            j.setStroke(Stroke.DOTTED);
            j.drawEllipse(1, 1, me.width - 2, me.height - 2);
        }
        else {
            //Set Opacity
            j.setOpacity(me.opacity);

            //Set fill color
            j.setColor(me.fillColor);

            //fill backgound
            j.fillEllipse(1, 1, me.width, me.height);

            //Do the stroke
            if ((me.stroke.color.length) && me.stroke.width) {
                j.setColor(me.stroke.color);
                j.setStroke(me.stroke.width);
                j.drawEllipse(1, 1, me.width - me.stroke.width, me.height - me.stroke.width);
            }
        }
        j.paint();
        j = null;
        return;
    };
    this.setWidth = function(w, flag) {
        if (!w) { return; }
        if (w < 0) { return; }
        me.width = w;
        if (!flag) {
            me.set.height(parseInt(w * me.getRatio()), true);
        }
        return;
    };
    this.setHeight = function(h, flag) {
        if (!h) { return; }
        if (h < 0) { return; }
        me.height = h;
        if (!flag) {
            me.set.width(parseInt(h / me.getRatio()), true);
        }
        return;
    };
    this.set = { height: me.setHeight, width: me.setWidth };
}


function drawLine(p) {
    var me = this;
    this.parent = p;
    this.initialized = false;

    //height and width added to support showing line selected
    this.height = null;
    this.width = null;

    this.opacity; //= me.parent.get.int("opacity", me.parent.showState, 100);
    this.fillColor; // = me.parent.get.string("fillColor", me.parent.showState, "BLACK");
    this.x1; // = me.parent.get.int("x1", me.parent.showState, 1);
    this.y1; // = me.parent.get.int("y1", me.parent.showState, 1);
    this.x2; // = me.parent.get.int("x2", me.parent.showState, 1);
    this.y2; // = me.parent.get.int("y2", me.parent.showState, 1);
    this.visible; // = (me.parent.get.int("visibility", me.parent.showState, 1) ? true : false);
    this.dashed; // = (me.parent.get.int("lineDashed", me.parent.showState, 0) ? true : false);

    this.lineEnds;

    this.stroke; // = {color:me.parent.get.string("strokeColor", me.parent.showState, "BLACK"),width:me.parent.get.int("strokeWidth", me.parent.showState, 2)};


    this.updateXML = function() {
        var n = me.parent.node;

        n.setAttribute("opacity", me.opacity);
        n.setAttribute("x1", me.x1);
        n.setAttribute("y1", me.y1);
        n.setAttribute("x2", me.x2);
        n.setAttribute("y2", me.y2);
        n.setAttribute("strokeWidth", me.stroke.width);
        n.setAttribute("strokeColor", me.stroke.color);
        n.setAttribute("visibility", (me.visible ? 1 : 0));
        n.setAttribute("xLeft", me.parent.div.coords.x);
        n.setAttribute("yTop", me.parent.div.coords.y);
        return;
    };

    this.run = function() {
        me.parent.div.remove();
        var div = me.parent.div.get();
        var j = new jsGraphics(div);

        if (!me.initialized) {
            me.opacity = me.parent.get.int("opacity", me.parent.showState, 100);
            me.fillColor = me.parent.get.string("fillColor", me.parent.showState, "BLACK");
            me.x1 = me.parent.get.int("x1", me.parent.showState, 1);
            me.y1 = me.parent.get.int("y1", me.parent.showState, 1);
            me.x2 = me.parent.get.int("x2", me.parent.showState, 1);
            me.y2 = me.parent.get.int("y2", me.parent.showState, 1);
            me.visible = (me.parent.get.int("visibility", me.parent.showState, 1) ? true : false);
            me.dashed = (me.parent.get.int("lineDashed", me.parent.showState, 0) ? true : false);
            me.stroke = { color: me.parent.get.string("strokeColor", me.parent.showState, "BLACK"), width: me.parent.get.int("strokeWidth", me.parent.showState, 2) };

            me.lineEnds = { start: me.parent.get.int("lineStart", me.parent.showState, 0), end: me.parent.get.int("lineEnd", me.parent.showState, 0) };
            me.initialized = true;
        }


        if (!me.visible) {
            //Set Opacity
            j.setOpacity(30);

            //Do the stroke
            j.setColor("black");
            j.setStroke(Stroke.DOTTED);
            j.drawLine(me.x1, me.y1, me.x2, me.y2);
        }
        else {
            //Set Opacity
            j.setOpacity(me.opacity);

            //Set fill color
            // j.setColor(me.fillColor);

            j.setColor(me.stroke.color);
            j.setStroke(me.stroke.width);

            if (me.dashed) {
                j.setStroke(Stroke.DOTTED);
            }

            j.drawLine(me.x1, me.y1, me.x2, me.y2, me.stroke.width);
        }

        j.paint();
        j = null;

        me.height = Math.abs(me.y1 - me.y2) + parseInt(me.stroke.width / 2);
        if (me.height < me.stroke.width) {
            me.height = me.stroke.width;
        }
        me.width = Math.abs(me.x1 - me.x2) + parseInt(me.stroke.width / 2);
        if (me.width < me.stroke.width) {
            me.width = me.stroke.width;
        }

        var endSize = parseInt(me.stroke.width * 4);

        if (me.lineEnds.start) {
            var img = new Image();
            img.src = strIconPath + "lineEndCircleBlack.gif";
            img.id = me.id + "_lineStart";
            div.appendChild(img);

            switch (browser.type) {
                case MSIE:
                    img.height = endSize;
                    img.width = endSize;
                    break;

                case FOX:
                case SAFARI:
                case OPERA:
                case BLACKBERRY:
                case CHROME:
                case ANDROID:
                    img.style.height = endSize + "px";
                    img.style.width = endSize + "px";
                    break;
            }
            img.style.position = "absolute";
            img.style.left = me.x1 - parseInt(endSize / 2) + parseInt(me.stroke.width / 2) + "px";
            img.style.top = me.y1 - parseInt(endSize / 2) + "px";

        }
        if (me.lineEnds.end) {
            var img = new Image();
            img.src = strIconPath + "lineEndCircleBlack.gif";
            img.id = me.id + "_lineEnd";
            div.appendChild(img);

            switch (browser.type) {
                case MSIE:
                    img.height = endSize;
                    img.width = endSize;
                    break;

                case FOX:
                case SAFARI:
                case OPERA:
                case BLACKBERRY:
                case CHROME:
                case ANDROID:
                    img.style.height = endSize + "px";
                    img.style.width = endSize + "px";
                    break;
            }
            img.style.position = "absolute";
            img.style.left = (me.x2 - parseInt(endSize / 2) + parseInt(me.stroke.width / 2)) + "px";
            img.style.top = (me.y2 - parseInt(endSize / 2)) + "px";
        }

        return;
    };

    this.slope = function() {
        //window.status = (me.y2-me.y1)/(me.x2-me.x1);
        return;
    };

    this.toggleLineEnd = function(action) {
        if (action == TRACK_ACTION_LINE_START) {
            me.lineEnds.start = (me.lineEnds.start > 0 ? 0 : 1);
            me.parent.saveInt("lineStart", me.lineEnds.start);
        }
        if (action == TRACK_ACTION_LINE_END) {
            me.lineEnds.end = (me.lineEnds.end > 0 ? 0 : 1);
            me.parent.saveInt("lineEnd", me.lineEnds.end);
        }
        return;
    };
}


function drawTextLabel(p) {
    var me = this;
    this.parent = p;
    this.oText = null;
    this.initialized = false;

    //These are here to make img compatable with other shapes
    this.height;

    this.isAnalog = false;

    this.type;
    this.precision;
    this.labelValue;
    this.title;
    this.width;
    this.intAlignment;
    this.visible;
    this.fontFamily;
    this.fontColor;
    this.fontSize;
    this.fontWeight;
    this.fillColor;
    this.strokeWidth;
    this.scaleFactor;

    this.font;



    this.updateXML = function() {
        var n = me.parent.node;

        n.setAttribute("precision", me.precision);
        n.setAttribute("labelValue", me.labelValue);
        n.setAttribute("description", me.title);
        n.setAttribute("width", me.width);

        n.setAttribute("alignment", "2");
        n.setAttribute("alignmentFalse", "2");

        n.setAttribute("fontFamily", "Arial");
        n.setAttribute("fontSize", "10");
        n.setAttribute("fontWeight", me.font.weight);
        n.setAttribute("fillColor", "none");

        n.setAttribute("fontFamilyOff", "Arial");
        n.setAttribute("fontSizeOff", "10");
        n.setAttribute("fontWeightOff", me.font.weight);
        n.setAttribute("fillColorOff", "none");

        n.setAttribute("visibility", (me.visible ? 1 : 0));
        n.setAttribute("xLeft", me.parent.div.coords.x);
        n.setAttribute("yTop", me.parent.div.coords.y);

        return;
    };


    this.run = function() {
        me.parent.div.remove();
        var div = me.parent.div.get();

        if (!me.initialized) {
            if (me.isAnalog) {
                me.parent.showState = true;
            }
            me.type = me.parent.get.int("objectTypeID", me.parent.showState, 2);
            me.precision = me.parent.get.int("precision", me.parent.showState, 1);
            me.labelValue = me.parent.get.string("labelValue", me.parent.showState, "[LABEL]");
            me.title = me.parent.get.string("description", me.parent.showState, "");
            me.width = me.parent.get.int("width", me.parent.showState, null);

            me.intAlignment = me.parent.get.int("alignment", me.parent.showState, 2);
            me.visible = (me.parent.get.int("visibility", me.parent.showState, 1) ? true : false);


            me.fontFamily = me.parent.get.string("fontFamily", me.parent.showState, "Arial");
            me.fontColor = me.parent.get.string("fontColor", me.parent.showState, "BLACK");
            me.fontSize = me.parent.get.int("fontSize", me.parent.showState, 10);
            me.fontWeight = me.parent.get.int("fontWeight", me.parent.showState, 0);
            me.font = { family: me.fontFamily, color: me.fontColor, size: me.fontSize, weight: me.fontWeight };

            me.fillColor = me.parent.get.string("fillColor", me.parent.showState, "NONE");
            me.strokeWidth = me.parent.get.int("strokeWidth", me.parent.showState, 0);
            me.scaleFactor = me.parent.get.float("scale", me.parent.showState, 1);
            me.initialized = true;
        }


        me.oText = document.createElement("div");   //Create div tag for text
        div.appendChild(me.oText);                //Append text div to main div

        div.style.clear = "both";
        me.oText.style.clear = "both";
        //div.style.border = "1px black solid";

        if (me.strokeWidth) {
            me.oText.style.border = me.strokeWidth + "px BLACK solid";
        }

        if (me.fillColor != "NONE") {
            me.oText.style.background = me.fillColor;
        }


        if (me.type == OBJ_TYPE_LABEL) {
            me.oText.innerHTML = me.labelValue;
        }

        else if ((!readOnly) || (isNaN(parseInt(me.parent.value)))) {
            if (!readOnly) {
                div.style.border = "1px black solid";
                div.style.background = "white";
            }
            var s = "##";
            if ((me.precision > 0) && (me.precision != 255)) {
                s += ".";
                for (var c = 0; c < me.precision; c++) {
                    s += "#";
                }
            }
            me.oText.innerHTML += s;
            me.oText.title = me.title;
        }
        else if (me.type == OBJ_TYPE_DATA_VALUE) {
            switch (me.precision) {
                case 255:
                    me.oText.innerHTML = me.parent.value;
                    break;

                case 0:
                    var newVal = me.parent.value; // * me.scaleFactor;
                    me.oText.innerHTML = Math.round(newVal);
                    break;

                default:

                    if (!me.parent.value) {
                        me.oText.innerHTML = Math.round(me.parent.value);
                        break;
                    }

                    var mult = 1;
                    for (i = 0; i < me.precision; i++) {
                        mult *= 10;
                    }
                    var newVal = me.parent.value; // * me.scaleFactor;

                    var newVal = (parseInt(parseFloat(newVal) * mult) / mult);
                    me.oText.innerHTML = newVal;

                    if (parseInt(newVal) == newVal) {
                        me.oText.innerHTML += ".";
                        for (i = 0; i < me.precision; i++) {
                            me.oText.innerHTML += "0";
                        }
                    }
                    break;

            }
        }


        me.oText.style.fontFamily = me.font.family;
        me.oText.style.fontWeight = (me.font.weight ? "700" : "400");
        me.oText.style.color = me.font.color;
        me.oText.style.fontSize = me.font.size + "px";
        me.oText.style.left = "0px";
        me.oText.style.top = "0px";

        me.oText.style.whiteSpace = "nowrap";
        me.oText.style.position = "absolute";

        if ((!me.visible) && (!readOnly)) {
            div.style.opacity = .3;
            div.style.filter = "alpha(opacity=30);";
            div.style.backgroundColor = "white";
            div.style.visibility = "visible";
            div.style.border = "2px dotted black";
            div.style.color = "blue";
        }
        else if (!me.visible) {
            div.style.visibility = "hidden";
        }

        var sz = me.getComputedSize(me.oText.innerHTML);

        me.oText.style.width = sz.width + "px";

        if (me.parent.type == OBJ_TYPE_LABEL) {
            me.width = me.oText.offsetWidth;
            me.width = sz.width;
            me.oText.style.width = me.width + "px";
        }
        else if (!me.width) {
            me.width = sz.width;
        }


        me.height = sz.height;

        me.height += (!me.strokeWidth ? 0 : (me.strokeWidth * 2));
        me.width += (!me.strokeWidth ? 0 : (me.strokeWidth * 2));
        div.style.height = me.height + "px";
        div.style.width = me.width + "px";

        var x = parseInt(div.style.left);
        var y = parseInt(div.style.top);


        switch (me.intAlignment) {
            default:
            case 0: //Default
                div.style.textAlign = "Left";
                break;

            case 1:
                //div.style.textAlign = "Center";
                me.oText.style.left = parseInt(me.width / 2 - sz.width / 2) + "px";
                break;

            case 2:
                //div.style.textAlign = "Right";
                me.oText.style.left = (parseInt(me.width - parseInt(me.oText.style.width))) + "px";
                //window.status = ("oTLeft:" + me.oText.style.left + ",w:" + me.width + ",sz:" + sz.width + ",dW:" + div.style.width);
                break;
        }
        return;
    };

    this.getComputedSize = function(strText) {
        var s = document.createElement("span");   //Create temp span tag
        s.innerHTML = strText;
        //s.style.left = "-10000px";
        //s.style.top = "-10000px";
        s.style.left = "300px";
        s.style.top = "300px";
        s.style.fontFamily = me.font.family;
        s.style.fontWeight = (me.font.weight ? "700" : "400");
        s.style.fontSize = me.font.size + "px";

        var hd = browser.html.get("hiddenBox");

        hd.appendChild(s);
        h = s.offsetHeight;
        w = s.offsetWidth;
        hd.removeChild(s);


        return { height: h, width: w };
    };
}

function clsEditLabel(p) {
    var me = this;
    this.parent = p;
    this.id = null;
    this.oTextBox = null;
    this.running = false;

    this.open = function() {
        var div = me.parent.div.get();
        var w = parseInt(div.style.width);
        if (w < 50) { w = 50; }

        me.parent.div.remove();
        var div = me.parent.div.get();

        me.oTextBox = document.createElement("Input");

        me.id = me.parent.id + "_textBox";
        me.oTextBox.id = me.id;
        me.oTextBox.type = "text";
        me.oTextBox.style.width = w + "px";
        me.oTextBox.value = me.parent.draw.labelValue;
        div.appendChild(me.oTextBox);
        me.oTextBox.focus();
        me.oTextBox.select();
        me.parent.div.clearEvents();
        me.running = true;
        browser.keys.dataEntryMode = true;
        me.oTextBox.onKeyDown = browser.keys.onKeyDown;
        return;
    };

    this.save = function() {
        browser.keys.dataEntryMode = false;
        if (!me.oTextBox) { return; }
        me.parent.saveString("labelValue", me.oTextBox.value);
        me.oTextBox = null;
        me.running = false;
        return (browser.block(event));
    };
}

function drawImage(p) {
    var me = this;
    this.parent = p;
    this.img = null;
    this.initialized = false;
    this.firstTime = true;

    this.counter = 0;
    this.refreshGraphTimer = null;

    //These are here to make img compatable with other shapes
    this.height;
    this.width;

    this.opacity;
    this.src;
    this.percentage;
    this.size;
    this.visible;
    this.coords;
    this.originalSize;
    this.lockRatio;
    this.ratio;
    this.strURL;




    this.getRatio = function() {
        if (me.lockRatio) { return (me.ratio); }
        var h = me.get.height();
        var w = me.get.width();

        if ((!h) || (!w)) {
            h = me.size.height;
            w = me.size.width;
        }
        me.ratio = parseFloat(h / w);
        return (me.ratio);
    };

    this.updateXML = function() {
        var n = me.parent.node;
        n.setAttribute("opacity", me.opacity);
        //    n.setAttribute("imageURL", me.src);
        n.setAttribute("percentage", me.percentage);
        n.setAttribute("imageWidth", me.get.width());
        n.setAttribute("imageHeight", me.get.height());
        n.setAttribute("zIndex", me.parent.div.zIndex);
        n.setAttribute("position", (me.parent.div.position == "absolute" ? 0 : 1));
        n.setAttribute("visibility", (me.visible ? 1 : 0));
        n.setAttribute("xLeft", me.parent.div.coords.x);
        n.setAttribute("yTop", me.parent.div.coords.y);
        if (me.parent.shape == OBJ_SHAPE_GRAPH) {
            n.setAttribute("objectTypeID", OBJ_TYPE_CHART);
        }
        if (me.parent.shape == OBJ_SHAPE_GAUGE) {
            n.setAttribute("objectTypeID", OBJ_TYPE_GAUGE);
        }
        return;
    };

    this.run = function() {
        me.parent.div.remove();
        var div = me.parent.div.get();

        if (readOnly) {
            div.style.left = (parseInt(div.style.left) - 4) + "px";
            me.firstTime = false;
        }

        if (!me.initialized) {
            me.opacity = me.parent.get.int("opacity", me.parent.showState, 100);
            me.src = me.parent.get.string("imageURL", me.parent.showState, "");
            me.percentage = (me.parent.get.int("imagePercent", me.parent.showState, 100) / 100);
            me.size = { height: me.parent.get.int("imageHeight", me.parent.showState, 0), width: me.parent.get.int("imageWidth", me.parent.showState, 0) };
            me.visible = (me.parent.get.int("visibility", me.parent.showState, 1) ? true : false);
            me.coords = { x: parseInt(div.style.left), y: parseInt(div.style.top) };
            me.originalSize = null;

            me.lockRatio = true;
            me.ratio = null;
            me.initialized = true;
        }



        if (readOnly) {

            if (me.refreshGraphTimer) {
                clearTimeout(me.refreshGraphTimer);
            }

            me.refreshGraphTimer = setTimeout(me.run, 60000);
        }

        me.getRatio();
        me.lockRatio = (me.parent.get.int("lockRatio", me.parent.showState, 1) ? true : false);

        me.img = new Image();

        if ((me.parent.shape == OBJ_SHAPE_GRAPH) || (me.parent.shape == OBJ_SHAPE_GAUGE)) {
            if (me.size.height <= 1) {
                me.size.height = 28;
            }
            if (me.size.width <= 1) {
                me.size.width = 28;
            }

            switch (me.parent.shape) {
                case OBJ_SHAPE_GRAPH:
                    if (maid == -2) {
                        me.img.src = "../images/graph.gif";
                    }
                    else {
                        me.img.src = strGraphPath + me.parent.id + "_" + timeZone + "_" + enableDST + "_" + maid + "_" + overrideDate + ".jpg?sid=" + parseInt(Math.random() * 1000000);
                    }
                    break;

                case OBJ_SHAPE_GAUGE:
                    if (maid == -2) {
                        me.img.src = "../images/gauge.gif";
                    }
                    else {
                        me.img.src = strGraphPath + me.parent.id + ".jpg?sid=" + parseInt(Math.random() * 1000000);
                    }
                    break;
            }
        }
        else {
            me.img.src = strImagePath + me.src;
        }

        div.appendChild(me.img);

        switch (browser.type) {
            case MSIE:
                me.originalSize = { height: me.img.height, width: me.img.width };
                me.img.style.filter = "alpha(opacity=" + me.opacity + ");";

                if (!me.size.width) {
                    me.size.width = me.getWidth();
                }


                if (!me.size.height) {
                    me.size.height = me.getHeight();
                }
                me.set.width(parseInt(me.size.width));
                me.set.height(parseInt(me.size.height));

                div.style.height = me.get.height() + "px";
                div.style.width = me.get.width() + "px";
                if (!me.visible) { me.hide(); }
                break;

            case FOX:
            case SAFARI:
            case OPERA:
            case BLACKBERRY:
            case CHROME:
            case ANDROID:
                //Set Coordinates off page
                div.style.left = -10000 + "px";
                div.style.top = -10000 + "px";
                me.img.style.opacity = (me.opacity / 100);
                me.img.onload = me.fixImageSafariFireFox;
                break;
        }
        return;
    };

    this.hide = function() {
        me.img.style.visibility = "hidden";
        if (readOnly) { return; }
        var div = me.parent.div.get();
        div.style.opacity = .3;
        div.style.filter = "alpha(opacity=30);";
        div.style.backgroundColor = "white";
        div.style.visibility = "visible";
        div.style.border = "2px dotted black";
        div.style.color = "blue";
        return;
    };

    this.fixImageSafariFireFox = function(event) {
        me.originalSize = { height: me.img.height, width: me.img.width };
        me.set.width(parseInt(me.size.width));
        me.set.height(parseInt(me.size.height));
        var div = me.parent.div.get();
        div.style.left = me.coords.x + "px";
        div.style.top = me.coords.y + "px";
        div.style.height = me.height + "px";
        div.style.width = me.width + "px";
        if (!me.visible) { me.hide(); }
        return;
    };

    this.setHeight = function(h, flag) {
        if (!h) { return; }
        if (h <= 0) { return; }
        switch (browser.type) {
            case MSIE:
                me.img.height = h;
                break;

            case FOX:
            case SAFARI:
            case OPERA:
            case BLACKBERRY:
            case CHROME:
            case ANDROID:
                me.img.style.height = h + "px";
                break;
        }
        if (!flag) {
            me.set.width(parseInt(h / me.getRatio()), true);
        }
        me.height = me.get.height();
        me.width = me.get.width();
        return;
    };

    this.setWidth = function(w, flag) {
        if (!w) { return; }
        if (w <= 0) { return; }
        switch (browser.type) {
            case MSIE:
                me.img.width = w;
                break;

            case FOX:
            case SAFARI:
            case OPERA:
            case BLACKBERRY:
            case CHROME:
            case ANDROID:
                me.img.style.width = w + "px";
                break;
        }
        if (!flag) {
            me.set.height(parseInt(w * me.getRatio()), true);
        }
        me.height = me.get.height();
        me.width = me.get.width();
        return;
    };

    this.set = { height: me.setHeight, width: me.setWidth };

    this.getHeight = function(h) {
        if (!me.img) { return; }
        switch (browser.type) {
            case MSIE:
                return (parseInt(me.img.height));
                break;

            case FOX:
            case SAFARI:
            case OPERA:
            case BLACKBERRY:
            case CHROME:
            case ANDROID:
                return (parseInt(me.img.style.height));
                break;
        }
        return (null);
    };

    this.getWidth = function(w) {
        if (!me.img) { return; }
        switch (browser.type) {
            case MSIE:
                return (parseInt(me.img.width));
                break;

            case FOX:
            case SAFARI:
            case OPERA:
            case BLACKBERRY:
            case CHROME:
            case ANDROID:
                return (parseInt(me.img.style.width));
                break;
        }
        return (null);
    };

    this.get = { height: me.getHeight, width: me.getWidth };
}

//----------------------------------------------------------------------------------------------------
//    OTHER MISC OBJECTS
//----------------------------------------------------------------------------------------------------
function clsDiv(p) {
    var me = this;
    this.parent = p;
    this.div = null;
    this.initialized = false;

    this.coords = null;
    this.zIndex = null;
    this.position = null;
    this.visibility = null;

    this.setEvents = function() {
        if (!me.div) { return; }
        me.div.onclick = me.parent.captureEvent;
        me.div.onmousedown = me.parent.captureEvent;
        me.div.onmousemove = me.parent.captureEvent;
        me.div.onmouseout = me.parent.captureEvent;
        me.div.onmouseup = me.parent.captureEvent;
        me.div.ondblclick = me.parent.captureEvent;
        return;
    };

    this.clearEvents = function() {
        if (!me.div) { return; }
        me.div.onclick = null;
        me.div.onmousedown = null;
        me.div.onmousemove = null;
        me.div.onmouseout = null;
        me.div.onmouseup = null;
        me.div.ondblclick = null;
        return;
    };

    this.remove = function() {
        if (me.div) {
            me.div.parentNode.removeChild(me.div);
        }

        if (n = browser.html.get(me.parent.id)) {
            //Node exists so remove it
            n.parentNode.removeChild(n);
        }
        me.div = null;
        me.initialized = false;
        return;
    };

    this.get = function(parentNode) {
        if (me.div) { return (me.div); }

        //setup local get method
        var get = me.parent.get;
        //get the show state
        var state = me.parent.parent.showState;

        if (!me.initialized) {
            me.coords = { x: get.int("xLeft", state, -1000), y: get.int("yTop", state, -1000) };
            me.zIndex = get.int("zIndex", state, 1);
            me.position = (get.int("position", state, 0) == 0 ? "absolute" : "relative");
            me.visibility = (get.int("visibility", state, 1) == 0 ? "hidden" : "visible");

            me.initialized = true;
        }

        //get div template
        var template = browser.html.get("divTemplate");

        //clone template
        me.div = template.cloneNode(true);


        //Set the ID
        me.div.setAttribute("id", me.parent.id);
        me.div.setAttribute("name", me.parent.id);

        //Set style stuff
        me.div.style.height = "1px";
        me.div.style.width = "1px";
        me.div.style.whiteSpace = "nowrap";
        me.div.style.zIndex = me.zIndex;

        me.div.style.position = me.position;

        //Set Coordinates
        me.div.style.left = me.coords.x + "px";
        me.div.style.top = me.coords.y + "px";

        me.div.style.visibility = "visible";
        me.setEvents();

        if (parentNode) {
            parentNode.appendChild(me.div);
        }
        else {
            //Get the overview node
            if (!me.parent.parent.canvas.node) { return; }
            me.parent.parent.canvas.node.appendChild(me.div);
        }
        return (me.div);
    };
}


//---------------------------------------------------------------------------------
function clsGet(n) {
    var me = this;
    this.node = n;

    this.int = function(strAttrib, bState, defaultValue) {
        dataPoint = defaultValue;
        if (!isNaN(parseInt(me.node.getAttribute(strAttrib + (bState ? "" : "Off"))))) {
            dataPoint = parseInt(me.node.getAttribute(strAttrib + (bState ? "" : "Off")));
        }
        else if (!bState) {
            if (!isNaN(parseInt(me.node.getAttribute(strAttrib)))) {
                dataPoint = parseInt(me.node.getAttribute(strAttrib));
            }
        }
        return (dataPoint)
    };

    this.float = function(strAttrib, bState, defaultValue) {
        dataPoint = defaultValue;
        if (!isNaN(parseFloat(me.node.getAttribute(strAttrib + (bState ? "" : "Off"))))) {
            dataPoint = parseFloat(me.node.getAttribute(strAttrib + (bState ? "" : "Off")));
        }
        else if (!bState) {
            if (!isNaN(parseFloat(me.node.getAttribute(strAttrib)))) {
                dataPoint = parseFloat(me.node.getAttribute(strAttrib));
            }
        }
        return (dataPoint)
    };

    this.string = function(strAttrib, bState, defaultValue) {
        dataPoint = defaultValue;
        if (me.node.getAttribute(strAttrib + (bState ? "" : "Off"))) {
            dataPoint = me.node.getAttribute(strAttrib + (bState ? "" : "Off"));
        }
        else if (!bState) {
            if (me.node.getAttribute(strAttrib)) {
                dataPoint = me.node.getAttribute(strAttrib);
            }
        }
        return (dataPoint)
    };
}
function clsSet(n) {
    var me = this;
    this.node = n;

    this.int = function(strAttrib, bState, value) {
        me.node.setAttribute((strAttrib + (bState ? "" : "Off")), value);
    };

    this.string = function(strAttrib, bState, value) {
        me.node.setAttribute((strAttrib + (bState ? "" : "Off")), value);
    };
}
