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

	// Прямой эфир
	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 == 'forum_message') { $("#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 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()})})}


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