$(function() {
    regEvents();
});

function regEvents() {
    $('.abuse_link').click(abuse);
    $('#part_button a').click(counter_up);
}

function remove_abuse(id,type) {
    $.get('/abuse', {'id': id, 'type': type});
    if(type == 'watermoment') {
	$('#water_moments').load('/watermoments/ #water_moments>*', regEvents);
    }
    else if (type=="declaration") {
	$('#water_moments').load('/declare/ #water_moments>*', regEvents);
    }
    else if (type == 'collaboration') {
	$('#water_moments').load('/collaborate #water_moments>*', regEvents);
    }
    else if (type == 'hp') {
	$('#water_moments').load('/ #water_moments>*', regEvents);
    }
    return false;
}

function abuse() {
    var id = $(this).attr('rel');
    var type = $(this).attr('contenttype');
    
    remove_abuse(id,type);
    return false;
}

function counter_up() {
    var current_count = parseInt($('#pp_taking_part').html());
    current_count += 1;
    $('#pp_taking_part').html(current_count);
    $.get('/count', {'update': 'true'});
    return false;
}
