var g_voted=false;
function turnStarsOn(aStarNumber,str){
	if (g_voted) return;
	//var starvalue = new Array('&nbsp;','poor', 'not so good', 'ok', 'good', 'great');
	var starvalue = new Array(str,'poor', 'not so good', 'ok', 'good', 'great');
	document.getElementById('ratingDefinition').innerHTML = starvalue[aStarNumber];
	for (i = aStarNumber; i < 5; i++) document.getElementById("star"+(i+1)).className = "emptyStar";
	for (i = 0; i < aStarNumber; i++) document.getElementById("star"+(i+1)).className = "fullStar";
}

function ratePost(aStars, msgID){
	//alert(aStars);
	var pars= "msgid=" + msgID + "&stars=" + aStars;
	var path="ajax/ajax_vote_post.php";
	var request = YAHOO.util.Connect.asyncRequest('POST', path, voteCallback, pars); 
}

function ratePostResponse(o) {
	if(o.responseText == undefined)
		return;
	
	if (o.responseText.indexOf("already_voted") != -1) /*alert('hai già votato');*/
		document.getElementById('ratingDefinition').className = "voted";
	else if (o.responseText.indexOf("ok") != -1) {
		g_voted = true;
		document.getElementById('ratingDefinition').className = "voted";
		document.getElementById('starDiv').className = "starDivNoPointer";
	}
	else alert("errore nel voto");
}

function ratePostFailure(o)
{
	
}


var voteCallback =
{
  success: ratePostResponse,
  failure: ratePostFailure,
  argument: ['f', 'b'],
  cache: false
};


function fbs_click() {
	u=location.href;
	t=document.title; 
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t), 'sharer',' toolbar=0, status=0, width=626, height=436');
	return false;
}