function checkchars(){
charleft=document.getElementById("writeherereview").value.length;remainchars=75-charleft
if(charleft<=75){
chars=document.getElementById("writeherereview").value
document.getElementById("tcleft").innerHTML='&nbsp;Characters left :'+remainchars}
else
document.getElementById("writeherereview").value=chars}
function writeareview2(game_id,player_id){
if(player_id==''){ alert("Please Login ");location.href="../signin.php"; }
try{
var i=Math.round(100*Math.random())
var j=Math.floor(Math.random()*100000)
new_rqst=i+j
nickname=document.getElementById('revnickname').value
review=document.getElementById('writeherereview').value
if(review==""){
document.getElementById('tcleft').innerHTML="Null Comments Not Allowed"
exit()}
var url="reviewthisgame.php?game_id="+game_id+"&player_id="+player_id+"&nickname="+nickname+"&review="+review+"&new_rqst="+new_rqst
if(window.XMLHttpRequest){
xmlHttpwriteareview=new XMLHttpRequest()}
else if(window.ActiveXObject){
xmlHttpwriteareview=new ActiveXObject("Microsoft.XMLHTTP")}
xmlHttpwriteareview.open("GET",url,true)
xmlHttpwriteareview.onreadystatechange=writeReviewsto
xmlHttpwriteareview.send(null)}
catch(e){}}
function writeReviewsto(){
if(xmlHttpwriteareview.readyState==4){
document.getElementById("reviewsholder").innerHTML=xmlHttpwriteareview.responseText;
document.getElementById("revnickname").value="";
document.getElementById("writeherereview").value="";
gid=document.getElementById("hid_gameid").value
var clrscr=setTimeout('document.getElementById("reviewsholder").innerHTML=""',3000)
showReviews(gid)}}
function showReviews(game_id){
document.getElementById("reviewsholder1").innerHTML='<iframe src="thisgamereviews.php?game_id='+game_id+'" height="190px" frameborder="0" width="320px" ></iframe>'}
function reviews(gameid){
try{
var i=Math.round(100*Math.random())
var j=Math.floor(Math.random()*100000)
new_rqst=i+j
var url="gamereviews_new.php?game_id="+gameid+"&new_rqst="+new_rqst
if(window.XMLHttpRequest){
xmlHttpreviews=new XMLHttpRequest()}
else if(window.ActiveXObject){
xmlHttpreviews=new ActiveXObject("Microsoft.XMLHTTP")}
xmlHttpreviews.open("GET",url,true)
xmlHttpreviews.onreadystatechange=handler_load_all_gamereviews
xmlHttpreviews.send(null)}
catch(e){}}
function handler_load_all_gamereviews(){
try{
document.getElementById('game_content').innerHTML=xmlHttpreviews.responseText}
catch(e){}}
function highscores(gameid,maingameid,gamename,interval){
try{
var i=Math.round(100*Math.random())
var j=Math.floor(Math.random()*100000)
new_rqst=i+j
var url="highscores.php?gameid="+gameid+"&interval="+interval+"&maingameid="+maingameid+"&gamename="+gamename+"&new_rqst="+
new_rqst
if(window.XMLHttpRequest){
xmlHttphighscores=new XMLHttpRequest()}
else if(window.ActiveXObject){
xmlHttphighscores=new ActiveXObject("Microsoft.XMLHTTP")}
xmlHttphighscores.open("GET",url,true)
xmlHttphighscores.onreadystatechange=handler_load_all_highscores
xmlHttphighscores.send(null)}
catch(e){}}
function handler_load_all_highscores(){
try{
if(xmlHttphighscores.readyState==4){
document.getElementById('game_content').innerHTML=xmlHttphighscores.responseText}}
catch(e){}}
function showhighscores_ref(gameid,main_gameid,gamename,interval){
var i=Math.round(100*Math.random())
var j=Math.floor(Math.random()*100000)
new_rqst=i+j
var url="highscore_query.php?gameid="+gameid+"&maingameid="+main_gameid+"&gamename="+gamename+"&interval="+interval+"&new_rqst="+
new_rqst
if(window.XMLHttpRequest){
xmlHttpHS=new XMLHttpRequest()}
else if(window.ActiveXObject){
xmlHttpHS=new ActiveXObject("Microsoft.XMLHTTP")}
xmlHttpHS.open("GET",url,true)
xmlHttpHS.onreadystatechange=displayHighScoresBy123
xmlHttpHS.send(null)}
function displayHighScoresBy123(){
try{
if(xmlHttpHS.readyState==4){
document.getElementById("highscores_holderforgames").innerHTML=xmlHttpHS.responseText}}
catch(e){}}
function challenge(gameid,gname,challenge,bpoints){
var i=Math.round(100*Math.random())
var j=Math.floor(Math.random()*100000)
sess=i+j

if(challenge=='create')
bpoints=document.getElementById("bc").value+","+document.getElementById("exp").value;

var url="challenge.php?gameid="+gameid+"&gname="+gname+"&challenge="+challenge+"&bpoints="+bpoints
if(window.XMLHttpRequest){
showmemchallenge=new XMLHttpRequest()
}else if(window.ActiveXObject){
showmemchallenge=new ActiveXObject("Microsoft.XMLHTTP")}
showmemchallenge.open("GET",url,true)
showmemchallenge.onreadystatechange=callbackchallenge
showmemchallenge.send(null)}
function callbackchallenge(){
if(showmemchallenge.readyState==4){
response=showmemchallenge.responseText
document.getElementById("game_content").innerHTML=response
}}
function makefavouritegame(name,player_id,game_id){ 
if(player_id==''){ alert("Please Login to Make Favourite This Game");location.href="../signin.php"; }
else{
var i=Math.round(100*Math.random())
var j=Math.floor(Math.random()*100000)
new_rqst=i+j
var url="make_favourite.php?gameid="+game_id+"&"+name+"="+player_id+"&status=1&new_rqst="+new_rqst
if(window.XMLHttpRequest){
xmlHttpmakefavourite=new XMLHttpRequest()}
else if(window.ActiveXObject){
xmlHttpmakefavourite=new ActiveXObject("Microsoft.XMLHTTP")}
xmlHttpmakefavourite.open("GET",url,true)
xmlHttpmakefavourite.onreadystatechange=makeFavouriteof
xmlHttpmakefavourite.send(null)}}
function makeFavouriteof(){
if(xmlHttpmakefavourite.readyState==4){
if(xmlHttpmakefavourite.responseText==1)
alert("Already Favourited")
if(xmlHttpmakefavourite.responseText==2)
alert("Favourited")}}
function rating(vote,id_num,ip_num,player_id){ 
if(player_id==''){ alert("Please Login to Rate");location.href="../signin.php";}
if(player_id!=''){
var i=Math.round(100*Math.random())
var j=Math.floor(Math.random()*100000)
new_rqst=i+j
var element=document.getElementById('unit_long'+id_num)
element.innerHTML='<div style="height: 30px;"><em>Loading ...</em></div>'
rating_element=element
var url="rpc.php?j="+vote+"&q="+id_num+"&t="+ip_num+"&p="+player_id+"&new_rqst="+new_rqst
if(window.XMLHttpRequest){
xmlHttp_rating=new XMLHttpRequest()}
else if(window.ActiveXObject){
xmlHttp_rating=new ActiveXObject("Microsoft.XMLHTTP")}
xmlHttp_rating.open("GET",url,true)
xmlHttp_rating.onreadystatechange=handleResponse
xmlHttp_rating.send(null)}}
function handleResponse(){
if(xmlHttp_rating.readyState==4){
if(xmlHttp_rating.status==200){
var response=xmlHttp_rating.responseText
var update=new Array()
if(response.indexOf('|')!=-1){
update=response.split('|')
changeText(update[0],update[1])}}}}
function changeText(div2show,text){
var IE=(document.all)? 1 : 0
var DOM=0
if(parseInt(navigator.appVersion)>=5){DOM=1}
if(DOM){
var viewer=document.getElementById(div2show)
viewer.innerHTML=text}
else if(IE){
document.all[div2show].innerHTML=text}}
function showScore_header(){
var url=SET_GLOBAL_VALUE+"score_header.php"
if(window.XMLHttpRequest){
xmlHttpscore=new XMLHttpRequest()}
else if(window.ActiveXObject){
xmlHttpscore=new ActiveXObject("Microsoft.XMLHTTP")}
xmlHttpscore.open("GET",url,true)
xmlHttpscore.onreadystatechange=stateChangedScore
xmlHttpscore.send(null)}
function stateChangedScore(){
if(xmlHttpscore.readyState==4){
var reply=xmlHttpscore.responseText
var ec=new Array()
if(reply.indexOf('|')!=-1){
ec=reply.split('|')
var eggs=ec[0]
var chicks=ec[1]}
document.getElementById("eggs").innerHTML=eggs
document.getElementById("chicks").innerHTML=chicks}}
