function resetStars(oldDescr, Stars, DescSelector, StarSelector) {
	$(StarSelector).rating('select', Stars, false);
	$(DescSelector).css("color", "#666").html(oldDescr);
}

	
function activaStarsFront(subID, fullSite, oldStars) {
	
	DescSelector 	= "#rating-"+subID+"-description";
	StarSelector 	= ".rating_"+subID;
	var username 	= $("#userName").html();
	$(StarSelector).rating({
		callback: function(value, link){
			// 'this' is the hidden form element holding the current value
			// 'value' is the value selected
			// 'element' points to the link element that received the click.
			// alert("The value selected was '" + value + "'\n\nWith this callback function I can automatically submit the form with this code:\nthis.form.submit();");
			
			$.post(fullSite+"/include/class.RatingInc.php",{vote:value, id:subID, user:username, tipo:"normal" }, function(data) {
				data = data.split("|");
				if (data[0]=="sucesso") {
					newDescr = data[1];
					newstars = parseInt(data[2]) - 1;
					$(DescSelector).css("color", "green").html("Obrigado pelo seu voto!");
					setTimeout('resetStars(newDescr, newstars, DescSelector, StarSelector);',1500);
					
				} else {
					starsss = parseInt(oldStars) - 1;
					oldDescr = $(DescSelector).html();
					$(DescSelector).css("color", "red").html(data[0]);
					setTimeout('resetStars(oldDescr, starsss, DescSelector, StarSelector);',1500);
				}
			});
		}
	});
}
