function Rating() {
	//this.attribut1 = parametre1;
	//this.attribut2 = parametre2;
		
	this.set = function(salle, val) {
		//alert("set : " + val + " pour la salle : " + salle);
		//$('unit-rating-comment').value='vote en cours ...';

		new Ajax.Request('/modules/addRating.php',{
			method: 'post',
			asynchronous: true,
			contentType: 'application/x-www-form-urlencoded',
			parameters: { salle_id: salle, vote: val },
			onSuccess: function(transport, json) {
				if (json.retval) {
					if (json.err == 1) {
						function getStyle(el,styleProp)
						{
							var x = document.getElementById(el);
							if (x.currentStyle)
								var y = x.currentStyle[styleProp];
							else if (window.getComputedStyle)
								var y = document.defaultView.getComputedStyle(x,null).getPropertyValue(styleProp);
							return y;
						}
						$('unit-rating-retval-' + salle).innerHTML=json.retval;
					} else {
						$('unit-rating-comment-' + salle).innerHTML=json.retval;
						//reloader les etoiles (changer la class)
						//Retirer la classe
						for (var i = 0; i<= 5; i++)
							$('ul-unit-rating-' + salle).removeClassName('ul' + i + 'star');
						
						
						// ajourer la nouvelle
						$('ul-unit-rating-' + salle).addClassName('ul' + val + 'star');
					}
				}
			},
			
			onFailure: function(){
				//$('unit-rating-comment').value='erreur';
				//$('unit-rating-comment').addClassName('error');
				//$('unit-rating-comment').style.display = 'block';
			}
		});
	}
	this.show = function(salle, val) {
		/*
		alert('before : ' + this.comment);
		if (this.comment == '') {
			this.comment = document.getElementById('unit-rating-comment');
		}
		alert('after : ' + this.comment);
		*/
		//$('unit-rating-comment').innerHTML = "attribuer une note de " + val + "/5";
	}
	this.clear = function() {
		//$('unit-rating-comment').value = this.comment;
	}
}

var rating = new Rating();

