	$(function()
	{
		$(".nyromodal").nyroModal();
		$("div.spoiler-title").click(function () {$(this).next("div").slideToggle();});
		$("a.scroll_to_up").click(function(){$.scrollTo( 150, 800 ); return false;});

		// Блоки на главной
		current_main_block = 'block_recommend';
		$("#main_block_tabs li").click( function() { $("#main_block_tabs li").removeClass("active"); $(this).addClass("active"); var block_show = $(this).attr("alt"); if (block_show != current_main_block) { $("#"+current_main_block).slideUp(); $("#"+block_show).slideDown(); current_main_block = block_show; } return false; } );

	});

	// Скрыть комменты
	function comments_tree_close() { $("div.not_null_level").slideUp(); }

	// Показать комменты
	function comments_tree_open() { $("div.not_null_level").slideDown(); }

	// Прямой эфир
	function block_stream(type) { $("#stream_div").slideUp("slow", function () { $("#stream_loader").slideDown("slow"); $.get("/ajax/stream_refresh.php", { block: type }, function(data){ $("#stream_loader").slideUp("slow"); $("#stream_ul").html(data); $("#stream_div").slideDown("slow");}); }); $("#switcher_ul li").removeClass("active"); $("#switcher_li_" + type).addClass("active"); }

	// Автообновление прямого эфира
	var auto_refresh = setInterval( function() { block_stream('comments'); }, 180000);

	// В избранное
	function favorite(id, who, type) { $.getJSON("/ajax/favorite.php", { id: id, type: type }, function(json){ jQuery.noticeAdd({text: json.text,type: json.type}); if (json.active == 1) { $(who).addClass("active"); } else { $(who).removeClass("active"); }});	}

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

	// Рейтинг
	function rating(id, who, type, what) {
		$.getJSON("/ajax/rating.php", {
			id: id,
			type: type,
			what: what
		}, function (json) {
			jQuery.noticeAdd({
				text: json.text,
				type: json.type
			});
			if (isnum(json.counter)) {
				var current_rating = json.counter;
				var current_rating_plus = '';
				if (current_rating > 0) {
					$(who).parent("li").addClass("positive voted " + what);
					var current_rating_plus = "+";
				} else if (current_rating < 0) {
					$(who).parent("li").addClass("negative voted " + what);
				} else {
					$(who).parent("li").removeClass("negative").removeClass("positive");
				}
				if (type == 'topic') {
					$("#vote_counter_" + id).html(current_rating_plus + current_rating);
				}
				if (type == 'comment') {
					$("#comment_vote_counter_" + id).html(current_rating_plus + current_rating);
				}
			}
		});
	}

	// Голосование
	function topic_vote(id,vote) { $.post("/ajax/topic_vote.php", {id: id, vote: vote}, function(json){ if (json.type == 'notice') { $("#topic_question_area_"+id).slideUp( function() {$("#topic_question_area_"+id).html(json.poll_data).slideDown()} ); } jQuery.noticeAdd({text: json.text, type: json.type}); }, "json"); }

	// Присоединение к блогам
	function join_blog(blog_id,id) { $.post("/ajax/join_blog.php", {id:blog_id}, function(json){ if (json.status == 1) { $(id).children().attr("src", "http://images.stopgame.ru/www/icon_minus.gif"); } if (json.status == 0) { $(id).children().attr("src", "http://images.stopgame.ru/www/icon_plus.gif"); } jQuery.noticeAdd({text: json.text, type: json.type}); }, "json"); }

	// Присоединение к блогу
	function join_blog2(blog_id,id) { $.post("/ajax/join_blog.php", {id:blog_id}, function(json){ if (json.status == 1) { $(id).removeClass("join").addClass("leave"); } if (json.status == 0) { $(id).removeClass("leave").addClass("join"); } jQuery.noticeAdd({text: json.text, type: json.type}); }, "json"); }

	// P.S. Пусть криво и не красиво, главное работает... кидайте камнями...
