$('.comment-item').live('mouseover', function() {
            $(this).find('.opt_show').show();
}).live('mouseout', function() {
            $(this).find('.opt_show').hide();
        });

$(document).ready(function() {
    $('html').click(function(){$('.opt-s').hide(); $('.opt_hide').addClass('opt_show').removeClass('opt_hide').hide();});
    $('.opt_show').live('click', function(){
       $(this).parent().children(".opt-s" ).show();
       $(this).addClass('opt_hide').removeClass('opt_show');
    });
    $('.opt_hide').live('click', function(){
       $(this).parent().children(".opt-s" ).hide();
       $(this).addClass('opt_show').removeClass('opt_hide');
    });
    $('.news-summary').live('mouseover', function() {
                $(this).find('.opt_show').show();
    }).live('mouseout', function() {
                $(this).find('.opt_show').hide();
            });
});

function _hide_item(id, opts, idname, item) {
        $(this).closest('.nl-hover_hidden').hide();
    $('#' + idname + id).closest('.' + item).slideUp();
    opts.closest('.' + item).after('<div class="hidden_text'+id+'" style="text-align:left;padding:20px;margin-bottom:10px;background:#eeeeee;">' + (item=='comment-item' ? comment_ : post) + ' '+post_is_hidden+' <a href="#return_item" onclick="_return_item(' + id +  ', \'' + idname + '\', \'' + item + '\'); return false;">'+cancel_action+'.</a></div>');
   item = item == 'comment-item' ? 'comment' : item;
   $.ajax({
        url: '/process/',
        type: 'post',
        data: { 'action': 'insert_ignore', 'object': item, 'object_id': id }
    });
        return false;
    }
    
function _return_item(id, idname, item) {
    $('.hidden_text' + id).remove();
    $('#' + idname + id).closest('.'+item).slideDown();

    $.ajax({
        url: '/process/',
        type: 'post',
        data: { 'action': 'delete_ignore', 'object': item, 'object_id': id }
    });
	return false;
    }

function _hide_all_comments(user_id, user_name, user_nick, opts){
    $('.comment-item').each(function() {
        if ($(this).find('a.comment-author').attr('href') == '/' + user_nick + '/') {
                                $(this).slideUp();
                        }
                 });
    opts.closest('.comment-item').after('<div class="hidden_text'+user_nick+'" style="text-align:left;padding:20px;margin-bottom:10px;background:#eeeeee;"> '+comments_by+' ' + user_name + ', '+posts_are_hidden+' <a href="#return_comments" onclick="_return_comments(' + user_id + ', \'' + user_nick + '\'); return false;">'+cancel_action+'.</a></div>');

    $.ajax({
        url: '/process/',
        type: 'post',
        data: { 'action': 'insert_ignore', 'object': 'user', 'object_id': user_id, 'ignore': 2 }
    });
}

function _return_comments(user_id, user_name) {
    $('.hidden_text' + user_name).remove();
    $('.comment-item').each(function() {
        if ($(this).find('a.comment-author').attr('href') == '/' + user_name + '/') {
                        $(this).slideDown();
                }
        });
    $.ajax({
        url: '/process/',
        type: 'post',
        data: { 'action': 'delete_ignore', 'object': 'user', 'object_id': user_id }
    });
}

function _hide_all_news(user_id, user_name, user_nick, opts, show) {
        $(this).closest('.nl-hover_hidden').hide();
    if (!show) {
        $('.news').each(function() {
            if ($(this).find('a.nla-username').attr('href') == '/' + user_nick + '/') {
                                $(this).slideUp();
                        }
                });
        }
    opts.closest('.news').after('<div class="hidden_text'+user_nick+'" style="padding:20px;margin-bottom:10px;background:#eeeeee;">'+posts_by+' <a class="username" href="/' + user_nick + '/">' + user_name + '</a>, '+posts_are_hidden+' <a href="#return_news" onclick="_return_news(' + user_id + ', \'' + user_nick + '\'); return false;">'+cancel_action+'.</a></div>');

    $.ajax({
        url: '/process/',
        type: 'post',
        data: { 'action': 'insert_ignore', 'object': 'user', 'object_id': user_id, 'ignore': 1 }
    });
}
function _return_news(user_id, user_name) {
	$(this).closest('.nl-hover_hidden').hide();
    $('.news').each(function() {
        if ($(this).find('a.nla-username').attr('href') == '/' + user_name + '/') {
			$(this).slideDown();
		}
	});
    $('.hidden_text' + user_name).remove();
	
     $.ajax({
        url: '/process/',
        type: 'post',
        data: { 'action': 'delete_ignore', 'object': 'user', 'object_id': user_id }
    });
}

function _block_user(user_id, user_name, user_nick, item/*comment/news*/, item_id, idname/*comment_body3_/place*/, spam_msg, show) {
    addToBlack(true, user_id);
    if (typeof spam_msg == 'undefined') spam_msg = '';
    var href = '/claim_form/?item=' + item + '&item_id=' + item_id + '&height=200&width=500';
    var mess= spam_msg+'<a class="username" href="/' + user_nick + '/">' + user_name + '</a> ' + user_ignored + '. ' + you_can + ' <a onclick="_activate_user(' + user_id + ', \'' + user_nick + '\');" href="javascript:{}">' + cancel_action + '</a>.';
    if (item=='news' && (typeof show == 'undefined' || !show)) {
        $('.news').each(function() {
            if ($(this).find('a.nla-username').attr('href') == '/' + user_nick + '/') {
                                $(this).slideUp();
                        }
                });
      } else if (item=='comment-item' && (typeof show == 'undefined' || !show)) {
        $('.comment-item').each(function() {
            if ($(this).find('a.comment-author').attr('href') == '/' + user_nick + '/') {
                                $(this).slideUp();
                        }
                });
      }
    $('#' + idname + item_id).closest('.' + item).after('<div class="hidden_text' + user_nick + '" style="text-align:left;padding:20px;margin-bottom:10px;background:#eeeeee;">' + mess + '</div>');
    }

function _activate_user(user_id, user_name) {
    addToBlack(false, user_id);
    $('.news, .comment-item').each(function() {
        if ($(this).find('a.nla-username').attr('href') == '/' + user_name + '/' || $(this).find('a.comment-author').attr('href') == '/' + user_name + '/') {
                $(this).show();
                }
         });
    $('.hidden_text' + user_name).remove();
}

function _delete_all(user_id, user_name) {
    if (!confirm(all_news_delete + ' ' + user_name + '?')) {
        return 0;
    } else {
    $.ajax({
        url: '/process/',
        type: 'post',
        dataType: 'html',
        data: { 'user_id': user_id, 'action': '_delete_all' },
        success: function() {
            alert(all_news_deleted);
        }
    });
  }
}

function _spam_msg(source, item_id) {
    $.ajax({
        url: '/process/',
        type: 'post',
        dataType: 'html',
        data: { 'source': source, 'item_id': item_id, 'link': '"' + window.location + '"', 'action': '_spam_msg' }
    });
}

