var sMax;var holder;var preSet;var rated;function GetXmlHttpObject(){var xmlHttp=null;try{xmlHttp=new XMLHttpRequest();}
catch(e){try{xmlHttp=new ActiveXObject("Msxml2.XMLHTTP");}
catch(e){xmlHttp=new ActiveXObject("Microsoft.XMLHTTP");}}
return xmlHttp;}
function AjaxPost(url,param,success_function){xmlHttp=GetXmlHttpObject();if(xmlHttp==null){alert("Your browser doesn't support AJAX. You should upgrade it!")
return}
xmlHttp.onreadystatechange=success_function;xmlHttp.open("POST",url,true);xmlHttp.setRequestHeader('Content-Type','application/x-www-form-urlencoded');xmlHttp.send(param);}
function $(d){return document.getElementById(d);}
function rating(num){sMax=0;for(n=0;n<num.parentNode.childNodes.length;n++){if(num.parentNode.childNodes[n].nodeName=="A"){sMax++;}}
if(!rated){s=num.id.replace("_",'');a=0;for(i=1;i<=sMax;i++){if(i<=s){document.getElementById("_"+i).className="on";holder=a+1;a++;}else{document.getElementById("_"+i).className="";}}}}
function off(me){if(!rated){if(!preSet){for(i=1;i<=sMax;i++){document.getElementById("_"+i).className="";}}else{rating(preSet);}}}
function rateIt(me,id,site_url){if(!rated){preSet=me;rated=1;sendRate(me,id,site_url);rating(me);}}
function sendRate(sel,id,site_url){AjaxPost(site_url+"/includes/view_game/ajax/add_rating.php","id="+id+"&rating="+sel.title,function(){})}
function AddFav(id,typ,site_url,unfav,fav){AjaxPost(site_url+"/includes/view_game/ajax/add_fav.php","id="+id,function(){})
if(typ==0){$('favbutton').innerHTML='<a href="#" onclick="AddFav('+id+', 1, \''+site_url+'\', \''+unfav+'\', \''+fav+'\'); return false">'+unfav+'</a>';}
else{$('favbutton').innerHTML='<a href="#" onclick="AddFav('+id+', 0, \''+site_url+'\', \''+unfav+'\', \''+fav+'\'); return false">'+fav+'</a>';}}
function AddComment(id,site_url){$('comment_submit').disabled=true;$('comment_submit').value="Adding comment...";thecomment=$('the_comment').value;AjaxPost(site_url+"/includes/view_game/ajax/add_comment.php","comment="+thecomment+"&id="+id,function(){if(xmlHttp.readyState==4||xmlHttp.readyState=="complete"){if(xmlHttp.responseText==''){alert("An error occured in sending your message");}
else{var container=document.getElementById('comment_list');var new_element=document.createElement('li');new_element.innerHTML=xmlHttp.responseText;container.insertBefore(new_element,container.firstChild);window.location.hash="1";$('comment_submit').value="Comment added!";setTimeout("EnableButton()",30000);}}})}
function EnableButton(){$('comment_submit').value="Add comment";$('comment_submit').disabled=false;}
function clickclear(thisfield,defaulttext){if(thisfield.value==defaulttext){thisfield.value="";}}
function clickrecall(thisfield,defaulttext){if(thisfield.value==""){thisfield.value=defaulttext;}}
function DeleteComment(id,site_url){AjaxPost(site_url+"/admin/includes/delete_comment.php","id="+id,function(){$('comment-'+id).style.display='none';})}