function rrppHandler(atyp,aid,vote) {
   var ajaxer = VOTESTOPPER[atyp][aid];
   if(ajaxer.readyState == 4) { // ready
      if(ajaxer.status != 200 || !ajaxer.responseText) {
         alert("An error occured; your vote could not be processed.");
      } else {
         var response = ajaxer.responseText.split('~');
         //VOTESTOPPER[atyp][aid] = true; // release from memory
         if(response[0] == 'RRVOTE') {
            if(response.length > 1) {
               switch(response[1]) {
               case 'OK':
                  document['votebooth' + atyp + "_" + aid + "_" + vote].src = '/passport/voteok.gif';
                  if(response.length > 2) {
                     var vel = document.getElementById('votebooth' + atyp + "_" + aid);
                     if(vel) {
                        vel.innerHTML = response[2];
                        if(response.length > 3)
                           vel.style.color = response[3];
                     }
                  }
                  return;
               case 'LOGIN':
                  if(confirm("You must be signed in to rate articles on this site. Do you wish to sign in right now?")) {
                     document.location.assign('/passport/?from=' + document.location.pathname + (document.location.search!=''?escape(document.location.search):''));
                  }
                  break;
               default: alert(response[1]);
               }
            } else alert(response[1]);
         } else
            alert("An error occured; your vote could not be processed.");
      }
      document['votebooth' + atyp + "_" + aid + "_" + vote].src = '/passport/voteerror.gif';
   }
}
function rrppRate(atyp,aid,vote) {
   if(VOTESTOPPER[atyp]) {
      if(VOTESTOPPER[atyp][aid]) {
         alert("You cannot vote on this again!");
         return;
      }
   } else
      VOTESTOPPER[atyp] = new Array();
   if(!XMLHttpRequest) {
      VOTESTOPPER[atyp][aid] = true; // vote stopping
      document.location.assign('/passport/vote.php?t=' + atyp + '&i=' + aid + '&v=' + vote + '&l=' + document.location.pathname + (document.location.search!=''?escape(document.location.search):''));
      return;
   }
   var ajaxer = new XMLHttpRequest();
   VOTESTOPPER[atyp][aid] = ajaxer; // keep in memory
   document['votebooth' + atyp + "_" + aid + "_" + vote].src = '/passport/voteloading.gif';
   ajaxer.onreadystatechange = new Function('rrppHandler(' + atyp + ',' + aid + ',"' + vote + '")');
   ajaxer.open("POST", "/passport/vote.php", true);
   var postBuffer = "x=&i=" + aid + "&t=" + atyp + "&v=" + vote;
   ajaxer.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
   ajaxer.setRequestHeader('Content-Length', postBuffer.length);
   ajaxer.setRequestHeader('Connection', 'close');
   ajaxer.send(postBuffer);
}
var VOTESTOPPER = new Array();

