document.observe('dom:loaded', function() {
	new IdgEvaluator;
});
var IdgEvaluator = Class.create({
	form: null,
	point: 0,
	initialize: function() {
		this.form = $('IdgEvaluator');
		this.form.observe('submit',this.evaluate.bind(this));
	},
	evaluate: function(ev) {
		$$('.idgPoint').each( function(unit) {
			if( unit.checked ) {
				this.point = parseInt(unit.value);
			}
		}.bind(this));
		new Ajax.Request('/main/idgEvaluator/evaluate', {
			parameters : {
				'tail' : 'section',
				'idx' : $F('relIdx'),
				'vote': this.point
			},
			onSuccess: this.update.bind(this)
		});
		ev.stop();
	},
	update: function(transport) {
		var text = transport.responseText;
		if (text == '1') {
			var target = $('point'+this.point).next('span');
			target.innerHTML = parseInt(target.innerHTML) + 1;
			this.form.down('.btnEvaluatorSubmit').remove();
			this.form.disable();
		} else {
			alert(text);
			// alert('ÀÇ°ßÀ» ÀúÀåÇÏ´Â µ¿¾È ¿¡·¯°¡ ³µ½À´Ï´Ù.');
		}
	}
});
