/* Cliente:			Treccani Pubblicità srl */

/* Autore:			Simone Bertoloni - simone@evoluzionetelematica.it */

/* Creato:			16/11/2007 */

/* Ultima Modifica:	gg/mm/aaaa	Autore: Nome Cognome */



var Treccani = {



	init: function(){

		if ($('myForm')) Treccani.form();

		if ($('myForm')) Treccani.send();

	},

	/* Metodo usato per far scrollare la form */

	form: function(){



		var mySlide = new Fx.Slide('myForm');

		

		mySlide.toggle();

		$('btnInvia').addEvent('click', function(e){

			e = new Event(e);

			mySlide.toggle();

			e.stop();

		});

	

	},

	/* 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', 607 - log.getStyle('height').toInt());	

					log.removeClass('loading');

					log.addEvent('mouseleave', function()

						{

							this.setStyle('display','none');

						}

					);

					

					

				}

			});

		});		

	}
};



window.addEvent('domready', Treccani.init );

