/* Nome Cliente 	il Mosnel */
/* Creato:			19/02/2009 */
/* Autore:			simone@evoluzionetelematica.it */
/* Ultima Modifica:	gg/mm/aaaa	Autore: Nome Cognome */

//<![CDATA[

var agrifutur = {

    // Utilizzare una variabile per fare riferimento al file SWF incorporato.

	startLoad: function(){
		if ($$('.fieldset-chiedInfo') != '') agrifutur.initForm()
		if ($$('.button-chiedInfo') != '') agrifutur.mostraForm()	
	},
	
	startDomReady: function(){
		if ($$('.boxed') != '') agrifutur.initSqueezeBox()
		if ($$('.tips') != '') agrifutur.toolTip()
	},	
	
	initSqueezeBox: function() // Inizializzo lo squuezebox x effetto lightbox x iFrame
	{
		SqueezeBox.assign($$('a.boxed'), {
			parse: 'rel'
		});
	}, // Fine initSqueezeBox()

	toolTip: function () 
	{
		var tooltips = $$('.tips');
		 
		var toolTips = new Tips(tooltips, {
			showDelay: 100,    //default is 100
			hideDelay: 100,   //default is 100
			className: 'tips', //default is null
			//this sets the x and y offets
			offsets: {
				'x': -100,       //default is 16
				'y': -30        //default is 16
			},
			fixed: false,      //default is false
			onShow: function(toolTipElement){
				toolTipElement.fade(1);
			},
			onHide: function(toolTipElement){
				toolTipElement.fade(0);
			}
		});


	}, // fine tooltip
	
	// METODI X FORM	
	/* Metodo usato per mostrare/nascondere la form x chiedere informazioni */
	mostraForm: function(){
		
		var result = $$('.fieldset-chiedInfo')[0]
		
		if (result) {
			
			var mySlide = new Fx.Slide(result);
			
			mySlide.toggle();
			$$('.button-chiedInfo').addEvent('click', function(e){
				e = new Event(e);
				mySlide.toggle();
				e.stop();
			});
		}
	
	},
	
	initForm: function()
	{

		var list = new Array;
		
		var myInput = $$('.fieldset-chiedInfo label input');
		var myTextarea = $$('.fieldset-chiedInfo label textarea');
		var mySelect = $$('.fieldset-chiedInfo label select');
		var errorMsg = $$('.fieldset-chiedInfo label span');
		
		var list = list.concat(myInput, myTextarea, mySelect)
		
		list.each(function(element) {


			var myEffects = new Fx.Morph(element, {duration: 300, transition: Fx.Transitions.Sine.easeOut});


			element.addEvent('focus', function(){
				myEffects.start({
					'background-color': '#06c',
					'color': '#fff'
				});
			element.getParent().getChildren('span').setStyle('display', 'none')
			
			})

			element.addEvent('blur', function(){
				myEffects.start({
					'background-color': '#fff',
					'color': '#06c'
				});
			})			
				
		});
		
		errorMsg.each(function(element) {
			
			element.getParent().addEvent('click', function(){
				element.setStyle('display', 'none')
			});
		
		})
		// loop through all anchor tags
	}

	
} // chiusura classe Agrifutur

///////////////////////////////////////////////////////

window.addEvent('domready', agrifutur.startDomReady);
window.addEvent('load', agrifutur.startLoad);
//]]>