function resize() {
	$('header').removeClass('preloader');
	$('header').removeClass('introHome').setStyle('height',501);		
	FX = new Fx.Styles($('header'), {wait:false, duration:1500, transition:Fx.Transitions.backOut});
	FX.start({'height':[501,300]});
	new Fx.Styles($('myGallery'), {	wait:false, 
									duration:1500, 
									transition:Fx.Transitions.backOut,
									onComplete:function(){
										$('myGallery').remove();
									}}).start({'opacity':[1,0]});
	new Fx.Styles($E('#header h1'), {wait:false, duration:500, transition:Fx.Transitions.backOut}).start({'opacity':[0,1]});	
}

function createPNGImage(src, width, height) {
		/*if (window.ie6) {
			var element = new Element("div");
			element.style.filter = "progid:DXImageTransform.Microsoft." +
								   "AlphaImageLoader(src='"+src+"')";
		} else {
			var element = new Element("img");
			element.src = src;
		}
		element.style.width = width + "px";
		element.style.height = height + "px";
		return element;*/
}
	
function loadGallery() {
	$$('#header h1').setOpacity(0);
	$('myGallery').setHTML("").setOpacity(0);
	img_path = base + "/images/slideshow/";
	images= [img_path+'000.jpg',img_path+'text.jpg',img_path+'001bis.jpg',img_path+'002.jpg',img_path+'003.jpg',img_path+'004.jpg',img_path+'005.jpg', img_path+'001a.jpg'];
	
	new Asset.image(img_path+'001.jpg');
	
	new Asset.images(images, {
    onComplete: function(){
        //alert('all images loaded!');
		images.each(function(img,i) {
			box = new Element('div', {'class':'imageElement'});
			h3 = new Element('h3').setHTML('item').injectInside(box);
			p = new Element('p').setHTML(' ').injectInside(box);
			a = new Element('a',{'class':'open','title':' '}).injectInside(box);
			im = new Element('img',{'src':img,'class':'full'}).injectInside(box);
			box.injectInside($('myGallery'));
		});
		new Fx.Styles($('myGallery'),{duration:1000,transition:Fx.Transitions.sineInOut}).start({'opacity':[0,1]});
		playIntroMovie();
    }
});

}
	
	
function playIntroMovie() {
	var myGallery = new gallery($('myGallery'), {
		timed: true,
		delay:4000,
		fadeDuration:1000,
		showArrows: false,
		showCarousel: false,
		showInfopane: false,
		embedLinks: false
	});
	
	//$$('#myGallery a.open').setStyle('cursor','default');
	//$$('#myGallery a.open').addEvent('click',function(ev) { new Event(ev).stop(); resize()});
	
	
}
window.addEvent('domready',function() {
	if (page=='home') {
		new Asset.css(base+'/style_jsonly.css');
		loadGallery();
	}
	$$('#navBar a').each(function(a) {
		if (a.getProperty('rel')==page) {
			
			
			a.addClass("notActive");
			a.addEvent('click', function(evt) {
				ev = new Event(evt);
				ev.stop();
				this.blur();
			})
		} 
	});
	$$('.nav_languages').each(function(li) {
		li.FX = new Fx.Styles(li.getElement('.lang_choice'),{wait:false, duration:100, transition:Fx.Transitions.sineInOut});
		li.addEvent('mouseenter',function() {
			li.getElement('.lang_choice').setStyles({'display':'block','opacity':0});
			li.FX.start({'opacity':[0,1]});
		});
		li.addEvent('mouseleave',function() {
			li.FX.start.delay(300,li.FX,{'opacity':[1,0]});			
		});	
		li.getElement('a').addEvent('focus',function() {
			li.getElement('.lang_choice').setStyles({'display':'block','opacity':0});
			li.FX.start({'opacity':[0,1]});
		});
	});

	$$('.lang_choice li').each(function(li) {
		if (window.ie6) {
			li.addEvent('mouseover',function(){li.addClass('hover')});
			li.addEvent('mouseout',function(){li.removeClass('hover')});
			li.h = li.getStyle('height').toInt();
			li.setStyle('line-height',li.h);
			
		}	// PRIOBLEMA VISUALIZZAZIONE CON IE6
		if (li.hasClass('selected')) {
			li.getElement('a').addEvent('click',function(evt) { ev = new Event(evt); ev.stop();});
		}	//	IMPEDISCE IL LINK ALLA LINGUA GIA' SELEZIONATA
	});

	if (window.ie6) {
		$$('ul.specific_specs li').addEvent('mouseover',function(ev) {
			this.addClass('specs_hover');
			
		});
		$$('ul.specific_specs li').addEvent('mouseout',function(ev) {
			this.removeClass('specs_hover');
		});
	}

	$$('.contact_form form').addEvent('submit',function(ev) {
		evt = new Event(ev);
		
		$$('.requiredField').each(function(i) {
			if (i.value.clean().length == 0) {
				i.addClass('error');
				evt.stop();
			}
		});
		
	})





	$$('a[href$="#"]').each(function(a) {
		a.addEvent('click',function(evt) {
			ev = new Event(evt);
			ev.stop();
		});
	});
	
	//new MultiBox('mb', {descClassName: 'multiBoxDesc'});
	
	$$('.groupBox a').each(function(a) {
		a.RollFx = new Fx.Styles(a,{duration:400, wait:false, transitions:Fx.Transitions.EaseInOut});
		a.setOpacity(.5);
		a.addEvent('mouseover',function() {
			a.RollFx.start({'opacity':[.5,1]});
		});
		a.addEvent('mouseout',function() {
			a.RollFx.start({'opacity':[1,.5]});
		});
		a.addEvent('click',function(ev) {
			evt = new Event(ev);
			window.open(a.getProperty('href'));
			evt.stop();
		});

		
	});
		

});
