var http;

function getHTTPObject() 
{ 
    if (typeof XMLHttpRequest != 'undefined') 
        { 
            return new XMLHttpRequest(); 
        } 
    try 
        { 
            return new ActiveXObject("Msxml2.XMLHTTP"); 
        } 
    catch (e) 
        { 
            try 	
            { 
                return new ActiveXObject("Microsoft.XMLHTTP"); 
            } 
            catch (e){} 
           
        } 
    return false; 
}

function responseItem() 
{
    if (http.readyState == 4) 
    {
        var rating = http.responseText;
        rating  = rating.split(' ');
        document.getElementById('rating').innerHTML = rating[0] + " (you added: "+rating[2]+")<br />[rated by "+(rating[1]) +" viewer(s)]";
        document.getElementById('ratenow').innerHTML = "<br /><b>Thank you for rating...</b>";
    }
}


function init()
{
   http = getHTTPObject();
    
    if (http == null)
    {
        alert ("Your browser does not support AJAX!");
        return;
    } 
    
}

function rateGame(rating,id) 
{			
    http.open("GET", "rategame.php?id="+id+"&rating=" + rating, true);
    http.onreadystatechange = responseItem;
    http.send(null);
    
}

function overRating(id)
{
   for(i = 1; i <= id;i++)
        document.getElementById("rating"+i).src = "images/ratingstar_over.png";
}

function outRating(id)
{
for(i = 1; i <= id;i++)
        document.getElementById("rating"+i).src = "images/ratingstar.png";
}
