<?
session_start();
if (!isset($_SESSION['uid'])) {
    header("Location: index.php");
}
include("config.php");
?>
<html>
<head>
    <title>Ещё один БК...</title>
    <meta charset="utf-8">
    <script src="js/jquery-1.7.2.min.js"></script>
    <script type="text/javascript">
        function clearc() {
            if (document.F1.text.value == '') {
                if (confirm('Очистить окно чата?')) {
                    top.frames['chat'].document.all("mes").innerHTML = '';
                }
            } else {
                document.F1.text.value = '';
            }
            document.F1.text.focus();
        }
    </script>

    <?
    $my_us = mysql_fetch_assoc(mysql_query("SELECT `enter_game`, `id` FROM `users` WHERE `id` = '" . $_SESSION['uid'] . "' LIMIT 1"));
    if ($my_us['enter_game'] == 1) {
        $my_us['enter_game'] = 0;
        mysql_query("UPDATE `users` SET `enter_game` = '" . $my_us['enter_game'] . "' WHERE `id` = '" . $my_us['id'] . "' LIMIT 1");
        ?>
        <script>clearc();</script>
    <? } ?>
    <script type="text/javascript">
        var CtrlPress = false;

        var SoundOff = true;
        var VolumeControl = 25;

        function p(text, type) {
            top.frames['chat'].p(text, type);
        }

        function soundD() {
            if (top.frames['bottom'].document.getElementById('soundM').innerHTML == '' && SoundOff == false) {
                if (navigator.userAgent.match(/MSIE/)) {
                    musicTag = '<object id="flashsound" classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="1" height="1"><param name="movie" value="sound/sound.swf?LevelVolume=' + VolumeControl + '" /><param name="quality" value="high" /></object>';
                } else {
                    musicTag = '<embed name="flashsound" src="sound/sound.swf?LevelVolume=' + VolumeControl + '" quality="best" width="1" height="1" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
                }
                top.frames['bottom'].document.getElementById('soundM').innerHTML = musicTag;
            }
        }

        function AddTo(login) {
            if (CtrlPress) {
                login = login.replace('%', '%25');
                while (login.indexOf('+') >= 0) {
                    login = login.replace('+', '%2B');
                }
                while (login.indexOf('#') >= 0) {
                    login = login.replace('#', '%23');
                }
                while (login.indexOf('?') >= 0) {
                    login = login.replace('?', '%3F');
                }
                window.open('inf.php?login=' + login, '_blank')
            } else {
                var o = top.frames['main'].Hint3Name;
                if (top.frames['main'].Hint3Closed) {
                    var c = top.frames['main'].Hint3Closed;
                } else {
                    var c = false;
                }
                if ((o != null) && (o != "") && (c == false)) {
                    top.frames['main'].document.all(o).value = login;
                    top.frames['main'].document.all(o).focus();
                } else {
                    top.frames['bottom'].window.document.F1.text.focus();
                    top.frames['bottom'].document.forms[0].text.value = 'to [' + login + '] ' + top.frames['bottom'].document.forms[0].text.value;
                }
            }
        }

        function AddToPrivate(login, nolookCtrl) {
            if (CtrlPress && !nolookCtrl) {
                login = login.replace('%', '%25');
                while (login.indexOf('+') >= 0) {
                    login = login.replace('+', '%2B');
                }
                while (login.indexOf('#') >= 0) {
                    login = login.replace('#', '%23');
                }
                while (login.indexOf('?') >= 0) {
                    login = login.replace('?', '%3F');
                }
                window.open('inf.php?login=' + login, '_blank')
            } else {
                top.frames['bottom'].window.document.F1.text.focus();
                top.frames['bottom'].document.forms[0].text.value = 'private [' + login + '] ' + top.frames['bottom'].document.forms[0].text.value;
            }
        }

        function setCookie(name, value) {
            document.cookie = name + "=" + escape(value) + "; path=/";
        }

        function getCookie(Name) {
            var search = Name + "="
            if (document.cookie.length > 0) {
                offset = document.cookie.indexOf(search)
                if (offset != -1) {
                    offset += search.length
                    end = document.cookie.indexOf(";", offset)
                    if (end == -1) {
                        end = document.cookie.length
                    }
                    return unescape(document.cookie.substring(offset, end))
                }
            }
        }

        var rnd = Math.random();
        var delay = 12;
        var redHP = 0.33;
        var yellowHP = 0.66;
        var TimerOn = -1;
        var tkHP, maxHP;

        function setHP(value, max) {
            tkHP = value;
            maxHP = max;
            if (TimerOn >= 0) {
                clearTimeout(TimerOn);
                TimerOn = -1;
            }
            setHPlocal();
        }

        function setHPlocal() {
            if (tkHP > maxHP) {
                tkHP = maxHP;
            }

            var sz1 = Math.round((149 / maxHP) * tkHP);
            var sz2 = 150 - sz1;

            if (top.frames['main'].document.all("HP")) {
                top.frames['main'].document.HP1.width = sz1;
                top.frames['main'].document.HP2.width = sz2;
                if (tkHP / maxHP < redHP) {
                    top.frames['main'].document.HP1.src = 'i/1red.gif';
                } else {
                    if (tkHP / maxHP < yellowHP) {
                        top.frames['main'].document.HP1.src = 'i/1yellow.gif';
                    } else {
                        top.frames['main'].document.HP1.src = 'i/1green.gif';
                    }
                }
                var s = top.frames['main'].document.all("HP").innerHTML;
                top.frames['main'].document.all("HP").innerHTML = s.substring(0, s.lastIndexOf(':') + 1) + Math.round(tkHP) + "/" + maxHP;
            }
            tkHP = (tkHP + (maxHP / 100));
            if (tkHP < maxHP) {
                TimerOn = setTimeout('setHPlocal()', delay * 1000);
            } else {
                TimerOn = -1;
            }
        }


        var ChatTimerID = -1;
        var ChatDelay = 15;
        var ChatNormDelay = 15;
        var ChatSlowDelay = 60;
        var ChatOm = false;
        var ChatSys = false;
        var ChatSlow = false;
        var ChatTranslit = false;
        var lid = 0;

        function RefreshChat() {
            var s = '&lid=' + lid;
            if (ChatOm) {
                s = s + '&om=1';
            }
            if (ChatSys) {
                s = s + '&sys=1';
            }
            if (ChatTimerID >= 0) {
                clearTimeout(ChatTimerID);
            }
            ChatTimerID = setTimeout('RefreshChat()', ChatDelay * 1000);
            top.frames['refreshed'].location = 'ch.php?show=' + Math.random() + s;
        }

        function StopRefreshChat() {
            if (ChatTimerID >= 0) {
                clearTimeout(ChatTimerID);
            }
            ChatTimerID = -1;
        }

        function show_new(id) {
            top.frames['chat'].document.getElementById('' + id + '').style.color = "Red";
        }

        function NextRefreshChat() {
            if (ChatTimerID >= 0) {
                clearTimeout(ChatTimerID);
            }
            ChatTimerID = setTimeout('RefreshChat()', ChatDelay * 1000);
        }

        function srld() {
            top.frames['chat'].window.scrollBy(0, 65000);
        }

        function slid(newlid) {
            var o = top.frames['bottom'].F1;
            if (o) {
                lid = newlid;
                o.lid.value = newlid;
            }
        }

        var OnlineDelay = 12;
        var OnlineTimerOn = -1;
        var OnlineOldPosition = 0;
        var OnlineStop = true;

        function rld(now) {
            if (OnlineTimerOn < 0 || now) {
                var tm = now ? 2000 : OnlineDelay * 1000;
                OnlineTimerOn = setTimeout('onlineReload(' + now + ')', tm);
            }
        }

        function onlineReload(now) {
            if (OnlineTimerOn >= 0) {
                clearTimeout(OnlineTimerOn);
            }
            OnlineTimerOn = -1;
            if (!OnlineStop || now) {
                top.frames['online'].location = 'ch.php?online=' + Math.round(Math.random() * 100000);
            }
            rld();
        }

        var changeroom = 1;
        var localroom = 1;

        setInterval(function () {
            if (localroom != changeroom) {
                localroom = changeroom;
                top.frames['online'].location = 'ch.php?online=' + Math.round(Math.random() * 100000);
            }
        }, 5000);

        var ChatClearTimerID = -1;
        var ChatClearDelay = 900;
        var ChatClearSize = 10000;

        function RefreshClearChat() {
            if (ChatClearTimerID >= 0) {
                clearTimeout(ChatClearTimerID);
            }
            ChatClearTimerID = setTimeout('RefreshClearChat()', ChatClearDelay * 1000);
            var s = top.frames['chat'].document.all("mes").innerHTML;
            if (s.length > ChatClearSize) {
                var j = s.lastIndexOf('<br />', s.length - ChatClearSize);
                top.frames['chat'].document.all("mes").innerHTML = s.substring(j, s.length);
            }
        }

        var oldlocation = '';

        function cht(nm) {
            if (oldlocation == '') {
                oldlocation = top.frames['main'].location.href;
                var i = oldlocation.indexOf('?', 0);
                if (i > 0) {
                    oldlocation = oldlocation.substring(0, i);
                }
            }
            top.frames['main'].location = nm;
        }

        function returned() {
            if (oldlocation != '') {
                top.frames['main'].location = oldlocation + '?tmp=' + Math.random();
                oldlocation = '';
            } else {
                top.frames['main'].location = 'main.php?edit=' + Math.random();
            }
        }

        function myscroll() {
            OnlineOldPosition = top.frames['online'].document.body.scrollTop;
        }

        function CLR1() {
            top.frames["bottom"].document.F1.text.value = '';
            top.frames["bottom"].document.F1.text.focus();
        }

        function CLR2() {
            top.frames['chat'].document.all("mes").innerHTML = '';
            top.frames['chat'].document.all("oMenu").style.top = "0px";
        }

        function strt() {
            ChatTimerID = setTimeout('RefreshChat()', 1000);
            OnlineTimerOn = setTimeout('onlineReload(true)', 2 * 1000);
            ChatClearTimerID = setTimeout('RefreshClearChat()', ChatClearDelay * 1000);
        }

        function getInternetExplorerVersion() {
            var rv = -1;
            if (navigator.appName == 'Microsoft Internet Explorer') {
                var ua = navigator.userAgent;
                var re = new RegExp("MSIE ([0-9]{1,}[\.0-9]{0,})");
                if (re.exec(ua) != null) {
                    rv = parseFloat(RegExp.$1);
                }
            }
            if (rv == -1) {
                if (navigator.userAgent.match(/Trident\/7.0.*rv.*11\.0/)) return 1;
            }
            if (rv == -1) {
                if (navigator.appVersion.indexOf("MSIE 10") !== -1) return 1;
            }
            return rv;
        }

        var frmval = 1;
        var addstyle = "";
        if (getInternetExplorerVersion() != -1) {
            frmval = 0;
            addstyle = ' style="border-left: 1px solid #cccccc" ';
        }

        var user = getCookie("battle");
        if ((user == null) || (user == '')) {
            document.write('<BODY>Внимание! Вы или не ввели ваш логин/пароль на титульной странице или в вашем браузере отключена поддержка Cookie. Необходимо их включить (это абсолютно безопасно!) для продолжения игры.<BR>');
            document.write('В меню браузера Internet Explorer выберите "Сервис" => "Свойства обозревателя" перейдите на закладку "Конфиденциальность" и передвиньте ползунок в положение "Средний". И попробуйте снова зайти с <A HREF="/">титульной страницы</A>.<BR>В браузере IE версии 5 меню: "Сервис" => "Свойства обозревателя" => "Безопасность" => "Интернет" кнопка "Другой" => файлы "cookie"<BR>Если у вас IE 4-й версии, возможно вам не удастся зайти, с проблемой этой версии браузера мы работаем, но пока единственным решением является: обновление браузера до 5-й или 6-й версии.<BR>Если ничего не помогает, проверьте настройки вашего FireWall, если он установлен, то может не пропускать активные страницы и cookie.</BODY>');
        } else {
            document.write(
                '<frameset rows="37, *, 30, 5" FRAMEBORDER="0" BORDER="0" FRAMESPACING="0">' +
                '<frame src="top_menu.php" target="_top" scrolling="no" noresize="noresize" FRAMEBORDER="0" BORDER="0" FRAMESPACING="0" MARGINWIDTH="0" MARGINHEIGHT="0">' +
                '<frameset cols="9, *, 9" FRAMEBORDER="0" BORDER="0" FRAMESPACING="0">' +
                '<frame src="left.html" target="_top" scrolling="no" noresize="noresize" FRAMEBORDER="0" BORDER="0" FRAMESPACING="0" MARGINWIDTH="0" MARGINHEIGHT="0">' +
                '<frameset rows="72%, *, 0" FRAMEBORDER="1" BORDER="1" FRAMESPACING="0">' +
                '<frame name="main" src="main.php?top=' + rnd + '" style="border-bottom-width: 2px; border-bottom-style:solid; border-bottom-color:#B0B0B0">' +
                '<frameset cols="*,263">' +
                '<frame id="chat" name="chat" src="buttons.php?ch=' + rnd + '" target="_top" scrolling="yes" FRAMEBORDER="0" BORDER="0" FRAMESPACING="0" MARGINWIDTH="3" MARGINHEIGHT="3">' +
                '<frame name="online" src="ch.php?online=' + rnd + '" target="_blank" scrolling="yes" FRAMEBORDER=' + frmval + ' BORDER="0" FRAMESPACING="0" MARGINWIDTH="3" MARGINHEIGHT="0" ' + addstyle + '>' +
                '</frameset>' +
                '<frame name="refreshed" target="_top" scrolling="no" noresize="noresize" src="refreshed.html">' +
                '</frameset>' +
                '<frame src="right.html" target="_top" scrolling="no" noresize="noresize" FRAMEBORDER="0" BORDER="0" FRAMESPACING="0" MARGINWIDTH="0" MARGINHEIGHT="0">' +
                '</frameset>' +
                '<frame name="bottom" scrolling="no" noresize="noresize" src="buttons.php?' + rnd + '">' +
                '<frame src="bottom.html" target="_top" scrolling="no" noresize="noresize" FRAMEBORDER="0" BORDER="0" FRAMESPACING="0" MARGINWIDTH="0" MARGINHEIGHT="0">' +
                '</frameset>');
        }
    </script>
    <noscript>
        <meta content="MSHTML 5.00.2614.3500" name="GENERATOR"/>
        </head>
<body style="background-color: #dedede; margin: 0px; padding: 0px; text-align: center;">
<span style="color: Red;">Внимание!</span> В вашем браузере отключена поддержка JavaScript. Необходимо её включить (это
абсолютно безопасно!) для продолжения игры.<br/>В меню браузера Internet Explorer выберите "Сервис" =&gt; "Свойства
обозревателя" перейдите на закладку "Безопасность". Для зоны <b>Интернет</b> нажмите кнопку "Другой". Установите уровень
безопасности "Средний", этого достаточно. Или же, в списке параметров найдите раздел "Сценарии" и там нужно разрешить
выполнение Активных сценариев.</noscript>
</body>
</html>