var $j = jQuery.noConflict();

$j(function()
{
	$j('#country > ul').tabs();
});

function updatePrayerStats(country_id) {
  //Store the current HREF value
  var href = $j('#hrefPrayed').attr('href');

  //Clear the HREF value so they don't submit it again while it's already processing
  $j('#hrefPrayed').attr({href:'#'});

  $j.ajax({
    type: "POST",
    url: "ajax_handler.php",
    data: "a=increment_prayer_counter&country="+country_id,
    success: function(msg){
      $j.ajax({
        type: "GET",
        url: "ajax_handler.php",
        data: "a=get_prayer_count&country="+country_id,
        success: function(msg){
          //If we're on the Countries page, increment the counter for this country
          //(we use this same function from the general Pray Now page, which doesn't have a counter)
          if ($j('#prayer_count')) {
            $j('#prayer_count').contents().replaceWith(msg);
          }

          //Change the image to show that the prayer count has finished being updated
          $j('#imgPrayed').attr({src:'http://www.prayeurope.com/images/buttons/button_yes_ive_prayed_check.png'});

          //Leave it disabled since we don't want them to submit it again. This forces them to
          //refresh the page if they want to submit again.
//          $j('#hrefPrayed').attr({href:href});
        }
      });
    }
  });
}