$(document).ready(function() {
    $("a.voteup").click(function(){
      var that = this;
      var comid = that.id.substring(1);
      $.post(that.href, {commentid: comid, votedirection: 'up', returntype: 'good'}, function(html) {
        var icon = "#imgu"+comid;
        var imgpc = "#imgpc"+comid;
        var assoc = "#imgd"+comid;
        var ciurl = $(icon).attr('src');
        var pcurl = $(imgpc).attr('src');
        $(icon).fadeTo('slow',0.1);
        $(imgpc).fadeTo('slow',0.1);
        $(this).delay(500,function(){
          $(icon).attr('src', ciurl+'&?time='+Math.random());
          $(imgpc).attr('src', pcurl+'&?time='+Math.random());
        });
        $(this).delay(500,function(){
        $(icon).fadeTo('slow',1);
        $(imgpc).fadeTo('slow',1);
        $(icon).click(function(){
        return false;
        });
        $(assoc).click(function(){
        return false;
        });
        });
      });
      return false;
    });
    
    $("a.votedown").click(function(){
      var that = this;
      var comid = that.id.substring(1);
      $.post(that.href, {commentid: comid, votedirection: 'down', returntype: 'bad'}, function(html) {
        var icon = "#imgd"+comid;
        var imgpc = "#imgpc"+comid;
        var assoc = "#imgu"+comid;
        var ciurl = $(icon).attr('src');
        var pcurl = $(imgpc).attr('src');
        $(icon).fadeTo('slow',0.1);
        $(imgpc).fadeTo('slow',0.1);
        $(this).delay(500, function(){
          $(icon).attr('src', ciurl+'&?time='+Math.random())
          $(imgpc).attr('src', pcurl+'&?time='+Math.random())
        });
        $(this).delay(1000, function(){
          $(icon).fadeTo('slow',1);
          $(imgpc).fadeTo('slow',1);
        });
        $(icon).click(function(){
        return false;
        });
        $(assoc).click(function(){
        return false;
        });
      });
      return false;
    });
    
  // find the div.fade elements and hook the hover event
  $('div.fade').hover(function() {
    // on hovering over, find the element we want to fade *up*
    var fade = $('> div', this);
    
    // if the element is currently being animated (to a fadeOut)...
    if (fade.is(':animated')) {
      // ...take it's current opacity back up to 1
      fade.stop().fadeTo(250, 1);
    } else {
      // fade in quickly
      fade.fadeIn(250);
    }
  }, function () {
    // on hovering out, fade the element out
    var fade = $('> div', this);
    if (fade.is(':animated')) {
      fade.stop().fadeTo(1000, 0);
    } else {
      // fade away slowly
      fade.fadeOut(1000);
    }
  });
  
  $("a.lightbox").lightBox();

});



