jQuery(document).ready( function ($) {

  $('li.hotornot-button').hover(
    function () {
      $(this).addClass('button-hover');
      $('li.hotornot-button:lt(' + this.id + ')').addClass('button-hover');
    },
    function () {
      $(this).removeClass('button-hover');
      $('li.hotornot-button:lt(' + this.id + ')').removeClass('button-hover');
    }
  );

  $('li.hotornot-button').click( function () {
    $('input#hotornot-vote').val(this.id);
    $('form#hotornot-form').submit();
  });

  $('#share-link').click( function () {
    $(this).select();
  });

  $('.hotornot-report').click( function () {
    $(this).parent().load($(this).attr('href'));
    $(this).parent().html($('#hotornot-loading').html());
    return false;
  });

  $('.hotornot-delete').click( function () {
    if (confirm('Are you sure you want to delete this image?'))
    {
      $(this).parent().load($(this).attr('href'));
      $(this).parent().html($('#hotornot-loading').html());
    }
    return false;
  });

  $('#hotornot-comments .update').load(root + 'index.php?option=com_hotornot&task=comments&format=raw&id=' + $('#hotornot-comments').attr('class') + '&source=' + $('#source').val());

  $('#show-comment-form').click( function () {
    $('#comment-form').show("normal");
    return false;
  });

});

