window.addEvent('domready',function(){
	if($('chiave').getElement('input')) {
		var myel = $('chiave').getElement('input');
		var val = myel.get('value');
		myel.addEvents({
		    focus: function(){if (myel.value == val) myel.value = '';},
		    blur: function(){if (myel.value == '') myel.value = val;}
		});
	}
	if($('usn')) {
			var myus = $('usn').getElement('input');
			var valus = myus.get('value');
			myus.addEvents({
			    focus: function(){if (myus.value == valus) myus.value = '';},
			    blur: function(){if (myus.value == '') myus.value = valus;}
			});
		}
	if($('ps')) {
			var myps = $('ps').getElement('input');
			var valps = myps.get('value');
			myps.addEvents({
			    focus: function(){if (myps.value == valps) myps.value = '';},
			    blur: function(){if (myps.value == '') myps.value = valps;}
			});
		}
	if ($('carousel')) {
		var tabs = new MGFX.Tabs('.tab','.slide',{autoplay: false,transitionDuration:500,slideInterval:3000,hover:true});
	}
	if ($('res_box1')) {
		var contenuti = new noobSlide({box: $('res_box1'),items: $$('#res_box1 div'),size: 660,addButtons: {previous: $$('span.prev'),next: $$('span.next')},onWalk: function(currentItem){var step = this.currentIndex +1;$$('.pages span').set('html',step + '/');} });
	}
	if ($('res_box2')) {
		var news = new noobSlide({box: $('res_box2'),items: $$('#res_box2 div'),size: 660,addButtons: {previous: $$('span.prev'),next: $$('span.next')},onWalk: function(currentItem){var step = this.currentIndex +1;$$('.pages span').set('html',step + '/');} });
	}
	if ($('res_box3')) {
		var fiere = new noobSlide({box: $('res_box3'),items: $$('#res_box3 div'),size: 660,addButtons: {previous: $$('span.prev'),next: $$('span.next')},onWalk: function(currentItem){var step = this.currentIndex +1;$$('.pages span').set('html',step + '/');} });
	}
	if ($('res_box4')) {
		var usato = new noobSlide({box: $('res_box4'),items: $$('#res_box4 div'),size: 660,addButtons: {previous: $$('span.prev'),next: $$('span.next')},onWalk: function(currentItem){var step = this.currentIndex +1;$$('.pages span').set('html',step + '/');} });
	}
	if ($('res_box5')) {
		var prodotti = new noobSlide({box: $('res_box5'),items: $$('#res_box5 div'),size: 660,addButtons: {previous: $$('span.prev'),next: $$('span.next')},onWalk: function(currentItem){var step = this.currentIndex +1;$$('.pages span').set('html',step + '/');} });
	}
	if ($('gallery'))	{
		var nS = new noobSlide({
			box: $('gallery'),
			items: $$('#gallery h3'),
			size: 734,
			//autoPlay: true,
			handles: $$('#handles span'),
			addButtons: {play: $('play'), stop: $('stop'), playback: $('playback')},
			onWalk: function(currentItem,currentHandle){
				//style for handles
				$$(this.handles).removeClass('active');
				$$(currentHandle).addClass('active');
			}
		});
		nS.walk(0);
		$$('#gallery img').each(function(el) {
			var altezza = el.height;
			if(altezza>127) el.setProperty('height',127);
		});
		
	}
	$$(".lightbox").slimbox();
	if ($('hp_fiere')) {
		$$('#hp_fiere .text').each( function( elem ){
			if (elem.getElement('img')) {
				var divs = new Element('div', {
				    'class': 'contentImage'
				}).inject(elem,'top');
				 elem.getElement('img').inject(divs);
			 }
		});
		$$('#hp_macc .text').each( function( elem ){
			if (elem.getElement('img')) {
				var divs = new Element('div', {
				    'class': 'contentImage'
				}).inject(elem,'top');
				 elem.getElement('img').inject(divs);
			 }
		});
	}

	if($('pageGallery')) {
		var info9 = $('boxGallery').getNext().set('opacity',0.5);
		var nS9 = new noobSlide({
			box: $('boxGallery'),
			items: $$('#boxGallery div'),
			size: 237,
			fade:true,
			interval:8000,
			autoPlay: true,
			onWalk: function(currentItem,currentHandle){
				//style for handles
				info9.empty();
				new Element('span').set('html',currentItem.getElement('img').alt).inject(info9);				
			}
		});
	}	
	if($('usato') && $('box_gallery')) {
		var foto = new noobSlide({
			box: $('box_gallery'),
			items: $$('#box_gallery a'),
			size: 200,
			addButtons: {
				previous: $('prev'),
				next: $('next')
			}
		});
	}	
	if($('form_lavoro')) {
		allega();
		new FormCheck('form_lavoro', {
			display: {
                closeTipsButton: 1,
                showErrors: 1
            }
		});
	}
	if($('form_contatti')) {
		new FormCheck('form_contatti', {
			display: {
                closeTipsButton: 1,
                showErrors: 1
            }
		});
	}
});
compid=['comp1','comp2','comp3','comp4','comp5','comp6','comp7','comp8','comp9','comp10'];
alleid=['alle1'];

function allega() {
	compid.each(function(e) {
		$(e).disabled=true;
		//$(e).removeClass('validate[\'required\']');
		$(e).getParent('fieldset').fade(0.4);
	});
	alleid.each(function(a) {
		$(a).disabled=false;
		//$(a).addClass('validate[\'required\']');
		$(a).getParent('fieldset').fade('in');
	});
}

function compila() {
	compid.each(function(e) {
		$(e).disabled=false;
		//$(e).addClass('validate[\'required\']');
		$(e).getParent('fieldset').fade('in');
	});
	alleid.each(function(e) {
		//$(e).setProperty('class','');
		$(e).disabled=true;
		$(e).getParent('fieldset').fade(0.4);
	});
}
