/* Cliente:			Treccani Pubblicità srl */
/* Autore:			Simone Bertoloni - simone@evoluzionetelematica.it */
/* Creato:			16/11/2008 */
/* Ultima Modifica:	gg/mm/aaaa	Autore: Nome Cognome */

var Treccani = {

	init: function(){
		if ($('myForm')) Treccani.send();
	},

	/* Meetodo per Spedire la FORM con Ajax */
	send: function(){

		$('myForm').addEvent('submit', function(e) {
			/**
			 * Prevent the submit event
			**/
			new Event(e).stop();
			/**
			 * This empties the log and shows the spinning indicator
			**/
			var log = $('risposta').empty().addClass('loading');
			log.setStyle('display','block');
			
			/**
			 * send takes care of encoding and returns the Ajax instance.
			 * onComplete removes the spinner from the log.
			 */
			this.send({
				update: log,
				onComplete: function() {
					log.setStyle('top', 454 - log.getStyle('height').toInt());	
					log.removeClass('loading');
					log.addEvent('mouseleave', function()
						{
							this.setStyle('display','none');
						}
					);
					
					
				}
			});
		});		
	}	// Fine Send()
};

window.addEvent('domready', Treccani.init );