  $(document).ready(function(){  
  
    $("a.cmDelete,a.cmKeep,a.cmKeepMod").click(function() {      
      var confirmation = confirm("If you press OK, you vote to " + this.target + " this post.");
      
      if (!confirmation) {
        return false;
      }
      
      var post_id = this.id.substring(9); // substring 9 cause expect the id to be cmDelete_12345 to get 12345 as the post_id    
    
      $.get("services/communitymod.php", {        
        p: post_id, 
        mode: this.target
      }, function(xml) {        
        updateDeleteVote( post_id, $("deleteVote",xml).text() );        
      });
      
      return false;
    });
    
    $("a.viewCmLog").click(function() {
      var post_id = this.id.substring(10);
      
      $.get("services/communitymod_log.php", {
        p: post_id
      }, function(data) {       
        $("#spaceRow_"+post_id).html(data);
      });
      
      return false;
    });
    
  }); // end ready function
  
  function updateDeleteVote(post_id, voteCount) {    
    $("#deleteVote_"+post_id).html( voteCount );
    
    $("#cmDelete_"+post_id).hide();
    $("#cmKeep___"+post_id).hide();    
    $("#cmKeepMod"+post_id).hide();
    
    if ( voteCount <= -5) {      
      $("#post_"+post_id).hide("slow");
    }
  }    
  
  function ref(object)
{
  if (document.getElementById)
  {
    return document.getElementById(object);
  }
  else if (document.all)
  {
    return eval('document.all.' + object);
  }
  else
  {
    return false;
  }
}

function toggle(pobject)
{
  object = ref('post_' + pobject);

  if( !object.style )
  {
    return false;
  }

  if( object.style.display == 'none' )
  {
    object.style.display = '';
  }
  else
  {
    object.style.display = 'none';
  }
}

function breakout()
{
  if (top.location!= self.location) {
    top.location.href = self.location.href 
  }
}
