function WritePersName(login, lvl, clan, clan_img, clansite, rase, mode, pers_name, w)
	{
	var s = '';

	if(login == '' && pers_name != '')
		{
		if(mode==2) s += '<a class="comms" style="font-weight:bold;" href="javascript:insert_text(\'\', \'[b]'+pers_name+'[/b]\\n\', 1);" title="Добавить имя в поле комментариев">'+pers_name+'</a> [??] ';
		else s += '<b>' + pers_name + ' [??]</b>';
		}
	else
	{
	var rase_img = '';
	var rase_alt = '';

	if(rase=='0')
		{
		rase_img = 'ico_human';
		rase_alt = 'Человек';
		}
	else
		{
		rase_img = 'ico_magmar';
		rase_alt = 'Магмар';
		}

	if(w=='1') w = 'prime';
	else w = 'minor';

	var style='';



	if(clansite!='0') clansite = 'href="http://dwar.ru/clan_info.php?clan_id='+clansite+'"';
	s += '<table border=0 style="margin:0px;padding:-1px;display:inline;white-space: nowrap;margin-bottom:-6px;margin-top:-3px;"><td>';
	if(mode!=1) style = 'style="font-weight:bold;"';
	s += '<span '+style+' align=absMiddle>';
	if(rase!='') s+= '<img src="/images/'+rase_img+'.gif" width=14 height=15 border=0 alt="'+rase_alt+'"> ';
	if(clan!="" && clan_img!="") s += '<a target="_blank" '+clansite+' title="'+clan+'"><img src="/images/data/clans/'+clan_img+'" width=13 height=13 border=0 alt="'+clan+'"></a> ';
	if(mode==2) s += '</td><td style="margin:0px;padding:0px;font-weight:bold;font-size:10px;"><a class="comms" style="font-weight:bold;" href="javascript:insert_text(\'\', \'[b]'+login+'[/b]\\n\', 1);" title="Добавить имя в поле комментариев">'+login+'</a><div style="font-size:8px;color:#776666;font-family:Verdana;padding:0px;margin:0px;margin-top:-4px;">'+w+'</div></td><td valign=top style="margin:0px;padding:0px;font-weight:bold;"> ['+lvl+'] ';
	else if(mode==3) s += '</td><td style="margin:0px;padding:0px;font-weight:bold;font-size:10px;"><a href=\'photogalery.php?login='+login+'\' title=\'Фотографии '+login+'\'>'+login+'</a><div style="font-size:8px;color:#776666;font-family:Verdana;padding:0px;margin:0px;margin-top:-3px;">'+w+'</div></td><td valign=top style="margin:0px;padding:0px;font-weight:bold;"> ['+lvl+'] ';
	else { s += '</td><td style="margin:0px;padding:0px;font-weight:bold;font-size:10px;">'+login+'<div style="font-size:8px;font-weight:bold;color:#776666;font-family:Verdana;padding:0px;margin:0px;margin-top:-4px;">'+w+'</div></td><td valign=top style="margin:0px;padding:0px;font-weight:bold;">['+lvl+'] '; }
	s += '<A title="Информация о персонаже" onclick="showUserInfo(\''+login+'\');return false;" href="#"><IMG height=10 src="/images/player_info.gif" width=10 align=absMiddle border=0 alt="Информация о персонаже"></A></span>';
	s += '</td></table>';
	}

	document.write(s);
	}

function showUserInfo(nick) {
	var url = "http://dwar.ru/user_info.php?nick="+nick;
	window.open(url, "", "width=915,height=700,location=yes,menubar=no,resizable=yes,scrollbars=yes,status=no,toolbar=no");
}

function insert_custom_code(code,text)
	{
	inserttext = prompt(text+"\n["+code+"]текст[/"+code+"]","");

	document.forms['comms'].elements['comtext'].value += "["+code+"]"+inserttext+"[/"+code+"] ";
	}

function label(text)
	{
	document.write("<a name='"+text+"'></a>");
	}

function prnt_img(img, w, h)
	{
	document.write("<img src='/images/"+img+".gif' width='"+w+"' height='"+h+"' border=0>");
	}

function preview()
	{
	alert("Эта функция на данный момент в стадии разработки");
	}

function write_pagetitle(title, skin)
	{
	var s = '';

	s += '<span class="page_title">'+title+'</span>';

	document.write(s);
	}

function write_title(title, skin)
	{
	document.write("<center><table cellspacing=0 cellpadding=0 border=0 width=98% align=center><tbody>");
	document.write("<tr>");
	document.write("<td width=100% height=9>");
	document.write("	<center><table cellspacing=0 cellpadding=0 align=center border=0 width=80% height=9><tbody>");
	document.write("	<tr>");

	document.write("	<td width=100% height=9 background='/input/skins/"+skin+"/img/svitok_news_bg01.gif'><img src='/input/skins/"+skin+"/img/spacer.gif' width=1 height=9 border=0></td>");

	document.write("	</tr>");
	document.write("	</tbody></table></center>");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td width=100% height=18>");
	document.write("	<table cellspacing=0 cellpadding=0 border=0 width=100% height=18><tbody>");
	document.write("	<tr>");
	document.write("	<td width=100% height=18>");
	document.write("		<table cellspacing=0 cellpadding=0 border=0 width=100% height=18><tbody>");
	document.write("		<tr>");	
	document.write("		<td width=100% height=18 align=center>");	
	document.write("		<span class='news_title'>");
	document.write(			title);
	document.write("		</span>");
	document.write("		</td>");
	document.write("		</tr>");
	document.write("		</tbody></table>");
	document.write("	</td>");
	document.write("	</tr>");
	document.write("	</tbody></table>");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td width=100% height=11>");
	document.write("	<table cellspacing=0 cellpadding=0 border=0 width=80% height=11><tbody>");
	document.write("	<tr>");
	document.write("	<td width=100% height=11 background='/input/skins/"+skin+"/img/svitok_news_bg02.gif'><img src='/input/skins/"+skin+"/img/spacer.gif' width=1 height=11 border=0></td>");
	document.write("	</tr>");
	document.write("	</tbody></table>");
	document.write("</td>");
	document.write("</tr>");
	document.write("</tbody></table></center>");	
	}

function write_news(id, title, text, date, owner, comms, pages, skin, single, attach)
	{
	if(pages > 1)
		{
	 	var p = 'Страницы: [ ';
	 	if(pages > 6)
			{
	 		for(z = 1; z<=3; z++)
				{
		 		p += '<a class="comms" style="font-size:10px;" href="index-comm-'+id+'-p-'+z+'.html?r='+Math.random()+'" target=_top>'+z+'</a> ';
		 		}
	 		p += '... ';

	 		for(z = pages -2; z<=pages; z++)
				{
		 		p += '<a class="comms" style="font-size:10px;" href="index-comm-'+id+'-p-'+z+'.html?r='+Math.random()+'" target=_top>'+z+'</a> ';
		 		}
			}
		else
			{
			for(z = 1; z<=pages; z++)
				{
		 		p += '<a class="comms" style="font-size:10px;" href="index-comm-'+id+'-p-'+z+'.html?r='+Math.random()+'" target=_top>'+z+'</a> ';
		 		}
			}
	 	p += '] ';
		}
	else
		{ var p = ''; }

	var s = "";

	document.write("<table cellspacing=0 cellpadding=0 border=0 width=95% align=center><tbody>");
	document.write("<tr>");
	document.write("<td width=100% height=9>");
	document.write("	<table cellspacing=0 cellpadding=0 border=0 width=95% align=center height=9><tbody>");
	document.write("	<tr>");
	document.write("	<td width=100% height=9 background='/input/skins/"+skin+"/img/svitok_news_bg01.gif'><img src='/input/skins/"+skin+"/img/spacer.gif' width=1 height=9 border=0></td>");
	document.write("	</tr>");
	document.write("	</tbody></table>");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td width=100% height=20>");
	document.write("	<center><table cellspacing=0 cellpadding=0 border=0 width=100% height=20><tbody>");
	document.write("	<tr>");
	document.write("	<td width=100% height=20>");
	document.write("		<table cellspacing=0 cellpadding=0 border=0 width=100% height=11><tbody>");
	document.write("		<tr>");	
	document.write("		<td width=70% height=20 align=left style='padding-left:5px;'>");	

	if(attach && !single)
		document.write("<span style='attach'>[Прикреплена]</span>&nbsp;");
	document.write("<a class='news_title' href='news-comm-"+id+".html' target=_top>");
	document.write(title);
	document.write("</a>");
	  news_global_abils(id, attach);

	document.write("		</td>");
	document.write("		<td width=30% height=20 align=right style='padding-right:5px;'>");	
	document.write("		<span class='news_date'>"+date+"</span>");
	document.write("		</td>");
	document.write("		</tr>");
	document.write("		</tbody></table></center>");
	document.write("	</td>");
	document.write("	</tr>");
	document.write("	</tbody></table>");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td width=100% height=11>");
	document.write("	<table cellspacing=0 cellpadding=0 border=0 width=95% height=11><tbody>");
	document.write("	<tr>");
	document.write("	<td width=100% height=11 background='/input/skins/"+skin+"/img/svitok_news_bg02.gif'><img src='/input/skins/"+skin+"/img/spacer.gif' width=1 height=11 border=0></td>");
	document.write("	</tr>");
	document.write("	</tbody></table>");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td width=100% style='padding-left:20px;padding-top:0px;padding-right:30px;' align=justify>");
	document.write(text);
	document.write("</td>");
	document.write("</tr>");

		document.write("<tr>");
		document.write("<td width=100% height=11>");
		document.write("	<table cellspacing=0 cellpadding=0 border=0 width=100% height=11><tbody>");
		document.write("	<tr>");
		document.write("	<td width=70% height=11 style='padding-left:20px;padding-top:8px;padding-right:20px;'>");
if(!single)	document.write("	<nobr><a style='font-size:10px;' class='comms' href='/index-comm-"+id+".html?r="+Math.random()+"' class=noline target=_top>Комментировать ["+comms+"]</a> "+p+"<a href='/index-comm-"+id+".html?r="+Math.random()+"' target=_blank><img src='input/skins/"+skin+"/img/pip.gif' width=12 height=9 border=0 alt='Открыть в новом окне'></a></nobr>");
		document.write("	</td>");
		document.write("	<td width=30% height=11 align=center style='color:#776666;'>");
if(!single)	document.write("	Автор: <a href='http://dwar.ru/user_info.php?nick="+owner+"' target=_blank>"+owner+"</a>");
else		{
		document.write("	Автор: ");
		WritePersName(pers1, pers2, pers3, pers4, pers5, pers6, pers7, pers8, pers9);
		}		
		document.write("	</td>");
		document.write("	</tr>");
		document.write("	</tbody></table>");
		document.write("</td>");
		document.write("</tr>");

	document.write("</tbody></table>");
	}

function write_pub(id, title, text, date, owner, comms, pages, skin, workfromkey, key, views, rating, rated)
	{
	if(pages > 1)
		{
	 	var p = 'Страницы: [ ';
	 	if(pages > 6)
			{
	 		for(z = 1; z<=3; z++)
				{
		 		if(workfromkey)
					p += '<a class="comms" style="font-size:10px;" href="/pub/'+key+'-p-'+z+'.html?r='+Math.random()+'" target=_top>'+z+'</a> ';
		 		else
					p += '<a class="comms" style="font-size:10px;" href="pub-c-'+id+'-p-'+z+'.html?r='+Math.random()+'" target=_top>'+z+'</a> ';
				}
	 		p += '... ';

	 		for(z = pages -2; z<=pages; z++)
				{
		 		if(workfromkey)
		 			p += '<a class="comms" style="font-size:10px;" href="/pub/'+key+'-p-'+z+'.html?r='+Math.random()+'" target=_top>'+z+'</a> ';
		 		else
		 			p += '<a class="comms" style="font-size:10px;" href="pub-c-'+id+'-p-'+z+'.html?r='+Math.random()+'" target=_top>'+z+'</a> ';
		 		}
			}
		else
			{
			for(z = 1; z<=pages; z++)
				{
		 		if(workfromkey)
			 		p += '<a class="comms" style="font-size:10px;" href="/pub/'+key+'-p-'+z+'.html?r='+Math.random()+'" target=_top>'+z+'</a> ';
		 		else
					p += '<a class="comms" style="font-size:10px;" href="pub-c-'+id+'-p-'+z+'.html?r='+Math.random()+'" target=_top>'+z+'</a> ';
		 		}
			}
	 	p += '] ';
		}
	else
		{ var p = ''; }

	var s = "";

	document.write("<table cellspacing=0 cellpadding=0 border=0 width=95% align=center><tbody>");
	document.write("<tr>");
	document.write("<td width=100% height=9>");
	document.write("	<table cellspacing=0 cellpadding=0 border=0 width=95% align=center height=9><tbody>");
	document.write("	<tr>");
	document.write("	<td width=100% height=9 background='/input/skins/"+skin+"/img/svitok_news_bg01.gif'><img src='/input/skins/"+skin+"/img/spacer.gif' width=1 height=9 border=0></td>");
	document.write("	</tr>");
	document.write("	</tbody></table>");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td width=100% height=20>");
	document.write("	<center><table cellspacing=0 cellpadding=0 border=0 width=100% height=20><tbody>");
	document.write("	<tr>");
	document.write("	<td width=100% height=20>");
	document.write("		<table cellspacing=0 cellpadding=0 border=0 width=100% height=11><tbody>");
	document.write("		<tr>");	
	document.write("		<td width=70% height=20 align=left style='padding-left:5px;'>");		
	if(workfromkey) document.write("<a class='news_title' href='/pub/"+key+".html' target=_top>");
	else document.write("<a class='news_title' href='pub-c-"+id+".html' target=_top>");
	document.write(title);
	document.write("</a>");
	  pub_global_abils(id);

	document.write("		</td>");
	document.write("		<td width=30% height=20 align=right style='padding-right:5px;'>");	
	document.write("		<span class='news_date'>"+date+"</span>");
	document.write("		</td>");
	document.write("		</tr>");
	document.write("		</tbody></table></center>");
	document.write("	</td>");
	document.write("	</tr>");
	document.write("	</tbody></table>");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td width=100% height=11>");
	document.write("	<table cellspacing=0 cellpadding=0 border=0 width=95% height=11><tbody>");
	document.write("	<tr>");
	document.write("	<td width=100% height=11 background='/input/skins/"+skin+"/img/svitok_news_bg02.gif'><img src='/input/skins/"+skin+"/img/spacer.gif' width=1 height=11 border=0></td>");
	document.write("	</tr>");
	document.write("	</tbody></table>");
	document.write("</td>");
	document.write("</tr>");
	document.write("<tr>");
	document.write("<td width=100% style='padding-left:20px;padding-top:0px;padding-right:30px;' align=justify>");
	document.write(text);
	document.write("</td>");
	document.write("</tr>");

		document.write("<tr>");
		document.write("<td width=100% height=11>");
		document.write("	<table cellspacing=0 cellpadding=0 border=0 width=100% height=11><tbody>");
		document.write("	<tr>");
		document.write("	<td width=70% height=11 style='padding-left:20px;padding-top:8px;padding-right:20px;'>");
		if(key) document.write("Прямая ссылка: <span style='color:#3333aa'>http://guards.dclans.ru/pub/"+key+".html</span><br />Просмотров: "+views);
		document.write("	</td>");
		document.write("	<td width=30% height=11 align=center style='color:#776666;'>");
		document.write("	Автор: ");
		WritePersName(pers1, pers2, pers3, pers4, pers5, pers6, pers7, pers8, pers9);
		document.write("	</td>");
		document.write("	</tr>");
		document.write("	</tbody></table>");
		document.write("</td>");
		document.write("</tr>");

	document.write("</tbody></table>");
	}

function write_comms_bbcodes(skin)
	{
	var s = '';

//	s += '&nbsp;';
	s += '<img onclick="javasript:AddTag(comtext, \'b\');" style="cursor:hand;border:0px solid #747474; " src="/input/skins/'+skin+'/img/bbcodes/bold.gif" border=0 width=23 height=22 alt="Жирный">';
//	s += '&nbsp;';
	s += '<img onclick="javasript:AddTag(comtext, \'i\');" style="cursor:hand;border:0px solid #747474; " src="/input/skins/'+skin+'/img/bbcodes/italic.gif" border=0 width=23 height=22 alt="Наклонный">';
//	s += '&nbsp;';
	s += '<img onclick="javasript:AddTag(comtext, \'u\');" style="cursor:hand;border:0px solid #747474; " src="/input/skins/'+skin+'/img/bbcodes/underline.gif" border=0 width=23 height=22 alt="Подчеркнутый">';
//	s += '&nbsp;';
	s += '<img onclick="javasript:AddTag(comtext, \'s\');" style="cursor:hand;border:0px solid #747474; " src="/input/skins/'+skin+'/img/bbcodes/small.gif" border=0 width=23 height=22 alt="Маленький">';
//	s += '&nbsp;';
	s += '<img onclick="javasript:AddTag(comtext, \'strike\');" style="cursor:hand;border:0px solid #747474; " src="/input/skins/'+skin+'/img/bbcodes/strike.gif" border=0 width=23 height=22 alt="Перечеркнутый">';
//	s += '&nbsp;';
//	s += '<img onclick="javasript:AddTag(comtext, \'url\');" style="cursor:hand;border:0px solid #747474; " src="/input/skins/'+skin+'/img/bbcodes/url.gif" border=0 width=23 height=22 alt="URL">';
//	s += '&nbsp;';
	s += '<img onclick="javasript:AddTag(comtext, \'img\');" style="cursor:hand;border:0px solid #747474; " src="/input/skins/'+skin+'/img/bbcodes/image.gif" border=0 width=23 height=22 alt="Изображение">';
//	s += '&nbsp;';
	s += '<img onclick="javasript:AddTag(comtext, \'q\');" style="cursor:hand;border:0px solid #747474; " src="/input/skins/'+skin+'/img/bbcodes/quote.gif" border=0 width=23 height=22 alt="Цитата">';
//	s += '&nbsp;';
	s += '<img onclick="javasript:AddTag(comtext, \'code\');" style="cursor:hand;border:0px solid #747474; " src="/input/skins/'+skin+'/img/bbcodes/code.gif" border=0 width=23 height=22 alt="Код">';
//	s += '&nbsp;';
//	s += '<img onclick="javasript:AddTag(comtext, \'m\');" style="cursor:hand;border:0px solid #747474; " src="/input/skins/'+skin+'/img/bbcodes/marquee.gif" border=0 width=23 height=22 alt="Двигающийся">';
//	s += '&nbsp;';
//	s += '<img onclick="javasript:AddTag(comtext, \'sp\');" style="cursor:hand;border:0px solid #747474; " src="/input/skins/'+skin+'/img/bbcodes/spoiler.gif" border=0 width=23 height=22 alt="Скрытый текст">';
//	s += '&nbsp;';

	return s;
	}

function write_comms_smiles(skin)
	{
	document.write('&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :stesn: \', 0);" style="cursor:hand;" src="/images/data/smiles/stesn.gif" border=0 alt=":stesn:">');
	document.write('&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :love: \', 0);" style="cursor:hand;" src="/images/data/smiles/love.gif" border=0 alt=":love:">');
	document.write('&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :love2: \', 0);" style="cursor:hand;" src="/images/data/smiles/love2.gif" border=0 alt=":love2:">');
	document.write('&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :devil: \', 0);" style="cursor:hand;" src="/images/data/smiles/sarcastic.gif" border=0 alt=":devil:">');
	document.write('&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :smile: \', 0);" style="cursor:hand;" src="/images/data/smiles/smile.gif" border=0 alt=":smile:">');
	document.write('&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :drink: \', 0);" style="cursor:hand;" src="/images/data/smiles/drink.gif" border=0 alt=":drink:">');
	document.write('&nbsp;<br />');
	document.write('<img onclick="javasript:insert_text(comtext, \' :rose: \', 0);" style="cursor:hand;" src="/images/data/smiles/rose.gif" border=0 alt=":rose:">');
	document.write('&nbsp;&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :peace: \', 0);" style="cursor:hand;" src="/images/data/smiles/peace.gif" border=0 alt=":peace:">');
	document.write('&nbsp;&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :podozr: \', 0);" style="cursor:hand;" src="/images/data/smiles/podozren.gif" border=0 alt=":podozr:">');
	document.write('&nbsp;&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :cool: \', 0);" style="cursor:hand;" src="/images/data/smiles/cool.gif" border=0 alt=":cool:">');
	document.write('&nbsp;&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :no: \', 0);" style="cursor:hand;" src="/images/data/smiles/no.gif" border=0 alt=":no:">');
	document.write('&nbsp;&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :red: \', 0);" style="cursor:hand;" src="/images/data/smiles/embarrassed2.gif" border=0 alt=":red:">');
	document.write('&nbsp;<br />');
	document.write('<img onclick="javasript:insert_text(comtext, \' :fuu: \', 0);" style="cursor:hand;" src="/images/data/smiles/fuu.gif" border=0 alt=":fuu:">');
	document.write('&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :king: \', 0);" style="cursor:hand;" src="/images/data/smiles/king.gif" border=0 alt=":king:">');
	document.write('&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :ogo: \', 0);" style="cursor:hand;" src="/images/data/smiles/ogo.gif" border=0 alt=":ogo:">');
	document.write('&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :lol: \', 0);" style="cursor:hand;" src="/images/data/smiles/lol.gif" border=0 alt=":lol:">');
	document.write('&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :wink: \', 0);" style="cursor:hand;" src="/images/data/smiles/winking2.gif" border=0 alt=":wink:">');
	document.write('&nbsp;');
	document.write('<img onclick="javasript:insert_text(comtext, \' :kiss: \', 0);" style="cursor:hand;" src="/images/data/smiles/kiss.gif" border=0 alt=":kiss:">');
	}

function write_comms_table(id, page, skin, url)
	{
	document.write('<table border=0 cellspacing=0 cellpadding=0 width=99%><tbody><tr><td align=left width=100%>');
	write_title("Добавить комментарий", skin);
	document.write('</td></tr></tbody></table>');

	document.write('<table cellspacing=0 cellpadding=4 border=0 width=99% align=center><tbody>');
	document.write("<div style='width:100%; height:15px;'></div>");
	document.write('<form action="'+url+'" method=post name="comms">');
	document.write('<tr><td align=center width=100%>');

			document.write('<table cellspacing=0 cellpadding=5 border=0 align=center width=400><tbody><tr><td width=300 align=center>');
			document.write('<textarea name="comtext" style="width:300px; height:150px;"></textarea>');
			document.write('</td><td valign=top align=left valign=middle>');
			document.write('<b>BB Codes:</b><br />');
			document.write(write_comms_bbcodes(skin));
			document.write('<hr />');
			document.write('<b>Смайлы:</b><br />');
			write_comms_smiles(skin);
			document.write('</td></tr><tr><td colspan=2 align=left>');
			document.write('<input style="width:300px;" class=button type=submit value="Добавить">&nbsp;');
			//document.write('<input style="width:190px;" class=button type=button onClick="javascript:preview();" value="Предварительный просмотр">');
			document.write('</td></tr></tbody></table>');
	document.write('</td></tr></form></tbody></table>');
	}

function write_addpost_table(fid, tid, page, fake, referer, skin)
	{
	var url;
	if(!page) url = 'forum-f-'+fid+'-t-'+tid+'-send.html#last';
	else url = 'forum-f-'+fid+'-t-'+tid+'-p-'+page+'-send.html#last';

	document.write('<table border=0 cellspacing=0 cellpadding=0 width=100%><tbody><tr><td align=left width=100%>');
	write_title("Добавить ответ", "", skin);
	document.write('</td></tr></tbody></table>');

	document.write('<table bgcolor="#dfdfdf" cellspacing=0 cellpadding=4 border=0 width=100% align=center><tbody>');
	document.write('<form action="'+url+'" method=post name="comms"><input name="referer" value="'+referer+'" type=hidden> ');
	document.write("<input type='hidden' name='act' value='Post' />");
	document.write('<tr><td align=center width=100%>');

			document.write('<table cellspacing=0 cellpadding=5 border=0 align=center width=400><tbody><tr><td width=300 align=center>');
			document.write('<textarea name="comtext" style="width:300px; height:150px;"></textarea>');
			document.write('</td><td valign=top align=left valign=middle>');
			document.write('<b>BB Codes:</b><br />');
			document.write(write_comms_bbcodes(skin));
			document.write('<hr />');
			document.write('<b>Смайлы:</b><br />');
			write_comms_smiles(skin);
			document.write('</td></tr><tr><td colspan=2 align=left>');
			if(fake!=0) document.write('<input type=checkbox name="usefake" id="fake">&nbsp;<label for="fake">Подписаться как <b>'+fake+'</b></label>&nbsp;</td></tr><tr><td colspan=2 align=left>');
			document.write('<input style="width:190px;" class=button type=submit value="Добавить ответ">&nbsp;');
			//document.write('<input style="width:190px;" class=button type=button onClick="javascript:preview();" value="Предварительный просмотр">');
			document.write('</td></tr></tbody></table>');
	document.write('</td></tr></form></tbody></table>');
	}

function switchCell(n)
	{
	for(i=0;i<navcell.length;i++)
		{
		navcell[i].className="tab-off";
		tb[i].style.display="none";
		}
	navcell[n].className="tab-on";
	tb[n].style.display="block";
	tb_content.height=screen.availHeight;
	}

//----------------------------------------------

var adv_mode = 1;
var tags = new Array(5);
var tag_size = 0;
var tag_color = 0;

function insert_tag_var(obj, t, list){
	if ((document.selection)) {
		obj.focus();
		obj.document.selection.createRange().text = '[' + t + '=' + list.value + ']'+ obj.document.selection.createRange().text+'[/' + t + ']';
	} else obj.value += '[' + t + '] [/' + t + ']';

//this.options[0].selected = true;

}

function AddCode(form,val,code) {
	form.comtext.value += "["+code+"="+val+"]";
	form.comtext.focus();
}

function AddTag(obj, tag){
	message='';
	if(adv_mode==0) {
		if (tags[tag]==1){
			t1='[/' + tag + ']';	
			tags[tag]=0;
		}else{
			tags[tag]=1;
			t1='[' + tag + ']';
		}
		insert_text(obj,t1);
	}else{
		insert_tag(obj,tag);
	}
}

function AddTagVar(tag, Var, obj){
	document.getElementById(obj).focus();
	 document.getElementById(obj).value += '[' + tag + ']'+ Var +'[/' + tag + ']';
	}


function insert_text(obj, t1, isglobal)
	{ 
	if(isglobal)
		{
		if (t1 != '') document.forms['comms'].elements['comtext'].value += t1;
		}
	else
		{
		if ((document.selection))
			{
			obj.focus();
			obj.document.selection.createRange().text = t1;
			}
		else document.getElementById(obj).value += t1;
		}
	}

function insert_tag(obj, t1,t2){ 
	if (t2=="" || t2==undefined) t2=t1;
	if ((document.selection)) {
		obj.focus();
		obj.document.selection.createRange().text = '[' + t1 + ']'+ obj.document.selection.createRange().text+'[/' + t2 + ']';
	} else obj.value += '[' + t1 + '] [/' + t2 + ']';
}