// Ratings Javascript.
// Credit to Architect and Sean X[[[[[[[[[[
// Last Change 14th April 2009

function loadPage(rating, gameid){
if(typeof XMLHttpRequest!="undefined") xobj=new XMLHttpRequest;
else xobj=ActiveXObject("Microsoft.XMLHTTP")
xobj.open('get', './ratings/rate.php?akey='+ key +'&rating=' + rating + '&gameID=' + gameid);
xobj.onreadystatechange=parsepage
xobj.send('')
function parsepage(){
if(xobj.readyState==4){
response = xobj.responseText;
if(response != ''){
alert(response);
}
return true;
}
}
}

function rate(rating, gameid){
rating = rating + 1;
var confirmed = confirm("Are you sure you want to give this game a rating of "+ rating +" stars?");
if(!confirmed){
return;
}
loadPage(rating, gameid);
}

var restore = new Array;
function rateImage(div_id, rating, mouseOut){	
if(mouseOut == true){
var images = document.getElementById('rate' + div_id).getElementsByTagName("img");
for(var img_index = 0; img_index < images.length; img_index++){
images[img_index].src = restore[img_index];
}
return;
}
var images = document.getElementById('rate' + div_id).getElementsByTagName("img");
for(var img_index = 0; img_index < images.length; img_index++){
restore[img_index] = images[img_index].src;
if(img_index <= (rating)) 
star = 1;
else
star = 0;
images[img_index].src = './ratings/rate'+ star +'.gif';
}
}
