// JavaScript Document
//<![CDATA[ 
var myForm = {
	
	start: function(){
		
		if ($('form-contatti')) {
			myForm.send();
			myForm.initForm();
		};
		
	},
	/* Spedizione con ajax */
	send: function(){
		
		//alert('ok')
		$('form-contatti').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');
		 
			/**
			 * send takes care of encoding and returns the Ajax instance.
			 * onComplete removes the spinner from the log.
			 */
			this.send({
				update: log,
				onComplete: function() {
					log.removeClass('loading');
				}
			});
		});		
		

	},	// Fine Send()
	
	/* Effetto over sui campi*/
	initForm: function()
	{

		var list = new Array;
		
		var myInput = $$('#form-contatti fieldset label input');
		var myTextarea = $$('#form-contatti fieldset label textarea');
		var mySelect = $$('#form-contatti fieldset label select');
		
		var list = list.concat(myInput, myTextarea, mySelect)
		
		list.each(function(element) {
			
			var fx = new Fx.Styles(element, {duration:300, wait:false});
			
			element.addEvent('focus', function(){
				fx.start({
							'background-color': '#afc42c',
							'color': '#FFF'
				});
				//element.setStyle('background-color', '#e1a721');	
			})

			element.addEvent('blur', function(){
				fx.start({
							'background-color': '#FFF',
							'color': '#000'
				});
			})			
				
		});
		// loop through all anchor tags
	}
	
}

///////////////////////////////////////////////////////

window.addEvent('load', myForm.start);
//]]>
