﻿Telligent_Modal = new Object(); Telligent_Modal._variableName = 'Telligent_Modal'; Telligent_Modal.LoadingHtmlUrl = null; Telligent_Modal.WindowCssClasses = new Array(); Telligent_Modal.WindowTitleCssClasses = new Array(); Telligent_Modal.WindowCloseCssClasses = new Array(); Telligent_Modal.WindowContentCssClasses = new Array(); Telligent_Modal.WindowMaskCssClasses = new Array(); Telligent_Modal.WindowFooterCssClasses = new Array(); Telligent_Modal.WindowResizeCssClasses = new Array(); Telligent_Modal.ZIndex = 100; Telligent_Modal._isShown = false; Telligent_Modal._initialized = false; Telligent_Modal._modal = null; Telligent_Modal._modalTitle = null; Telligent_Modal._modalClose = null; Telligent_Modal._modalAnimationMask = null; Telligent_Modal._modalMask = null; Telligent_Modal._modalIframe = null; Telligent_Modal._modalResize = null; Telligent_Modal._modalFooter = null; Telligent_Modal._modalContent = null; Telligent_Modal._animationHandle = null; Telligent_Modal._isOpening = false; Telligent_Modal._checkForScrollResizeHandle = null; Telligent_Modal._lastModalInfo = null; Telligent_Modal._lastWindowInfo = null; Telligent_Modal._isDragging = false; Telligent_Modal._moveModalInfo = null; Telligent_Modal._resizeModalInfo = null; Telligent_Modal._isResizing = false; Telligent_Modal.EnableAutoResizing = true; Telligent_Modal.Configure = function(loadingHtmlUrl, windowCssClasses, windowTitleCssClasses, windowCloseCssClasses, windowContentCssClasses, windowFooterCssClasses, windowResizeCssClasses, windowMaskCssClasses, zIndex, enableAnimation, enableAutoResizing)
{ this.LoadingHtmlUrl = loadingHtmlUrl; this.WindowCssClasses = windowCssClasses; this.WindowTitleCssClasses = windowTitleCssClasses; this.WindowCloseCssClasses = windowCloseCssClasses; this.WindowContentCssClasses = windowContentCssClasses; this.WindowMaskCssClasses = windowMaskCssClasses; this.WindowFooterCssClasses = windowFooterCssClasses; this.WindowResizeCssClasses = windowResizeCssClasses; this.ZIndex = zIndex; this.EnableAnimation = enableAnimation; this.EnableAutoResizing = enableAutoResizing; Telligent_Common.RegisterDisposableControl('Telligent_Modal'); }
Telligent_Modal.IsShown = function()
{ return this._isShown; }
Telligent_Modal.Resize = function(width, height, preventAutomaticResizing) {
    if (this._isShown && !this._isOpening && this._lastModalInfo)
        this.Open(null, width, height, this._lastModalInfo.OnCloseFunction, this._lastModalInfo.X, this._lastModalInfo.Y, true, preventAutomaticResizing ? true : this._lastModalInfo.IsManuallyResized);
}
Telligent_Modal.MoveTo = function(x, y) {
    if (this._isShown && !this._isOpening && this._lastModalInfo)
        this.Open(null, this._lastModalInfo.Width, this._lastModalInfo.Height, this._lastModalInfo.OnCloseFunction, x, y, true, this._lastModalInfo.IsManuallyResized);
}
Telligent_Modal.Open = function(url, width, height, onCloseFunction, x, y, ignoreCloseAndAnimation, isManuallyResized) {
    if (!ignoreCloseAndAnimation && this._isShown)
        this.Close(); else
        Telligent_Common.ShowSelectBoxes(this._modalAnimationMask)
    if (!this._initialized)
        this._initialize(); try
{ this._modalTitle.childNodes[1].innerHTML = this._modalIframe.contentWindow.document.title; }
    catch (err)
{ }
    if (!ignoreCloseAndAnimation)
        this._modalIframe.src = url; try
{ this._modalIframe.contentWindow.opener = window; }
    catch (err)
{ }
    this._modalAnimationMask.style.display = 'none'; this._modalMask.style.display = 'none'; this._lastWindowInfo = Telligent_Common.GetWindowInfo(); this._modalAnimationMask.style.display = 'block'; this._modalAnimationMask.style.position = 'absolute'; this._modalAnimationMask.style.zIndex = this.ZIndex; this._modalAnimationMask.style.display = 'block'; this._modalAnimationMask.style.visibility = 'hidden'; this._modalAnimationMask.style.overflow = 'hidden'; this._modal.style.position = 'absolute'; this._modal.style.display = 'block'; this._modal.style.visibility = 'hidden'; this._modal.style.left = '0px'; this._modal.style.top = '0px'; this._modalMask.style.position = 'absolute'; this._modalMask.style.display = 'block'; this._modalMask.style.zIndex = this.ZIndex; this._modalMask.style.visibility = 'visible'; var modalContentOffset = Telligent_Common.GetStyleOffset(this._modalContent); var widthOffset = (this._modal.offsetWidth - this._modalContent.offsetWidth) - modalContentOffset.Width; var heightOffset = (this._modal.offsetHeight - this._modalContent.offsetHeight) - modalContentOffset.Height; if (width + widthOffset > this._lastWindowInfo.Width)
        width = this._lastWindowInfo.Width - widthOffset; this._modalAnimationMask.style.width = width + 'px'; this._modalContent.style.width = width + 'px'; if (height + heightOffset > this._lastWindowInfo.Height)
        height = this._lastWindowInfo.Height - heightOffset; if (width < this._modalResize.offsetWidth * 2)
        width = this._modalResize.offsetWidth * 2; if (width < this._modalClose.offsetWidth * 2)
        width = this._modalClose.offsetWidth * 2; if (height < this._modalTitle.offsetHeight + this._modalFooter.offsetHeight)
        height = this._modalTitle.offsetHeight + this._modalFooter.offsetHeight - heightOffset; this._modalIframe.style.height = height + 'px'; this._modalIframe.style.width = width + 'px'; this._modalContent.style.height = height + 'px'; this._modalContent.style.width = width + 'px'; this._modalAnimationMask.style.width = this._modal.offsetWidth + 'px'; this._modalAnimationMask.style.height = this._modal.offsetHeight + 'px'; this._modalMask.style.left = '0px'; this._modalMask.style.top = '0px'; this._modalMask.style.width = this._lastWindowInfo.ContentWidth + 'px'; this._modalMask.style.height = this._lastWindowInfo.ContentHeight + 'px'; this._lastWindowInfo = Telligent_Common.GetWindowInfo(); var panelWidth = this._modal.offsetWidth; var panelHeight = this._modal.offsetHeight; var animatePropertyName, animateTargetValue, animateNextValue; if (typeof (x) == 'undefined' || isNaN(parseInt(x, 10)))
        x = ((this._lastWindowInfo.Width - panelWidth) / 2) + this._lastWindowInfo.ScrollX; if (x + panelWidth > this._lastWindowInfo.Width + this._lastWindowInfo.ScrollX)
        x = this._lastWindowInfo.Width + this._lastWindowInfo.ScrollX - panelWidth; if (x < this._lastWindowInfo.ScrollX)
        x = this._lastWindowInfo.ScrollX; if (typeof (y) == 'undefined' || isNaN(parseInt(y, 10)))
        y = ((this._lastWindowInfo.Height - panelHeight) / 2) + this._lastWindowInfo.ScrollY; if (y + panelHeight > this._lastWindowInfo.Height + this._lastWindowInfo.ScrollY)
        y = this._lastWindowInfo.Height + this._lastWindowInfo.ScrollY - panelHeight; if (y < this._lastWindowInfo.ScrollY)
        y = this._lastWindowInfo.ScrollY; this._modalAnimationMask.style.left = x + 'px'; this._modalAnimationMask.style.top = y + 'px'; animateTargetValue = 0; animateNextValue = -panelHeight; this._modal.style.visibility = 'visible'; this._modalAnimationMask.style.visibility = 'visible'; this._modalAnimationMask.style.overflow = 'hidden'; Telligent_Common.HideSelectBoxes(this._modalAnimationMask, true); this._modalIframe.style.visibility = 'visible'; this._isOpening = true; if (!this.EnableAnimation || ignoreCloseAndAnimation)
        this._animationHandle = window.setTimeout(new Function(this._variableName + '._animate(0,0,0,0);'), 9); else
    { this._modalIframe.style.display = 'none'; this._animate(0, -panelHeight, panelHeight / 3, .67); }
    this._lastModalInfo = { Url: this._modalIframe.src, OnCloseFunction: onCloseFunction, X: x, Y: y, Width: parseInt(width, 10), Height: parseInt(height, 10), IsManuallyResized: isManuallyResized }; this._isShown = true;
}
Telligent_Modal._checkForScrollResize = function() {
    if (this._checkForScrollResizeHandle)
        window.clearTimeout(this._checkForScrollResizeHandle); if (this._isShown && !this._isOpening && this._lastWindowInfo) {
        try
{ this._modalTitle.childNodes[1].innerHTML = this._modalIframe.contentWindow.document.title; }
        catch (err)
{ }
        var windowInfo = Telligent_Common.GetWindowInfo(); if (windowInfo.ScrollX != this._lastWindowInfo.ScrollX || windowInfo.ScrollY != this._lastWindowInfo.ScrollY || windowInfo.Width != this._lastWindowInfo.Width || windowInfo.Height != this._lastWindowInfo.Height)
        { this.Resize(this._lastModalInfo.Width, this._lastModalInfo.Height, false); return; }
        if (this.EnableAutoResizing && !this._isDragging && !this._isResizing) {
            try {
                var iFrameDocument = this._modalIframe.contentWindow.document; if (!iFrameDocument.readyState || iFrameDocument.readyState == 'complete') {
                    var currentHeight = this._lastModalInfo.Height; if (Telligent_Common.IsIE())
                        currentHeight = iFrameDocument.body.scrollHeight + 32; else if (Telligent_Common.IsSafari())
                        currentHeight = iFrameDocument.body.offsetHeight + 32; else
                        currentHeight = iFrameDocument.documentElement.offsetHeight; var modalContentOffset = Telligent_Common.GetStyleOffset(this._modalContent); var heightOffset = (this._modal.offsetHeight - this._modalContent.offsetHeight) - modalContentOffset.Height; if (currentHeight > windowInfo.Height - heightOffset)
                        currentHeight = windowInfo.Height - heightOffset; if (currentHeight != this._lastModalInfo.Height && (currentHeight > this._lastModalInfo.Height || (this._lastModalInfo.Height - currentHeight > 64 && currentHeight > 32)) && (!this._lastModalInfo.IsManuallyResized || currentHeight > this._lastModalInfo.Height))
                    { this.Resize(this._lastModalInfo.Width, currentHeight, false); return; }
                }
            }
            catch (e) { }
        }
        this._checkForScrollResizeHandle = window.setTimeout(new Function('window.' + this._variableName + '._checkForScrollResize();'), 249);
    }
}
Telligent_Modal.Close = function(returnValue) {
    if (this._isShown) {
        if (!this._initialized)
            this._initialize(); this._modal.style.position = 'absolute'; this._modal.style.display = 'none'; this._modalAnimationMask.style.position = 'absolute'; this._modalAnimationMask.style.display = 'none'; this._modalMask.style.position = 'absolute'; this._modalMask.style.display = 'none'; this._modalIframe.src = this.LoadingHtmlUrl; var onCloseFunction = this._lastModalInfo.OnCloseFunction; this._isShown = false; this._lastModalInfo = null; this._windowInfo = null; Telligent_Common.ShowSelectBoxes(this._modalAnimationMask)
        if (onCloseFunction)
            onCloseFunction(returnValue); this.Dispose();
    }
}
Telligent_Modal.Refresh = function() {
    if (this._animationHandle)
        window.clearTimeout(this._animationHandle); this.Dispose(); if (this._isShown && this._lastModalInfo)
        this.Resize(this._lastModalInfo.Width, this._lastModalInfo.Height, false);
}
Telligent_Modal._initialize = function() {
    this._modalMask = document.createElement('div'); this._modalMask.style.width = 'auto'; this._modalMask.style.height = 'auto'; this._modalMask.style.position = 'absolute'; this._modalMask.style.display = 'none'; this._modalMask.dispose = new Function('Telligent_Modal.Dispose();'); var mm = this._modalMask; if (this.WindowMaskCssClasses.length > 0) {
        mm.className = this.WindowMaskCssClasses[0]; for (var i = 1; i < this.WindowMaskCssClasses.length; i++)
        { mm.appendChild(document.createElement('div')); mm = mm.childNodes[0]; mm.className = this.WindowMaskCssClasses[i]; mm.style.width = 'auto'; mm.style.height = 'auto'; }
    }
    document.body.appendChild(this._modalMask); this._modalAnimationMask = document.createElement('div'); this._modalAnimationMask.style.position = 'absolute'; this._modalAnimationMask.style.display = 'none'; this._modalAnimationMask.style.overflow = 'hidden'; this._modal = document.createElement('div'); this._modal.style.width = 'auto'; this._modal.style.height = 'auto'; this._modal.style.position = 'absolute'; this._modal.style.display = 'none'; var m = this._modal; if (this.WindowCssClasses.length > 0) {
        m.className = this.WindowCssClasses[0]; for (var i = 1; i < this.WindowCssClasses.length; i++)
        { m.appendChild(document.createElement('div')); m = m.childNodes[0]; m.className = this.WindowCssClasses[i]; m.style.width = 'auto'; m.style.height = 'auto'; }
    }
    this._modalTitle = document.createElement('div'); m.appendChild(this._modalTitle); if (this.WindowTitleCssClasses.length > 0) {
        this._modalTitle.className = this.WindowTitleCssClasses[0]; for (var i = 1; i < this.WindowTitleCssClasses.length; i++)
        { this._modalTitle.appendChild(document.createElement('div')); this._modalTitle = this._modalTitle.childNodes[0]; this._modalTitle.className = this.WindowTitleCssClasses[i]; }
    }
    this._modalTitle.onmousedown = new Function('event', 'window.' + this._variableName + '._startDrag(event); return false;'); this._modalClose = document.createElement('div'); this._modalTitle.appendChild(this._modalClose); var mc = this._modalClose; if (this.WindowCloseCssClasses.length > 0) {
        mc.className = this.WindowCloseCssClasses[0]; for (var i = 1; i < this.WindowCloseCssClasses.length; i++)
        { mc.appendChild(document.createElement('div')); mc = mc.childNodes[0]; mc.className = this.WindowCloseCssClasses[i]; }
    }
    this._modalClose.onclick = new Function('window.' + this._variableName + '.Close();'); this._modalTitle.appendChild(document.createElement('span')); var e = document.createElement('div'); e.style.clear = 'both'; this._modalTitle.appendChild(e); this._modalContent = document.createElement('div'); m.appendChild(this._modalContent); if (this.WindowContentCssClasses.length > 0) {
        this._modalContent.className = this.WindowContentCssClasses[0]; for (var i = 1; i < this.WindowContentCssClasses.length; i++)
        { this._modalContent.appendChild(document.createElement('div')); this._modalContent = this._modalContent.childNodes[0]; this._modalContent.className = this.WindowContentCssClasses[i]; }
    }
    this._modalIframe = document.createElement('iframe'); this._modalIframe.src = this.LoadingHtmlUrl; this._modalIframe.width = '100%'; this._modalIframe.border = '0'; this._modalIframe.frameBorder = '0'; this._modalIframe.style.borderLeftWidth = '0px'; this._modalIframe.style.borderRightWidth = '0px'; this._modalIframe.style.borderTopWidth = '0px'; this._modalIframe.style.borderBottomWidth = '0px'; this._modalContent.appendChild(this._modalIframe); this._modalFooter = document.createElement('div'); m.appendChild(this._modalFooter); var mf = this._modalFooter; if (this.WindowFooterCssClasses.length > 0) {
        mf.className = this.WindowFooterCssClasses[0]; for (var i = 1; i < this.WindowFooterCssClasses.length; i++)
        { mf.appendChild(document.createElement('div')); mf = mf.childNodes[0]; mf.className = this.WindowFooterCssClasses[i]; }
    }
    this._modalResize = document.createElement('div'); mf.appendChild(this._modalResize); var e = document.createElement('div'); e.style.clear = 'both'; mf.appendChild(e); var mr = this._modalResize; if (this.WindowResizeCssClasses.length > 0) {
        mr.className = this.WindowResizeCssClasses[0]; for (var i = 1; i < this.WindowResizeCssClasses.length; i++)
        { mr.appendChild(document.createElement('div')); mr = mr.childNodes[0]; mr.className = this.WindowResizeCssClasses[i]; }
    }
    this._modalResize.onmousedown = new Function('event', 'window.' + this._variableName + '._startResize(event); return false;'); this._modalAnimationMask.appendChild(this._modal); document.body.appendChild(this._modalAnimationMask); this._initialized = true;
}
Telligent_Modal.Dispose = function() {
    if (this._initialized) {
        if (this._animationHandle)
            window.clearTimeout(this._animationHandle); this._isShown = false; this._isOpening = false; if (document && document.body)
        { document.body.removeChild(this._modalAnimationMask); document.body.removeChild(this._modalMask); this._modalClose.onclick = null; this._modalTitle.onmousedown = null; this._modalResize.onmousedown = null; this._modal = null; this._modalTitle = null; this._modalClose = null; this._modalAnimationMask = null; this._modalMask = null; this._modalIframe = null; this._modalResize = null; this._modalFooter = null; this._modalContent = null; }
        this._initialized = false;
    }
}
Telligent_Modal._animate = function(targetValue, nextValue, step, acceleration) {
    if (this._animationHandle)
        window.clearTimeout(this._animationHandle); if (!this._isOpening)
        return; var currValue = parseInt(this._modal.style.top, 10); if ((step < 0 && currValue < targetValue) || (step > 0 && currValue > targetValue) || Math.abs(step) < 1) {
        this._modal.style.top = targetValue + 'px'; this._modal.style.position = 'static'; this._modalAnimationMask.style.overflow = 'visible'; this._animationHandle = null; if (!this._isResizing && !this._isDragging)
            this._modalIframe.style.display = 'block'; this._isOpening = false; this._lastWindowInfo = Telligent_Common.GetWindowInfo(); this._checkForScrollResizeHandle = window.setTimeout(new Function('window.' + this._variableName + '._checkForScrollResize();'), 249);
    }
    else {
        this._modal.style.top = nextValue + 'px'; nextValue = nextValue + step; if (step > 0 && nextValue > targetValue)
            nextValue = targetValue; else if (step < 0 && nextValue < targetValue)
            nextValue = targetValue; step = step * acceleration; this._animationHandle = window.setTimeout(new Function(this._variableName + '._animate(' + targetValue + ',' + nextValue + ',' + step + ',' + acceleration + ');'), 19);
    }
}
Telligent_Modal._startDrag = function(event) {
    if (!this._initialized)
        this._initialize(); if (!event)
        event = window.event; this._moveModalInfo = new Object(); this._moveModalInfo.StartMouseX = event.pageX ? event.pageX : event.screenX; this._moveModalInfo.StartMouseY = event.pageY ? event.pageY : event.screenY; this._moveModalInfo.StartModalX = this._lastModalInfo.X; this._moveModalInfo.StartModalY = this._lastModalInfo.Y; this._moveModalInfo.Button = event.button; document.onmouseup = new Function('event', 'window.' + this._variableName + '._endDrag(event); return false;'); document.onmousemove = new Function('event', 'window.' + this._variableName + '._drag(event); return false;'); this._isDragging = true; this._modalIframe.style.display = 'none';
}
Telligent_Modal._endDrag = function(event) {
    if (!this._initialized)
        this._initialize(); document.onmouseup = null; document.onmousemove = null; this._modalIframe.style.display = 'block'; this._isDragging = false; this._moveModalInfo = null;
}
Telligent_Modal._drag = function(event) {
    if (!this._initialized)
        this._initialize(); if (!event)
        event = window.event; if (event.button != this._moveModalInfo.Button)
    { this._endDrag(event); return; }
    var eventX = typeof (event.pageX) != 'undefined' ? event.pageX : event.screenX; var eventY = typeof (event.pageY) != 'undefined' ? event.pageY : event.screenY; var xChange = eventX - this._moveModalInfo.StartMouseX; var yChange = eventY - this._moveModalInfo.StartMouseY; this.MoveTo(this._moveModalInfo.StartModalX + xChange, this._moveModalInfo.StartModalY + yChange);
}
Telligent_Modal._startResize = function(event) {
    if (!this._initialized)
        this._initialize(); if (!event)
        event = window.event; this._resizeModalInfo = new Object(); this._resizeModalInfo.StartMouseX = event.pageX ? event.pageX : event.screenX; this._resizeModalInfo.StartMouseY = event.pageY ? event.pageY : event.screenY; this._resizeModalInfo.StartModalWidth = this._lastModalInfo.Width; this._resizeModalInfo.StartModalHeight = this._lastModalInfo.Height; this._resizeModalInfo.Button = event.button; document.onmouseup = new Function('event', 'window.' + this._variableName + '._endResize(event); return false;'); document.onmousemove = new Function('event', 'window.' + this._variableName + '._resize(event); return false;'); this._modalIframe.style.display = 'none'; this._isResizing = true;
}
Telligent_Modal._endResize = function(event) {
    if (!this._initialized)
        this._initialize(); this._isResizing = false; this._resizeModalInfo = null; document.onmouseup = null; document.onmousemove = null; this._modalIframe.style.display = 'block';
}
Telligent_Modal._resize = function(event) {
    if (!this._initialized)
        this._initialize(); if (!event)
        event = window.event; if (event.button != this._resizeModalInfo.Button)
    { this._endResize(event); return; }
    var eventX = typeof (event.pageX) != 'undefined' ? event.pageX : event.screenX; var eventY = typeof (event.pageY) != 'undefined' ? event.pageY : event.screenY; var xChange = eventX - this._resizeModalInfo.StartMouseX; var yChange = eventY - this._resizeModalInfo.StartMouseY; this.Resize(this._resizeModalInfo.StartModalWidth + xChange, this._resizeModalInfo.StartModalHeight + yChange, true);
};






var Telligent_Common = new Object(); Telligent_Common._state = new Array(); Telligent_Common.ConvertHsvColorToRgbColor = function(hsv) {
    var h = hsv[0]; var s = hsv[1]; var v = hsv[2]; var r; var g; var b; if (s == 0)
        return new Array(v, v, v); var htemp; if (h == 360)
        htemp = 0; else
        htemp = h; htemp = htemp / 60; var i = Math.floor(htemp); var f = htemp - i; var p = v * (1 - s); var q = v * (1 - (s * f)); var t = v * (1 - (s * (1 - f))); if (i == 0) { r = v; g = t; b = p; }
    if (i == 1) { r = q; g = v; b = p; }
    if (i == 2) { r = p; g = v; b = t; }
    if (i == 3) { r = p; g = q; b = v; }
    if (i == 4) { r = t; g = p; b = v; }
    if (i == 5) { r = v; g = p; b = q; }
    r = Math.round(r); g = Math.round(g); b = Math.round(b); return new Array(r, g, b);
}
Telligent_Common.ConvertRgbColorToHsvColor = function(rgb) {
    var r = rgb[0]; var g = rgb[1]; var b = rgb[2]; var h; var s; var v = Math.max(Math.max(r, g), b); var min = Math.min(Math.min(r, g), b); var delta = v - min; if (v == 0)
        s = 0
    else
        s = delta / v; if (s == 0)
        h = 0; else {
        if (r == v)
            h = 60 * (g - b) / delta; else if (g == v)
            h = 120 + 60 * (b - r) / delta; else if (b == v)
            h = 240 + 60 * (r - g) / delta;
    }
    if (h < 0)
        h += 360; return new Array(h, s, v);
}
Telligent_Common.ConvertDecimalToHexadecimal = function(d, digits) {
    var chars = "0123456789abcdef"; var h = ''; var mod; while (d > 0)
    { mod = d % 16; h = chars.substr(mod, 1) + h; d -= mod; d /= 16; }
    if (digits) {
        while (h.length < digits)
        { h = "0" + h; } 
    }
    return h;
}
Telligent_Common.ConvertHtmlColorToRgbColor = function(html) {
    html = html.replace(/[^0-9a-f]/ig, ''); if (html.length == 3)
        return new Array(parseInt(html.substr(0, 1) + html.substr(0, 1), 16), parseInt(html.substr(1, 1) + html.substr(1, 1), 16), parseInt(html.substr(2, 1) + html.substr(2, 1), 16)); else if (html.length == 6)
        return new Array(parseInt(html.substr(0, 2), 16), parseInt(html.substr(2, 2), 16), parseInt(html.substr(4, 2), 16)); else
        return new Array(255, 255, 255);
}
Telligent_Common.ConvertRgbColorToHtmlColor = function(rgbColor)
{ return "#" + Telligent_Common.ConvertDecimalToHexadecimal(rgbColor[0], 2) + Telligent_Common.ConvertDecimalToHexadecimal(rgbColor[1], 2) + Telligent_Common.ConvertDecimalToHexadecimal(rgbColor[2], 2); }
Telligent_Common.GetContrastingHtmlColorForRgbColor = function(rgb) {
    var illuminance = (rgb[0] * 2) + (rgb[1] * 5) + (rgb[2]); if (illuminance > 1024)
        return "#000000"; else
        return "#ffffff";
}
Telligent_Common.GetElementInfo = function(element) {
    var curleft = 0; var curtop = 0; var obj = element; var leftComplete = false; var topComplete = false; var isIE = Telligent_Common.IsIE(); while (obj) {
        if (!leftComplete)
            curleft += obj.offsetLeft; if (!topComplete)
            curtop += obj.offsetTop; if (isIE && obj.offsetParent && obj.offsetParent.style.position == 'relative') {
            if (!obj.offsetParent.style.width) {
                leftComplete = true; if ((obj.offsetParent.style.top || obj.offsetParent.style.bottom))
                { curtop += obj.offsetHeight; topComplete = true; } 
            } 
        }
        obj = obj.offsetParent;
    }
    var elementInfo = new Object(); elementInfo.Left = curleft; elementInfo.Top = curtop; elementInfo.Width = element.offsetWidth; elementInfo.Height = element.offsetHeight; return elementInfo;
}
Telligent_Common.GetWindowInfo = function() {
    var scrollX = 0, scrollY = 0, width = 0, height = 0; if (typeof (window.pageXOffset) == 'number')
    { scrollX = window.pageXOffset; scrollY = window.pageYOffset; }
    else if (document.body && (document.body.scrollLeft || document.body.scrollTop))
    { scrollX = document.body.scrollLeft; scrollY = document.body.scrollTop; }
    else if (document.documentElement && (document.documentElement.scrollLeft || document.documentElement.scrollTop))
    { scrollX = document.documentElement.scrollLeft; scrollY = document.documentElement.scrollTop; }
    if (typeof (window.innerWidth) == 'number')
    { width = window.innerWidth; height = window.innerHeight; }
    else if (document.documentElement && (document.documentElement.clientWidth || document.documentElement.clientHeight))
    { width = document.documentElement.clientWidth; height = document.documentElement.clientHeight; }
    else if (document.body && (document.body.clientWidth || document.body.clientHeight))
    { width = document.body.clientWidth; height = document.body.clientHeight; }
    if (document.documentElement && (document.documentElement.scrollHeight || document.documentElement.offsetHeight)) {
        if (document.documentElement.scrollHeight > document.documentElement.offsetHeight)
        { contentWidth = document.documentElement.scrollWidth; contentHeight = document.documentElement.scrollHeight; }
        else
        { contentWidth = document.documentElement.offsetWidth; contentHeight = document.documentElement.offsetHeight; } 
    }
    else if (document.body && (document.body.scrollHeight || document.body.offsetHeight)) {
        if (document.body.scrollHeight > document.body.offsetHeight)
        { contentWidth = document.body.scrollWidth; contentHeight = document.body.scrollHeight; }
        else
        { contentWidth = document.body.offsetWidth; contentHeight = document.body.offsetHeight; } 
    }
    else
    { contentWidth = width; contentHeight = height; }
    if (height > contentHeight)
        height = contentHeight; if (width > contentWidth)
        width = contentWidth; var rect = new Object(); rect.ScrollX = scrollX; rect.ScrollY = scrollY; rect.Width = width; rect.Height = height; rect.ContentWidth = contentWidth; rect.ContentHeight = contentHeight; return rect;
}
Telligent_Common.GetCurrentStyleValue = function(element, styleRule, jsStyleRule, defaultValue) {
    var value = ''; try {
        if (document.defaultView && document.defaultView.getComputedStyle)
            value = document.defaultView.getComputedStyle(element, "").getPropertyValue(styleRule); else if (element.currentStyle)
            value = element.currentStyle[jsStyleRule];
    } catch (e) { }
    if ((value == 'inherit' || value == 'transparent') && element.parentNode != null)
        return Telligent_Common.GetCurrentStyleValue(element.parentNode, styleRule, jsStyleRule, defaultValue); else if (value != '' && value != undefined && value != 'rgba(0, 0, 0, 0)')
        return value; else
        return defaultValue;
}
Telligent_Common.GetStyleOffset = function(element) {
    var result = new Object(); result.Height = Telligent_Common.IsNanDefault(parseInt(Telligent_Common.GetCurrentStyleValue(element, 'border-top-width', 'borderTopWidth', '0')), 0) +
Telligent_Common.IsNanDefault(parseInt(Telligent_Common.GetCurrentStyleValue(element, 'border-bottom-width', 'borderBottomWidth', '0')), 0) +
Telligent_Common.IsNanDefault(parseInt(Telligent_Common.GetCurrentStyleValue(element, 'padding-top', 'paddingTop', '0')), 0) +
Telligent_Common.IsNanDefault(parseInt(Telligent_Common.GetCurrentStyleValue(element, 'padding-bottom', 'paddingBottom', '0')), 0); result.Width = Telligent_Common.IsNanDefault(parseInt(Telligent_Common.GetCurrentStyleValue(element, 'border-left-width', 'borderLeftWidth', '0')), 0) +
Telligent_Common.IsNanDefault(parseInt(Telligent_Common.GetCurrentStyleValue(element, 'border-right-width', 'borderRightWidth', '0')), 0) +
Telligent_Common.IsNanDefault(parseInt(Telligent_Common.GetCurrentStyleValue(element, 'padding-left', 'paddingLeft', '0')), 0) +
Telligent_Common.IsNanDefault(parseInt(Telligent_Common.GetCurrentStyleValue(element, 'padding-right', 'paddingRight', '0')), 0); return result;
}
Telligent_Common.IsNanDefault = function(value, defaultValue) {
    if (isNaN(value))
        return defaultValue; else
        return value;
}
Telligent_Common.EscapeForRegExp = function(value)
{ return value.replace(/([\\\(\^\$\*\+\?\{\}\.\)\|\-])/g, '\\$1'); }
Telligent_Common.GetSelectedHtmlInElement = function(element, includeAllContentIfNoSelection, includeAllContentIfInvalidSelection, invalidSelectionMessage) {
    var selectionIsValid = true; var content = null; if (window.getSelection) {
        var selection = window.getSelection(); if (selection && selection.rangeCount > 0 && selection.toString().length > 0) {
            selectionIsValid = false; var selectedRange = selection.getRangeAt(0); var availableRange = document.createRange(); availableRange.selectNode(element); if (availableRange.compareBoundaryPoints(Range.START_TO_START, selectedRange) <= 0 && availableRange.compareBoundaryPoints(Range.END_TO_END, selectedRange) >= 0)
            { var temp = document.createElement('div'); temp.appendChild(selectedRange.cloneContents()); content = temp.innerHTML; }
            else if (invalidSelectionMessage)
                alert(invalidSelectionMessage);
        } 
    }
    else if (document.selection) {
        var range = document.selection.createRange(); if (range && range.text) {
            selectionIsValid = false; var parent = range.parentElement(); if (parent != null && Telligent_Common.ElementContainsElement(element, parent))
                content = range.htmlText; else if (invalidSelectionMessage)
                alert(invalidSelectionMessage);
        } 
    }
    if (content == null && ((selectionIsValid && includeAllContentIfNoSelection) || includeAllContentIfInvalidSelection))
        content = element.innerHTML; return content;
}
Telligent_Common.ElementContainsElement = function(parent, child) {
    if (!parent || !child)
        return false; if (parent == child)
        return true; if (parent && parent.childNodes) {
        for (var i = 0; i < parent.childNodes.length; i++) {
            if (parent.childNodes[i] == child || Telligent_Common.ElementContainsElement(parent.childNodes[i], child))
                return true;
        } 
    }
    return false;
}
Telligent_Common.GetCurrentCursorIndex = function(inputElement) {
    var index = 0; if (inputElement.selectionStart || inputElement.selectionStart == '0')
        index = inputElement.selectionStart; else if (document.selection)
    { var originalValue = inputElement.value; var range = document.selection.createRange(); var escapeChar = String.fromCharCode(1); range.text = escapeChar; index = inputElement.value.indexOf(escapeChar); inputElement.value = originalValue; }
    return index;
}
Telligent_Common._delayedSetCurrentCursorSelection = function(stateId) {
    var state = Telligent_Common.GetStateByStateId(stateId, 'Telligent_Common_SetCurrentCursorSelection'); if (state)
    { Telligent_Common.SetCurrentCursorSelection(state.InputElement, state.StartIndex, state.EndIndex, false, state.PersistedValue); Telligent_Common.ClearStateByStateId(stateId, 'Telligent_Common_SetCurrentCursorSelection'); } 
}
Telligent_Common.IsSafari = function()
{ return navigator.userAgent.indexOf('Safari') != -1; }
Telligent_Common.IsOpera = function()
{ return window.opera != null; }
Telligent_Common.IsIE = function()
{ return (navigator && navigator.userAgent && navigator.userAgent.indexOf('MSIE') != -1) }
Telligent_Common.CreateSafeFunction = function(instance, func)
{ return function() { return func.apply(instance, arguments); } }
Telligent_Common.DisposeContent = function(parentElement) {
    if (parentElement && parentElement.childNodes && parentElement.childNodes.length > 0) {
        for (var i = 0; i < parentElement.childNodes.length; i++) {
            if (parentElement.childNodes[i].dispose) {
                try
{ parentElement.childNodes[i].dispose(); }
                catch (e) { } 
            }
            Telligent_Common.DisposeContent(parentElement.childNodes[i]);
        } 
    } 
}
Telligent_Common.SetCurrentCursorSelection = function(inputElement, startIndex, endIndex, functionKeyWasHandled, persistedValue) {
    if (Telligent_Common.IsSafari() || Telligent_Common.IsOpera()) {
        if (functionKeyWasHandled) {
            var state = Telligent_Common.GetStateByKey(inputElement, 'Telligent_Common_SetCurrentCursorSelection'); if (state && state.CursorTimeout)
                window.clearTimeout(state.CursorTimeout); state = new Object(); state.InputElement = inputElement; state.StartIndex = startIndex; state.EndIndex = endIndex; state.PersistedValue = persistedValue; var stateId = Telligent_Common.SaveStateByKey(inputElement, 'Telligent_Common_SetCurrentCursorSelection', state); state.CursorTimeout = window.setTimeout(new Function('Telligent_Common._delayedSetCurrentCursorSelection(' + stateId + ');'), 9); Telligent_Common.SaveStateByKey(inputElement, 'Telligent_Common_SetCurrentCursorSelection', state); return;
        }
        else {
            inputElement.focus(); if (persistedValue)
                inputElement.value = persistedValue;
        } 
    }
    try {
        if (document.selection)
        { var range = inputElement.createTextRange(); range.move('character', startIndex); range.moveEnd('character', endIndex - startIndex); range.select(); }
        else if (inputElement.setSelectionRange)
        { inputElement.setSelectionRange(startIndex, endIndex); inputElement.focus(); }
        else if (inputElement.selectionStart || inputElement.selectionStart == '0')
        { inputElement.selectionStart = startIndex; inputElement.selectionEnd = endIndex; } 
    } catch (e) { } 
}
Telligent_Common.GetStateByStateId = function(stateId, processId) {
    if (Telligent_Common._state.length > stateId && stateId >= 0 && Telligent_Common._state[stateId] && Telligent_Common._state[stateId]._stateProcessId == processId)
        return Telligent_Common._state[stateId]._state; else
        return null;
}
Telligent_Common.GetStateByKey = function(key, processId) {
    for (var i = 0; i < Telligent_Common._state.length; i++) {
        if (Telligent_Common._state[i] && Telligent_Common._state[i]._stateKey == key && Telligent_Common._state[i]._stateProcessId == processId)
            return Telligent_Common._state[i]._state;
    }
    return null;
}
Telligent_Common.SaveStateByStateId = function(stateId, processId, state) {
    if (Telligent_Common._state.length > stateId && stateId >= 0 && Telligent_Common._state[stateId] && Telligent_Common._state[stateId]._stateProcessId == processId)
        Telligent_Common._state[stateId]._state = state;
}
Telligent_Common.SaveStateByKey = function(key, processId, state) {
    var emptyIndex = -1; for (var i = 0; i < Telligent_Common._state.length; i++) {
        if (!Telligent_Common._state[i])
            emptyIndex = i; else if (Telligent_Common._state[i]._stateKey == key && Telligent_Common._state[i]._stateProcessId == processId)
        { Telligent_Common._state[i]._state = state; return i; } 
    }
    var stateBucket = new Object(); stateBucket._stateKey = key; stateBucket._stateProcessId = processId; stateBucket._state = state; if (emptyIndex != -1)
    { Telligent_Common._state[emptyIndex] = stateBucket; return emptyIndex; }
    else
    { Telligent_Common._state[Telligent_Common._state.length] = stateBucket; return Telligent_Common._state.length - 1; } 
}
Telligent_Common.ClearStateByStateId = function(stateId, processId) {
    if (Telligent_Common._state.length > stateId && stateId >= 0 && Telligent_Common._state[stateId] && Telligent_Common._state[stateId]._stateProcessId == processId)
        Telligent_Common._state[stateId] = null;
}
Telligent_Common._hiddenSelects = new Array(); Telligent_Common._elementsHidingSelects = new Array(); Telligent_Common._addHiddenSelect = function(elementHidingSelect, selectElement) {
    var hiddenSelect = null; var emptyIndex = -1; for (var i = 0; i < Telligent_Common._hiddenSelects.length && hiddenSelect == null; i++) {
        if (Telligent_Common._hiddenSelects[i]) {
            if (Telligent_Common._hiddenSelects[i].SelectElement == selectElement)
                hiddenSelect = Telligent_Common._hiddenSelects[i];
        }
        else
            emptyIndex = i;
    }
    if (hiddenSelect == null) {
        hiddenSelect = new Object(); hiddenSelect.SelectElement = selectElement; hiddenSelect.ElementsHidingSelectsIndeces = new Array(); hiddenSelect.OriginalVisibility = selectElement.style.visibility; hiddenSelect.SelectElement.style.visibility = 'hidden'; if (emptyIndex == -1)
        { Telligent_Common._hiddenSelects[Telligent_Common._hiddenSelects.length] = hiddenSelect; hiddenSelect.Index = Telligent_Common._hiddenSelects.length - 1; }
        else
        { Telligent_Common._hiddenSelects[emptyIndex] = hiddenSelect; hiddenSelect.Index = emptyIndex; } 
    }
    var ignore = false; for (var i = 0; i < hiddenSelect.ElementsHidingSelectsIndeces.length && !ignore; i++) {
        if (hiddenSelect.ElementsHidingSelectsIndeces[i] == elementHidingSelect.Index)
            ignore = true;
    }
    if (!ignore)
    { elementHidingSelect.HiddenSelectsIndeces[elementHidingSelect.HiddenSelectsIndeces.length] = hiddenSelect.Index; hiddenSelect.ElementsHidingSelectsIndeces[hiddenSelect.ElementsHidingSelectsIndeces.length] = elementHidingSelect.Index; } 
}
Telligent_Common._addElementHidingSelect = function(element) {
    var elementHidingSelect = null; var emptyIndex = -1; for (var i = 0; i < Telligent_Common._elementsHidingSelects.length && elementHidingSelect == null; i++) {
        if (Telligent_Common._elementsHidingSelects[i]) {
            if (Telligent_Common._elementsHidingSelects[i].Element == element)
                elementHidingSelect = Telligent_Common._elementsHidingSelects[i];
        }
        else
            emptyIndex = i;
    }
    if (elementHidingSelect == null) {
        elementHidingSelect = new Object(); elementHidingSelect.Element = element; elementHidingSelect.HiddenSelectsIndeces = new Array(); if (emptyIndex == -1)
        { Telligent_Common._elementsHidingSelects[Telligent_Common._elementsHidingSelects.length] = elementHidingSelect; elementHidingSelect.Index = Telligent_Common._elementsHidingSelects.length - 1; }
        else
        { Telligent_Common._elementsHidingSelects[emptyIndex] = elementHidingSelect; elementHidingSelect.Index = emptyIndex; } 
    }
    return elementHidingSelect;
}
Telligent_Common.HideElementsInWindow = function(element, w, hideAll) {
    var elementHidingSelect = null; var subWindows = w.document.getElementsByTagName('iframe'); for (var i = 0; i < subWindows.length; i++) {
        if (!Telligent_Common.ElementContainsElement(element, subWindows[i])) {
            try
{ Telligent_Common.HideElementsInWindow(element, subWindows[i].contentWindow, hideAll); }
            catch (e) {
                if (elementHidingSelect == null)
                    elementHidingSelect = Telligent_Common._addElementHidingSelect(element); Telligent_Common._addHiddenSelect(elementHidingSelect, subWindows[i]); subWindows[i].style.visibility = 'hidden';
            } 
        } 
    }
    var tagsToHide = ['object', 'embed', 'applet']; for (var i = 0; i < tagsToHide.length; i++) {
        var objects = document.getElementsByTagName(tagsToHide[i]); for (var j = 0; j < objects.length; j++) {
            if (!Telligent_Common.ElementContainsElement(element, objects[j])) {
                if (elementHidingSelect == null)
                    elementHidingSelect = Telligent_Common._addElementHidingSelect(element); Telligent_Common._addHiddenSelect(elementHidingSelect, objects[j]); objects[j].style.visibility = 'hidden';
            } 
        } 
    }
    if (element.getClientRects) {
        var selectBoxes = document.getElementsByTagName('select'); var elementRect = element.getClientRects()[0]; for (var i = 0; i < selectBoxes.length; i++) {
            if (selectBoxes[i].getClientRects) {
                var rects = selectBoxes[i].getClientRects(); for (var j = 0; j < rects.length; j++) {
                    if (hideAll || (rects[j].top < elementRect.bottom && elementRect.top < rects[j].bottom && rects[j].left < elementRect.right && elementRect.left < rects[j].right)) {
                        if (!Telligent_Common.ElementContainsElement(element, selectBoxes[i])) {
                            if (elementHidingSelect == null)
                                elementHidingSelect = Telligent_Common._addElementHidingSelect(element); Telligent_Common._addHiddenSelect(elementHidingSelect, selectBoxes[i]); selectBoxes[i].style.visibility = 'hidden';
                        }
                        break;
                    } 
                } 
            } 
        } 
    } 
}
Telligent_Common.HideSelectBoxes = function(element, hideAll)
{ Telligent_Common.HideElementsInWindow(element, window.window, hideAll); }
Telligent_Common.ShowSelectBoxes = function(element) {
    var elementHidingSelect = null; for (var i = 0; i < Telligent_Common._elementsHidingSelects.length && elementHidingSelect == null; i++) {
        if (Telligent_Common._elementsHidingSelects[i]) {
            if (Telligent_Common._elementsHidingSelects[i].Element == element)
                elementHidingSelect = Telligent_Common._elementsHidingSelects[i];
        } 
    }
    if (elementHidingSelect == null)
        return; var hiddenSelect; for (var i = 0; i < elementHidingSelect.HiddenSelectsIndeces.length; i++) {
        hiddenSelect = Telligent_Common._hiddenSelects[elementHidingSelect.HiddenSelectsIndeces[i]]; if (hiddenSelect) {
            if (hiddenSelect.ElementsHidingSelectsIndeces.length == 1) {
                try {
                    if (hiddenSelect.SelectElement.style.visibility == 'hidden')
                        hiddenSelect.SelectElement.style.visibility = hiddenSelect.OriginalVisibility;
                }
                catch (e)
{ }
                Telligent_Common._hiddenSelects[hiddenSelect.Index] = null;
            }
            else {
                var elementsHidingSelects = new Array(); for (var j = 0; j < hiddenSelect.ElementsHidingSelectsIndeces.length; j++) {
                    if (hiddenSelect.ElementsHidingSelectsIndeces[j] != elementHidingSelect.Index)
                        elementsHidingSelects[elementsHidingSelects.length] = hiddenSelect.ElementsHidingSelectsIndeces[i];
                }
                hiddenSelect.ElementsHidingSelectsIndeces = elementsHidingSelects;
            } 
        } 
    }
    Telligent_Common._elementsHidingSelects[elementHidingSelect.Index] = null;
}
Telligent_Common._disposableControls = new Array(); Telligent_Common.RegisterDisposableControl = function(controlName) {
    if (controlName)
        Telligent_Common._disposableControls[Telligent_Common._disposableControls.length] = controlName;
}
Telligent_Common._windowOnUnload = function() {
    for (var i = 0; i < Telligent_Common._disposableControls.length; i++) {
        try
{ eval(Telligent_Common._disposableControls[i]).Dispose(); }
        catch (e) { } 
    }
    Telligent_Common._disposableControls = new Array(); if (this._originalWindowOnUnload)
        this._originalWindowOnUnload();
}
this._originalWindowOnUnload = null; if (window.onunload)
    this._originalWindowOnUnload = window.onunload; window.onunload = new Function('Telligent_Common._windowOnUnload();');