function vote(gId, rating)
{
  var ah = new AjaxHandler({url: '/cgi-bin/vote.cgi?game='+
                                gId+'&rating='+rating,
                           fn:  function(obj) { dhtml_update(obj); }
                          }).go();
}

function dhtml_update(obj)
{
  var result = eval('('+obj.responseText+')');
  document.getElementById('vote').innerHTML = result.dhtml;
}

function getReq()
{
var xmlHttp;
try
  {
  // Firefox, Opera 8.0+, Safari
  xmlHttp=new XMLHttpRequest();
  }
catch (e)
  {
  // Internet Explorer
  try
    {
    xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
    }
  catch (e)
    {
    try
      {
      xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
      }
    catch (e)
      {
      }
    }
  }
  return xmlHttp;
}

function AjaxHandler(ref)
{ this.url = ref.url;
  this.fn  = ref.fn;
  this.req = new getReq();
}

AjaxHandler.prototype =
{ go:function()
  { if (!this.url || !this.fn || !this.req) return;
    var fn  = this.fn;
    var req = this.req;
    req.open('GET', this.url, true);
    req.onreadystatechange = function() { if (req.readyState == 4 && req.status == 200)
                                          { fn(req); }
                                        };
    req.send(null);
  }
}

