
$(document).ready(function(){

	/* ANIMAZIONE TOP */
	var menutop=0;
	var menubottom=0;
	$("div.click_top").click(function() {
		if (menutop==0){
			if (menubottom==1){
				$("div.click_bottom a").removeClass("attivo");	
				$('div.contiene_bottom').animate({
					 bottom:-454
				}, 1500,'easeInOutExpo', function() {
					$("div.click_top a").addClass("attivo");
					$('div.contiene_top').animate({
						 top:0
					}, 1500,'easeInOutExpo');
				  });
				menubottom=0;
				menutop=1;
			} else {
				$("div.click_top a").addClass("attivo");
				$('div.contiene_top').animate({
					 top:0
				}, 1500,'easeInOutExpo');
				menutop=1;
			}
		} else {
			$("div.click_top a").removeClass("attivo");
			$('div.contiene_top').animate({
				 top:-454
			}, 1500,'easeInOutExpo');
			menutop=0;
		}
		
	});
	
	/* ANIMAZIONE BOTTOM */
	
	$("div.click_bottom").click(function() {
		if (menubottom==0){
			if (menutop==1){
				$("div.click_top a").removeClass("attivo");	
				$('div.contiene_top').animate({
					 top:-454
				}, 1500,'easeInOutExpo', function() {
					$("div.click_bottom a").addClass("attivo");
					$('div.contiene_bottom').animate({
						 bottom:0
					}, 1500,'easeInOutExpo');
				  });
				menutop=0;
				menubottom=1;
			} else {
				$("div.click_bottom a").addClass("attivo");
				$('div.contiene_bottom').animate({
				 	bottom:0
				}, 1500,'easeInOutExpo');
				menubottom=1;
			}
			
			
		} else {
			$("div.click_bottom a").removeClass("attivo");
			$('div.contiene_bottom').animate({
				 bottom:-454
			}, 1500,'easeInOutExpo');
			menubottom=0;
		}
	});
	 
	  var timer;
	  $("div.regaleali_pal a").mouseenter(function() {
		if(timer) {
			clearTimeout(timer);
			timer = null
		}	
		timer = setTimeout(function() { 
			$('div.sposta_rega').animate({
				 right:0
			}, 600,'easeInOutExpo');
		}, 200);
	  }).mouseleave(function() {
		if(timer) {
			clearTimeout(timer);
			timer = null
		}     	
		$('div.sposta_rega').animate({
			 right:-178
		}, 300,'easeInOutExpo');
	  });
	  
	  var timer2;
	  $("div.capofaro_pal a").mouseenter(function() {
		if(timer2) {
			clearTimeout(timer2);
			timer2 = null
		}	
		timer2 = setTimeout(function() { 
		$('div.sposta_capofaro').animate({
			 right:0
		}, 600,'easeInOutExpo');
		}, 200);
	  }).mouseleave(function() {
	  	if(timer2) {
			clearTimeout(timer2);
			timer2 = null
		}   
		$('div.sposta_capofaro').animate({
			 right:-178
		}, 300,'easeInOutExpo');
	  });
	  
	  var timer3;
	  $("div.sallier_pal a").mouseenter(function() {
		if(timer3) {
			clearTimeout(timer3);
			timer3 = null
		}	
		timer3 = setTimeout(function() {   
			$('div.sposta_sallier').animate({
				 left:0
			}, 600,'easeInOutExpo');
		}, 200);
	  }).mouseleave(function() {
	  	if(timer3) {
			clearTimeout(timer3);
			timer3 = null
		}   
		$('div.sposta_sallier').animate({
			 left:-233
		}, 300,'easeInOutExpo');
	  });	  
	  
	  
	  var timer4;
	  $("div.tascante_pal a").mouseenter(function() {
		if(timer4) {
			clearTimeout(timer4);
			timer4 = null
		}	
		timer4 = setTimeout(function() {   
			$('div.sposta_tascante').animate({
				 right:0
			}, 600,'easeInOutExpo');
		}, 200);
	  }).mouseleave(function() {
	  	if(timer4) {
			clearTimeout(timer4);
			timer4 = null
		}   
		$('div.sposta_tascante').animate({
			 right:-178
		}, 300,'easeInOutExpo');
	  });	  
	  
	  
	  var timer5;
	  $("div.mozia_pal a").mouseenter(function() {
		if(timer5) {
			clearTimeout(timer5);
			timer5 = null
		}	
		timer5 = setTimeout(function() {   
			$('div.sposta_mozia').animate({
				 left:0
			}, 600,'easeInOutExpo');
		}, 200);
	  }).mouseleave(function() {
	  	if(timer5) {
			clearTimeout(timer5);
			timer5 = null
		}   
		$('div.sposta_mozia').animate({
			 left:-178
		}, 300,'easeInOutExpo');
	  });	  
	  


 var timer6;
	  $('div.tenuta').live('mouseenter', function() {
	  
	  
	  //$("div.tenuta").mouseenter(function() {
		$(this).find("div").fadeIn('fast');
		valore = $(this).attr("id");

		if(timer6) {
			clearTimeout(timer6);
			timer6 = null
		}	
		timer6 = setTimeout(function() {
			if (valore=='sposta_rega'){
				$('div.'+valore).animate({
					 right:0
				}, 600,'easeInOutExpo');
			}
			if (valore=='sposta_capofaro'){
				$('div.'+valore).animate({
					 right:0
				}, 600,'easeInOutExpo');
			}
			if (valore=='sposta_mozia'){
				$('div.'+valore).animate({
					 left:0
				}, 600,'easeInOutExpo');
			}
			if (valore=='sposta_tascante'){
				$('div.'+valore).animate({
					 right:0
				}, 600,'easeInOutExpo');
			}
			if (valore=='sposta_sallier'){
				$('div.'+valore).animate({
					 left:0
				}, 600,'easeInOutExpo');
			}
		}, 200);
		
		
		/*}).mouseleave(function() {*/
		}).live('mouseleave', function() {
		
		$(this).find("div").fadeOut('fast');
		if(timer6) {
			clearTimeout(timer6);
			timer6 = null
		}     	
		if (valore=='sposta_rega'){
			$('div.'+valore).animate({
				 right:-178
			}, 300,'easeInOutExpo');
		}
		if (valore=='sposta_capofaro'){
			$('div.'+valore).animate({
				 right:-178
			}, 300,'easeInOutExpo');
		}
		if (valore=='sposta_mozia'){
			$('div.'+valore).animate({
				 left:-178
			}, 300,'easeInOutExpo');
		}
		if (valore=='sposta_tascante'){
			$('div.'+valore).animate({
				 right:-178
			}, 300,'easeInOutExpo');
		}
		if (valore=='sposta_sallier'){
			$('div.'+valore).animate({
				 left:-233
			}, 300,'easeInOutExpo');
		}
		
	  });
	  

		
});

