var whoisV = '';

function chkboo () {

	var bVisH = $('booking_f_h_h').getStyle('visibility');
	var bVisF = $('booking_f_h_f').getStyle('visibility');
	
	if (bVisH == 'visible') {
		
		$('booking_f_h_h').setStyle('visibility', 'hidden');
		whoisV = 'booking_f_h_h';
	}	
	else if (bVisF == 'visible') {
	
		$('booking_f_h_f').setStyle('visibility', 'hidden');
		whoisV = 'booking_f_h_f';
	}
}

function rstboo () {
	if (whoisV!='')
	{
		$(whoisV).setStyle('visibility', 'visible');
	}
	
	//alert(whoisV);
}



window.addEvent('domready', function() {
	
	var status_box=1;

    $('box_home1').setStyle('opacity', '0');
	$('box_home1').setStyle('display', 'block');     
 		
		
	var HomeEffect = new Fx.Morph('box_home1', {duration: 2500, wait: true, transition: Fx.Transitions.Sine.easeOut}); //2500


	HomeEffect.start.delay(2000, HomeEffect, {'opacity': 1}); //1500



  	tabs = new MGFX.Tabs('#box_home_tab','.content_box',{
          				            autoplay: false,
          				            transitionDuration:700,
          				            slideInterval:6000,
          				            startIndex: 0,
          				            hover:true
          			       });


	var CloseEffect = new Fx.Morph('box_home', {
								   duration: 1000,
								   wait: true, 
								   transition: Fx.Transitions.Sine.easeOut,
								   onComplete: function(){
             						if (status_box==0)
									{
	      								$('box_home_tab').setStyle('background-position', '0px -75px');
									}
									}
});
	


	$('close_tabs1').addEvent('click', function(e){
		e.stop();
		CloseEffect.start({'padding-top': [0, 190]  });
		status_box=0;
	});
	
	$('close_tabs2').addEvent('click', function(e){
		e.stop();
		CloseEffect.start({'padding-top': [0, 190]  });
		status_box=0;
	});
	
	$('close_tabs3').addEvent('click', function(e){
		e.stop();
		CloseEffect.start({'padding-top': [0, 190]  });
		status_box=0;
	});
	

	$('tab1').addEvent('click', function(e){
		e.stop();
		$('box_home_tab').setStyle('background-position', '0px 0px');
		rstboo();
		if (status_box==0)
		{
			 CloseEffect.start({'padding-top': [190, 0]  });
			 status_box=1;
		}
	});

	$('tab2').addEvent('click', function(e){
		e.stop();
		$('box_home_tab').setStyle('background-position', '0px -25px');
		chkboo();
		if (status_box==0){
		 CloseEffect.start({'padding-top': [190, 0]  });
		status_box=1;
			}	
	});
	
	
		$('tab3').addEvent('click', function(e){
		e.stop();
		$('box_home_tab').setStyle('background-position', '0px -50px');
		chkboo();
		if (status_box==0){
		 CloseEffect.start({'padding-top': [190, 0]  });
		status_box=1;
			}

	});
			
	var info_pages_e = $('contatore_home');				 								 
	var eS4 = new noobSlide({
			box: $('box_home_news'),
			items: $$('#box_home_news div'),
			size: 232,
			addButtons: {previous: $('preve_home'), next: $('nexte_home') },
			onWalk: function(currentItem,currentHandle)
			{
				info_pages_e.empty();
				info_pages_e.set('html',(this.currentIndex+1)+'/'+this.items.length);		
			}
		});
	
	var info_pages_ee = $('contatore_home_events');				 								 
	var eS5 = new noobSlide({
			box: $('box_home_events'),
			items: $$('#box_home_events div'),
			size: 232,
			addButtons: {previous: $('preve_home_events'), next: $('nexte_home_events') },
			onWalk: function(currentItem,currentHandle)
			{
				info_pages_ee.empty();
				info_pages_ee.set('html',(this.currentIndex+1)+'/'+this.items.length);		
			}
		});

	
});