
var VoteFloatingWidget = new Class({
  initialize: function(element) {
    this.element = element;
    this.vote_text = $("vote_text");
    this.description = element.getElement("div")

//    this.vote_text.addEvent("mouseover", this.show.bind(this));
//    this.description.addEvent("mouseout", this.hide.bind(this));
    $$(".vote_widget .close_button")[0].addEvent("click", this.hide.bind(this));
    $$(".show_vote_container .show_vote")[0].addEvent("click", this.toggle_show.bind(this));
  },

  show: function() {
    this.description.style.display = '';
  },

  toggle_show: function() {
    if (this.description.style.display == 'none')
      this.show();
    else
      this.hide();
  },

  hide: function() {
    this.description.style.display = 'none';
  }
});


function SubmitVote(vote_type,kimi_msid)
    {
    if (vote_type=="") return;
//    ajaxSwap(,"vote_saving","vote_display",true);
    url="/protected/vote/"+kimi_msid+"?vote_type="+vote_type;

    $('vote_saving').style.display="block";
    $('vote_display').style.display="none";
    ajaxExecFunction
      (
      url,
      function(URL,response)
        {
        res=eval('('+response+')');
        $('vote_saving').style.display="none";
//        if (res.result=="error" && res.retry)
          $('vote_display').style.display="block";
        if (res.info) alert(res.info);
        if (res.result=="success") document.location.reload();
        }
      );



    //setAjaxBoolVar("user_can_rate",false);

    //supress all further star error messages until a new _view_kimi_partial is loaded.
    //I would prefer to suppress the errors until the user moves the mouse away from the stars, a certain amount of time has passed, the ajax operation has completed, THEN re-enable the "already rated" error message.
    //setAjaxBoolVar("supress_errors",true);
    };
