/* AJAX */
var xmlhttp;
function getXmlHttp()
{
  try
  {
    xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
  }
  catch (e)
  {
    try
    {
      xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
    }
    catch (E)
    {
      xmlhttp = false;
    }
  }
  if (!xmlhttp && typeof XMLHttpRequest!='undefined')
  {
    xmlhttp = new XMLHttpRequest();
  }
  return xmlhttp;
}
/* Кнопки по жанрам */
function mOver(id)
{
	  if (id!=='but6' && id!=='but7' && id!=='but8')
	  {
	  		document.getElementById(id).className = 'mmbutton1';
	  }
	  if (id=='but6' || id=='but7')
	  {
	  		document.getElementById(id).className = 'mmbutton4';
	  }
	  if (id=='but8')
	  {
	  		document.getElementById(id).className = 'mmbutton6';
	  }
}
function divhelpshow()
{
    document.getElementById('divuserHELP').style.display = 'block';
}
function divhelphide()
{
	document.getElementById('divuserHELP').style.display = 'none';
}
function mOut(id)
{
	  if (id!=='but6' && id!=='but7' && id!=='but8')
	  {
	  		document.getElementById(id).className = 'mmbutton2';
	  }
	  if (id=='but6' || id=='but7')
	  {
	  		document.getElementById(id).className = 'mmbutton3';
	  }
	  if (id=='but8')
	  {
	  		document.getElementById(id).className = 'mmbutton5';
	  }
}
/* Жанры в аддере */
function JanSelect()
{
	var i = document.getElementById('add_jan').value;
	if(i >= 1000 && i < 2000)document.getElementById('jan_idr').innerHTML = '(Художественная проза)';
	if(i >= 2000 && i < 3000)document.getElementById('jan_idr').innerHTML = '(Документальная проза)';
	if(i >= 3000 && i < 4000)document.getElementById('jan_idr').innerHTML = '(Поэзия)';
	if(i >= 4000 && i < 5000)document.getElementById('jan_idr').innerHTML = '(Детская литература)';
	if(i == 0)document.getElementById('jan_idr').innerHTML = '(&laquo;Разное&raquo;)';
}
function add(f)
{
	if (f.add_nam.value.replace(/\s/g, "") == "")
    {
     	alert("Вы не указали название произведения");
      	f.add_nam.focus();
      	return (false);
    }
    if (f.add_tex.value.replace(/\s/g, "") == "")
    {
     	alert("Вы не написали произведение");
      	f.add_tex.focus();
      	return (false);
    }
}
function news(f)
{
	if (f.new_nam.value.replace(/\s/g, "") == "")
    {
     	alert("Вы не указали заголовок новости");
      	f.new_nam.focus();
      	return (false);
    }
    if (f.new_tex.value.replace(/\s/g, "") == "")
    {
     	alert("Вы не написали текст новости");
      	f.new_tex.focus();
      	return (false);
    }
}
function addtag(text1, text2)
{
   if (document.selection)
   {
   		document.getElementById('addbbcode').add_tex.focus();
   		document.getElementById('addbbcode').document.selection.createRange().text = text1+document.getElementById('addbbcode').document.selection.createRange().text+text2;
   }
   else if(document.getElementById('addbbcode').elements['add_tex'].selectionStart != undefined)
   {
       var element = document.getElementById('addbbcode').elements['add_tex'];
       var str = element.value;
       var start = element.selectionStart;
       var length = element.selectionEnd - element.selectionStart;
       element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
   }
   else
   {
   		document.getElementById('addbbcode').add_tex.value += text1+text2;
   }
}
function faddtag(text1, text2)
{
   if (document.selection)
   {
   		document.getElementById('addbbcode').fadd_tex.focus();
   		document.getElementById('addbbcode').document.selection.createRange().text = text1+document.getElementById('addbbcode').document.selection.createRange().text+text2;
   }
   else if(document.getElementById('addbbcode').elements['fadd_tex'].selectionStart != undefined)
   {
       var element = document.getElementById('addbbcode').elements['fadd_tex'];
       var str = element.value;
       var start = element.selectionStart;
       var length = element.selectionEnd - element.selectionStart;
       element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
   }
   else
   {
   		document.getElementById('addbbcode').fadd_tex.value += text1+text2;
   }
}
/* Загрузка файла */
function load(f)
{
	if (f.loa_nam.value.length < 8)
    {
     	alert("Ошибка! Вы не указали файл!");
      	f.loa_nam.focus();
      	return (false)
    }
    if (f.loa_tit.value.replace(/\s/g, "") == "")
    {
     	alert("Ошибка! Необходимо подписать файл!");
      	f.loa_tit.focus();
      	return (false);
    }
    var type = f.loa_nam.value[f.loa_nam.value.length-4]+f.loa_nam.value[f.loa_nam.value.length-3]+f.loa_nam.value[f.loa_nam.value.length-2]+f.loa_nam.value[f.loa_nam.value.length-1];
    if (type!=='.doc' && type!=='.docx' && type!=='.rar' && type!=='.zip' && type!=='.jpg' && type!=='.jpeg' && type!=='.JPEG' && type!=='.RAR' && type!=='.ZIP' && type!=='.JPG' && type!=='.gif' && type!=='.GIF' && type!=='.DOC' && type!=='.DOCX')
    {
    	alert("Ошибка! Неверный тип файла");
      	f.loa_nam.focus();
      	return (false);
    }
    document.getElementById('loa_ind').innerHTML = '<div id="loa_ind" style="text-align:center;color:#555;font-size:12px;padding-top:30px"><img src="http://orionis.ru/img/142.gif"></div>Подождите, идёт загрузка...</div>';
}
/* Новый конкурс */
function kon(f)
{
	if (f.kon_nam.value.replace(/\s/g, "") == "")
    {
     	alert("Вы не указали название конкурса");
      	f.kon_nam.focus();
      	return (false);
    }
    if (f.add_tex.value.replace(/\s/g, "") == "")
    {
     	alert("Вы не описали конкурс");
      	f.kon_tex.focus();
      	return (false);
    }
    if (f.kon_tem.value.replace(/\s/g, "") == "")
    {
     	alert("Вы не указали тему конкурса");
      	f.kon_tem.focus();
      	return (false);
    }
}
function sadd(f)
{
	if (f.sadd_nam.value.replace(/\s/g, "") == "" && f.sadd_tex.value.replace(/\s/g, "") == "")
    {
     	confirm("Статья будет удалена");
    }
}
function kontag(text1, text2)
{
   if (document.selection)
   {
   		document.getElementById('addbbcode').kon_tex.focus();
   		document.getElementById('addbbcode').document.selection.createRange().text = text1+document.getElementById('addbbcode').document.selection.createRange().text+text2;
   }
   else if(document.getElementById('addbbcode').elements['kon_tex'].selectionStart != undefined)
   {
       var element = document.getElementById('addbbcode').elements['kon_tex'];
       var str = element.value;
       var start = element.selectionStart;
       var length = element.selectionEnd - element.selectionStart;
       element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
   }
   else
   {
   		document.getElementById('addbbcode').kon_tex.value += text1+text2;
   }
}
function newtag(text1, text2)
{
   if (document.selection)
   {
   		document.getElementById('addbbcode').new_tex.focus();
   		document.getElementById('addbbcode').document.selection.createRange().text = text1+document.getElementById('addbbcode').document.selection.createRange().text+text2;
   }
   else if(document.getElementById('addbbcode').elements['new_tex'].selectionStart != undefined)
   {
       var element = document.getElementById('addbbcode').elements['new_tex'];
       var str = element.value;
       var start = element.selectionStart;
       var length = element.selectionEnd - element.selectionStart;
       element.value = str.substr(0, start) + text1 + str.substr(start, length) + text2 + str.substr(start + length);
   }
   else
   {
   		document.getElementById('addbbcode').new_tex.value += text1+text2;
   }
}
function regmailcheck(type)
{
	document.getElementById('che_ind1').innerHTML = '<img src="http://orionis.ru/img/img1.gif" class="smile"/>';
	if (document.getElementById('regmail1').value.replace(/\s/g, "") == "")
    {
     	alert("Ошибка! Вы не указали E-mail!");
      	document.getElementById('regmail1').focus();
      	document.getElementById('regmail1').style.background = '#FFAC97';
      	document.getElementById('che_ind1').innerHTML = '<input type="button" style="width:100px;" value="Проверить" onClick="regmailcheck(1)">';
      	return (false);
    }
	if (document.getElementById('regmail1').value.replace(/^([a-z0-9_\-]+\.)*[a-z0-9_\-]+@([a-z0-9][a-z0-9\-]*[a-z0-9]\.)+[a-z]{2,4}$/i, "") !== "")
    {
     	alert("Ошибка! Вы неверно указали E-mail! \n Обнаружена грамматическая ошибка!");
      	document.getElementById('regmail1').focus();
      	document.getElementById('regmail1').style.background = '#FFAC97';
      	document.getElementById('che_ind1').innerHTML = '<input type="button" style="width:100px;"  value="Проверить" onClick="regmailcheck(1)">';
      	return (false);
    }
	var xmlhttp = getXmlHttp();
	xmlhttp.open("POST", "index.php?r="+Math.random(), true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4)
		{
		   if(xmlhttp.status == 200)
		   {
		   		if (xmlhttp.responseText=='1')
		   		{
		   			alert("Данный E-mail уже используется! \n Возможно вы регистрировались ранее.");
		   			document.getElementById('regmail1').style.background = '#FFAC97';
		   		}
		   		if (xmlhttp.responseText=='0')
		   		{
		   			alert("Данный E-mail ранее не регистрирвался! \n Можете смело использовать его!");
		   			document.getElementById('regmail1').style.background = '#97FF97';
		   		}
				if (xmlhttp.responseText=='2')
		   		{
		   			alert("Ошибка! Неверный E-mail! \n Грамматическая ошибка!");
		   			document.getElementById('regmail1').style.background = '#FFAC97';
		   		}
		   		if (xmlhttp.responseText=='3')
		   		{
		   			alert("Ошибка! Установлено ограничение! \n Разрешено не более 20 запросов в 1 час!");
		   			document.getElementById('regmail1').style.background = '#FFAC97';
		   		}
		   		if ((xmlhttp.responseText!=='0')&&(xmlhttp.responseText!=='1')&&(xmlhttp.responseText!=='3')&&(xmlhttp.responseText!=='2'))
		   		{
		   			alert("Ошибка! Нет доступа к базе данных. \n Проверить E-mail не удалось! \n\n Техническая поддержка сайта: support@orionis.ru");
		   		}
		   }
		   else
		   {
           		alert("Ошибка! Нет доступа к сайту \n Проверте ваше соединение! \n\n Техническая поддержка сайта: support@orionis.ru");
		   }
		   document.getElementById('che_ind1').innerHTML = '<input type="button"  style="width:100px;"  value="Проверить" onClick="regmailcheck(1)">';
		}
	}
	xmlhttp.send(encodeURI('regmailcheck1='+document.getElementById('regmail1').value));
}
function poll(id,text)
{
	document.getElementById('pol_ind').innerHTML = '<span>Подождите, идёт загрузка...</span>';
	var xmlhttp = getXmlHttp();
	xmlhttp.open("POST", cdir+"index.php?r="+Math.random(), true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4)
		{
		   if(xmlhttp.status == 200)
		   {
		   		if (xmlhttp.responseText=='1')
		   		{
		   			document.getElementById('pol_ind').innerHTML = '';
		   		}
		   		if (xmlhttp.responseText=='2')
		   		{
		   			document.getElementById('pol_ind').innerHTML = '<span style="color:#0a0;">Благодарим вас за оценку произведения!</span>';
		   		}
				if (xmlhttp.responseText=='0')
		   		{
		   			document.getElementById('pol_ind').innerHTML = '<span style="color:#900;">Ошибка! Произведение не обнаружено!</span>';
		   		}
		   }
		   else
		   {
           		document.getElementById('pol_ind').innerHTML = '<span style="color:#900;">Ошибка! Нет доступа к сайту. Проверте ваше соединение!</span>';
		   }
		}
	}
	xmlhttp.send(encodeURI('pol_tex='+text+'&pol_id='+id));
}
function IMpoll(id,text)
{
	document.getElementById('pol_ind-'+id).innerHTML = '<span>Подождите, идёт загрузка...</span>';
	var xmlhttp = getXmlHttp();
	xmlhttp.open("POST", cdir+"index.php?r="+Math.random(), true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4)
		{
		   if(xmlhttp.status == 200)
		   {
		   		if (xmlhttp.responseText=='1')
		   		{
		   			document.getElementById('pol_ind-'+id).innerHTML = '';
		   		}
		   		if (xmlhttp.responseText=='2')
		   		{
		   			document.getElementById('pol_ind-'+id).innerHTML = '<span style="color:#0a0;">Благодарим вас за оценку произведения!</span>';
		   		}
				if (xmlhttp.responseText=='0')
		   		{
		   			document.getElementById('pol_ind-'+id).innerHTML = '<span style="color:#900;">Ошибка! Произведение не обнаружено!</span>';
		   		}
		   }
		   else
		   {
           		document.getElementById('pol_ind-'+id).innerHTML = '<span style="color:#900;">Ошибка! Нет доступа к сайту. Проверте ваше соединение!</span>';
		   }
		}
	}
	xmlhttp.send(encodeURI('IMpol_tex='+text+'&IMpol_id='+id));
}
function commgame1over(id)
{
    document.getElementById(id).className = 'c1';
}
function commgame1out(id)
{
	document.getElementById(id).className = 'c0';
}
function addgamebal(id)
{
	var xmlhttp = getXmlHttp();
	xmlhttp.open("POST", cdir+"index.php?r="+Math.random(), true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4)
		{
		   if(xmlhttp.status == 200 && xmlhttp.responseText.length<5)
		   {
		   		document.getElementById('gamepol-'+id).style.display = 'none';
		   		document.getElementById('game2-'+id).innerHTML = '<span class="obslistauto" title="Набрано баллов">+'+xmlhttp.responseText+'</span>';
		   }
		}
	}
	xmlhttp.send(encodeURI('gamepoll_id='+id));
}
function rasdel(f)
{
	return confirm("Уверены, что следует удалить произведение?");
}
function fordel(f)
{
	return confirm("Уверены, что следует удалить сообщение?");
}
function imagerdel(f)
{
	return confirm("Уверены, что следует удалить игру?");
}
function imagerrassdel(f)
{
	return confirm("Уверены, что следует удалить произведение? \r P.S. оно выше нажатй кнопки со знаком \"Х\"");
}
function gamedel(f)
{
	return confirm("Уверены, что следует удалить строку?");
}
function fildel(f)
{
	return confirm("Уверены, что следует удалить файл?");
}
function newdel(f)
{
	return confirm("Уверены, что следует удалить новость?");
}
function game1(f)
{
	if (f.game1_tex.value.replace(/\s/g, "") == "")
    {
     	alert("Ошибка! Введите текст!");
      	f.game1_tex.focus();
      	return (false);
    }
}
function imager(f)
{
	if (f.ima_tex.value.replace(/\s/g, "") == "")
    {
     	alert("Ошибка! Введите текст!");
      	f.ima_tex.focus();
      	return (false);
    }
}
function fadd(f)
{
	if (f.fadd_nam.value.replace(/\s/g, "") == "")
    {
     	alert("Ошибка! Введите заголовок сообщения!");
      	f.fadd_nam.focus();
      	return (false);
    }
    if (f.fadd_aut_reg.value.replace(/\s/g, "") == "0" && f.fadd_aut.value.replace(/\s/g, "") == "")
    {
     	alert("Ошибка! Введите ваше имя!");
      	f.fadd_aut.focus();
      	return (false);
    }
}
function game1ov(id)
{
	document.getElementById('s'+id).style.display = 'block';
}
function game1ou(id)
{
	document.getElementById('s'+id).style.display = 'none';
}
function bOver(id)
{
    if (id == 'bal1')
    {
   		document.getElementById('bal5').src = cdir+'img/s1.png';
   		document.getElementById('bal4').src = cdir+'img/s1.png';
   		document.getElementById('bal3').src = cdir+'img/s1.png';
   		document.getElementById('bal2').src = cdir+'img/s1.png';
   		document.getElementById('bal1').src = cdir+'img/s2.png';
    }
    if (id == 'bal2')
    {
   		document.getElementById('bal5').src = cdir+'img/s1.png';
   		document.getElementById('bal4').src = cdir+'img/s1.png';
   		document.getElementById('bal3').src = cdir+'img/s1.png';
   		document.getElementById('bal2').src = cdir+'img/s2.png';
   		document.getElementById('bal1').src = cdir+'img/s2.png';
    }
    if (id == 'bal3')
    {
   		document.getElementById('bal5').src = cdir+'img/s1.png';
   		document.getElementById('bal4').src = cdir+'img/s1.png';
   		document.getElementById('bal3').src = cdir+'img/s2.png';
   		document.getElementById('bal2').src = cdir+'img/s2.png';
   		document.getElementById('bal1').src = cdir+'img/s2.png';
    }
    if (id == 'bal4')
    {
   		document.getElementById('bal5').src = cdir+'img/s1.png';
   		document.getElementById('bal4').src = cdir+'img/s2.png';
   		document.getElementById('bal3').src = cdir+'img/s2.png';
   		document.getElementById('bal2').src = cdir+'img/s2.png';
   		document.getElementById('bal1').src = cdir+'img/s2.png';
    }
    if (id == 'bal5')
    {
   		document.getElementById('bal5').src = cdir+'img/s2.png';
   		document.getElementById('bal4').src = cdir+'img/s2.png';
   		document.getElementById('bal3').src = cdir+'img/s2.png';
   		document.getElementById('bal2').src = cdir+'img/s2.png';
   		document.getElementById('bal1').src = cdir+'img/s2.png';
    }
}
function bOverG1(bal,id)
{
	if (bal == 'bal1')
    {
   		document.getElementById('bal1-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal2-'+id).src = cdir+'img/s1.png';
   		document.getElementById('bal3-'+id).src = cdir+'img/s1.png';
   		document.getElementById('bal4-'+id).src = cdir+'img/s1.png';
   		document.getElementById('bal5-'+id).src = cdir+'img/s1.png';
    }
    if (bal == 'bal2')
    {
   		document.getElementById('bal1-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal2-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal3-'+id).src = cdir+'img/s1.png';
   		document.getElementById('bal4-'+id).src = cdir+'img/s1.png';
   		document.getElementById('bal5-'+id).src = cdir+'img/s1.png';
    }
    if (bal == 'bal3')
    {
   		document.getElementById('bal1-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal2-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal3-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal4-'+id).src = cdir+'img/s1.png';
   		document.getElementById('bal5-'+id).src = cdir+'img/s1.png';
    }
    if (bal == 'bal4')
    {
   		document.getElementById('bal1-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal2-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal3-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal4-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal5-'+id).src = cdir+'img/s1.png';
    }
    if (bal == 'bal5')
    {
   		document.getElementById('bal1-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal2-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal3-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal4-'+id).src = cdir+'img/s2.png';
   		document.getElementById('bal5-'+id).src = cdir+'img/s2.png';
    }
}
function bOutG1(id)
{
	document.getElementById('bal1-'+id).src = cdir+'img/s1.png';
	document.getElementById('bal2-'+id).src = cdir+'img/s1.png';
	document.getElementById('bal3-'+id).src = cdir+'img/s1.png';
	document.getElementById('bal4-'+id).src = cdir+'img/s1.png';
	document.getElementById('bal5-'+id).src = cdir+'img/s1.png';
}
function bOut(id)
{
	document.getElementById('bal1').src = cdir+'img/s1.png';
	document.getElementById('bal2').src = cdir+'img/s1.png';
	document.getElementById('bal3').src = cdir+'img/s1.png';
	document.getElementById('bal4').src = cdir+'img/s1.png';
	document.getElementById('bal5').src = cdir+'img/s1.png';
}
/* ЧАТ */
function chatsend(type)
{
 	if (document.getElementById('chattext').value.replace(/\s/g, "") == "")
    {
      	return (false);
    }
    var tim = Math.round(new Date().getTime()/1000.0);
    if (document.getElementById('chattime').value > (tim-5))
    {
    	alert('Минимальный интервал между сообщениями 5 секунд.');
    	return (false);
    }
    document.getElementById('chattime').value = tim;
 	var xmlhttp = getXmlHttp();
	xmlhttp.open("POST", cdir+"index.php?r="+Math.random(), true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4)
		{
		   if(xmlhttp.status !== 200)
		   {
           		alert("Ошибка! Нет доступа к чату \n Проверте ваше соединение!");
		   }
		   else
		   {
		   		document.getElementById('chattext').value = "";
		   		document.getElementById('chat').innerHTML = xmlhttp.responseText;
		   		if (type == 0)
		   		{
		   			document.getElementById('chat').scrollTop = '0';
		   		}
		   		else
		   		{
		   			document.getElementById('chat').scrollTop = document.getElementById('chat').scrollHeight;
		   		}
		   }
		}
	}
	xmlhttp.send(encodeURI('chattext='+document.getElementById('chattext').value+'&type='+type));
}
var chatstartstat = 0;
function GetBrowser()
{
	var
	    UA=window.navigator.userAgent,
		OperaB = /Opera[ \/]+\w+\.\w+/i,     //
		OperaV = /Version[ \/]+\w+\.\w+/i,   //
		FirefoxB = /Firefox\/\w+\.\w+/i,     // шаблоны для распарсивания юзерагента
		ChromeB = /Chrome\/\w+\.\w+/i,       //
		SafariB = /Version\/\w+\.\w+/i,      //
		IEB = /MSIE *\d+\.\w+/i,             //
		SafariV = /Safari\/\w+\.\w+/i,       //
		OperaV = UA.match(OperaV),
		Firefox = UA.match(FirefoxB),
		Chrome = UA.match(ChromeB),
		Safari = UA.match(SafariB),
		SafariV = UA.match(SafariV),
		IE = UA.match(IEB),
		Opera = UA.match(OperaB);
		browser = '0';
		if ((!Opera=="")&&(!OperaV=="")) browser = 0;
		if (!IE=="")      browser = 0;
		if (!Firefox=="") browser = 1;
		if (!Chrome=="")  browser = 0;
		if ((!Safari=="")&&(!SafariV==""))  browser = 0;
		return browser;
}
function chatread(type)
{
 	var xmlhttp = getXmlHttp();
	xmlhttp.open("POST", cdir+"index.php?r="+Math.random(), true);
	xmlhttp.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
	xmlhttp.onreadystatechange = function()
	{
		if (xmlhttp.readyState == 4)
		{
		   if(xmlhttp.status !== 200)
		   {
           		document.getElementById('chat').innerHTML = 'Связь с чатом прервана!';
		   }
		   else
		   {
		   		document.getElementById('chat').innerHTML = xmlhttp.responseText;
		   		if (type == 0)
		   		{
		   			document.getElementById('chat').scrollTop = '0';
		   		}
		   		else
		   		{
		   			if (GetBrowser()==1)
		   			{
		   				var hei = document.getElementById('chat').scrollHeight - document.getElementById('chat').scrollTop - 900 - 433;
		   			}
		   			else
		   			{
						var hei = document.getElementById('chat').scrollHeight - document.getElementById('chat').scrollTop - 433;
					}
		   			if (hei < 100 || chatstartstat == 0)
		   			{
		   				chatstartstat = 1;
		   				document.getElementById('chat').scrollTop = document.getElementById('chat').scrollHeight;
		   			}
		   		}
		   }
		}
	}
	xmlhttp.send(encodeURI('chatread=1&type='+type));
	setTimeout('chatread('+type+')',5000);
}
function enter(type,event)
{
	key = event.which || event.keyCode || event.charCode;
	if(key==13)
	{
		chatsend(type);
	}
}
/*Новости*/
function newst(f)
{
	if (f == 'newstype1')
	{
    	document.getElementById('newstype1').style.borderBottom = '0px';
    	document.getElementById('newstype2').style.borderBottom = '1px solid #CCC';
    	document.getElementById('newstype3').style.borderBottom = '1px solid #CCC';
    	document.getElementById('newstable1').style.display = 'block';
    	document.getElementById('newstable2').style.display = 'none';
    	document.getElementById('newstable3').style.display = 'none';
	}
	if (f == 'newstype2')
	{
    	document.getElementById('newstype1').style.borderBottom = '1px solid #CCC';
    	document.getElementById('newstype2').style.borderBottom = '0px';
    	document.getElementById('newstype3').style.borderBottom = '1px solid #CCC';
    	document.getElementById('newstable1').style.display = 'none';
    	document.getElementById('newstable2').style.display = 'block';
    	document.getElementById('newstable3').style.display = 'none';
	}
	if (f == 'newstype3')
	{
    	document.getElementById('newstype1').style.borderBottom = '1px solid #CCC';
    	document.getElementById('newstype2').style.borderBottom = '1px solid #CCC';
    	document.getElementById('newstype3').style.borderBottom = '0px';
    	document.getElementById('newstable1').style.display = 'none';
    	document.getElementById('newstable2').style.display = 'none';
    	document.getElementById('newstable3').style.display = 'block';
	}
	if (f == 'mail1')
	{
    	document.getElementById('mailtype2').style.borderBottom = '1px solid #CCC';
    	document.getElementById('mailtype1').style.borderBottom = '0px';
    	document.getElementById('mail1').style.display = 'none';
    	document.getElementById('mail2').style.display = 'block';
	}
	if (f == 'mail2')
	{
    	document.getElementById('mailtype1').style.borderBottom = '1px solid #CCC';
    	document.getElementById('mailtype2').style.borderBottom = '0px';
    	document.getElementById('mail2').style.display = 'none';
    	document.getElementById('mail1').style.display = 'block';
	}
}
function imagershow()
{
 	document.getElementById('bigimg').style.display = 'block';
}
function imagerhide()
{
    document.getElementById('bigimg').style.display = 'none';
}
function UserDiv(id,name,moder,photo,vkon,bal,rass,date,pol,stat,city,lvl,text)
{
	if (stat.length == 0)stat = 'писатель, читатель';
	if (rass.length == 0 || rass == '0')rass = 'пока нет';
	if (bal.length  == 0)bal = '0';
	if (city.length == 0)city = 'не указано';
	var vkonBUT = '';
	if (vkon !== '0')
	{
		vkonBUT = '<br /><a rel="nofollow" href="http://www.vkontakte.ru/id'+vkon+'"><img src="'+cdir+'img/usinf.png" title="Подробная информация в сети Вконтакте" alt="Вконтакте" style="width:89px;height:21px;border:0px;" /></a>';
	}
	if (text.length >  0)
	{
		text = '<div style="clear:both;position:relative;color:#666;font:normal 10px Tahoma;text-align:justify;padding:10px;"><b>О себе:</b> '+text+'</div>';
	}
	else
	{
		text = '<div style="clear:both;position:relative;color:#666;font:normal 10px Tahoma;text-align:justify;padding:0px;"></div>';
	}
	var v1 = document.documentElement.clientWidth;
	document.body.className = "unselbody";
	var v2 = v1-document.documentElement.clientWidth;
	document.body.style.margin = '0px 0px 0px '+v2+'px';
	var us  = document.getElementById('divuser');
	var us1 = document.getElementById('divuser1');
	us.style.top = document.documentElement.scrollTop+'px';
	us.style.height = window.screen.height+'px';
	us1.style.top  = document.documentElement.scrollTop+(document.documentElement.clientHeight/2-150)+'px';
	us1.style.left = (document.documentElement.clientWidth/2-200)+'px';
	if (moder == '1')
	{
    	name = '<a rel="nofollow" href="'+cdir+'index.php?pro='+id+'">'+name+'<img src="'+cdir+'/img/pro.png" alt="х" title="Редактор профиля" class="smile" style="float:right;margin-right:5px;"/></a>';
	}
	document.getElementById('divuser2').innerHTML = '<div style="float:left;text-align:center;width:100px;margin:2px 15px 2px 2px;"><img src="'+cdir+'users/b'+photo+'.jpg" title="Фотография" alt="Фото" style="width:100px;height:100px;" />'+vkonBUT+'</div><div style="margin-top:5px;text-align:left;font:normal 11px tahoma"><b>'+name+'</b><table cellpadding="0" cellspacing="2" border="0" style="width:270px;padding-top:10px;"><tr><td style="width:40%">от куда:</td><td style="width:60%">'+city+'</td></tr><tr><td style="width:40%">опыт:</td><td style="width:60%">'+bal+' <span style="cursor:pointer;color:#777;font:normal 10px Verdana" onmouseover="divhelpshow()" onmouseout="divhelphide()"> [Уровень: '+lvl+']</span></td></tr><tr><td style="width:40%">произведений:</td><td style="width:60%">'+rass+'&nbsp;&nbsp;&nbsp;(<a href="'+cdir+'avtory/user'+id+'/">посмотреть все</a>)</td></tr><tr><td style="width:40%">зарегистрирован:</td><td style="width:60%">'+date+'</td></tr></table><div style="margin-top:15px;"><img src="'+cdir+'img/img'+pol+'.png" class="smilesmall">&nbsp;'+stat+'</div></div>'+text+'</div>';
	us1.style.display = 'block';
	us.style.display = 'block';
}
function UserDivHide()
{
 	document.getElementById('divuser').style.display = 'none';
 	document.getElementById('divuser1').style.display = 'none';
 	document.getElementById('regwindow').style.display        = 'none';
 	document.body.className = "";
 	document.body.style.margin = '0px 0px 0px 0px';
}
function openreg(type)
{
	var v1 = document.documentElement.clientWidth;
	document.body.className = "unselbody";
	var v2 = v1-document.documentElement.clientWidth;
	document.body.style.margin = '0px 0px 0px '+v2+'px';
	var us  = document.getElementById('divuser');
	var us1 = document.getElementById('regwindow');
	us.style.top = document.documentElement.scrollTop+'px';
	us.style.height = window.screen.height+'px';
	us1.style.top  = document.documentElement.scrollTop+20+'px';
	us1.style.left = (document.documentElement.clientWidth/2-325)+'px';
	us1.style.display = 'block';
	us.style.display = 'block';
}
function flashOVER(id)
{
   if (id == 'flashimg1')document.getElementById(id).src = cdir+'img/flash1.png';
   if (id == 'flashimg2')document.getElementById(id).src = cdir+'img/flash2.png';
   if (id == 'flashimg3')document.getElementById(id).src = cdir+'img/flash3.png';
   if (id == 'flashimg4')document.getElementById(id).src = cdir+'img/flash4.png';
}
function flashOUT(id)
{
   if (id == 'flashimg1')document.getElementById(id).src = cdir+'img/5.png';
   if (id == 'flashimg2')document.getElementById(id).src = cdir+'img/4.png';
   if (id == 'flashimg3')document.getElementById(id).src = cdir+'img/2.png';
   if (id == 'flashimg4')document.getElementById(id).src = cdir+'img/3.png';
}
function inscript(input)
{
	if (input.value=="") {input.value='Поиск по сайту...'}
}
