var formNoteUpdater;
var FormNoteUpdater = Class.create();

FormNoteUpdater.attributes = [ "average", "note_date", "note_message" ];

FormNoteUpdater.prototype = {
   initialize: function() {
   },
   ajaxUpdate: function(ajaxResponse) {
      this.setNote(ajaxResponse.childNodes[0]);
   },
   setNote: function(aNote) {
      FormNoteUpdater.attributes.each(function(attr){
        val = aNote.getAttribute(attr)
        $$("span." + attr).each(function(e){ e.innerHTML = val})
      }.bind(this));
   }
};

Event.observe(window, 'load', function() { 
	formNoteUpdater = new FormNoteUpdater();
	ajaxEngine.registerRequest( 'submitNote', 'submitNote.php' );
	ajaxEngine.registerAjaxObject( 'formNoteUpdater', formNoteUpdater );
})

function sendNote(oeuvre) {
   var crit1 = document.getElementById('sliderValue1').value;
   var crit2 = document.getElementById('sliderValue2').value;
   var crit3 = document.getElementById('sliderValue3').value;

   ajaxEngine.sendRequest( 'submitNote',
                           "crit1=" + crit1,
                           "crit2=" + crit2,
                           "crit3=" + crit3,
                           "oeuvre=" + oeuvre);
}
