

window.addEvent('domready',function(){
	$$('.subMenuTop').each(function(item){
		item.setStyles({"opacity":0,"visibility":"visible","height":0});
	});
	
	$('menuTopList').getElements('li').each(function(item){
		item.addEvent('mouseenter',function(e){
			item.getElement('a').tween('color','#FF5E00');
			if($defined(item.getElement('.subMenuTop'))){
				var h = item.getElement('.subMenuTop').getStyle('height');
				item.getElement('.subMenuTop').morph({'opacity':0.8,'height':130});
			}
		});
		item.addEvent('mouseleave',function(e){
			if(item.getParent()==$('menuTopList')){
				item.getElement('a').tween('color','#981B1E');
			} else {
				item.getElement('a').tween('color','#fff');
			}
			if($defined(item.getElement('.subMenuTop'))){
				item.getElement('.subMenuTop').morph({'opacity':0,'height':0});
			}
		});
	});
	
	$('menuLeftList').getElements('a').each(function(item){
		item.addEvent('mouseenter',function(e){
			item.tween('color','#FF5E00');
		});
		item.addEvent('mouseleave',function(e){
			item.tween('color','#981B1E');
		});
	});


	if($defined($('slideshowContainer'))){
		loadSlideshow(1);
	}
	
	if($defined($('slideshowBancContainer'))){
		loadSlideshow(2);
	}
	if($defined($('slideshowCamereContainer'))){
		loadSlideshow(3);
	}
	
	if($defined($('slideshowAppContainer'))){
		loadSlideshow(4);
	}
	if($defined($('videoContainer'))){
		loadBotroVideo();
	}
	
	
	if($defined($('prezziSubMenu'))){
		var w = $('prezziFrame').getStyle('width').replace(/px/,"");
		$('prezziSubMenuApp').addEvent('click',function(e){
			new Event(e).stop();
			$('prezziContainer').tween('left',0);
			this.setStyle('text-decoration','underline');
			$('prezziSubMenuCamere').setStyle('text-decoration','none');
			$('prezziSubMenuTrasp').setStyle('text-decoration','none');
		});
		$('prezziSubMenuCamere').addEvent('click',function(e){
			new Event(e).stop();
			$('prezziContainer').tween('left',(0-w));
			this.setStyle('text-decoration','underline');
			$('prezziSubMenuApp').setStyle('text-decoration','none');
			$('prezziSubMenuTrasp').setStyle('text-decoration','none');
		});
		$('prezziSubMenuTrasp').addEvent('click',function(e){
			new Event(e).stop();
			$('prezziContainer').tween('left',(0-2*w));
			this.setStyle('text-decoration','underline');
			$('prezziSubMenuCamere').setStyle('text-decoration','none');
			$('prezziSubMenuApp').setStyle('text-decoration','none');
		});
		
		$('prezziSubMenu').getElements('a').each(function(item){
			item.addEvent('mouseenter',function(){
				item.tween('color','#981B1E')
			});
			item.addEvent('mouseleave',function(){
				item.tween('color','#FF5E00')
			});
		});
	}
	
	
	if($defined($('novitaLink'))){
		var tween = new Fx.Tween('novitaLink');
		tween.start('color','#981B1E').chain(function(){
			tween.start('color','#FF5E00').chain(function(){
				tween.start('color','#981B1E').chain(function(){
					tween.start('color','#FF5E00').chain(function(){
						tween.start('color','#981B1E').chain(function(){
							tween.start('color','#FF5E00');
						});
					});
				});
			});
		});
	}
	
});




function loadSlideshow(num){
	
	var curName = "";
	var curBox = "";
	var curMax = 0;
	var curW = 0;
	var curH = 0;
	if(num==1){
		curName = 'galleria';
		curBox = 'slideshowBox';
		curMax = 45;
		curW = 600;
		curH = 380;
	} else if(num==2) {
		curName = 'banchettistica';
		curBox = 'slideshowBancBox';
		curMax = 10;
		curW = 412;
		curH = 269;
	} else if(num==3) {
		curName = 'camere';
		curBox = 'slideshowCamereBox';
		curMax = 9;
		curW = 412;
		curH = 269;
	} else if(num==4) {
		curName = 'appartamenti';
		curBox = 'slideshowAppBox';
		curMax = 4;
		curW = 412;
		curH = 269;
	}

	var imgArray = new Array();
	var i=0;
	for(i=0; i<curMax;i++){
		imgArray[i] = curName+'-'+(i+1)+'.jpg';
	}
	if(Browser.Engine.trident || num>1){
    	new Slideshow(curBox, imgArray, { height: curH, hu: 'img/'+curName+'/', width: curW, duration: 3000 });
	} else {
		new Slideshow.KenBurns(curBox, imgArray, { height: curH, hu: 'img/'+curName+'/', width: curW, duration: 3000 });
	}
}


function loadBotroVideo(){
	var s1 = new SWFObject("flash/player.swf","ply","600","413","9","#FFFFFF");
	s1.addParam("allowfullscreen","true");
	s1.addParam("allownetworking","all");
	s1.addParam("allowscriptaccess","always");
	s1.addParam("flashvars","file=../video/botro1.flv&image=img/content/video-1.jpg");
	s1.write("videoContainer");
}
