// Comment alert event

$(document).ready(function() {
	$("img.comment-alert").click(function() {

		if(confirm('Weet je zeker dat je melding wilt maken van een ongepaste reactie? De redactie zal op de hoogte worden gebracht en de reactie controleren. \n\nLet op, misbruik wordt bestraft met een IP-Ban.')) {

			var comment_id = $(this).attr('comment_id');
			var weblog_id = $(this).attr('weblog_id');
			var entry_id = $(this).attr('entry_id');

			$.ajax({
				type: "POST",
				cache: false,
				url: "/index/ajax/comment-alert",
				data: "comment_id="+comment_id+"&weblog_id="+weblog_id+"&entry_id="+entry_id+"&client_ip="+client_ip,
				success: function(msg){
					if(msg == "ok") { alert("Melding succesvol verzonden.\n\nLet op: Misbruik wordt direct bestraft met een IP-Ban"); }
				}
			});
		}				
	});
});

// reply form

$(function(){
// Find all the "reply to" links and bind to the click event
$('a[href^=/index/comment-form/]').click(function() {

  var url_array = $(this)    // The anchor object
	.attr('href')    // Fetch the value of the href attribute
	.split("/");    // Divide into chunks, using / as the divider
  var id = url_array[4];    // We want the fourth chunk


  // Change the value of weever-parent-id
  $('#weever-parent-id').val(id);

  // Now we'll move the form
  
  $('form#comment_form')
	.insertAfter(    // Insert the comment form after div.entry
	  $(this)
	  .parent()    // The containing p tag
	  .parent()    // div.entry
	  );

  return false;
});
});
