function processJson(form,data,formid) { 
    data = data[0];
    $.get('/partial/'+data.pk+'/', function(to_append, textStatus) {
            $('#a'+formid).append(to_append);
            $('.responseform').clearForm();
    });
}
function ajaxize_form(form){
	var ajax_url = form.attr('action')+'json/';
	var formid = form.attr('id');
	var on_succ = function(data) {
	  	processJson(form,data,formid);
	}
    form.ajaxForm({ 
        dataType:  'json', 
        
        url: ajax_url,
        
        beforeSubmit:function(data,form) {
          return true; 
        },          
        
        success: on_succ
    });
}
function toggle_reply(id)
    {
        $("#reply-"+id).toggle();    
        return false; 
    }
function planet_checkbox_a(){
	if ($('#id_all_activities').attr('checked')){
		$('#id_reviews').removeAttr('checked');
		$('#id_shorts').removeAttr('checked');
		$('#id_comments').removeAttr('checked');
		$('#id_links').removeAttr('checked');
        $('#id_most_interesting_reviews').removeAttr('checked')
	}
}
function planet_checkbox_u(){
	if ($('#id_all_users').attr('checked')){
		$('#id_comrades').removeAttr('checked');
		$('#id_similar_taste').removeAttr('checked');
	}
}
function planet_checkboxa(){
	if ($('#id_all_activities').attr('checked')){
		$('#id_all_activities').removeAttr('checked');
	}
    if ($('#id_most_interesting_reviews').attr('checked')){
        $('#id_most_interesting_reviews').removeAttr('checked')
    }
}
function planet_checkboxu(){
	if ($('#id_all_users').attr('checked')){
		$('#id_all_users').removeAttr('checked');
	}
}
function planet_checkboxmi(){
	if ($('#id_most_interesting_reviews').attr('checked')){
        $('#id_all_activities').removeAttr('checked');
		$('#id_reviews').removeAttr('checked');
		$('#id_shorts').removeAttr('checked');
		$('#id_comments').removeAttr('checked');
		$('#id_links').removeAttr('checked');
	}
}
$(document).ready(function() {
    $('form.responseform').each(function(i,form) {
        ajaxize_form($(form));
      });
});
