var GLOBAL_Forums_HowTo='';
function HowTo(unit)
{
if (GLOBAL_Forums_HowTo==unit)
 {$("#HowTo").hide(); $("#HowTo"+unit).hide();
  GLOBAL_Forums_HowTo='';
 }
else
 {
if (unit=="Cards") {var unit2="Rules";} else {var unit2="Cards";}
$("#HowTo"+unit2).hide(); $("#HowTo"+unit).show(); $("#HowTo").show();
GLOBAL_Forums_HowTo=unit;
 }
}
 
function DeleteForumsMessage(id, topic, login)
{
var text='';
if (id==topic) {text='Äåéñòâèòåëüíî ÓÄÀËÈÒÜ ÂÅÑÜ ÒÎÏÈÊ ?';}
else  {text='Óäàëèòü ñîîáùåíèå '+login+' ?';}

if (confirm(text))
{$.post('/forums/admin/delete.phtml', 'id='+id+'&topic='+topic+'&nocache='+Math.random(),
	function(data)
	{
		if (data=='all')
			{$("[class^=Message]").addClass("table-error");
			 $("[id^=ModeratorInterface]").html("");
			}
		if (data > 0)
			{$(".MessageTR"+id).addClass("table-error");
			 $("#ModeratorInterface"+id).html("");
			}
	}
		  );
}
}

function EditForumsMessage(forum, topic, id, login, date)
{
if (login && date)
 {
$.post('/forums/admin/edit.phtml', 'forum='+forum+'&topic='+topic+'&id='+id+'&login='+login+'&date='+date+'&nocache='+Math.random(),function(data){$("#Message"+id).html(data);});
 }
else
 {
$.post('/forums/admin/edit.phtml', 'forum='+forum+'&topic='+topic+'&nocache='+Math.random(),function(data){var help=$.trim($("#MessageTitle").text()); $("#MessageTitle").html(data); $("#EditTitle").val(help);});
 }
}

function Quote(login, time)
{
quote_text=document.selection?document.selection.createRange().text.replace(/(^\s*)/, "").replace(/(\s*$)/, ""):window.getSelection();
if (quote_text)
  {
	quote_header="[quote "+login+"@"+time+"]";
	quote_text=quote_header+quote_text+"[/quote]";
	
	$("#Text").val($.trim($("#Text").val()+"\n"+quote_text)+"\n");
	alert('Öèòàòà äîáàâëåíà â ñîîáùåíèå.');
  }
else
  {alert('Ïîæàëéñòà, âûäåëèòå öèòèðóåìûé òåêñò.');
  }
}

GLOBAL_Authors=new Array();


function ShowAuthorsInfo(id)
{
	Author=$("#"+id).text().replace(' ', '+');
	if (!$("#DIV"+id).length)
		{$("#"+id).after('<div id="DIV'+id+'" style="display: none; margin-top: 10px;">'+GLOBAL_Authors[Author]+'</div>');
		}
	if (!GLOBAL_Authors[Author])
	{
		$.getScript('/forums/get_user_info.phtml?id='+id+'&login='+Author,
		function()
			{
			 if (ForumUserInfo) {GLOBAL_Authors[Author]=ForumUserInfo;}
			 $("#DIV"+id).html(GLOBAL_Authors[Author]);
			 $("#"+id).click();
			}
		);
	}
	else
	{
		$("#DIV"+id).toggle();
	}
}

function NewTopicsForums(forum)
{
  if ($("#CheckForum"+forum).attr("checked"))
	{$.post("/forums/fresh_topics_list.phtml",{forum: forum, check: "on"},
	function(){$("#Forum"+forum).removeClass("opacity40"); alert("Òîïèêè ýòîãî ôîðóìà ñíîâà ÁÓÄÓÒ ÏÎßÂËßÒÜÑß â ñïèñêå íîâûõ è îáíîâëåííûõ òåì.");}
		);
	}
	else
	{$.post("/forums/fresh_topics_list.phtml",{forum: forum, check: "off"},
	function(){$("#Forum"+forum).addClass("opacity40"); alert("Òîïèêè ýòîãî ôîðóìà áîëüøå ÍÅ ÁÓÄÓÒ ÏÎßÂËßÒÜÑß â ñïèñêå íîâûõ è îáíîâëåííûõ òåì.");}
		);
	}
}