﻿  $(function(){
    // Find all the "reply to" links and bind to the click event
    $('a[href^=/index.php/asked-answered/answer/]').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[5];    // 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
          );

      return false;
    });
  }); 