// JavaScript Document
function VoteSelect(Vote)
{
	var i;
    var imgVote = new Array;

    if(document.all) {
        // Internet Explorer
		imgVote[0] = ImgVote0;
		imgVote[1] = ImgVote1;
		imgVote[2] = ImgVote2;
		imgVote[3] = ImgVote3;
		imgVote[4] = ImgVote4;
	}
	else if (document.getElementById) {
        // FireFox
        imgVote[0] = document.getElementById('ImgVote0');
        imgVote[1] = document.getElementById('ImgVote1');
        imgVote[2] = document.getElementById('ImgVote2');
        imgVote[3] = document.getElementById('ImgVote3');
        imgVote[4] = document.getElementById('ImgVote4');
	}
	
	for(i = 0; i < 5; i ++) {
		if(i <= Vote) {
			imgVote[i].src = "images/river-star-gold.png";
		} else {
			imgVote[i].src = "images/river-star-grey.png";
		}
	}
	
	cursor = "hand";
}

function VoteClick(Id, Vote)
{
	var xhr_object;
	
	if(window.XMLHttpRequest) // Firefox
	   xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // Internet Explorer
	   xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return;
		
	xhr_object.open("GET", "vote-" + Id + "-" + Vote + ".html", true);	
	xhr_object.onreadystatechange = function()
	{
	   if(xhr_object.readyState == 4)
	   		document.getElementById('voteList').innerHTML = xhr_object.responseText;
	}	
	xhr_object.send(null);
}

function VoteSubmitClick(Id, Vote)
{
	var xhr_object;
	
	if(window.XMLHttpRequest) // Firefox
	   xhr_object = new XMLHttpRequest();
	else if(window.ActiveXObject) // Internet Explorer
	   xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
	else
		return;
		
	xhr_object.open("GET", "vote-submit-" + Id + "-" + Vote + ".html", true);
	//alert("vote_submit-" + Id + "-" + Vote + ".html");	
	xhr_object.onreadystatechange = function()
	{
	   if(xhr_object.readyState == 4)
	   		document.getElementById('voteList').innerHTML = xhr_object.responseText;
	}	
	xhr_object.send(null);
}

function MediaProblem(Id)
{
	if(confirm("Vous avez un message d'erreur ? Vous ne pouvez pas voir l'image ou la vidéo ?\n\nATTENTION : Parfois les vidéos peuvent mettre du temps se télécharger, soyez donc patient :-)\n\nCliquez sur OK pour avertir l'administrateur ou ANNULER pour retourner sur le site."))
	{
		var xhr_object;
		
		if(window.XMLHttpRequest) // Firefox
		   xhr_object = new XMLHttpRequest();
		else if(window.ActiveXObject) // Internet Explorer
		   xhr_object = new ActiveXObject("Microsoft.XMLHTTP");
		else
			return;
			
		xhr_object.open("GET", "problem_" + Id + ".html", true);	
		xhr_object.send(null);
	}
}

