//
//	hide or show a span
//	also support hide_clear whcih empties the contents of the span
//
function _spanSetVisible(span, is_visible) {
    if (is.ie) {
        if (is_visible == 'hide_clear') {
            span.style.visibility = 'hidden';
            span.innerHTML = '';
        } else {
            span.style.visibility = is_visible;
        }
    } else if (is.ns) {
        if (is_visible == 'hide_clear') {
            span.visibility = 'hidden';

            span.document.open();
            span.document.write();
            span.document.close();
        } else {
            span.style.visibility = is_visible;
        }
    }
}

function _spanShow(span) {
    _spanSetVisible(span, 'visible');
}

function _spanHide(span) {
    _spanSetVisible(span, 'hidden');
}

function _spanHideClear(span) {
    _spanSetVisible(span, 'hide_clear');
}

function _spanMove(span, x, y) {
    if (is.ie) {
        span.style.pixelLeft = x;
        span.style.pixelTop = y;
    } else if (is.ns) {
        span.left = x;
        span.top = y;
    }
}

function _spanGetClip(span, which) {
    if (is.ie) {
        var clipv = span.clip.split("rect(")[1].split(")")[0].split("px")

        if (which == "t")
            return Number(clipv[0])

        if (which == "r")
            return Number(clipv[1])

        if (which == "b")
            return Number(clipv[2])

        if (which == "l")
            return Number(clipv[3])

        if (which == "h")
            return Number(clipv[2]) - Number(clipv[0])

        if (which == "w")
            return Number(clipv[3]) - Number(clipv[1])
    } else if (is.ns) {
        if (which == "t")
            return span.clip.top

        if (which == "r")
            return span.clip.right

        if (which == "b")
            return span.clip.bottom

        if (which == "l")
            return span.clip.left

        if (which == "h")
            return span.clip.height

        if (which == "w")
            return span.clip.width
    }
}

function _spanClearClip(span) {
    if (is.ie) {
        span.clip = '';
    } else if (is.ns) {
        span.clip.top = 0;
        span.clip.left = 0;
        span.clip.width = 0;
        span.clip.height = 0;
    }
}

function _spanSetClip(span, t, r, b, l) {
    if (is.ie) {
        span.clip = "rect(" + t + "px " + r + "px " + b + "px " + l + "px)";
    } else if (is.ns) {
        span.clip.top = t;
        span.clip.right = r;
        span.clip.bottom = b;
        span.clip.left = l;
    }
}

function _spanSetClip(span, which, value) {
    if (is.ie) {
        var clipv = span.clip.split("rect(")[1].split(")")[0].split("px");

        var t = Number(clipv[0]);
        var r = Number(clipv[1]);
        var b = Number(clipv[2]);
        var l = Number(clipv[3]);
        var h = Number(clipv[2]) - Number(clipv[0]);
        var w = Number(clipv[3]) - Number(clipv[1]);

        if (which == "t") {
            t = value;
        } else if (which == "r") {
            r = value;
        } else if (which == "b") {
            b = value;
        } else if (which == "l") {
            l = value;
        } else if (which == "w") {
            w = value;
            r = l + w;
        } else if (which == "h") {
            h = value;
            b = t + h;
        }

        _spanSetClip(span, t, r, b, l);
    } else if (is.ns) {
        if (which == "t")
            span.clip.top = value;

        if (which == "r")
            span.clip.right = value;

        if (which == "b")
            span.clip.bottom = value;

        if (which == "l")
            span.clip.left = value;

        if (which == "w")
            span.clip.width = value;

        if (which == "h")
            span.clip.height = value;
    }
}

function _spanSetClipDelta(span, which, delta) {
    var value = _spanSetClip(span, which) + delta;
    _spanSetClip(span, which, value);
}

function _spanClip(span, obj) {
    if (is.ie) {
        span.clip = "rect(" + obj.top + "px " + obj.right + "px " + obj.bottom + "px " + obj.left + "px)"
    } else if (is.ns) {
        span.clip.top = obj.top
        span.clip.left = obj.left
        span.clip.bottom = obj.bottom
        span.clip.right = obj.right
    }
}

// not finished for NS width and height ...
function _spanSetSize(span, x, y, width, height) {
    if (is.ie) {
        span.style.pixelLeft = x;
        span.style.pixelTop = y;
        span.style.pixelWidth = width;
        span.style.pixelHeight = height;
    } else if (is.ns) {
        span.left = x;
        span.top = y;
    //span.clip.width=width;
    //span.clip.height=height;
    }
}