	$(function()
	{
		$("div.hide_content").slideUp();
		$("a.morebutton").click(function(){$(this).toggleClass("morebutton_close").parent().next("div.hide_content").slideToggle();return false;});
		$(".nyromodal").nyroModal();
		$("div.spoiler-title").click(function () {$(this).next("div").slideToggle();});
	});

	function my_rate_news(rate,id) {$.ajax({type:"POST",url:"/ajax/rate_news.php",data:"rate="+rate+"&id="+id,beforeSend:function(){$("#rate_result").fadeOut(500,function(){$("#rate_indicator").fadeIn(500)})},success:function(msg){$("#rate_indicator").fadeOut(500,function(){$("#rate_result").html(msg);$("#rate_result").fadeIn(500)})}})}

	function yes_no(vote,id,tag) {$.ajax({type:"POST",url:"/ajax/rate_yes_no.php",data:"vote="+vote+"&id="+id+"&tag="+tag,beforeSend:function(){$("#yes_no_result_"+id).fadeOut(500,function(){$("#yes_no_indicator_"+id).fadeIn(500)})},success:function(msg){$("#yes_no_indicator_"+id).fadeOut(500,function(){$("#yes_no_result_"+id).html(msg);$("#yes_no_result_"+id).fadeIn(500)})}})}

	function my_rate_game(rate,id) {$.ajax({type:"POST",url:"/ajax/rate_game.php",data:"rate="+rate+"&id="+id,beforeSend:function(){$("#rate_result").fadeOut(500,function(){$("#rate_indicator").fadeIn(500)})},success:function(msg){$("#rate_indicator").fadeOut(500,function(){$("#rate_result").html(msg);$("#rate_result").fadeIn(500)})}})}

	$(document).ready(function()
	{
		$("#notes").append("<ol id=\"footnotes\"></ol>");
		footnote = 1;
		$("ref[cite],ref[title],blockquote[cite],blockquote[title]").addClass("footnote");
		$(".footnote").each(function() {
			$(this).append("<sup id=\"sn"+footnote+"\"><a href=\"#sl"+footnote+"\">"+footnote+"</a></sup>");
			cite="<li id=\"sl"+footnote+"\">";
			url=$(this).attr("cite");
			title=$(this).attr("title");
			if(title && url) {
				cite+="<a href=\""+url+"\">"+title+"</a> <a href=\"#sn"+footnote+"\">К цитате</a>";
			} else if(title) {
				cite+=title;
			} else if(url) {
				cite+="<a href=\""+url+"\">"+url+"</a> <a href=\"#sn"+footnote+"\">К цитате</a>";
			}
			cite+="</li>";
			$("#footnotes").append(cite);
			footnote++;
		});
	});


	function div_comment_form()
	{
		$("#div_comment_form").slideToggle();
	}



	// Показать форму комментирования
	current_form=0;function show_comment_form(id){$('#preview_div').hide();if(current_form==id&&window.show_form)return false;div_current_form=$("#reply_"+current_form);div_next_form=$("#reply_"+id);div_current_form.slideUp();var form_data=div_current_form.html();div_current_form.html("");div_next_form.html(form_data).slideToggle();$("#form_comment_reply").attr("value",id);current_form=id;show_form=1;set_keypress()}

	// Горячие клавиши
	function set_keypress()	{ $('#comment_form').keypress(function (e) { if (e.which == 13 && e.ctrlKey ) $('#submit_comment').click(); }); }

	// Добавление комментария
	function add_comment(form,id,type,hash){var text=jQuery.trim($("#form_comment_text").val());var form_comment_reply=$("#form_comment_reply").attr("value");if(text.length>2){$("#form_comment_text").addClass("textarea_loader");$.post("/ajax/add_comment.php",{id:id,type:type,text:text,pid:form_comment_reply,hash:hash},function(json){if(json.type=='notice-error'){jQuery.noticeAdd({text:json.text,type:json.type})}else{$.each(json,function(key,val){var comment_id=val.comment_id;var comment_id_prev=val.comment_id_prev;var comment_text=val.text;$("#comment_id_"+comment_id_prev).after(comment_text)})}$('#form_comment_text').removeClass("textarea_loader");$('div.reply').slideUp();spoiler_activate();$.scrollTo('#comment_id_'+json.current_comment_id,500,{offset:{top:-220}})},"json")}else{alert("Минимальный размер сообщения - 3 символа.")}}

	// Обновление дерева комментариев
	function update_comments(type,id,hash,load){$("#update-comments").attr("src","http://images.stopgame.ru/blogs/update_act.gif");$.post("/ajax/add_comment.php",{type:type,id:id,hash:hash,action:'update'},function(json){if(json.type=='notice-error'){jQuery.noticeAdd({text:json.text,type:json.type})}else{update_comment_id=[];$.each(json,function(key,val){var comment_id=val.comment_id;var comment_id_prev=val.comment_id_prev;if(load==1){var comment_text=val.text;$("#comment_id_"+comment_id_prev).after(comment_text)}update_comment_id[key]=comment_id})}$("#update-comments").attr("src","http://images.stopgame.ru/blogs/update.gif");$("#new-comments").show().html(json.update_count);spoiler_activate()},"json")}

	// Переход к новому комменту
	function update_comment_scroll(){if(update_comment_id[0]){$.scrollTo("#comment_id_"+update_comment_id[0],800);update_comment_id.shift();$("#new-comments").html(update_comment_id.length)}}

	// Рейтинг
	function rate_comment(id,who,type,what){$.getJSON("/ajax/rate_comment.php",{id:id,type:type,what:what},function(json){jQuery.noticeAdd({text:json.text,type:json.type});var current_rating=json.counter;$("#comment_rating_"+id).html(current_rating);$("#comment_button_"+id).find('div.comment_rating_minus').addClass('comment_rating_minus_na');$("#comment_button_"+id).find('div.comment_rating_plus').addClass('comment_rating_plus_na')})}

	// Инфа о пользователе
	function show_user_info(user_id,href_id){$('div.comment_user_popup').hide();$.post("/ajax/comment_user_popup.php",{user_id:user_id},function(data){$('#href_user_'+href_id).after(data);$('div.comment_user_popup').hover(function(){},function(){$(this).fadeOut()})})}

	// Спойлер
	function spoiler_activate(){$("div.spoiler-title").unbind('click');$("div.spoiler-title").click(function(){$(this).next("div").slideToggle()})}

	// Проверка на число
	function isnum(num) { if ( num == 0 ) return true; return res = ( num / num ) ? true : false; }
