// JavaScript Document

function toggle_parent_comment (id) {
	
	var cm = $('#comment-'+id+' > .text');
	
	if (cm.hasClass('selected') == true) {
		cm.removeClass('selected');
	} else {
		cm.addClass('selected');
	}
	
}

function check_cookie () {

	if ($.cookies.test() == false) {
		alert('Вам нужно включить cookie.');
		return false;
	} else {
		return true;	
	}
	
}

function get_comment_form (comment_id) {
	
	$('#comments_list').find('.reply_form').remove();
	$('#article_reply > .reply_form').clone().insertAfter($('#comment-'+comment_id+' > .column_right > .info'));
	$("#comment-"+comment_id+" input[name='parent_id']").val(comment_id);
		
}

function rate_this_old (content_id, content_type, direction) {
	var rating_box_id = '#rating-box-'+content_id+'-'+content_type;
	if (direction == 1) var span_class = 'love';
	if (direction == 2) {
		var span_class = 'hate';
		var comment = '#comment-'+content_id;
		var comment_text = comment+' .text';
		$(comment_text).hide();
		$(comment_text).before('<div class="sys-alert">Комментарий скрыт для вас. <span onClick="$(\''+comment_text+'\').show(); $(\''+comment+' .sys-alert\').hide();" class="link">Показать</span>?</div>');
	}
	var current_value_dom = rating_box_id+' > .'+span_class+' > .value';
	var current_value = $(current_value_dom).html();
	$(current_value_dom).html(++current_value); 
	$(rating_box_id+' > span').removeAttr('onClick').removeClass('hover');
	$.get('/code/?action=update_rating&content_id='+content_id+'&content_type='+content_type+'&direction='+direction);
	return true;	
}

function rate_this (content_id, content_type, direction) {
	var rating_box_id = '#rating-box-'+content_id+'-'+content_type;
	if (direction == 1) var span_class = 'love';
	if (direction == 2) {
		var span_class = 'hate';
		var comment = '#comment-'+content_id;
		var comment_text = comment+' .text';
		$(comment_text).css('color', '#CCC');
		$(comment_text).css('background', 'none');
	}
	var current_value_dom = rating_box_id+' > .'+span_class+' > .value';
	var current_value = $(current_value_dom).html();
	$(current_value_dom).html(++current_value); 
	$(rating_box_id+' > span').removeAttr('onClick').removeClass('hover');
	$.get('/code/?action=update_rating&content_id='+content_id+'&content_type='+content_type+'&direction='+direction);
	return true;	
}

