window.addEvent('domready', function() {
									 

	/*
 e24PNGFix
	- MooTools version required: 1.2.2
	Changelog:
		- 1.0: First release
*/
 
/*Based on the fixPNG module from MooTools, My Object Oriented Javascript Tools. Copyright (c) 2006-2007 Valerio Proietti, <http://mad4milk.net>, MIT Style License.||Clientcide Copyright (c) 2006-2008, http://www.clientcide.com/wiki/cnet-libraries#license*/
/* Copyright: equipo24 S.L.N.E <http://equipo24.com/> - Distributed under MIT License - Keep this message! */
 
$extend(Browser, {
	fixPNG: function(el) {
		if (Browser.Engine.trident){
			//el = document.id(el);
			el=$(el);
			
			var w = el.getStyle('width');
			var h = el.getStyle('height');
			var imgURL = el.getStyle('background');
			//alert(w+" "+h+" "+imgURL);
			if (imgURL.test(/\((.+)\)/)){
				el.setStyle('background', '');
 				var subEl = new Element('div', {
					'style': 'width: ' + w + ';' +
					'height: ' + h + ';' +
					"filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(enabled='true', sizingMethod='crop', src='" + imgURL.match(/\((.+)\)/)[1] + "');"							
				});	
				el.grab(subEl);							
			};
		}
	}
});

Browser.fixPNG('logo');

//menus
	menu_home=$('home-06_');
	menu_guarda=$('home-10_');
	menu_ascolta=$('home-11_');
	menu_assaggia=$('home-12_');
	menu_contatti=$('home-13_');

	switch (id) {
	case 0: menu_corr=menu_home; break;
	case 11: case 12: case 13: case 14: menu_corr=menu_guarda; break;
	case 21: case 22: case 23: case 24: menu_corr=menu_ascolta; break;
	case 31: case 32: case 33: case 34: menu_corr=menu_assaggia; break;
	case 41: case 42: case 43: case 44: menu_corr=menu_contatti; break;
	}

	//evidenzia link corrente
	$$('#menu a').each(function(e){
	 	eid=e.get('id');
		if (eid==id) e.setStyle('color','#fc0');
	}); 
	if (id==12 || id==13 || id==14 )  $('11').setStyle('color','#fc0');
	if (id==22 || id==23 || id==24 )  $('21').setStyle('color','#fc0');	
	//eventi onmouseenter e onmouseleave per i menu
	$$('#menu .menuitem').each(function(menu){
	
		  if (menu_corr==menu) {
			  menu_corr.setStyle('height', 70); 
			  eid=menu_corr.get('id');
			   if (eid=='home-10_' || eid=='home-11_') menu_corr.setStyle('width', 500);
			   if (eid=='home-12_' ) menu_corr.setStyle('width', 300);
			   
			  //if (eid!='home-12_' && eid!='home-13_')	
			  //	 menu_corr.setStyle('width', 500);
		  }  else {
			  menu.addEvent('mouseenter',function(){ 										 
				  this.set('tween',{duration:100, transition: Fx.Transitions.Bounce.easeOut, link:'chain'});
				  this.tween('height', 70);
				  eid=this.get('id');	 
				  //if (eid!='home-12_' && eid!='home-13_')
				  //   this.tween('width', 400); 
				  if (eid=='home-10_' || eid=='home-11_') this.tween('width', 400); 
				  if (eid=='home-12_' ) this.tween('width', 280); 
				  menu_corr.setStyle('height',37);
			  });		
			  menu.addEvent('mouseleave',function(){ 
				  this.set('tween',{duration:100, transition: Fx.Transitions.Bounce.easeOut, link:'chain'});
				  this.tween('height', 37); 
				  if (eid!='home-13_')
					 this.tween('width', 220); 
				  menu_corr.setStyle('height',70);
			  });
	  
		  }
	});

/*	if (menu_corr==menu_guarda) {
		menu_guarda.setStyle('height', 70); 
		menu_guarda.setStyle('width', 500);
	}  else {
		menu_guarda.addEvent('mouseenter',function(){ 										 
			this.set('tween',{duration:100, transition: Fx.Transitions.Bounce.easeOut, link:'chain'});
			this.tween('height', 70); this.tween('width', 500); 
			menu_corr.setStyle('height',37);
		});		
		menu_guarda.addEvent('mouseleave',function(){ 
			this.set('tween',{duration:100, transition: Fx.Transitions.Bounce.easeOut, link:'chain'});
			this.tween('height', 37); this.tween('width', 158); 
			menu_corr.setStyle('height',70);
		});

	}
	if (menu_corr==menu_ascolta) {
		menu_ascolta.setStyle('height', 70); 
		menu_ascolta.setStyle('width', 500);
	} else {
		menu_ascolta.addEvent('mouseenter',function(){ 
			this.set('tween',{duration:100, transition: Fx.Transitions.Bounce.easeOut, link:'chain'});
			this.tween('height', 70); this.tween('width', 500); 
			menu_corr.setStyle('height',37);
		});
		menu_ascolta.addEvent('mouseleave',function(){ 
			this.set('tween',{duration:100, transition: Fx.Transitions.Bounce.easeOut, link:'chain'});
			this.tween('height', 37); this.tween('width', 158); 
			menu_corr.setStyle('height',70);
		});
    }
	if (menu_corr==menu_assaggia) {
		menu_assaggia.setStyle('height', 70); 
		menu_assaggia.setStyle('width', 500);
	} else {	
		menu_assaggia.addEvent('mouseenter',function(){ 
			this.set('tween',{duration:100, transition: Fx.Transitions.Bounce.easeOut, link:'chain'});
		    this.tween('height', 70); 
			menu_corr.setStyle('height',37);
		});
   		menu_assaggia.addEvent('mouseleave',function(){ 
		    this.set('tween',{duration:100, transition: Fx.Transitions.Bounce.easeOut, link:'chain'});
		    this.tween('height', 37); 
			menu_corr.setStyle('height',70);
	    });
	}
	if (menu_corr==menu_contatti) {
		menu_contatti.setStyle('height', 70); 
		menu_contatti.setStyle('width', 500);
	} else {	
		menu_contatti.addEvent('mouseenter',function(){ 
			this.set('tween',{duration:100, transition: Fx.Transitions.Bounce.easeOut, link:'chain'});
		    this.tween('height', 70); 
			menu_corr.setStyle('height',37);
		});
   		menu_contatti.addEvent('mouseleave',function(){ 
		    this.set('tween',{duration:100, transition: Fx.Transitions.Bounce.easeOut, link:'chain'});
		    this.tween('height', 37); 
			menu_corr.setStyle('height',70);
	    });
	}*/


	/*var effectlogospecchioR = new Fx.Tween('logo_specchio', {duration:2000});
	var effectlogospecchio = new Fx.Tween('logo_specchio', {
		duration:1000, 
		transition: Fx.Transitions.Bounce.easeOut,
		onComplete: function(){
			effectlogospecchioR.start('margin-top', 0, 80).delay(10000);
		}

	});*/
	
	
	$$('#photos img').each(function(e){
		e.set('width','100%');
		e.set('height','100%');
	});
	
	var photos =$('photos');
	switch (id) {
	case 0:
	case 11: case 12: case 13: case 14:
	case 21: case 22: case 23: case 24:
		var FxPhotos = new Fx.Cycle.fade(photos, {duration:3000, steps:2000}); break;
	case 31: case 41:
		var FxPhotos = new Fx.Cycle.fade(photos, {duration:3000, steps:2000, autostart:false }); break;
	 	
	} 
	
	var barra1=$('barra1'); barra1.set('opacity',0.74);
	var barra2=$('barra2'); barra2.set('opacity',0.87);
	var barra3=$('barra3'); barra3.set('opacity',0.55);
	var barra4=$('barra4'); barra4.set('opacity',0.55);
	var barra5=$('barra5'); barra5.set('opacity',0.55);
	switch (id) {
	case 0:
		barra1.setStyle('background-color','#70c82f'); 
		barra2.setStyle('background-color','#d4ee8d'); 
		barra3.setStyle('background-color','#a4e259'); 
		barra4.setStyle('background-color','#a4e25a'); 
		barra5.setStyle('background-color','#6ba634'); break;
	case 11: case 12: case 13: case 14: 
		barra1.setStyle('background-color','#d7e200'); 
		barra2.setStyle('background-color','#faec4e');
		barra3.setStyle('background-color','#faf17c'); 
		barra4.setStyle('background-color','#faec4e'); 
		barra5.setStyle('background-color','#d7e200'); break;
	case 21: case 22: case 23: case 24: 
		barra1.setStyle('background-color','#87431e'); 
		barra2.setStyle('background-color','#a8594c');
		barra3.setStyle('background-color','#913d1e'); 
		barra4.setStyle('background-color','#913d1e'); 
		barra5.setStyle('background-color','#a8594c'); break;
	case 31: case 32: case 33: case 34: 
		barra1.setStyle('background-color','#7b2426'); 
		barra2.setStyle('background-color','#fd4239');
		barra3.setStyle('background-color','#fa2938'); 
		barra4.setStyle('background-color','#e70033'); 
		barra5.setStyle('background-color','#f32837'); break;
	case 41: case 42: case 43: case 44: 
		barra1.setStyle('background-color','#1d1d1d'); 
		barra2.setStyle('background-color','#373534');
		barra3.setStyle('background-color','#a2a5a4'); 
		barra4.setStyle('background-color','#1f1d1d'); 
		barra5.setStyle('background-color','#a2a5a4'); break;

	}

	
	var effect1 = new Fx.Tween('barra1', { duration:6000, transition: Fx.Transitions.Elastic.easeOut });	
	var effect2 = new Fx.Tween('barra2', { duration:4400, transition: Fx.Transitions.Elastic.easeOut });
	var effect3 = new Fx.Tween('barra3', { duration:5000, transition: Fx.Transitions.Elastic.easeOut });
	var effect4 = new Fx.Tween('barra4', { duration:5000, transition: Fx.Transitions.Elastic.easeOut });
	var effect5 = new Fx.Tween('barra5', { duration:3500, transition: Fx.Transitions.Elastic.easeOut });
	
	/*var photo1 =$('photo1'); photo1.set('opacity',0.5);
	var photo2 =$('photo2'); photo2.set('opacity',0.5);
	var photo3 =$('photo3'); photo3.set('opacity',0.5);
	var photo4 =$('photo4'); photo4.set('opacity',0.5);
	var photo5 =$('photo5'); photo5.set('opacity',0.5);
	var photo6 =$('photo6'); photo6.set('opacity',0.5);
	var photo7 =$('photo7'); photo7.set('opacity',0.5);*/
	
	/*var fx1 = new Fx.Tween('photo1', { duration:6000});	
	var fx2 = new Fx.Tween('photo2', { duration:6000});	
	var fx3 = new Fx.Tween('photo3', { duration:6000});
	var fx4 = new Fx.Tween('photo4');	
	var fx5 = new Fx.Tween('photo5');	
	var fx6 = new Fx.Tween('photo6');	
	var fx7 = new Fx.Tween('photo7');
	
	var Todo = new Class({
        Implements: Chain,
        initialize: function(){
            this.chain.apply(this, arguments);
        }
    });
 
    var myTodoList = new Todo(
        function(){ alert("la 1 parte"); fx1.start('opacity', 1, 0); },
		function(){ alert("la 2 parte"); fx2.start('opacity', 1, 0); },
		function(){ alert("la 3 parte"); fx3.start('opacity', 1, 0); }
		
    );*/
	
	
	
	//myTodoList.callChain();
	

	
    
/*	$('logo').addEvent('click', function(e){
		effectlogo.start('margin-top', 170, 300);
		//effectlogospecchio.start('margin-top', 80,0);
	});*/
	start_b=-100;
	effect1.start('left', start_b, 0);
	effect2.start('left', start_b, 62);
	effect3.start('left', start_b, 114);
	effect4.start('left', 1280, 738);
	effect5.start('left', 1280, 854);

	
	if (id==31) {
		$$("#portate a").addEvent('click', function(e){
			e.stop();
			pos=e.target.get('rel');
		 	FxPhotos.goTo(pos);

		});
	}
	


	/*$$('div.menuitem').addEvent('mouseenter', function(e){
		e.stop();													  
		var a=new Fx.Tween(e.target, { 
			duration:100, 
			transition: Fx.Transitions.Sine.easeInOut,
			link:'chain'
			
		});
		q=30;
		a.start('margin-left',0, -q);
		a.start('margin-left',-q, q);
		a.start('margin-left',q, 0);
	});*/
	
	/*$$('div.menuitem').addEvents({
		mouseenter: function() {
			this.set('tween',{duration:100, transition: Fx.Transitions.Elastic.easeIn});
			this.tween('margin-left','30px');
		}
	});*/
	
	/*var items=	$$('div.menuitem');
	
	items.each(function(element){
		element.set('tween',{duration:100, transition: Fx.Transitions.Sine.easeInOut, link:'chain'});
		element.addEvent('mouseenter', function(){
			q=30;
			this.tween('margin-left',0, -q);
			this.tween('margin-left',-q, q);
			this.tween('margin-left',q, 0);
		});
	});*/

	
	/*$$('div.lavoro img').addEvent('mouseenter', function(e){ e.stop();															
		var a=new Fx.Tween(e.target, {duration:300,transition: Fx.Transitions.Sine.easeInOut });
		q=57; a.start('width',q,q+100);
	});*/
	
	/*$$('div.lavoro img').addEvent('mouseenter', function(e){ e.stop();															
		var a=new Fx.Tween(e.target, {duration:300,transition: Fx.Transitions.Sine.easeInOut });
		q=e.target.getStyle('width'); a.start('width',q,'100px');
	});*/
	
	
	/*var limg=$$('div.lavoro div.foto_small');
	limg.each(function(e){ e.set('morph',{duration:300, transition: Fx.Transitions.Sine.easeInOut}); });
	limg.addEvents({
		mouseenter: function(){ 
			//this.set('morph',{duration:300, transition: Fx.Transitions.Sine.easeInOut});
			this.morph({width:75, height:75});
		},
		mouseleave: function(){ 
			//this.set('morph',{duration:300, transition: Fx.Transitions.Sine.easeInOut});
			//this.tween('width','57px');
			this.morph({width:57, height:57});
		}
	});*/
	


	
	/*$$('div.lavoro img').addEvent('mouseleave', function(e){ e.stop();															
		var a=new Fx.Tween(e.target, {duration:300,transition: Fx.Transitions.Sine.easeInOut });
		q=e.target.getStyle('width'); a.start('width',q,'57px');
	});*/
	
	/*$$('div.lavoro img').addEvent('mouseleave', function(e){ e.stop();
		var a=new Fx.Tween(e.target, { duration:300, transition: Fx.Transitions.Sine.easeInOut });
		q=57; a.start('width',q+100,q);
	});

	$$('div.lavoro img').addEvent('mouseenter', function(e){ e.stop();
		var a=new Fx.Tween(e.target, { 	duration:300, transition: Fx.Transitions.Sine.easeInOut	});
		q=57; a.start('height',q,q+100);
	});

	$$('div.lavoro img').addEvent('mouseleave', function(e){ e.stop();
		var a=new Fx.Tween(e.target, { 	duration:300, transition: Fx.Transitions.Sine.easeInOut	});
		q=57; a.start('height',q+100,q);
	});*/
	

	
	
});
