$(document).ready(function(){
		//$("#dxCont").accordion();
		$("#dxCont").accordion({clearStyle:true,active:false});
		$("#dxCont div").each(function(){
			$(this).css('height','auto')
		})
		$("#dxCont h3").each(function(){
			$(this).click(function(){
				num=parseInt($(this).attr('id').split('_')[1]);
				slideGalleryTo(num);
				num-=1;
				$('.Content_Image_absolute:visible').stop(true, true).fadeOut();
				$('.Content_Image_absolute').eq(num).stop(true, true).fadeIn();
			})
		})
		/*$("#dxCont .pressAct").each(function(){
			$(this).mouseup(function(){
				num=parseInt($(this).attr('id').split('_')[1]);
				
				//$('.testoAreaStampa:visible').stop(true, true).fadeOut();
				$('.activator_'+num).stop(true, true).fadeIn();
			})
		})*/
		//$('#aprigallery').css('visibility','visible')
		//$('#aprigallery').hide();



	var tempoShow=500;
	var tempoHide=1000;
	var upDown="up";
	var inMotion=false;
	var h1,h2,yM1;
	var tim;
	
	function slideGalleryTo(num){
		upDown='up';
		var x=-710*num;
		x+=710;
		//alert(x)
		
		//tim=setTimeout(nascondiGallery,2000);
		mostraGallery()
		
		
		/*$('#aprigallery').stop(true,true).fadeOut();
		$('.Nav_Event_Image2').stop(true).animate({
			bottom: '0px',
			paddingTop: '0px'
		  }, tempoShow, function() {
			inMotion=false;
			upDown='up';
		  });*/
		$('.slider_Event2').stop(true).animate({
				left: x+'px', bottom:'0px', opacity:1
			  }, 300 );
			  
			
		//$('.slider_Event2').stop(true).fadeOut();
	}
	
	function none(){
	
	}
	function mostraGallery(hide){
		//if(!hide)	
			clearTimeout(tim)
		$('.Nav_Event_Image2').css('bottom','0px')
		$('.Nav_Event_Image2').css('paddingTop','0px')
		$('#aprigallery').css('visibility','hidden')
		$('.slider_Event2').css('visibility','visible')
		
		
		//if(inMotion || upDown=='up') return;
		inMotion=true;
		/*$('#aprigallery').stop(true,true).fadeOut();
		$('.Nav_Event_Image2').stop(true).animate({
			bottom: '0px',
			paddingTop: '0px'
		  }, tempoShow, function() {
			inMotion=false;
			upDown='up';
		  });
		//$('.slider_Event2').stop(true).fadeIn();
		$('.slider_Event2').stop(true).animate({
			//bottom: '0px'
			
			opacity:1
		  }, tempoShow, function() {
		  });*/
	}
	function nascondiGallery(){
		//if(inMotion || upDown=='down') return;
		inMotion=true;
		
		$('.Nav_Event_Image2').css('bottom','-115px')
		$('.Nav_Event_Image2').css('paddingTop','20px')
		$('#aprigallery').css('visibility','visible')
		$('.slider_Event2').css('visibility','hidden')
		
		/*$('#aprigallery').stop(true,true).fadeIn();
		$('.Nav_Event_Image2').stop(true).animate({
			bottom: '-115px',
			paddingTop: '20px'
		  }, tempoHide, function() {
			inMotion=false;
			upDown='down';
		  });
		//$('.slider_Event2').stop(true).fadeOut();
		$('.slider_Event2').stop(true).animate({
			//bottom: '-30px',
			opacity:0
		  }, tempoHide, function() {
		  });
		//$('.slider_Event2').fadeOut()*/
	}
	function setHover(){
		$('.Nav_Event_Image2').hover(mostraGallery,nascondiGallery);
	}
	function initGallery(){
		mostraGallery();
		//setTimeout(nascondiGallery,2000);
	}
	initGallery();
	setHover();
	
	function aggiornaFS(){
			if(!$('#fsDx_contentwrapper').size())
				return;
			var top=parseInt($('#fsDx_contentwrapper').css('top').split('px')[0]);
			$('#fsDx').css('height','auto')
			var height=parseInt($('#dxCont').css('height').split('px')[0]);
			if(top+height<0){
				riportaCont();
			}else{
				fleXenv.updateScrollBars();
			}
	}
	function riportaCont(){
	fleXenv.updateScrollBars();
		$('#fsDx_contentwrapper').animate({
			top: '0px'
		  }, tempoHide, function() {
		});
	}
	$('#fsDx').mouseup(function(){
		setTimeout(aggiornaFS,500);
	});
});
