// JavaScript Document

function bookmarksite(title,url){
if (window.sidebar) // firefoxwww.google.
	window.sidebar.addPanel(title, url, "");
else if(window.opera && window.print){ // opera
	var elem = document.createElement('a');
	elem.setAttribute('href',url);
	elem.setAttribute('title',title);
	elem.setAttribute('rel','sidebar');
	elem.click();
} 
else if(document.all)// ie
	window.external.AddFavorite(url, title);
}

function bookmarkpage(url,description){
alert_txt="Hit CTRL+D to add a bookmark to this site."
if (navigator.appName=='Microsoft Internet Explorer'){
	window.external.AddFavorite(url, description);
}
else if (navigator.appName=='Netscape' || navigator.appName=='Opera'){
	alert(alert_txt);
}
}

alreadyvoted=false;

function rategame(rating,gameid,addr) {

document.getElementById("ratetxt").innerHTML = "Please wait...";

var xmlhttp = false;

/*@cc_on @*/

/*@if (@_jscript_version >= 5)

	// JScript gives us Conditional compilation, we can cope with old IE versions.
	// and security blocked creation of the objects.

	try {
		xmlhttp = new ActiveXObject("Msxml2.XMLHTTP");
	} catch (e) {
	try {
		xmlhttp = new ActiveXObject("Microsoft.XMLHTTP");
	} catch (E) {
		xmlhttp = false;
	}
}

/*@end @*/

if (!xmlhttp && typeof XMLHttpRequest!='undefined') {
	xmlhttp = new XMLHttpRequest();
}

if(!alreadyvoted){
	xmlhttp.open("GET", addr + '/includes/rategame.php?game=' + gameid + '&rating=' + rating,true);
	xmlhttp.onreadystatechange=function() {
		if (xmlhttp.readyState==4) {
			var width = (parseFloat(xmlhttp.responseText)*20)+"%";
			setTimeout('document.getElementById("ratetxt").innerHTML = "Thanks for voting!";',2000);
			setTimeout('document.getElementById("star-rating").innerHTML = "<li id=\'current-rating\' style=\'width:'+ width +';\'>Currently '+ xmlhttp.responseText +'/5 Stars.</li>";',3000);
			defaulttxt="Rating of <strong>"+xmlhttp.responseText+"/5 Stars</strong>";
			setTimeout('document.getElementById("ratetxt").innerHTML = "Rating of <strong>'+xmlhttp.responseText+'/5 Stars</strong>"',3000);
		}
	}
	xmlhttp.send(null)
}else{
	oldstr=document.getElementById("ratetxt").innerHTML;
	document.getElementById("ratetxt").innerHTML="You already voted!";
	setTimeout('document.getElementById("ratetxt").innerHTML = "'+defaulttxt+'"',1000);
}
	alreadyvoted=true;
}


