<?php
session_start();
if ($_SESSION['uid'] == null) { header("Location: index.php"); }
include "config.php";
$user = mysql_fetch_array(mysql_query("SELECT * FROM `users` WHERE `id` = '".$_SESSION['uid']."' LIMIT 1"));
include "functions.php";
header("Cache-Control: no-cache");


if($_GET['header']) {
  die();
} elseif($_GET['ch'] != null) {
?>
<html>
<head>
<link rel="stylesheet" type="text/css" href="css/main.css" />
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<script type="text/javascript" src="js/ZeroClipboard.js"></script>
<script language="JavaScript" src="js/jquery.min.js"></script>
<script language="JavaScript" src="js/ch.js"></script>
<script language="JavaScript" src="js/sl2.js"></script>
<script language="JavaScript" src="js/chat.js"></script>
<script language="JavaScript" type="text/JavaScript">
function solo(n) {
  window.location.href = '/movement.php?path='+n+'&rnd='+Math.random();
}

function chts(nm) {
  top.frames['main'].location = 'give.php?undate=1';
}

function cht_s() {
  top.frames['main'].location = 'give.php';
}

function showtable(tblname) {
  hidesel(tblname);
  hidemenu(0);
  document.getElementById('menu'+tblname).style.visibility = 'visible';
  document.getElementById('menu'+tblname).style.width = '';
  document.getElementById('menu'+tblname).style.overflow = 'visible';
}

function hidesel(tblname) {
  for(var i = 1; i <= 5; i++) {
    if(i != tblname) {
      document.getElementById('el'+i).style.backgroundColor = '';
      document.getElementById('el'+i).style.color = '';
    }
  }
}

function hidemenu(time) {
  for(var i = 1; i <= 4; i++) {
    document.getElementById('menu'+i).style.visibility = 'hidden';
    document.getElementById('menu'+i).style.width = '1px';
    document.getElementById('menu'+i).style.overflow = 'hidden';
  }
}

function jumptopath(path, topframe) {
  var rnd = Math.random();
  if(!topframe) {
    top.frames['main'].location.href = ''+path+'&rand='+rnd;
  } else {
    top.location.href = ''+path+'&rand='+rnd;
  }
}

function loadpers() {
  document.getElementById('el4').style.backgroundColor = '#404040';
  document.getElementById('el4').style.color = '#FFFFFF';
  showtable('4');
}

function toold() {
  top.OnlineOld = true;
}
</script>
<style type="text/css">
a.hoversmile:hover {
  background-color: gray;
}

.ssm-smile {
  width:400px;
  height:140px;
  background-color:#f2f0f0;
  text-align: center;
  border: 2px groove black;
  opacity: 0.8; filter: alpha (opacity=80);
}

.ssm-smile-title {
  height:10px;
  font-size:120%;
  FONT-FAMILY:Tahoma;
  background:url(../i/smilestitle.gif);
}
.ssm-smile-body {
  padding: 5px;
  overflow-y:scroll;
  height: 110px;
}

.menu {
  background-color: #d2d0d0;
  border-color: #ffffff #626060 #626060 #ffffff;
  border-style: solid;
  border-width: 1px;
  position: absolute;
  left: 0px;
  top: 0px;
  visibility: hidden;
}

.menuItem {
  border: 0px solid #000000;
  color: #003388;
  display: block;
  font-family: MS Sans Serif, Arial, Tahoma,sans-serif;
  font-size: 8pt;
  font-weight: bold;
  padding: 2px 12px 2px 8px;
  text-decoration: none;
  cursor:pointer;
}

.menuItem:hover {
  background-color: #a2a2a2;
  color: #0066FF;
}

span {
  font-size: 10pt;
  font-family: Verdana, Arial, Helvetica, Tahoma, sans-serif;
  text-decoration: none;
  font-weight: bold;
  cursor: pointer;
}

.my_clip_button {
  border: 0px solid #000000;
  color: #003388;
  display: block;
  font-family: MS Sans Serif, Arial, Tahoma,sans-serif;
  font-size: 8pt;
  font-weight: bold;
  padding: 2px 12px 2px 8px;
  text-decoration: none;
}

.my_clip_button.hover {
  background-color: #a2a2a2;
  color: #0066FF;
}

.chheadpas {
	background:url(http://i.oldbk.com/i/chat/chat_passive.jpg);
	background-repeat:no-repeat;
	text-align: center;
}

.chheadact {
	background:url(http://i.oldbk.com/i/chat/chat_aaactive.jpg);
	background-repeat:no-repeat;
	text-align: center;	
}

.newspas {
	background:url(http://i.oldbk.com/i/chat/news_pass.gif);
	background-repeat:no-repeat;
	text-align: center;
	cursor:pointer;
	white-space: nowrap;
}

.newspasr {
	background:url(http://i.oldbk.com/i/chat/news_passr.gif);
	background-repeat:no-repeat;
	text-align: center;
	cursor:pointer;	
	white-space: nowrap;	
}

.newsact {
	background:url(http://i.oldbk.com/i/chat/news_active.gif);
	background-repeat:no-repeat;
	text-align: center;	
	cursor:pointer;	
	white-space: nowrap;	
}

.cho {
		background:url(http://i.oldbk.com/i/chat/x_bg.jpg);
}

.chmtext {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
	color: #8b8b8b;
	font-size: 10px;
	text-align: center;
	text-decoration:none

}

.chheadpas {
	cursor:pointer;
}

.chheadpas.chmtext:hover {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
	color: #1b1b1b;
	font-size: 10px;
	text-align: center;
	text-decoration:none;
}

.chmtext:visited {
	font-family: Verdana, Arial, Helvetica, sans-serif;
	font-weight: bold;
	color: #1b1b1b;
	font-size: 10px;
	text-align: center;
	text-decoration:none
}

.chheadpas:hover a {color:#000000;}
.chheadact:hover a {color:#8b8b8b;}
.chheadact a {color:#000000;}
.chheadact:hover a {color:#000000;}
.chheadact:hover a {cursor:default;}

.ssm-smile {
   width:400px;
   height:140px;
   background-color:#f2f0f0;
   text-align: center;
   border: 2px groove black;
   opacity: 0.8; filter: alpha (opacity=80);
}

</style>
<style>
#qsst {
	position:absolute;
	z-index:10000000;
	cursor:default;
	display:none;
	top:50px;
	left:50px;
}
#onbon {
	position:absolute;
	z-index:100;
	cursor:default;
	display:none;
	bottom:30px;
	left:18px;
}
#mini_qsst {
	position:absolute;
	z-index:100;
	cursor:default;
	display:none;
	bottom:10px;
	right:18px;
}
</style>
<div id="qsst"></div>
 <div id="mini_qsst" onClick="top.qn_slk()" style="cursor:pointer">
 

 
 </div>
<script>
function S(name) {
  var sData = top.frames['bottom'].window.document;
  sData.F1.text.focus();
  sData.F1.text.value = sData.F1.text.value + ':'+name+': ';
}

function SSm(name) {
  ssminput = top.frames['bottom'].document.getElementById('ssmtext');
  ssminput.focus();
  ssminput.value += ':'+name+': ';
}

var MsgArray = new Array();
var ImHelper = false;

function p(text, type) {
  if(type == 2 && text.indexOf("private") == -1) type = 1;
  MsgArray.push(new Array(text, type));

  if(MsgArray.length >= 350) {
	MsgArray.splice(0, 100);
	redraw = true;
  }

  var redraw = false;

  if(type == currenttab || (currenttab == 1 && CheckMask(type) && type != 6 && type != 8) || (currenttab == 6 && CheckMask2(type) && type != 8) || (type == 7 && currenttab != 99) || (currenttab == 8 && CheckMask3(type) && type != 6))  {
	document.getElementById("mes").innerHTML += text+"<BR>";
	if(redraw) { RedrawWindow(); }
    if(!top.OnlineOld) { document.getElementById("wtab"+type).style.color = "#1b1b1b"; }
  } else {
	if((viewmask[4] == 0 && !CheckMask(type) && type != 6) || (ImHelper && type == 6) || (viewmask[4] == 0 && ((currenttab >= 2 && currenttab <= 5) || (currenttab == 8)) && type != 6 && type != 8) || (viewmask[4] == 0 && currenttab == 6 && !CheckMask2(type) && type != 6)) {
	  if(type != 1 && type != 7) {
		if(!top.OnlineOld) { document.getElementById("wtab"+type).style.color = "#1b1b1b"; }
	  }
	}
  }
}

var currenttab = 1;
var viewmask = new Array(1, 1, 1, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0);
var showhelpalert = true;

function ctab(n) {
  if(n == currenttab) return;

  document.getElementById("wtab"+n).style.color = "#1b1b1b";

  if(currenttab == 99) {
	for(i = 2; i < 16; i++) {
	  val = document.getElementById("mask"+i).checked;
	  viewmask[i-2] = val;
	}
  }
  document.getElementById("ctab"+currenttab).className = "chheadpas";
  document.getElementById("ctab"+n).className = "chheadact";
  currenttab = n;
  RedrawWindow();

}


function clearfull() {
  if(confirm('Очистить весь чат?')) {
	clrchat();
  }
  document.getElementById("ClearMenu").style.display = "none";
}

function clearpanel() {
  MsgArray = new Array();
  if(currenttab == 1) {
    document.getElementById("mes").innerHTML = "";
  } else if(currenttab == 2) {
    document.getElementById("mes_private").innerHTML = "";
  } else if(currenttab == 3) {
    document.getElementById("mes_klan").innerHTML = "";
  } else if(currenttab == 4) {
    document.getElementById("mes_pal").innerHTML = "";
  } else if(currenttab == 5) {
    document.getElementById("mes_system").innerHTML = "";
  } else if(currenttab == 6) {
    document.getElementById("mes_help").innerHTML = "";
  } else if(currenttab == 8) {
    document.getElementById("mes_trade").innerHTML = "";
  }
  document.getElementById("ClearMenu").style.display = "none";
}

function clrchat() {
  MsgArray = new Array();	
  if((currenttab != 99) && (currenttab != 9)) {
    document.getElementById("mes").innerHTML = "";
    document.getElementById("mes_private").innerHTML = "";
    document.getElementById("mes_klan").innerHTML = "";
    document.getElementById("mes_pal").innerHTML = "";
    document.getElementById("mes_trade").innerHTML = "";
    document.getElementById("mes_system").innerHTML = "";
    document.getElementById("mes_help").innerHTML = "";
  }
}



function RedrawWindow() {
  if(currenttab == 1) {
    $('#mes').show();
    $('#mes_private').hide();
    $('#mes_klan').hide();
    $('#mes_pal').hide();
    $('#mes_trade').hide();
    $('#mes_system').hide();
    $('#mes_help').hide();
  } else if(currenttab == 2) {
    $('#mes').hide();
    $('#mes_private').show();
    $('#mes_klan').hide();
    $('#mes_pal').hide();
    $('#mes_trade').hide();
    $('#mes_system').hide();
    $('#mes_help').hide();   
  } else if(currenttab == 3) {
    $('#mes').hide();
    $('#mes_private').hide();
    $('#mes_klan').show();
    $('#mes_pal').hide();
    $('#mes_trade').hide();
    $('#mes_system').hide();
    $('#mes_help').hide();
  } else if(currenttab == 4) {
    $('#mes').hide();
    $('#mes_private').hide();
    $('#mes_klan').hide();
    $('#mes_pal').show();
    $('#mes_trade').hide();
    $('#mes_system').hide();
    $('#mes_help').hide();
  } else if(currenttab == 5) {
    $('#mes').hide();
    $('#mes_private').hide();
    $('#mes_klan').hide();
    $('#mes_pal').hide();
    $('#mes_trade').hide();
    $('#mes_system').show();
    $('#mes_help').hide();
  } else if(currenttab == 6) {
    $('#mes').hide();
    $('#mes_private').hide();
    $('#mes_klan').hide();
    $('#mes_pal').hide();
    $('#mes_trade').hide();
    $('#mes_system').hide();
    $('#mes_help').show();
  } else if(currenttab == 8) {
    $('#mes').hide();
    $('#mes_private').hide();
    $('#mes_klan').hide();
    $('#mes_pal').hide();
    $('#mes_trade').show();
    $('#mes_system').hide();
    $('#mes_help').hide();
  }

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

function CheckMask(tab) {
  if(viewmask[tab-2]) return true;
  return false;
}

function CheckMask2(tab) {
  if(viewmask[tab+3]) return true;
  return false;
}

function CheckMask3(tab) {
  if(viewmask[tab+8]) return true;
  return false;
}
</script>
<script src="js/jquery.cookie.js"></script>
</head>
<body leftmargin=0 topmargin=0 marginheight=0 marginwidth=0 bgcolor=#eeeeee onload="top.RefreshChat()" style="background: rgb(226, 224, 224);">
<div id="fixednew" style="position: fixed; margin: -3px; padding: 0px; z-index: 999; width: 100%; text-align: center; overflow: auto;">
  <table border="0" cellspacing="0" cellpadding="0" width="100%">
    <tr>
      <td background="http://i.oldbk.com/i/chat/x_bg.jpg" height="26">&nbsp;</a></td>
      <td nowrap width="26" height="26" background="http://i.oldbk.com/i/chat/chat_icon.jpg"></td>
	  <td nowrap width=115 height="26" id="ctab1" class="chheadact" onclick="ctab(1); return false;"><a href="#" id="wtab1" class="chmtext">Общий чат</a></td>
      <!--<td nowrap width=115 height="26" id="ctab2" class="chheadpas" onclick="ctab(2); return false;"><a href="#" id="wtab2" onclick="ctab(2); return false;" class="chmtext">Приваты</a></td>-->
      <? if($user['klan'] != '') { ?>
	    <!--<td nowrap width=115 height="26" id="ctab3" class="chheadpas" onclick="ctab(3); return false;"><a href="#" id="wtab3" onclick="ctab(3); return false;" class="chmtext">Клановый чат</a></td>-->
	  <? } ?>
      <? if((int)$user['align'] == 1 || $user['align'] == 1.5 || $user['align'] == 1.7 || $user['align'] == 1.75 || $user['align'] == 1.91 || $user['align'] == 1.92 || $user['align'] == 1.97 || $user['align'] == 1.98 || $user['align'] == 1.99 || $user['align'] == 2.99) { ?>
	    <td nowrap width=115 height="26" id="ctab4" class="chheadpas" onclick="ctab(4); return false;"><a href="#" id="wtab4" onclick="ctab(4); return false;" class="chmtext">Пал. чат</a></td>
	  <? } ?>
      <td nowrap width=115 height="26" id="ctab8" class="chheadpas" onclick="ctab(8); return false;"><a href="#" id="wtab8" onclick="ctab(8); return false;" class="chmtext">Торговый</a></td>	    
	  <td nowrap width=115 height="26" id="ctab5" class="chheadpas" onclick="ctab(5); return false;"><a href="#" id="wtab5" onclick="ctab(5); return false;" class="chmtext">Системные</a></td>
	  <!--<td nowrap width=115 height="26" id="ctab6" class="chheadpas" onclick="ctab(6); return false;"><a href="#" id="wtab6" onclick="ctab(6); return false;" class="chmtext">Помощь</a></td>-->
	  <td background="http://i.oldbk.com/i/chat/x_bg.jpg" height="26" width="100%">&nbsp;</a></td>
    </tr>
  </table>
</div>

<br style="margin: 0px; padding: 0px;" /><br />
<div style="margin-top: 10px; margin-left: 3px; margin-bottom: 10px; display: block;" id="mes"></div>
<div style="margin-top: 10px; margin-left: 3px; margin-bottom: 10px; display: none;" id="mes_private"></div>
<div style="margin-top: 10px; margin-left: 3px; margin-bottom: 10px; display: none;" id="mes_klan"></div>
<div style="margin-top: 10px; margin-left: 3px; margin-bottom: 10px; display: none;" id="mes_pal"></div>
<div style="margin-top: 10px; margin-left: 3px; margin-bottom: 10px; display: none;" id="mes_trade"></div>
<div style="margin-top: 10px; margin-left: 3px; margin-bottom: 10px; display: none;" id="mes_system"></div>
<div style="margin-top: 10px; margin-left: 3px; margin-bottom: 10px; display: none;" id="mes_help"></div>

<div id="oMenu"  style="position: absolute; border:1px solid #666; background-color:#CCC; display:none; "></div>
<div id="ClearMenu" style="position: absolute; border:1px solid #666; background-color: #e2e0e0; display: none;"></div>

<? } else {
    
  $now="night";
  if (date("H") <=5) {
    $tme=mktime(6, 1,0);
  } elseif (date("H")<22) {
    $tme=mktime(22, 1,0);
  } else {
    $tme=mktime (6, 1, 0, date("n"), date("j")+1,0);
  }
  $left=$tme-time();
?>
<html>
<head>
<meta content="text/html; charset=utf-8" http-equiv="Content-type" />
<script language="JavaScript" src="js/jquery-1.7.2.min.js"></script>
<script language="JavaScript" src="js/chat.js"></script>
<script language="JavaScript">

top.ChatTranslit = false;

var map_en = new Array('s`h','S`h','S`H','s`Х','sh`','Sh`','SH`',"'o",'yo',"'O",'Yo','YO','zh','w','Zh','ZH','W','ch','Ch','CH','sh','Sh','SH','e`','E`',"'u",'yu',"'U",'Yu',"YU","'a",'ya',"'A",'Ya','YA','a','A','b','B','v','V','g','G','d','D','e','E','z','Z','i','I','j','J','k','K','l','L','m','M','n','N','o','O','p','P','r','R','s','S','t','T','u','U','f','F','h','H','c','C','`','y','Y',"'")
var map_ru = new Array('сх','Сх','СХ','сХ','щ','Щ','Щ','ё','ё','Ё','Ё','Ё','ж','ж','Ж','Ж','Ж','ч','Ч','Ч','ш','Ш','Ш','э','Э','ю','ю','Ю','Ю','Ю','я','я','Я','Я','Я','а','А','б','Б','в','В','г','Г','д','Д','е','Е','з','З','и','И','й','Й','к','К','л','Л','м','М','н','Н','о','О','п','П','р','Р','с','С','т','Т','у','У','ф','Ф','х','Х','ц','Ц','ъ','ы','Ы','ь')

function convert(str) {
  for(var i = 0; i < map_en.length; ++i) while(str.indexOf(map_en[i])>=0) str = str.replace(map_en[i],map_ru[i]);
  return str;
}

function send(adm) {
  document.write(adm);
}

function defPosition2(event) {
  var isIE11 = navigator.userAgent.match(/Trident\/7.0.*rv.*11\.0/);
  var x = y = 0;
  if(document.attachEvent != null || isIE11) {
    x = window.event.clientX + (document.documentElement.scrollLeft ? document.documentElement.scrollLeft : document.body.scrollLeft);
    y = window.event.clientY + (document.documentElement.scrollTop ? document.documentElement.scrollTop : document.body.scrollTop);
    if(window.event.clientY + 10 > document.body.clientHeight) { y-=6 } else { y-=2 }
   } else if(!document.attachEvent && document.addEventListener) {
     x = event.clientX + window.scrollX;
     y = event.clientY + window.scrollY;
     if(event.clientY + 10 > document.body.clientHeight) { y-=6 } else { y-=2 }
   } else {

   }
   return {x:x, y:y};
}


function translate() {
    var strarr = new Array();
    strarr = document.F1.text.value.split(' ');
    for(var k=0;k<strarr.length;k++) {
        if(strarr[k].indexOf("http://") < 0 && strarr[k].indexOf('@') < 0 && strarr[k].indexOf("www.") < 0 && !(strarr[k].charAt(0)==":" && strarr[k].charAt(strarr[k].length-1)==":")) {
            if ((k<strarr.length-1)&&(strarr[k]=="to" || strarr[k]=="private")&&(strarr[k+1].charAt(0)=="[")) {
                while ( (k<strarr.length-1) && (strarr[k].charAt(strarr[k].length-1)!="]") ) k++;
            } else { strarr[k] = convert(strarr[k]) }
        }
    }
    document.F1.text.value = strarr.join(' ');
}

function trns() {
    var strarr = new Array();
    strarr = document.F1.text.value.split(' ');
    for(var k=0;k<strarr.length;k++) {
        if(strarr[k].indexOf("http://") < 0 && strarr[k].indexOf('@') < 0 && strarr[k].indexOf("www.") < 0 && !(strarr[k].charAt(0)==":" && strarr[k].charAt(strarr[k].length-1)==":")) {
            if ((k<strarr.length-1)&&(strarr[k]=="to" || strarr[k]=="private")&&(strarr[k+1].charAt(0)=="[")) {
                while ( (k<strarr.length-1) && (strarr[k].charAt(strarr[k].length-1)!="]") ) k++;
            } else { strarr[k] = convert(strarr[k]) }
        }
    }
    document.F1.text.value = strarr.join(' ');
}


function set_local(item, key) {
  try {
    localStorage.setItem(key, item);
    var localValue = localStorage.getItem(key);
    console.log(localValue);
  } catch(e) {
    if(e == QUOTA_EXCEEDED_ERR) {
      alert('Превышен лимит ...');
    }
  }
}

function sw_translit() {
  top.ChatTranslit = !top.ChatTranslit;
  if (top.ChatTranslit) {
    document.all('b___translit').src = b___translit_on.src;
    document.all('b___translit').alt = b___translit_on.alt;
  } else {
    document.all('b___translit').src = b___translit_off.src;
    document.all('b___translit').alt = b___translit_off.alt;
   }
}

function sw_filter() {
  top.ChatOm = !top.ChatOm;
  if (top.ChatOm) { 
    document.all('b___filter').src = b___filter_on.src; 
    document.all('b___filter').alt = b___filter_on.alt;
    document.F1.om.value = '1';
   } else { 
    document.all('b___filter').src = b___filter_off.src; 
    document.all('b___filter').alt = b___filter_off.alt;
    document.F1.om.value = '';
  }
}

function sw_sys() {
  top.ChatSys = ! top.ChatSys;
  if (top.ChatSys) {
    document.all('b___sys').src = b___sys_on.src; 
    document.all('b___sys').alt = b___sys_on.alt;
    document.F1.sys.value = '1';
  } else { 
    document.all('b___sys').src = b___sys_off.src; 
    document.all('b___sys').alt = b___sys_off.alt;
    document.F1.sys.value = '';
  }
}

function sw_slow() {
  if(top.ChatSlow) {
    if(top.ChatTimerID >= 0) {
      top.StopRefreshChat();
      document.all('b___slow').src = b___chat_off.src; document.all('b___slow').alt = b___chat_off.alt; 
    } else {
      top.ChatSlow = false;
      top.ChatDelay=top.ChatNormDelay;
      top.RefreshChat();
      document.all('b___slow').src = b___slow_off.src; document.all('b___slow').alt = b___slow_off.alt; 
    }
  } else {
    top.ChatSlow = true;
    document.all('b___slow').src = b___slow_on.src; document.all('b___slow').alt = b___slow_on.alt; 
    top.ChatDelay=top.ChatSlowDelay;
    top.RefreshChat();
  }
}

function subm() {
  t = top.frames['chat'].currenttab;
  $('input[name="chtype"]:hidden').val(t);
  if(top.ChatTranslit) { translate(); }
}

var b___translit_on = new Image; b___translit_on.src="i/b___translit_on.gif"; b___translit_on.alt="(включено) Преобразовывать транслит в русский текст";
var b___translit_off = new Image; b___translit_off.src="i/b___translit_off.gif"; b___translit_off.alt="(выключено) Преобразовывать транслит в русский текст";
var b___filter_on = new Image; b___filter_on.src="i/b___filter_on.gif"; b___filter_on.alt="(включено) Показывать в чате только сообщения адресованные мне";
var b___filter_off = new Image; b___filter_off.src="i/b___filter_off.gif"; b___filter_off.alt="(выключено) Показывать в чате только сообщения адресованные мне";
var b___sys_on = new Image; b___sys_on.src="i/b___sys_on.gif"; b___sys_on.alt="(включено) Показывать в чате системные сообщения";
var b___sys_off = new Image; b___sys_off.src="i/b___sys_off.gif"; b___sys_off.alt="(выключено) Показывать в чате системные сообщения";
var b___slow_on = new Image; b___slow_on.src="i/b___slow_on.gif"; b___slow_on.alt="(включено) Медленное обновление чата (раз в минуту)";
var b___slow_off = new Image; b___slow_off.src="i/b___slow_off.gif"; b___slow_off.alt="(выключено) Медленное обновление чата (раз в минуту)";
var b___chat_off = new Image; b___chat_off.src="i/b___chat_off.gif"; b___chat_off.alt="Обновление чата выключено!";

function IsIE(elem) {
  ss = top.frames['chat'].document.getElementById('mes').offsetHeight;
  if(ss > 0 && (ss-140) > 0) {
    ss -= 144;
  }
  elem.style.position = 'absolute';
  elem.style.top = ss+'px';
}

function smiles() {
  if (document.all && document.all.item && !window.opera && !document.layers) {
    var x = event.screenX - 150;
    var y = event.screenY - 320;
    var sFeatures = 'dialogLeft:'+x+'px;dialogTop:'+y+'px;dialogHeight:310px;dialogWidth:300px;help:no;status:no;unadorned:yes';
    window.showModelessDialog("smiles.html", window, sFeatures);
  } else {
    var sm = new Array("horse",60,40,  "hug",48,20, "laugh",15,15,  "susel",70,34 , "fingal",22,15,  "eek",15,15, "flowers",28,29, "smoke",20,20,  "hi",31,28,  "bye",15,15,
    "king",21,22, "king2",28,24, "boks2",28,21, "boks",62,28,  "gent",15,21,  "lady",15,19,  "tongue",15,15,  "smil",16,16,  "rotate",15,15,
    "ponder",21,15,  "bow",15,21, "smile",18,18, "angel",42,23, "angel2",26,25,  "hello",25,27,  "dont",26,26,  "idea",26,27,  "mol",27,22,  "super",26,28,
    "beer",15,15,  "drink",19,17,  "baby",15,18,  "tongue2",15,15,  "sword",49,18,  "agree",37,15, "loveya",27,15,  "kiss",15,15,  "kiss2",15,15,  "kiss3",15,15,  "kiss4",37,15,  "rose",15,15,  "love",27,28,
    "love2", 55,24, "inv",80,20, "confused",15,22,  "yes",15,15,  "no",15,15,  "shuffle",15,20,  "nono",22,19,  "maniac",70,25,  "privet",27,29,  "ok",22,16,  "ninja",15,15,
    "pif",46,26,  "smash",30,26,  "alien",13,15,  "pirate",23,19,  "gun",40,18,  "trup",20,20, "mdr",56,15,  "sneeze",15,20,  "mad",15,15,  "friday",57,28,  "cry",16,16,  "grust",15,15,  "rupor",38,18,
    "fie",15,15,  "nnn",82,16,  "row",36,15,  "red",15,15,  "lick",15,15, "help",23,15,  "wink",15,15, "jeer",26,16, "tease",33,19, "str", 35, 25, "kruger",34,27, "girl",37,26, "Knight1",69,37, "rev",40,25, "smile100",44,39, "smile118",25,25, 
    "smile149", 54,37, "smile166",46,29, "smile237",35,35, "smile245",50,30, "smile28",33,34, "smile289",46,31, "smile314",36,29, "smile36",50,46, "smile39",46,48,
    "smile44",27,26, "smile70",50,32 );

function createMessage(title, body) {
  var container = document.createElement('div');
  var i = 0;
  body = '';
  while(i < sm.length) {
    var s = sm[i++];
    body +='<a class="hoversmile" href="javascript: void(0);" onClick="SSm(\''+s+'\')"><IMG SRC=i/smiles/'+s+'.gif WIDTH='+sm[i++]+' HEIGHT='+sm[i++]+' BORDER=0 ALT="" ></a>';
  }
  container.innerHTML = '<div id="ssmsmilediv" class="ssm-smile"><div class="ssm-smile-body">'+body+'</div><input class="ssm-smile-ok" type="button" value="Закрыть"/></div>';
  return container.firstChild;
}

function positionMessage(elem) {
  var ua = navigator.userAgent.toLowerCase();
  if (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1) {
    IsIE(elem);
  } else {
    elem.style.position = 'fixed'; 
    elem.style.bottom =0+'px';
  }
  elem.style.right = 2+'px';
}

function addCloseOnClick(messageElem) {
  var input = messageElem.getElementsByTagName('INPUT')[0];
  input.onclick = function() {
  messageElem.parentNode.removeChild(messageElem);
  }
}

function setupMessageButton(title, body) {
  var messageElem = createMessage(title, body);
  positionMessage(messageElem);
  addCloseOnClick(messageElem);
  top.frames['chat'].document.body.appendChild(messageElem);
}

try {
  el = top.frames['chat'].document.getElementById('ssmsmilediv');
  el.parentNode.removeChild(el);
} catch(err) {

}

setupMessageButton('Смайлики ;)', '');
}
}

function rslength() { // изменяет размер строки ввода текста
  var size = document.body.clientWidth-(2*30)-66-256-30;
  if (size<100) { size=100 }
  document.F1.text.width = size;
  document.all('T2').width = size;
}

function clearc() {
  if (document.forms[0].text.value == '') {
    if(confirm('Очистить окно чата?')) top.frames['chat'].document.all("mes").innerHTML='';
  } else { document.F1.text.value=''; }
  document.F1.text.focus();
}

function clearnew(evt) {
  if(document.forms[0].text.value == '') {
    menu = top.frames['chat'].document.getElementById("ClearMenu");
    if(menu.style.display == "none") {
      evt = evt || window.event;
      evt.cancelBubble = true;
                
      var html = '<p style="margin: 10px;"><input type="button" style="cursor: pointer;" onclick="clearfull();" value="Очистить весь чат" /><br style="margin-top: 5px;"> \
				  <input type="button" style="font-weight: bold; cursor: pointer;" onclick="clearpanel();" value="Очистить текущую вкладку" /><br style="margin-top: 5px;"> \
		          <input type="button" style="cursor: pointer;" value="Отменить" onclick="top.frames[\'chat\'].document.getElementById(\'ClearMenu\').style.display=\'none\';" /><br style="margin-top: 5px;"></p> \
      ';

	  if(html) {
        menu.innerHTML = html;
        var ua = navigator.userAgent.toLowerCase();
        if(false) {
		  ss = top.frames['chat'].document.getElementById('mes').offsetHeight;
          if(ss > 0 && (ss-140) > 0) ss -= 144;
		  menu.style.position = 'absolute';
		  menu.style.top=ss+'px';
		} else {
		  menu.style.position = 'fixed';
		  menu.style.bottom =0+'px';
		}

		menu.style.left = defPosition2(evt).x + "px";
		menu.style.display = "";
	  }
	} else {
	  menu.style.display = "none";
	}
  } else { 
	document.F1.text.value=''; 
  }
  document.F1.text.focus();
}


window.onresize = rslength;

</script>

<script language="VBScript">
sub flashsound_FSCommand(byval command, byval args)
call flashsound_DoFSCommand(command, args) 
end sub
</script>

<script language=JavaScript>
function flashsound_DoFSCommand(command, args) {
  top.frames['bottom'].document.getElementById('soundM').innerHTML = '';
}

function SoundB() {
  if (top.SoundOff==true)
    top.frames['bottom'].document.getElementById('but_sound').src = 'i/zvuk.gif';
  else top.frames['bottom'].document.getElementById('but_sound').src = 'i/zvuk_off.gif';
    top.SoundOff=!top.SoundOff;
}

</script>
</head>

<body leftmargin=0 topmargin=0 marginheight=0 marginwidth=0 bgcolor=#E6E6E6 onload="top.strt();"> <!-- rslength(); -->

<form action="ch.php" target="refreshed" method="GET" name="F1" id="F1" onsubmit="subm(); top.NextRefreshChat();">
<input type="hidden" name="color" value="000000" />
<input type="hidden" name="sys" value="" />
<input type="hidden" name="om" value="" />
<input type="hidden" name="lid" value="" />
<input type="hidden" name="chtype" value="0" />

<table width="100%" height="30" cellspacing="0" cellpadding="0">
    <tr valign="top" style="background-image:url(i/buttons/beg_chat_03.gif); background-position: top; background-repeat:repeat-x; ">
      <td width="9"><img src="i/buttons/bkf_l_r1_02.gif" width="9" height="30"></td>
<td width="30"><IMG SRC="i/buttons/b___.gif" WIDTH=30 HEIGHT=30 BORDER=0 ALT="Чат"></td>

<div id="soundM" style="position:absoluite;"></div>
<div id="soundM2" style="position:absoluite;"></div>



<td valign="middle" id="T2">
<input class="sms_txt" type="text" id="ssmtext" name="text" maxlength="300" size="100" style="width: 100%;" autocomplete="off" placeholder="Введите текст сообщения" />
</TD>
<td nowrap id="T3">
<a href="javascript:void(0)" onclick="if(top.ChatTranslit) { trns(); } document.forms[0].submit()" title="Добавить текст в чат"><IMG SRC="i/buttons/b___ok.gif" WIDTH=30 HEIGHT=30 BORDER=0 ALT="Добавить текст в чат"></a><IMG SRC="i/buttons/1x1.gif" WIDTH="8" HEIGHT="1" BORDER=0 ALT="">

<a href="javascript:void(0)" onclick="clearnew(event);" title="Очистить строку ввода"><IMG SRC="i/buttons/b___clear.gif" WIDTH=30 HEIGHT=30 BORDER=0 ALT="Очистить строку ввода"></a><a href="javascript:void(0)" onclick="sw_filter();" title="(выключено) Показывать в чате только сообщения адресованные мне"><IMG SRC="i/buttons/b___filter_off.gif" WIDTH=30 HEIGHT=30 BORDER=0 name="b___filter" ALT="(выключено) Показывать в чате только сообщения адресованные мне"></a><a href="javascript:void(0)" onclick="sw_sys();" title="(выключено) Показывать в чате системные сообщения"><IMG SRC="i/buttons/b___sys_off.gif" WIDTH=30 HEIGHT=30 BORDER=0 name="b___sys" ALT="(выключено) Показывать в чате системные сообщения"></a><a href="javascript:void(0)" onclick="sw_slow();" title="(выключено) Медленное обновление чата (раз в минуту)"><IMG SRC="i/buttons/b___slow_off.gif" WIDTH=30 HEIGHT=30 BORDER=0 name="b___slow" ALT="(выключено) Медленное обновление чата (раз в минуту)"></a><img src="i/buttons/b___translit_off.gif" alt="(выключено) Преобразовывать транслит в русский текст (правила перевода см. в энциклопедии)" name="b___translit" width="30" height="30" id="b___translit" style="cursor: hand;" onclick="sw_translit();"><a href="javascript:void(0)" onclick="SoundB()" title="Звуки"><IMG SRC="i/buttons/zvuk_off.gif" id="but_sound" WIDTH=30 HEIGHT=30 BORDER=0></a><a href="javascript:void(0)" onclick="smiles()" title="Смайлики"><IMG SRC="i/buttons/1x1.gif" WIDTH="8" HEIGHT="1" BORDER=0 ALT=""><IMG SRC="i/buttons/b___smile.gif" WIDTH=30 HEIGHT=30 BORDER=0 ALT="Смайлики"></a>
</TD>
<td width="19" id="T4" background="i/buttons/b___bg2.gif"><img src="i/buttons/b___1.gif" width="19" height="30" alt="" /></td>
<td align="right" nowrap="nowrap" bgcolor="BAB7B3" id="T5" background="i/buttons/b___bg2.gif">
<?php
echo "<a href=\"javascript:void(0)\" title=\"Настройки/Инвентарь\"><IMG SRC=\"/i/$now/a___inv.gif\" WIDTH=30 HEIGHT=30 BORDER=0 ALT=\"Настройки/Инвентарь\" onclick=\"top.cht('main.php?edit='+Math.random())\"></a>";
echo "<a href=\"javascript:void(0)\" title=\"Реликты\"><IMG SRC=\"/design/i/buttons/otheralign.png\" WIDTH=30 HEIGHT=30 BORDER=0 ALT=\"Реликты\" onclick=\"top.cht('relikt.php?edit='+Math.random())\"></a>";

#echo "<a class=\"buttons\" href=\"javascript:void(0)\" title=\"Сделки\"><img src=\"i/deal.png\" width=30 height=30 border=0 onclick=\"top.cht('deal.php?edit='+Math.random())\" /></a>";


if ($user['level'] > 1) {
  echo "<a class=\"buttons\" href=\"javascript:void(0)\" title=\"Друзья\"><img src=\"i/friend.gif\" width=30 height=30 border=0 onclick=\"top.cht('friend.php?edit='+Math.random())\" /></a>";
}

if ($user['level'] > 3) {
  echo "<a class=\"buttons\" href=\"javascript:void(0)\" onclick=\"top.cht('give.php')\" title=\"Передачи\"><img src=\"i/b__give.gif\" width=30 height=30 border=0 /></a>";
}

if ($user['klan']) {
  echo "<a class=\"buttons\" href=\"javascript:void(0)\" onclick=\"top.cht('klan.php?'+Math.random())\" title=\"Клан\"><img src=\"i/clan.gif\" width=30 height=30 border=0 /></a>";
}

if ($user['klan']) {
  #echo "<a class=\"buttons\" href=\"javascript:void(0)\" onclick=\"top.cht('__modules/clan_panel.php?'+Math.random())\" title=\"Клан\"><img src=\"i/clan.gif\" width=30 height=30 border=0 /></a>";
}


if ($user['deal']==1) {
  echo "<a class=\"buttons\" href=\"javascript:void(0)\" onclick=\"top.cht('orden.php')\" title=\"Дилерская панель\"><IMG SRC=\"i/chatalign_7.gif\" WIDTH=30 HEIGHT=30 BORDER=0 /></a>";
} elseif ((($user['align']>1) && ($user['align']<2)) || (($user['align']>2) && ($user['align']<3))) {
  echo "<a class=\"buttons\" href=\"javascript:void(0)\" onclick=\"top.cht('palklan.php?'+Math.random())\" title=\"Клан\"><img src=\"i/clan.gif\" width=30 height=30 border=0 /></a>";
  echo "<a class=\"buttons\" href=\"javascript:void(0)\" onclick=\"top.cht('orden.php')\" title=\"Склонность\"><img src=\"i/a___pal.gif\" width=30 height=30 border=0 /></a>";
} elseif ($user['align']==2 || $user['align']==8.31) {
  echo "<a class=\"buttons\" href=\"javascript:void(0)\" onclick=\"top.cht('orden.php')\" title=\"Склонность\"><img src=\"i/chatalign_2.gif\" width=30 height=30 border=0 /></a>";
} elseif ($user['align']==3) {
  echo "<a class=\"buttons\" href=\"javascript:void(0)\" onclick=\"top.cht('orden.php')\" title=\"Склонность\"><img src=\"i/chatalign_3.gif\" width=30 height=30 border=0 /></a>";
} elseif ($user['align']==6) {
  echo "<a class=\"buttons\" href=\"javascript:void(0)\" onclick=\"top.cht('orden.php')\" title=\"Склонность\"><img src=\"i/chatalign_6.gif\" width=30 height=30 border=0 /></a>";
}

if ((($user['align']>7) && ($user['align']<8))) {
  echo "<a class=\"buttons\" href=\"javascript:void(0)\" onclick=\"top.cht('orden.php')\" title=\"Панель сенатора\"><img src=\"i/a___vip.gif\" width=30 height=30 border=0 /></a>";
}

echo "<a class=\"buttons\" href=\"/forum.php\" target=\"_blank\" title=\"Форум\"><img src=\"i/a__forum.gif\" width=30 height=30 border=0 /></a>";

$CH = date("H");
$CM = date("i");
$CS = date("s");
?>
<a href="javascript:void(0)" title="Выход из игры"><IMG SRC="/i/<?=$now?>/a___ext.gif" WIDTH=30 HEIGHT=30 BORDER=0 onclick="if (confirm('Выйти из игры?')) top.window.location='index.php?exit=0.560057875997465'"></a></TD>
<td width="70" valign="middle" background="/i/<?=$now?>/b___bg2.gif" bgcolor="BAB7B3" id="T6">
<script>
    var html='';
        if (navigator.userAgent.match(/MSIE/)) {
            // IE gets an OBJECT tag
            html += '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="70" height="26"><param name="movie" value="<?=IMGBASE?>/i/clock.swf?hours=<?=date("H")?>&minutes=<?=date("i")?>&sec=<?=date("s")?>" /><param name="quality" value="high" /></object>';
        }
        else {
            // all other browsers get an EMBED tag
            html += '<embed src="http://old-combats.com/flash/clock.swf?hours=<?=$CH?>&minutes=<?=$CM?>&sec=<?=$CS?>" quality="best" width="70" height="26" allowScriptAccess="always" allowFullScreen="false" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
        }
        document.write(html);
</script>
</td>
<td width="9" valign="middle" background="/i/<?=$now?>/b___bg2.gif" bgcolor="BAB7B3"><img src="/i/<?=$now?>/bkf_l_r1_06.gif" width="9" height="30"></td>

</TR>
</TABLE>



<script language="JavaScript">
var user = top.getCookie("ChatColor");
if ((user != null)&&(user != "")) document.F1.color.value = user;



function smiles(){
if (document.all && document.all.item && !window.opera && !document.layers){
   var x = event.screenX - 150;
   var y = event.screenY - 320;
   var sFeatures = 'dialogLeft:'+x+'px;dialogTop:'+y+'px;dialogHeight:310px;dialogWidth:300px;help:no;status:no;unadorned:yes';
   window.showModelessDialog("smiles.html?", window, sFeatures);
}
else{ 
var sm = new Array("horse",60,40,  "hug",48,20, "laugh",15,15,  "susel",70,34 , "fingal",22,15,  "eek",15,15, "flowers",28,29, "smoke",20,20,  "hi",31,28,  "bye",15,15,
    "king",21,22, "king2",28,24, "boks2",28,21, "boks",62,28,  "gent",15,21,  "lady",15,19,  "tongue",15,15,  "smil",16,16,  "rotate",15,15,
    "ponder",21,15,  "bow",15,21, "smile",18,18, "angel",42,23, "angel2",26,25,  "hello",25,27,  "dont",26,26,  "idea",26,27,  "mol",27,22,  "super",26,28,
    "beer",15,15,  "drink",19,17,  "baby",15,18,  "tongue2",15,15,  "sword",49,18,  "agree",37,15, "loveya",27,15,  "kiss",15,15,  "kiss2",15,15,  "kiss3",15,15,  "kiss4",37,15,  "rose",15,15,  "love",27,28,
    "love2", 55,24, "inv",80,20, "confused",15,22,  "yes",15,15,  "no",15,15,  "shuffle",15,20,  "nono",22,19,  "maniac",70,25,  "privet",27,29,  "ok",22,16,  "ninja",15,15,
    "pif",46,26,  "smash",30,26,  "alien",13,15,  "pirate",23,19,  "gun",40,18,  "trup",20,20, "mdr",56,15,  "sneeze",15,20,  "mad",15,15,  "friday",57,28,  "cry",16,16,  "grust",15,15,  "rupor",38,18,
    "fie",15,15,  "nnn",82,16,  "row",36,15,  "red",15,15,  "lick",15,15, "help",23,15,  "wink",15,15, "jeer",26,16, "tease",33,19, "str", 35, 25, "kruger",34,27, "girl",37,26, "Knight1",69,37, "rev",40,25, "smile100",44,39, "smile118",25,25, 
    "smile149", 54,37, "smile166",46,29, "smile237",35,35, "smile245",50,30, "smile28",33,34, "smile289",46,31, "smile314",36,29, "smile36",50,46, "smile39",46,48,
    "smile44",27,26, "smile70",50,32 );
function createMessage(title, body) {
  var container = document.createElement('div');
  var i=0;
  body='';
  while(i<sm.length) {
    var s = sm[i++];
    //javascript:top.AddToPrivate('Baks', top.CtrlPress)  
    body +='<a class="hoversmile" href="javascript:void(0)" onClick="SSm(\''+s+'\')"><IMG SRC=i/smiles/'+s+'.gif WIDTH='+sm[i++]+' HEIGHT='+sm[i++]+' BORDER=0 ALT="" ></a>';
  }
  //container.innerHTML = '<div id="ssmsmilediv" class="ssm-smile"><div class="ssm-smile-title">'+title+'</div><div class="ssm-smile-body">'+body+'</div><input class="ssm-smile-ok" type="button" value="Закрыть"/></div>';
  container.innerHTML = '<div id="ssmsmilediv" class="ssm-smile"><div class="ssm-smile-body">'+body+'</div><input class="ssm-smile-ok" type="button" value="Закрыть"/></div>';
  return container.firstChild;
}

    function positionMessage(elem) {
        var ua = navigator.userAgent.toLowerCase();
        if (ua.indexOf("msie") != -1 && ua.indexOf("opera") == -1 && ua.indexOf("webtv") == -1) {
            IsIE(elem);
         }
        else{
            elem.style.position = 'fixed';
            elem.style.bottom =0+'px';
        }

        elem.style.right = 2+'px';
    }

    function addCloseOnClick(messageElem) {
        var input = messageElem.getElementsByTagName('INPUT')[0];
        input.onclick = function() {
            messageElem.parentNode.removeChild(messageElem);
        }
    }

    function setupMessageButton(title, body) {
        var messageElem = createMessage(title, body);
        positionMessage(messageElem);
        addCloseOnClick(messageElem);
        top.frames['chat'].document.body.appendChild(messageElem);
    }
    try{
        el=top.frames['chat'].document.getElementById('ssmsmilediv');
        el.parentNode.removeChild(el);
    }
    catch(err){
    }
    setupMessageButton('Смайлики ;)', '');
}
}
</script>
</FORM>
<? } ?>
</body>
</html>