/* Nome Cliente 	STS */
/* Creato:			08/06/2009 */
/* Autore:			simone@evoluzionetelematica.it */

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

//<![CDATA[

var sts = {

	startLoad: function(){
	},
	
	startDomReady: function(){
		if ($('vetrina')) sts.slide()
		if ($$('.boxed') != '') sts.initSqueezeBox()
		if ($('fotografie') || $$('.fotoSede') != '') sts.initGallery()
		if ($('accordion')) sts.initAccordion()
		if ($('formContatti')) sts.initForm()
		//if ($$('.tips') != '') sts.toolTip()
	},	

	slide: function() {
		var nS = new noobSlide({
			box: $('box'),
			items: $$('#box li'),
			size: 940,
			interval: 10000,
			autoPlay: true,
			fxOptions: {
				duration: 500,
				transition: Fx.Transitions.Sine.easeIn,
				wait: false
			},
			addButtons: {
				previous: $('prev'),
				play: $('play'),
				stop: $('stop'),
				next: $('next')
			}
		});
	},

	initGallery: function() { // Inizializzo la gallery delle foto con zoom
		Milkbox = new Milkbox();
	},
	
	initSqueezeBox: function() // Inizializzo lo squuezebox x effetto lightbox x iFrame
	{
		SqueezeBox.assign($$('.boxed'), {
			parse: 'rel'
		});
	}, // Fine initSqueezeBox()
	
	initAccordion: function()
	{
		var myAccordion = new Accordion($('accordion'), 'h3.toggler', 'div.element', {
			opacity: false,
			show: -1,
			alwaysHide: true,
			onActive: function(toggler, element){
				//toggler.setStyle('color', '#41464D');
			},
			onBackground: function(toggler, element){
				//toggler.setStyle('color', '#528CE0');
			}
		});	
	},
	
	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': -45        //default is 16
			},
			fixed: false,      //default is false
			onShow: function(toolTipElement){
				toolTipElement.fade(1);
			},
			onHide: function(toolTipElement){
				toolTipElement.fade(0);
			}
		});


	}, // fine tooltip
	
	initForm: function()
	{

		var list = new Array;

		var myInput = $$('#formContatti label input');
		var myRadio = $$('#formContatti #rbSedi input');
		var myRadio2 = $$('#formContatti #rbPosizioni input');
		var myTextarea = $$('#formContatti label textarea');
		var mySelect = $$('#formContatti label select');
		var errorMsg = $$('#formContatti label span.errore');
		
		var list = list.concat(myInput, myRadio, myRadio2, 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': '#CCC',
					'color': '#C00'
				});
			element.getParent().getChildren('span').setStyle('display', 'none')
			
			})

			element.addEvent('blur', function(){
				myEffects.start({
					'background-color': '#fff',
					'color': '#666'
				});
			})			
				
		});
		
		errorMsg.each(function(element) {
			
			element.getParent().addEvent('click', function(){
				element.setStyle('display', 'none')
			});
		
		})

	} // fine CAMPI FORM	
	
} // chiusura classe ilMosnel

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

window.addEvent('domready', sts.startDomReady);
window.addEvent('load', sts.startLoad);
//]]>