HumanLayer = function() { }
HumanLayer.ServerHttpName = "webassist.eurobankefg.rs";

HumanLayer.HelpLinkRenderer = function() {

    var onSameDomain = true;
    try {
        var a = top.document.location;
    }
    catch (e) {
        onSameDomain = false;
    }

    var scrollOutFrames = 0;
    var layoutFrameset = onSameDomain
        ? top.document.getElementById("layoutFrameset")
        : null;
    var contentFrame = onSameDomain
        ? parent.document.getElementById("contentFrame")
        : null;
    var inHelpMode = onSameDomain
        ? (/HumanLayer\.FrontEnd\/Content\.htm/.test(parent.location)) && layoutFrameset && contentFrame
        : true; /* todo: make this detection a bit more elaborate */

    this.render = function() {
        if (inHelpMode) {
            if (onSameDomain) {
                document.write("<a href='#' onclick='helpLinkRenderer.onCancel()'>Cancel help</a>");
            }
            else {
                document.write("<a href='#' class='assist con' title='live help active'><span>live help active</span></a>");
            }
        }
        else {
            document.write("<a href='http://" + HumanLayer.ServerHttpName + "/HumanLayer.FrontEnd/ui/index.htm?" + escape(window.top.location) + "' class='assist closed' title='live help' target='_top'><span>live help</span></a>");
        }
    }

    function scrollOut() {
        layoutFrameset.cols = "" + (192 - (scrollOutFrames * scrollOutFrames)) + "px, *";

        if (scrollOutFrames++ != 14) {
            setTimeout(scrollOut, 30);
        }
        else {
            top.document.location = unescape(contentFrame.src.substr(contentFrame.src.indexOf("?") + 1));
        }
    }

    this.onCancel = function() {
        setTimeout(scrollOut, 30);
    }
}

var helpLinkRenderer = new HumanLayer.HelpLinkRenderer();
helpLinkRenderer.render();
