// JavaScript Document

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 = "Veuillez Patienter...";

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 = "Merci d\'avoir voté!";',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);
		  window.location.reload()
    }
	}
	xmlhttp.send(null)
}else{
	oldstr=document.getElementById("ratetxt").innerHTML;
	document.getElementById("ratetxt").innerHTML="Vous avez déja voté !";
	setTimeout('document.getElementById("ratetxt").innerHTML = "'+defaulttxt+'"',1000);
}
	alreadyvoted=true;
}

function star_change(id)
{

  for (i=1; i<=5; i++)
  {
    if (i<=id)
      document.getElementById('star'+i).src="http://www.ze-flash.com/templates/ajc/images/star.png";
    else
      document.getElementById('star'+i).src="http://www.ze-flash.com/templates/ajc/images/star_vide.png";
  }

}

function star_change_add(id)
{

  for (i=1; i<=5; i++)
  {
    if (i<=id)
      document.getElementById('star'+i).src="http://www.ze-flash.com/templates/ajc/images/star.png";
    else
      document.getElementById('star'+i).src="http://www.ze-flash.com/templates/ajc/images/star_vide.png";
  }
  document.getElementById('stars').value = id;
}
