var konferoHost = 'http://konfero.com:80';
var konferoKroogiMode = true;
//var konferoAnyWare = %%ANYWARE%%;
if (typeof window.konferoAnyWare == 'undefined') {
    if (false) {
        window.konferoAnyWare = {
            AnimateKonferoButton : function(animate) {
                if (konferoAnyWareProxyElement) {
                    konferoAnyWareProxyElement.setAttribute("eventType", "AnimateKonferoButton");
                    konferoAnyWareProxyElement.setAttribute("animate", animate > 0);
                    this._dispatchEvent();
                }
            },

            ShowBubble : function(text, visible) {
                if (konferoAnyWareProxyElement) {
                    konferoAnyWareProxyElement.setAttribute("eventType", "ShowBubble");
                    konferoAnyWareProxyElement.setAttribute("text", text);
                    konferoAnyWareProxyElement.setAttribute("visible", visible > 0);
                    this._dispatchEvent();
                }
            },

            ResetState : function() {
            },

            SetUserStatus : function(userStatus) {
                if (konferoAnyWareProxyElement) {
                    konferoAnyWareProxyElement.setAttribute("eventType", "SetUserStatus");
                    konferoAnyWareProxyElement.setAttribute("userStatus", userStatus);
                    this._dispatchEvent();
                }
            },

            SetButtonState : function(anywareButton, state) {
                if (konferoAnyWareProxyElement) {
                    konferoAnyWareProxyElement.setAttribute("eventType", "SetButtonState");
                    konferoAnyWareProxyElement.setAttribute("button", anywareButton);
                    konferoAnyWareProxyElement.setAttribute("state", state);
                    this._dispatchEvent();
                }
            },

            SetKonferoState : function(state) {
                if (konferoAnyWareProxyElement) {
                    konferoAnyWareProxyElement.setAttribute("eventType", "SetKonferoState");
                    konferoAnyWareProxyElement.setAttribute("state", state);
                    this._dispatchEvent();
                }
            },

            _dispatchEvent : function() {
                var ev = document.createEvent("Events");
                ev.initEvent("EmbeddedKonferoEvent", true, false);
                konferoAnyWareProxyElement.dispatchEvent(ev);
            }
        }

        document.addEventListener("KonferoAnyWareEvent", function(ev) {
            var functionName = ev.target.getAttribute("functionName");
            var sParams = ev.target.getAttribute("params");
            var params = undefined;
            if (sParams) {
                params = sParams.split("|");
            }
            window[functionName].apply(window, params);
        }, false, true);
    } else {
        window.konferoAnyWare = false;
    }
}
if (typeof window.konferoAnyWareUserStatus == 'undefined') {
    window.konferoAnyWareUserStatus = -1;
}
var konferoAvailable = false;
var konferoChatRoomUrl = 'http://neboslov.kroogi.ru';
var konferoChatRoomTitle = 'Kroogi: чат "neboslov"';
var konferoBuildNumber = '2419';
var konferoIsDebug = false;
var konferoOpenId = undefined;
var konferoOpenIdServer = '%%OPEN_ID_SERVER%%';
var konferoUserLanguage = 'ru' != null ? 'ru' : (navigator.language ? navigator.language : navigator.userLanguage);
var konferoFollowingUrl = undefined;
var konferoIsEnterAsGuest = true;
var konferoInitialUserStatus = undefined;
var konferoAnyWareProxyElement = null;
var konferoClosedIdUserDate = null;
var konferoClosedIdSignature = null;
var konferoKroogiProjectName = 'Илья Прозоров';
var konferoKroogiProjectAvatar = 'http://assets0.kroogi.com/images/noavatar_med.gif?1268663770';

if (window.opera) {
    history.navigationMode = 'compatible';
}

(function() {
    var agt = navigator.userAgent.toLowerCase();
    var isIE = (!window.opera && agt.indexOf('msie') != -1);
    var isIE6minus = (!window.opera && agt.indexOf('msie') != -1) && (agt.indexOf('msie 7.0') == -1) && (agt.indexOf('msie 8.0') == -1);
    var isIE8 = (agt.indexOf('msie 8.0') != -1);
    var isOpera = agt.indexOf("opera") != -1;
    var isSafari = agt.indexOf("safari") != -1;
    var isChrome = agt.indexOf("chrome") != -1;
    var isQuirks = ('BackCompat' == document.compatMode);

    var messageBubble = null;
    var icon = null;
    var kroogiPreloader = null;
	var kroogiPreloaderMidTd = null;
    var konferoAppContainer = null;
    var messageBubbleText = null;
    window.konferoLoading = false;
    var mouseOverIcon = false;
    var scriptRpc = null;
    var initialized = false;
    var konferoLoaded = false;
    var operaRequestAnyAliveInstanceInterval = null;
    var operaRequestAnyAliveInstanceIntervalStartTime = 0;
    var operaRequestAnyAliveInstanceIntervalTimeout = 2000;
    var operaRequestAnyAliveInstanceIframe = null;
    var operaRequestAnyAliveInstanceScript = null;
    var flashStorage = null;
    var allMessageBubbleImagesLoaded = false;
    var messageBubbleImagesPreloadTimeout = 3000;
    var showMessageBubbleTimeout = null;
    var checkAnyWareInterval = null;

    var ANYWARE_STATE_LOADING = 0x4;
    var ANYWARE_STATE_STANDBY = 0x20;

    var onlineUsersCountRequestId = 'konferoOnlineUserCountRequestId';
    var preloaderOnlineUsersCountRequestId = 'konferoPreloaderRequestId';

    window.hideKonferoPreloader = function() {
        if (messageBubble != null) {
            document.body.removeChild(messageBubble);
            messageBubble = null;
        }
        if (icon != null) {
            document.body.removeChild(icon);
            icon = null;
        }
        if (kroogiPreloader != null) {
            document.body.removeChild(kroogiPreloader);
            kroogiPreloader = null;
        }
        if (checkAnyWareInterval) {
            clearInterval(checkAnyWareInterval);
        }
        window.konferoLoading = false;
        konferoLoaded = true;
    }

    var konferoForcedAutoEnter = false;
    var konferoAutoEnter = false;
    var konferoNoUser = true;
    var konferoUserInStandby = false;

    function getFlashVersion() {
        var UNDEF = "undefined",
            OBJECT = "object",
            SHOCKWAVE_FLASH = "Shockwave Flash",
            SHOCKWAVE_FLASH_AX = "ShockwaveFlash.ShockwaveFlash",
            FLASH_MIME_TYPE = "application/x-shockwave-flash";

        var win = window,
            nav = navigator;

        var playerVersion = [0,0,0];
        var d = null;
        if (typeof nav.plugins != UNDEF && typeof nav.plugins[SHOCKWAVE_FLASH] == OBJECT) {
            d = nav.plugins[SHOCKWAVE_FLASH].description;
            if (d && !(typeof nav.mimeTypes != UNDEF && nav.mimeTypes[FLASH_MIME_TYPE] && !nav.mimeTypes[FLASH_MIME_TYPE].enabledPlugin)) { // navigator.mimeTypes["application/x-shockwave-flash"].enabledPlugin indicates whether plug-ins are enabled or disabled in Safari 3+
                d = d.replace(/^.*\s+(\S+\s+\S+$)/, "$1");
                playerVersion[0] = parseInt(d.replace(/^(.*)\..*$/, "$1"), 10);
                playerVersion[1] = parseInt(d.replace(/^.*\.(.*)\s.*$/, "$1"), 10);
                playerVersion[2] = /r/.test(d) ? parseInt(d.replace(/^.*r(.*)$/, "$1"), 10) : 0;
            }
        }
        else if (typeof win.ActiveXObject != UNDEF) {
            var a = null, fp6Crash = false;
            try {
                a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".7");
            }
            catch(e) {
                try {
                    a = new ActiveXObject(SHOCKWAVE_FLASH_AX + ".6");
                    playerVersion = [6,0,21];
                    a.AllowScriptAccess = "always";	 // Introduced in fp6.0.47
                }
                catch(e) {
                    if (playerVersion[0] == 6) {
                        fp6Crash = true;
                    }
                }
                if (!fp6Crash) {
                    try {
                        a = new ActiveXObject(SHOCKWAVE_FLASH_AX);
                    }
                    catch(e) {}
                }
            }
            if (!fp6Crash && a) { // a will return null when ActiveX is disabled
                try {
                    d = a.GetVariable("$version");	// Will crash fp6.0.21/23/29
                    if (d) {
                        d = d.split(" ")[1].split(",");
                        playerVersion = [parseInt(d[0], 10), parseInt(d[1], 10), parseInt(d[2], 10)];
                    }
                }
                catch(e) {}
            }
        }
        return playerVersion[0];
    }

    function preloadImage(src, onloadHandler) {
        var img = document.createElement('img');
        img.src = src;
        img.onload = function() {
            onloadHandler();
            setTimeout(function() {
                img.onload = null;
                img = null;
            });
        }
    }

    function preloadMessageBubbleImages() {
        if (allMessageBubbleImagesLoaded) return;

        setTimeout(function() {
            allMessageBubbleImagesLoaded = true;
        }, messageBubbleImagesPreloadTimeout);

        var imageToPreloadCount = 8;
        var onloadHandler = function() {
            imageToPreloadCount--;
            if (imageToPreloadCount == 0) {
                allMessageBubbleImagesLoaded = true;
            }
        }
        preloadImage(konferoHost + '/embeddedkonfero/images/preloader/loading_5percent.gif', onloadHandler);
        preloadImage(konferoHost + '/embeddedkonfero/images/preloader/cbb_tl.png', onloadHandler);
        preloadImage(konferoHost + '/embeddedkonfero/images/preloader/cbb_tbg.gif', onloadHandler);
        preloadImage(konferoHost + '/embeddedkonfero/images/preloader/cbb_tr.png', onloadHandler);
        preloadImage(konferoHost + '/embeddedkonfero/images/preloader/cbb_lbg.gif', onloadHandler);
        preloadImage(konferoHost + '/embeddedkonfero/images/preloader/cbb_rbg.gif', onloadHandler);
        preloadImage(konferoHost + '/embeddedkonfero/images/preloader/cbb_bl.png', onloadHandler);
        preloadImage(konferoHost + '/embeddedkonfero/images/preloader/cbb_bbg.gif', onloadHandler);
        preloadImage(konferoHost + '/embeddedkonfero/images/preloader/cbb_br.png', onloadHandler);
    }

    function initializeKonfero() {
        if (isSafari && !isChrome && konferoNoUser && getFlashVersion() < 8) {
            location.replace(konferoHost + "/embeddedkonfero/safari4redirection?page=" + encodeURIComponent(location.href));
        }

        if (!icon) {
            initializeKonferoPreloader();
        }

        if (!window.konferoAnyWare) {
            if (!konferoUserInStandby) {
                setImgSrc(icon, konferoHost + '/embeddedkonfero/images/preloader/loading_5percent.gif');
            } else {
                setImgSrc(icon, konferoHost + '/embeddedkonfero/images/preloader/konferoStandby.png');
            }
        } else {
            if (konferoUserInStandby) {
                konferoAnyWare.SetKonferoState(ANYWARE_STATE_LOADING | ANYWARE_STATE_STANDBY);
            } else {
                konferoAnyWare.SetKonferoState(ANYWARE_STATE_LOADING);
                konferoAnyWare.AnimateKonferoButton(1);
            }
        }
        window.konferoLoading = true;

        konferoAppContainer = document.createElement('div');
        konferoAppContainer.id = 'konferoAppContainer';
        konferoAppContainer.style.cssText = 'position: absolute; top: 0; left: 0; width: 0; height: 0;';
        document.body.appendChild(konferoAppContainer);

        var konferoCss = document.createElement('link');
        konferoCss.setAttribute('rel', 'stylesheet');
        konferoCss.setAttribute('type', 'text/css');
        konferoCss.setAttribute('href', 'http://konfero.com:80/embeddedkonfero/Konfero.css?2419');
        document.getElementsByTagName('head')[0].appendChild(konferoCss);

        var konferoScript = document.createElement('script');
        konferoScript.setAttribute('type', 'text/javascript');
        konferoScript.setAttribute('src', 'http://konfero.com:80/embeddedkonfero/com.mirantis.konfero.web.application.Konfero.nocache.js');
        document.body.appendChild(konferoScript);

        if (konferoAnyWare && isIE8 && isQuirks) {
            var oldOnScroll = document.body.onscroll;
            document.body.onscroll = function(evt) {
                if (konferoAppContainer != null) {
                    konferoAppContainer.style.left = document.body.scrollLeft + 'px';
                    konferoAppContainer.style.top = document.body.scrollTop + 'px';
                }
                var retVal = oldOnScroll && oldOnScroll(evt);
                if (retVal) {
                    return retVal;
                }
            }
        }

        var connectionTimeoutTimer = setTimeout(function() {
            clearTimeout(connectionTimeoutTimer);
            if (window.konferoLoading) {
                window.konferoLoading = false;
                if (!window.konferoAnyWare) {
                    setImgSrc(icon, konferoHost + '/embeddedkonfero/images/preloader/konferoInactive.png');
                    document.body.removeChild(konferoAppContainer);
                    document.getElementsByTagName('head')[0].removeChild(konferoCss);
                    document.body.removeChild(konferoScript);
                    showMessageBubble(konferoUserLanguage == 'ru' ? "\u041f\u043e\u0434\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0435 \u043d\u0435\u0443\u0434\u0430\u0447\u043d\u043e." : "Connection failed. Try again.", true, 3000);
                } else {
                    window.konferoAnyWare.SetKonferoState(0);
                    window.konferoAnyWare.AnimateKonferoButton(0);
                }
            }
        }, 30 * 1000);
    }

    function getWindowClientWidth() {
        if (isOpera) {
            var docBody = (!isQuirks && opera.version() >= 9.5) ? document.documentElement : document.body;
            return docBody.clientWidth;
        } else {
            var docRoot = !isQuirks ? document.documentElement : document.body;
            return docRoot.clientWidth;
        }
    }

    function getWindowClientHeight() {
        if (isOpera) {
            var docBody = (!isQuirks && opera.version() >= 9.5) ? document.documentElement : document.body;
            return docBody.clientHeight;
        } else {
            var docRoot = !isQuirks ? document.documentElement : document.body;
            return docRoot.clientHeight;
        }
    }

    function setImgSrc(img, src) {
        if (isIE6minus) {
            img.src = konferoHost + '/embeddedkonfero/clear.cache.gif';
            img.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='image')";
        } else {
            img.src = src;
        }
    }

    function setElemPngBackground(elem, src, scale) {
        if (isIE6minus) {
            elem.style.filter = "progid:DXImageTransform.Microsoft.AlphaImageLoader(src='" + src + "', sizingMethod='" + (scale ? "scale" : "image") + "')";
        } else {
            elem.style.background = "url(" + src + ") " + (scale ? "repeat-x" : "no-repeat");
        }
    }

    function setCellAlign(td, horizontalAlign, verticalAlign) {
        if (horizontalAlign) {
            if (isIE) {
                td.style.textAlign = horizontalAlign;
            } else {
                td.align = horizontalAlign;
            }
        }
        if (verticalAlign) {
            td.style.verticalAlign = verticalAlign;
        }
    }

    function createMessageBubble() {
        if (messageBubble && messageBubbleText) return;
        var tlimg = document.createElement('img');
        setImgSrc(tlimg, konferoHost + '/embeddedkonfero/images/preloader/cbb_tl.png');
        var tl = document.createElement('td');
        tl.width = 5 + 'px';
        tl.height = 5 + 'px';
        setCellAlign(tl, 'right', 'bottom');
        tl.appendChild(tlimg);

        var tbg = document.createElement('td');
        tbg.style.background = 'url(' + konferoHost + '/embeddedkonfero/images/preloader/cbb_tbg.gif) repeat-x';

        var trimg = document.createElement('img');
        setImgSrc(trimg, konferoHost + '/embeddedkonfero/images/preloader/cbb_tr.png');
        var tr = document.createElement('td');
        tr.width = 5 + 'px';
        tr.height = 5 + 'px';
        setCellAlign(tr, 'left', 'bottom');
        tr.appendChild(trimg);

        var lbg = document.createElement('td');
        lbg.style.background = 'url(' + konferoHost + '/embeddedkonfero/images/preloader/cbb_lbg.gif) repeat-y';

        var texttd = document.createElement('td');
        texttd.style.background = 'white';
        setCellAlign(texttd, 'left', 'middle');

        messageBubbleText = document.createElement('div');
        messageBubbleText.style.marginTop = '-2px';
        messageBubbleText.style.lineHeight = 'normal';
        messageBubbleText.style.color = '#BC0000';
        messageBubbleText.style.fontFamily = 'Tahoma, Verdana, Helvetica, Arial, sans-serif';
        messageBubbleText.style.fontSize = '11px';
        texttd.appendChild(messageBubbleText);

        var rbg = document.createElement('td');
        rbg.style.background = 'url(' + konferoHost + '/embeddedkonfero/images/preloader/cbb_rbg.gif) repeat-y';

        var blimg = document.createElement('img');
        setImgSrc(blimg, konferoHost + '/embeddedkonfero/images/preloader/cbb_bl.png');
        var bl = document.createElement('td');
        bl.width = 5 + 'px';
        bl.height = 5 + 'px';
        setCellAlign(bl, 'right', 'top');
        bl.appendChild(blimg);

        var bbg = document.createElement('td');
        bbg.style.background = 'url(' + konferoHost + '/embeddedkonfero/images/preloader/cbb_bbg.gif) repeat-x';

        var brimg = document.createElement('img');
        setImgSrc(brimg, konferoHost + '/embeddedkonfero/images/preloader/cbb_br.png');
        var br = document.createElement('td');
        br.width = 11 + 'px';
        br.height = 13 + 'px';
        setCellAlign(br, 'left', 'bottom');
        br.appendChild(brimg);

        var ttr = document.createElement('tr');
        ttr.appendChild(tl);
        ttr.appendChild(tbg);
        ttr.appendChild(tr);

        var mtr = document.createElement('tr');
        mtr.appendChild(lbg);
        mtr.appendChild(texttd);
        mtr.appendChild(rbg);

        var btr = document.createElement('tr');
        btr.appendChild(bl);
        btr.appendChild(bbg);
        btr.appendChild(br);

        var tbody = document.createElement('tbody');
        tbody.appendChild(ttr);
        tbody.appendChild(mtr);
        tbody.appendChild(btr);

        messageBubble = document.createElement('table');
        messageBubble.cellPadding = '0';
        messageBubble.cellSpacing = '0';
        messageBubble.border = '0';
        messageBubble.style.display = 'none';
        messageBubble.style.position = 'absolute';
        messageBubble.style.left = '0px';
        messageBubble.style.top = '-1000px';
        messageBubble.style.zIndex = 100001;
        messageBubble.style.fontSize = '1px';
        messageBubble.style.lineHeight = '1px';

        messageBubble.appendChild(tbody);

        document.body.appendChild(messageBubble);
    }

    function showMessageBubble(message, red, timeout) {
        if (showMessageBubbleTimeout) {
            clearTimeout(showMessageBubbleTimeout);
        }
        if (!allMessageBubbleImagesLoaded) {
            showMessageBubbleTimeout = setTimeout(function() {
                showMessageBubble(message, red, timeout);
            }, 100);
            return;
        }
        createMessageBubble();
        messageBubbleText.innerHTML = message;
        messageBubbleText.style.color = red ? '#BC0000' : '#4A4D52';
        messageBubble.style.display = '';
        icon.style.display = '';
        if (isIE6minus || isIE && isQuirks) {
            messageBubble.fixedLeft = getWindowClientWidth() - 22 - 7 - 10 - messageBubble.offsetWidth + 6;
            messageBubble.fixedTop = getWindowClientHeight() - 22 - 3 - messageBubble.offsetHeight + 5;
            if (!isIE8) {
                messageBubble.style.setExpression("left", "(document.compatMode && document.compatMode=='CSS1Compat' ? document.documentElement.scrollLeft : document.body.scrollLeft) + this.fixedLeft");
                messageBubble.style.setExpression("top", "(document.compatMode && document.compatMode=='CSS1Compat' ? document.documentElement.scrollTop : document.body.scrollTop) + this.fixedTop");
                document.recalc(true);
            } else {
                messageBubble.style.left = document.body.scrollLeft + messageBubble.fixedLeft + 'px';
                messageBubble.style.top = document.body.scrollTop + messageBubble.fixedTop + 'px';
            }
        } else {
            messageBubble.style.position = 'fixed';
            messageBubble.style.left = getWindowClientWidth() - 22 - 7 - 10 - messageBubble.offsetWidth + 6 + 'px';
            messageBubble.style.top = getWindowClientHeight() - 22 - 3 - messageBubble.offsetHeight + 5 + 'px';
        }
        if (timeout) {
            setTimeout(hideMessageBubble, timeout);
        }
    }

    function hideMessageBubble() {
        if (!window.konferoLoading && !mouseOverIcon) {
            try {
                messageBubble.style.display = 'none';
            } catch (e) {
            }
        }
    }

    function initializeKonferoPreloader() {
        icon = document.createElement('img');
        icon.style.position = 'absolute';
        icon.style.zIndex = 100000;
        icon.style.width = 22 + 'px';
        icon.style.height = 22 + 'px';
        icon.style.cursor = 'pointer';
        if (konferoAnyWare) {
            icon.style.display = 'none';
        }
        setImgSrc(icon, konferoHost + '/embeddedkonfero/images/preloader/konferoInactive.png');
        icon.onmouseover = function() {
            if (!window.konferoLoading && !konferoUserInStandby) {
                setImgSrc(icon, konferoHost + '/embeddedkonfero/images/preloader/konferoActive.png');
                mouseOverIcon = true;
				if (!konferoKroogiMode) {
					showPeopleHereBubble(onlineUsersCountRequestId);
				}
            }
        }
        icon.onmouseout = function() {
            if (!window.konferoLoading && !konferoUserInStandby) {
                setImgSrc(icon, konferoHost + '/embeddedkonfero/images/preloader/konferoInactive.png');
                mouseOverIcon = false;
                if (!konferoKroogiMode) {
					hideMessageBubble();
				}
            }
        }
        icon.onclick = function() {
            icon.onclick = null;
            initializeKonfero();
        }
        document.body.appendChild(icon);
        if (isIE6minus || (isIE && isQuirks)) {
            icon.fixedLeft = getWindowClientWidth() - 22 - 7 - 10;
            icon.fixedTop = getWindowClientHeight() - 22 - 3;
            if (!isIE8) {
                icon.style.setExpression("left", "(document.compatMode && document.compatMode=='CSS1Compat' ? document.documentElement.scrollLeft : document.body.scrollLeft) + this.fixedLeft");
                icon.style.setExpression("top", "(document.compatMode && document.compatMode=='CSS1Compat' ? document.documentElement.scrollTop : document.body.scrollTop) + this.fixedTop");
                document.recalc(true);
            } else {
                icon.style.left = document.body.scrollLeft + icon.fixedLeft + 'px';
                icon.style.top = document.body.scrollTop + icon.fixedTop + 'px';
            }
        } else {
            icon.style.position = 'fixed';
            icon.style.left = getWindowClientWidth() - 22 - 7 - 10 + 'px';
            icon.style.top = getWindowClientHeight() - 22 - 3 + 'px';
        }

        if (konferoKroogiMode) {
            initializeKroogiPreloader();
        }
    }

    function initializeKroogiPreloader() {
        kroogiPreloader = document.createElement('table');
        var tbody = document.createElement('tbody');
        var tr = document.createElement('tr');
        var leftTd = document.createElement('td');
        kroogiPreloaderMidTd = document.createElement('td');
        var rightTd = document.createElement('td');

        kroogiPreloader.style.position = 'absolute';
        kroogiPreloader.style.zIndex = 100000 - 1;
        kroogiPreloader.cellSpacing = '0';
        kroogiPreloader.cellPadding = '0';
        kroogiPreloader.border = '0';
        kroogiPreloader.style.fontSize = '1px';
        kroogiPreloader.style.width = getWindowClientWidth() - 20 + 'px';
        kroogiPreloader.style.height = 28 + 'px';
        kroogiPreloader.style.cursor = 'default';

        leftTd.style.width = 3 + 'px';
        leftTd.innerHTML = '&nbsp;';
        setElemPngBackground(leftTd, konferoHost + '/embeddedkonfero/images/preloader/bar_left.png', false);

		setCellAlign(kroogiPreloaderMidTd, 'left', 'middle');
		setElemPngBackground(kroogiPreloaderMidTd, konferoHost + '/embeddedkonfero/images/preloader/bar_mid.gif', true);

        rightTd.style.width = 152 + 'px';
		rightTd.innerHTML = '&nbsp;';
        setElemPngBackground(rightTd, konferoHost + '/embeddedkonfero/images/preloader/bar_right.png', false);

        tr.appendChild(leftTd);
        tr.appendChild(kroogiPreloaderMidTd);
        tr.appendChild(rightTd);
        tbody.appendChild(tr);
        kroogiPreloader.appendChild(tbody);
        document.body.appendChild(kroogiPreloader);

        if (isIE6minus || (isIE && isQuirks)) {
            kroogiPreloader.fixedLeft = 10;
            kroogiPreloader.fixedTop = getWindowClientHeight() - 28;
            if (!isIE8) {
                kroogiPreloader.style.setExpression("left", "(document.compatMode && document.compatMode=='CSS1Compat' ? document.documentElement.scrollLeft : document.body.scrollLeft) + this.fixedLeft");
                kroogiPreloader.style.setExpression("top", "(document.compatMode && document.compatMode=='CSS1Compat' ? document.documentElement.scrollTop : document.body.scrollTop) + this.fixedTop");
                document.recalc(true);
            } else {
                kroogiPreloader.style.left = document.body.scrollLeft + kroogiPreloader.fixedLeft + 'px';
                kroogiPreloader.style.top = document.body.scrollTop + kroogiPreloader.fixedTop + 'px';
            }
        } else {
            kroogiPreloader.style.position = 'fixed';
            kroogiPreloader.style.left = 10 + 'px';
            kroogiPreloader.style.top = getWindowClientHeight() - 28 + 'px';
        }
    }

	function createKroogiProjectBlock(userCount) {
		var projectBlock = document.createElement('table');
		var tbody = document.createElement('tbody');
		var tr = document.createElement('tr');
		var tdProjectIcon = document.createElement('td');
		var tdProjectName = document.createElement('td');
		var tdUsersCount = document.createElement('td');
		var tdJoin = document.createElement('td');

		projectBlock.cellPadding = 0;
		projectBlock.cellSpacing = 0;
		projectBlock.border = 0;
		projectBlock.style.fontFamily = 'Tahoma, Verdana, Arial, Helvetica, sans-serif';
		projectBlock.style.fontSize = '11px';
		projectBlock.style.color = '#666666';
		projectBlock.style.lineHeight = 'normal';
		projectBlock.style.cursor = 'default';
		projectBlock.style.whiteSpace = 'nowrap';
		projectBlock.style.height = 28 + 'px';

		var projectIconSrc = konferoKroogiProjectAvatar ? konferoKroogiProjectAvatar :
							   konferoHost + '/embeddedkonfero/images/preloader/konferoInactive.png';
		var projectIcon = document.createElement('img');
		projectIcon.style.width = '22px';
		projectIcon.style.height = '22px';
		setImgSrc(projectIcon, konferoHost + '/embeddedkonfero/borderedImage?url=' + encodeURIComponent(projectIconSrc));
		setCellAlign(tdProjectIcon, 'left', 'middle');
		tdProjectIcon.appendChild(projectIcon);

		setCellAlign(tdProjectName, 'left', 'middle');
		tdProjectName.style.paddingLeft = '10px';
		tdProjectName.innerHTML = (konferoKroogiProjectName ? konferoKroogiProjectName :
								  (konferoChatRoomTitle ? konferoChatRoomTitle : getChatRoomName())) + ":&nbsp;";

		setCellAlign(tdUsersCount, 'left', 'middle');
		tdUsersCount.innerHTML = getUserCountMessage(userCount) + ".";

		var joinLink = document.createElement('div');
		joinLink.style.color = '#DD8003';
		joinLink.style.fontWeight = 'bold';
		joinLink.style.cursor = 'pointer';
		joinLink.innerHTML = getKroogiJoinMessage(userCount);
		joinLink.onclick = function() {
            joinLink.onclick = null;
            initializeKonfero();
		};

		setCellAlign(tdJoin, 'left', 'middle');
		tdJoin.style.paddingLeft = '10px';
		tdJoin.appendChild(joinLink);

		tr.appendChild(tdProjectIcon);
		tr.appendChild(tdProjectName);
		tr.appendChild(tdUsersCount);
		tr.appendChild(tdJoin);
		tbody.appendChild(tr);
		projectBlock.appendChild(tbody);
		return projectBlock;
	}

	function getKroogiJoinMessage(userCount) {
		if (userCount == 0) {
			return konferoUserLanguage == 'ru' ?
				   '\u041d\u0430\u0447\u0430\u0442\u044c \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440.' :
				   'Start the conversation.';
		} else {
			return konferoUserLanguage == 'ru' ?
				   '\u041f\u0440\u0438\u0441\u043e\u0435\u0434\u0438\u043d\u0438\u0442\u044c\u0441\u044f \u043a \u0440\u0430\u0437\u0433\u043e\u0432\u043e\u0440\u0443.' :
				   'Join the conversation.';
		}
	}

	function getUserCountMessage(userCount) {
		var sUserCount = '' + userCount;
		var message;
		if (userCount == 0) {
			message = konferoUserLanguage == 'ru' ? '\u043d\u0438\u043a\u043e\u0433\u043e \u043d\u0435\u0442' : 'nobody here';
		} else if (userCount == 1) {
			message = konferoUserLanguage == 'ru' ? '\u0437\u0434\u0435\u0441\u044c 1 \u0447\u0435\u043b\u043e\u0432\u0435\u043a' : '1 person here';
		} else {
			if (konferoUserLanguage == 'ru') {
				message = "\u0437\u0434\u0435\u0441\u044c " + userCount + " \u0447\u0435\u043b\u043e\u0432\u0435\u043a";
				var lastChar = sUserCount.charAt(sUserCount.length - 1);
				if ((lastChar == "2" || lastChar == "3" || lastChar == "4") &&
						(userCount < 12 || userCount > 14)) {
					message += "\u0430";
				}
			} else {
				message = userCount + " people here";
			}
		}
		return message;
	}

    function toCamelCase(value) {
		var arr = value.split('-'), cc = arr[0];
		for(var i = 1; i < arr.length; i++) {
			cc += arr[i].charAt(0).toUpperCase() + arr[i].substring(1);
		}
		return cc;
    }

    function toSelectorCase(value) {
		return value.replace(/([A-Z])/g, "-$1" ).toLowerCase() ;
    }

    function getCurrentStyle(node, styleName) {
        // cssSelector may actually be in camel case, so force selector version
        var cssSelector = toSelectorCase(styleName);
        var property = toCamelCase(styleName);
        if(!node || !node.style){
            return null;
        }else if(document.defaultView){ // W3, gecko, KHTML
            try{
                var cs = document.defaultView.getComputedStyle(node, "");
                if (cs){
                    return cs.getPropertyValue(cssSelector);
                }
            }catch(e){ // reports are that Safari can throw an exception above
                if (node.style.getPropertyValue){ // W3
                    return node.style.getPropertyValue(cssSelector);
                }else return null;
            }
        }else if(node.currentStyle){ // IE
            return node.currentStyle[property];
        }if(node.style.getPropertyValue){ // W3
            return node.style.getPropertyValue(cssSelector);
        }else{
            return null;
        }
    }

    window.konferoAjaxCallback = function(requestId, sUserCount) {
        if (requestId == onlineUsersCountRequestId || requestId == preloaderOnlineUsersCountRequestId) {
            setTimeout(function() {
                document.getElementsByTagName('head')[0].removeChild(scriptRpc);
                scriptRpc = null;
            }, 0);
            if (!window.konferoLoading && (mouseOverIcon || requestId == preloaderOnlineUsersCountRequestId)) {
                var userCount = parseInt(sUserCount);
                if (konferoKroogiMode) {
					kroogiPreloaderMidTd.appendChild(createKroogiProjectBlock(userCount));
				} else if (userCount > 0 || requestId == onlineUsersCountRequestId) {
					showMessageBubble(getUserCountMessage(userCount), userCount > 0, requestId == preloaderOnlineUsersCountRequestId ? 3000 : null);
				}
            }
        }
    };

    function showPeopleHereBubble(requestId) {
        if (scriptRpc == null) {
            scriptRpc = document.createElement('script');
            scriptRpc.type = 'text/javascript';
            scriptRpc.src = konferoHost + '/service/chat/getOnlineUsersCount?requestId=' + requestId + '&chatRoomName=' + encodeURIComponent(getChatRoomName());
            document.getElementsByTagName('head')[0].appendChild(scriptRpc);
        }
    }

	function getChatRoomName() {
		return konferoChatRoomUrl ? konferoChatRoomUrl : location.href;
	}

    function operaRequestAnyAliveInstance() {
        if (operaRequestAnyAliveInstanceScript) {
            document.getElementsByTagName('head')[0].removeChild(operaRequestAnyAliveInstanceScript);
        }
        operaRequestAnyAliveInstanceScript = document.createElement('script');
        operaRequestAnyAliveInstanceScript.type = 'text/javascript';
        operaRequestAnyAliveInstanceScript.src = konferoHost + '/embeddedkonfero/operaCheckAliveInstance?time=' + new Date().getTime();
        document.getElementsByTagName('head')[0].appendChild(operaRequestAnyAliveInstanceScript);
    }

    function init0() {
        if (initialized) return;

        initialized = true;
        if (isIE6minus || (isIE && isQuirks)) {
            var bodyBackgroundImage = getCurrentStyle(document.body, "backgroundImage");
            if (bodyBackgroundImage == null || bodyBackgroundImage.length == 0 || bodyBackgroundImage == "none") {
                document.body.style.backgroundImage = "url(" + konferoHost + "/embeddedkonfero/images/transparent_pix.gif)";
                document.body.style.backgroundRepeat = "repeat";
                document.body.style.backgroundAttachment = "fixed";
            }
        }

        createMessageBubble();
        initializeKonferoPreloader();

        if (isSafari && !isChrome && konferoAutoEnter && getFlashVersion() >= 8) {
            flashStorage = document.createElement('object');
            flashStorage.setAttribute('type', 'application/x-shockwave-flash');
            flashStorage.setAttribute('width', '0');
            flashStorage.setAttribute('height', '0');
            flashStorage.setAttribute('data', konferoHost + "/embeddedkonfero/flash/storage.swf");

            var srcParam = document.createElement('param');
            srcParam.setAttribute('name', 'allowScriptAccess');
            srcParam.setAttribute('value', 'always');
            flashStorage.appendChild(srcParam);

            var flashvarsParam = document.createElement('param');
            flashvarsParam.setAttribute('name', 'flashvars');
            flashvarsParam.setAttribute('value', 'host=' + konferoHost);
            flashStorage.appendChild(flashvarsParam);

            document.body.appendChild(flashStorage);
        } else if ((!konferoAvailable && konferoAutoEnter) || konferoForcedAutoEnter) {
            setTimeout(initializeKonfero, 0);
        } else if (konferoAvailable && isOpera) {
            operaRequestAnyAliveInstanceIframe = document.createElement('iframe');
            operaRequestAnyAliveInstanceIframe.src = konferoHost + "/embeddedkonfero/OperaRequestAnyAliveInstance.html";
            operaRequestAnyAliveInstanceIframe.style.cssText = 'position: absolute; top: -1000px; left: 0; width: 0; height: 0;';
            document.body.appendChild(operaRequestAnyAliveInstanceIframe);

            operaRequestAnyAliveInstanceIntervalStartTime = new Date().getTime();
            operaRequestAnyAliveInstance();
        } else {
            showPeopleHereBubble(preloaderOnlineUsersCountRequestId);
        }

        var oldOnResize = window.onresize;
        window.onresize = function(evt) {
            setTimeout(function() {
                if (isIE6minus || (isIE && isQuirks)) {
                    if (icon != null && icon.style.display != 'none') {
                        icon.fixedLeft = getWindowClientWidth() - 22 - 7 - 10;
                        icon.fixedTop = getWindowClientHeight() - 22 - 3;
                        if (isIE8) {
                            icon.style.left = document.body.scrollLeft + icon.fixedLeft + 'px';
                            icon.style.top = document.body.scrollTop + icon.fixedTop + 'px';
                        }
                    }
                    if (kroogiPreloader != null && kroogiPreloader.style.display != 'none') {
                        kroogiPreloader.fixedLeft = 10;
                        kroogiPreloader.fixedTop = getWindowClientHeight() - 28;
                        kroogiPreloader.style.width = getWindowClientWidth() - 20 + 'px';
                        if (isIE8) {
                            kroogiPreloader.style.left = document.body.scrollLeft + kroogiPreloader.fixedLeft + 'px';
                            kroogiPreloader.style.top = document.body.scrollTop + kroogiPreloader.fixedTop + 'px';
                        }
                    }
                    if (messageBubble != null && messageBubble.style.display != 'none') {
                        messageBubble.fixedLeft = getWindowClientWidth() - 22 - 7 - 10 - messageBubble.offsetWidth + 6;
                        messageBubble.fixedTop = getWindowClientHeight() - 22 - 3 - messageBubble.offsetHeight + 5;
                        if (isIE8) {
                            messageBubble.style.left = document.body.scrollLeft + messageBubble.fixedLeft + 'px';
                            messageBubble.style.top = document.body.scrollTop + messageBubble.fixedTop + 'px';
                        }
                    }
//                    if (!isIE8) {
//                        document.recalc(true);
//                    }
                } else {
                    if (icon != null && icon.style.display != 'none') {
                        icon.style.left = getWindowClientWidth() - 22 - 7 - 10 + 'px';
                        icon.style.top = getWindowClientHeight() - 22 - 3 + 'px';
                    }
                    if (kroogiPreloader != null && kroogiPreloader.style.display != 'none') {
                        kroogiPreloader.style.width = getWindowClientWidth() - 20 + 'px';
                        kroogiPreloader.style.left = 10 + 'px';
                        kroogiPreloader.style.top = getWindowClientHeight() - 28 + 'px';
                    }
                    if (messageBubble != null && messageBubble.style.display != 'none') {
                        messageBubble.style.left = getWindowClientWidth() - 22 - 7 - 10 - messageBubble.offsetWidth + 6 + 'px';
                        messageBubble.style.top = getWindowClientHeight() - 22 - 3 - messageBubble.offsetHeight + 5 + 'px';
                    }
                }
            }, 10);
            var retVal = oldOnResize && oldOnResize(evt);
            if (retVal) {
                return retVal;
            }
        }

        if (isIE6minus || isIE && isQuirks) {
            var oldOnScroll = document.body.onscroll;
            document.body.onscroll = function(evt) {
                if (isIE8) {
                    if (icon != null && icon.style.display != 'none') {
                        icon.style.left = document.body.scrollLeft + icon.fixedLeft + 'px';
                        icon.style.top = document.body.scrollTop + icon.fixedTop + 'px';
                    }
                    if (kroogiPreloader != null && kroogiPreloader.style.display != 'none') {
                        kroogiPreloader.style.left = document.body.scrollLeft + kroogiPreloader.fixedLeft + 'px';
                        kroogiPreloader.style.top = document.body.scrollTop + kroogiPreloader.fixedTop + 'px';
                    }
                    if (messageBubble != null && messageBubble.style.display != 'none') {
                        messageBubble.style.left = document.body.scrollLeft + messageBubble.fixedLeft + 'px';
                        messageBubble.style.top = document.body.scrollTop + messageBubble.fixedTop + 'px';
                    }
                    if (konferoAppContainer != null) {
                        konferoAppContainer.style.left = document.body.scrollLeft + 'px';
                        konferoAppContainer.style.top = document.body.scrollTop + 'px';
                    }
//                } else {
//                    document.recalc(true);
                }
                var retVal = oldOnScroll && oldOnScroll(evt);
                if (retVal) {
                    return retVal;
                }
            }
        }
    }

    function onPageReady() {
        preloadMessageBubbleImages();
        if (!window.konferoAnyWare) {
            init0();
        } else {
            if ((!konferoAvailable && konferoAutoEnter) || konferoForcedAutoEnter) {
                setTimeout(initializeKonfero, 0);
            }
        }
    }

    if (self == top) {
        if (document.addEventListener) {
            if (false) {
                konferoAnyWareProxyElement = document.createElement("konferoAnyWareProxyElement");
                document.body.appendChild(konferoAnyWareProxyElement);
            
                onPageReady();
            } else {
                document.addEventListener("DOMContentLoaded", function() {
                    onPageReady();
                }, false);
            }
        }

//        window.konferoAnyWareGetUserType = function() {
//            return window.konferoLoading ? (!konferoUserInStandby ? 4 : 1024) : 0; // refer AnywareStates class
//        }

        window.konferoAnyWareConnect = function(userStatus) {
            if (userStatus) {
                window.konferoAnyWareUserStatus = userStatus;
            }
            initializeKonfero();
        }

        window.konferoOperaCheckAliveInstanceResponse = function(value) {
            switch (value) {
                case 0: // no cookie
                    if (new Date().getTime() - operaRequestAnyAliveInstanceIntervalStartTime < operaRequestAnyAliveInstanceIntervalTimeout) {
                        setTimeout(operaRequestAnyAliveInstance, 500);
                    } else {
                        if (konferoAutoEnter && !window.konferoLoading && !konferoLoaded) {
                            initializeKonfero();
                        } else if (!konferoAutoEnter) {
                            showPeopleHereBubble(preloaderOnlineUsersCountRequestId);
                        }
                    }
                    break;
                case 1: // konfero available
                    showPeopleHereBubble(preloaderOnlineUsersCountRequestId);
                    break;
                case 2: // konfero unavailable
                    if (konferoAutoEnter && !window.konferoLoading && !konferoLoaded) {
                        initializeKonfero();
                    } else if (konferoAutoEnter) {
                        showPeopleHereBubble(preloaderOnlineUsersCountRequestId);
                    }
                    break;
            }
        }

        window.onKonferoFlash8StorageReady = function() {
            if (isSafari && !isChrome && flashStorage != null) {
                var konferoAvailableCookie = flashStorage.getItem("konferoAvailable");
                if ((konferoForcedAutoEnter || (konferoAvailableCookie != 'true' && konferoAutoEnter)) && !window.konferoLoading && !konferoLoaded) {
                    initializeKonfero();
                } else {
                    showPeopleHereBubble(preloaderOnlineUsersCountRequestId);
                }
                document.body.removeChild(flashStorage);
            }
        }

        var onBodyDoneTimerId = setInterval(function() {
            if (/loaded|complete/.test(document.readyState)) {
                onPageReady();
                clearInterval(onBodyDoneTimerId);
            }
        }, 50);

        if (isIE) {
            var oldOnUnload = window.onbeforeunload;
            window.onbeforeunload = function(ev) {
                if (window.konferoAnyWare) {
                    window.konferoAnyWare.ResetState();
                }
                if (oldOnUnload) {
                    oldOnUnload(ev);
                }
            }
            if (!window.konferoAnyWare) {
                checkAnyWareInterval = setInterval(function() {
                    if (window.konferoAnyWare) {
                        clearInterval(checkAnyWareInterval);
                        checkAnyWareInterval = undefined;

                        if (messageBubble != null) {
                            document.body.removeChild(messageBubble);
                            messageBubble = null;
                        }
                        if (icon != null) {
                            document.body.removeChild(icon);
                            icon = null;
                        }
                        if (kroogiPreloader != null) {
                            document.body.removeChild(kroogiPreloader);
                            kroogiPreloader = null;
                        }
                    }
                }, 100);
            }
        }
    }
})();