var gGame
var gRating
var gfavoritegame

function countOut(id)
{
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="http://www.dannyzgames.com/php/countOut.php"
url=url+"?id="+id;
url=url+"?sid="+Math.random();
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function addtofavorites(favoritegame)
{
gfavoritegame = favoritegame;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="http://www.dannyzgames.com/php/addtofavorites.php"
url=url+"?favoritegame="+favoritegame
xmlHttp.onreadystatechange=favoritestateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function removefromfavorites(favoritegame)
{
gfavoritegame = favoritegame;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="http://www.dannyzgames.com/php/removefromfavorites.php"
url=url+"?favoritegame="+favoritegame
xmlHttp.onreadystatechange=favoritestateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function favoritestateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById('favorite'+gfavoritegame).innerHTML=xmlHttp.responseText 
 } 
}

function displayGames(category,sort,page,search)
{
xmlHttp=GetXmlHttpObject()
 document.getElementById('loadingdiv').style.display = 'block';
 document.getElementById('content').className='loading';
 document.getElementById('topcontent').className='loading';
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="http://www.dannyzgames.com/content.php"
url=url+"?search="+search+"&sort="+sort+"&category="+category+"&page="+page
xmlHttp.onreadystatechange=contentstateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function contentstateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById('content').className='doneloading';
 document.getElementById('topcontent').className='doneloading';
 document.getElementById('loadingdiv').style.display = 'none';
 document.getElementById('content').innerHTML=xmlHttp.responseText 
 } 
}

function searchGames(search,sort)
{
 document.getElementById('loadingdiv').style.display = 'block';
 document.getElementById('content').className='loading';
 document.getElementById('topcontent').className='loading';
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="content.php"
url=url+"?search="+search+"&sort="+sort
xmlHttp.onreadystatechange=searchstateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function searchstateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 {
 document.getElementById('content').className='doneloading';
 document.getElementById('topcontent').className='doneloading';
 document.getElementById('loadingdiv').style.display = 'none';
 document.getElementById('content').innerHTML=xmlHttp.responseText;
} 
}

function Count(str)
{
gGame = str;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="php/count.php"
url=url+"?game="+str
xmlHttp.onreadystatechange=countstateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function countstateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById(''+gGame).innerHTML=xmlHttp.responseText 
 } 
}


function gameRate(game,rating,ip)
{
gRating = game;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="php/rating.php"
url=url+"?game="+game+"&rating="+rating+"&ip="+ip
xmlHttp.onreadystatechange=ratingstateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}


function ratingstateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById('rating'+gRating).innerHTML=xmlHttp.responseText 
 } 
}


function gamepageRate(game,rating,ip)
{
gRating = game;
xmlHttp=GetXmlHttpObject()
if (xmlHttp==null)
 {
 alert ("Browser does not support HTTP Request")
 return
 }
var url="../../php/gamepagerating.php"
url=url+"?game="+game+"&rating="+rating+"&ip="+ip
xmlHttp.onreadystatechange=gamepageratingstateChanged 
xmlHttp.open("GET",url,true)
xmlHttp.send(null)
}

function gamepageratingstateChanged() 
{ 
if (xmlHttp.readyState==4 || xmlHttp.readyState=="complete")
 { 
 document.getElementById('rating'+gRating).innerHTML=xmlHttp.responseText 
 } 
}


function GetXmlHttpObject()
{
var xmlHttp=null;
try
 {
 // Firefox, Opera 8.0+, Safari
 xmlHttp=new XMLHttpRequest();
 }
catch (e)
 {
 //Internet Explorer
 try
  {
  xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");
  }
 catch (e)
  {
  xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");
  }
 }
return xmlHttp;
}
