//Слайдер
function sliderElement(element , speed) 
{
	$('html, body').animate({
			scrollTop: $(element).offset().top
	}, speed);
}

//Меняем теги
function tag_module() {
	$.get('../../ajax/tags.php' ,  {}, function(response) {
			$("#tags_module").fadeOut('300' , function() {
				$("#tags_module").html(response);
				$("#tags_module").fadeIn('300');
			});
            
			
    },  'html');
}


//Добавление голоса
function set_rating(id , type , rate_up , rate_down) {
	//, 'rating_up' : rate_up , 'rating_down' : rate_down
	$.get('../../ajax/rating.php' ,  {'act' : 'set' , 'id_torrent' : id , 'to' : type }, function(response) {
				$("#rating_status").html(response);
				$("#rating_plus").html('<img src="public/images/edit_add_em.gif">');
				$("#rating_minus").html('<img src="public/images/messagebox_critical_em.gif">');
				
				var rating_num_real = rate_up - rate_down;
				if(type == 'up') {
					rating_num_real += 1;
				} else {
					rating_num_real += 1 * (-1);
						
				}
				
				$("#rating_num").html(rating_num_real);
				
    },  'html');
}


//Одобрние раздачи/или ее отклонение
function moderated(id , status) {
	// if(status != 'yes' || status != 'no') {
		// return false;
	// }
	
	$.get('../../ajax/moderated.php' ,  {'status' : status , 'id' : id  }, function(response) {
		$("#status_moderated").html(response);
	});
}

function open_div(el) {	
	$('#'+el).slideToggle();
	// if($('#'+el).is(":visible")) { 
		// $('#'+el).slideDown();
	// } else { 
		// $('#'+el).slideUp(500, 1.0);
	// }
}


var ExternalLinks_InNewWindow = '1';

function initSpoilers(context) {
	var context = context || 'body';
	$('div.news-wrap', $(context))
		.click(function(){
		    var ctx = $(this).next('div.news-body');
			var code = ctx.children('textarea').text();
			if (code) {
			    ctx.children('textarea').replaceWith(code);
			    initSpoilers(ctx);
			}
			$(this).toggleClass('unfolded');
            $(this).next('div.news-body').slideToggle('fast');
            $(this).next('div.news-body').next().slideToggle('fast');
		});
}

// $(document).ready(function(){
	$(document).ready(
	function(){
	  $('div.news-head')
	  .click(function() {
			$(this).toggleClass('unfolded');
			$(this).next('div.news-body').slideToggle('fast');
		});
  }
);
// });

