function select_vote_star(star_id)
{
	var star_img;
	for (var i=1; i<=5; i++)
	{
		star_img = $("voting_stars_" + i);
		if (i <= star_id)
		{
			star_img.src = "/images/egirlNou/voting_star_on.jpg";
		}
		else
		{
			star_img.src = "/images/egirlNou/voting_star_off.jpg";
		}
	}
}

function deselect_vote_star()
{
	var star_img;
	for (var i=1; i<=5; i++)
	{
		star_img = $("voting_stars_" + i);
		star_img.src = "/images/egirlNou/voting_star_off.jpg";
	}
}

function loadVoting()
{
	var assoc = "assoc=" + $("assoc").value;
	var assoc_id = "assoc_id=" + $("assoc_id").value;

	var params = "?" + [assoc, assoc_id].join("&");
	
	new Ajax.Request("/voting/load",
	{
		method: "GET",
		parameters: params,
		onSuccess: function(transport) {
			var json = transport.responseText.evalJSON();
			if (json==false)
			{
				alert("Eroare Ajax!");
			} else
			{
				if (json.err) 
				{
					alert("EROARE: "+json.msg);
				}
				else
				{
					if (typeof(json.template) != "undefined")
					{
						$("voting_count_display").innerHTML = json.template;
					}
				}
			}
		},
		onFailure: function() {
			alert("Eroare Ajax!");
		}
	});
	
	return false;
}

function addVoting(vote_score)
{
	$("voting_container").style.display = "";
	f = $("votingForm");
	f["vote_score"].value = vote_score;
	
	new Ajax.Request("/voting/add",
	{
		method: f.action,
		parameters: f.serialize(true),
		onSuccess: function(transport) {
			var json = transport.responseText.evalJSON();
			if (json==false)
			{
				alert("Eroare Ajax!");
			} else
			{
				loadVoting();
				$("voting_stars_holder_id").innerHTML = vote_score;
				$("voting_stars_holder_id").style.padding = "5px 0 0 0";
			}
		},
		onFailure: function() {
			alert("Eroare Ajax!");
		}
	});
}