$(window).resize(function(){

//VARS DEFINITION
var EddieEasing = 'easeOutCubic';
var EddieOutEasing = 'easeOutCubic';
var EddieTime = 1800;	
var EddieSlowTime = 500;

//SCREEN SIZE
var containerHeight = $(window).height();
var containerWidth = $(window).width();

var whereIam = $('#wrapper').offset().top;

if(whereIam==0){
	//alert('normal');
	}else if(whereIam<0){
		//alert('change');
		}

if(containerWidth<="1024"){
		
		$(".plane_leaving").removeClass('big');
		$(".plane_leaving").addClass('small');
		
		$("h1.title").removeClass('big');
		$("h1.title").addClass('small');
		
		$(".text").removeClass('big');
		$(".text").addClass('small');
		
		$("a.optional_element").removeClass('big');
		$("a.optional_element").addClass('small');
		
		$(".xtra_cloud").css('display', 'none');
		
		$(".social_icons").removeClass('big');
		$(".social_icons").addClass('small');
		
		$('#splash_paragraph').css('margin-left','-240px');
		$('#triangles, #inner_splash').css('margin-left','-165px');
		$('#splash_footer').css('margin-left','-350px');
		
	}else{
		$(".plane_leaving").removeClass('small');
		$(".plane_leaving").addClass('big');
		
		$("h1.title").removeClass('small');
		$("h1.title").addClass('big');
		
		$(".text").removeClass('small');
		$(".text").addClass('big');
		
		$("a.optional_element").removeClass('small');
		$("a.optional_element").addClass('big');
		
		$(".xtra_cloud").css('display', 'block');
		
		$(".social_icons").removeClass('small');
		$(".social_icons").addClass('big');
		
		$('#splash_paragraph').css('margin-left','-340px');
		$('#triangles, #inner_splash').css('margin-left','-265px');
		$('#splash_footer').css('margin-left','-450px');
		
		}

//var totalWidth = containerWidth*7;

$("li.box").css('width', containerWidth);
//$("ul#mask").css('width', totalWidth);

// iPad check
var isiPad = navigator.userAgent.match(/iPad/i) != null;
if(isiPad){
orientation = Math.abs(window.orientation) == 90 ? 'landscape' : 'portrait';
	
	if(orientation=='0' || orientation=='180'){
		
		var center = (containerWidth/2)-111;
		
		$('#logo').stop().animate({left: 0}, 300, EddieEasing);
		
		$('#logo_splash').stop().animate({left: center}, 300, EddieEasing);
		$('#splash_paragraph').stop().animate({top: 200}, 300, EddieEasing);
		$('#triangles').stop().animate({top: '40%'}, 300, EddieEasing);
		$('#inner_splash').stop().animate({top: '42%'}, 300, EddieEasing);
		$('#splash_paragraph').css('margin-left','-340px');
		$('#triangles, #inner_splash').css('margin-left','-265px');
		$('#splash_footer').css('margin-left','-450px');
		
		
		var containerHeight = $(window).height();
		$('#on-ground, #wrapper').css('height', containerHeight);
		$('#header').stop().animate({top:52}, 500, EddieEasing);
		
		$('#header li.trattino').css('width','10px');
			
			$('.menu_ground li.trattino').not('#footer .menu_ground li.trattino').css('width','15px');
			$('#header, .menu_ground').not('#footer .menu_ground').css('margin-left','-300px');
			$('#header, .menu_ground').not('#footer .menu_ground').css('width','760px');
			$('.menu_ground').not('#footer .menu_ground').css('margin-left','-300px');
			$('.menu_ground').not('#footer .menu_ground').css('width','759px');
			$('.menu_ground').not('#footer .menu_ground').css('margin-top','81px');
		
		
		
		}else if(orientation=='-90' || orientation=='90'){
			
			$('#logo').stop().animate({left: 0}, 300, EddieEasing);
			
			
			$('#logo_splash').stop().animate({left: 0}, 300, EddieEasing);
			$('#splash_paragraph').stop().animate({top: 30}, 300, EddieEasing);
			$('#triangles').stop().animate({top: '25%'}, 300, EddieEasing);
			$('#inner_splash').stop().animate({top: '28%'}, 300, EddieEasing);
			$('#splash_paragraph').css('margin-left','-240px');
			$('#triangles, #inner_splash').css('margin-left','-165px');
			$('#splash_footer').css('margin-left','-350px');
			
			
			var containerHeight = $(window).height();
			$('#on-ground, #wrapper').css('height', containerHeight);
			$('#header').stop().animate({top:52}, 500, EddieEasing);
			
			$('#header li.trattino').css('width','10px');
			$('.menu_ground li.trattino').not('#footer .menu_ground li.trattino').css('width','15px');
			$('#header').css('margin-left','-300px');
			$('#header').css('width','760px');
			$('.menu_ground').not('#footer .menu_ground').css('margin-left','-300px');
			$('.menu_ground').not('#footer .menu_ground').css('width','759px');
			$('.menu_ground').not('#footer .menu_ground').css('margin-top','81px');
			
			
			}


}//iPad


	
	
// iPad check
var isiPad = navigator.userAgent.match(/iPad/i) != null;

		
//ALTEZZE ELEMENTI SEZIONI
var textHeight = $("#box1 .text").height();
var titleHeight = $("h1.title").height();
var planeHeight = $(".plane_leaving").height();
		
//MARGINE DEFAULT TITOLO
var titleMarginTop = (containerHeight-titleHeight) - planeHeight;
var titleFixedMargin = titleMarginTop - 180;
		
//MARGINE DEFAULT TESTO
var textMarginTop = 20;
		
//APPLICO MARGINI CSS
$("#box1 .text").css("margin-top", textMarginTop);
//$("h1.title").css("margin-top", titleFixedMargin);

//GENERO DIMENSIONI BORDO BIANCO PAGINA
var innerBorderHeight = containerHeight - 40;
var innerBorderWidth = containerWidth -40;
$(".inner_border").css("height", innerBorderHeight);
$(".inner_border").css("width", innerBorderWidth);
		
//ALTEZZA CONTENUTI
$("#content").css("height", containerHeight);
$(".inner").css("height", containerHeight);

$("#splash").css('height', containerHeight);
		


//POSIZIONE NUVOLE FRONTALI
$("#clouds-frontal").css("height", containerHeight);
var frontalCloudsHeight = $("#clouds-frontal img#frontal").height();
var frontalCloudsMargin = (containerHeight - frontalCloudsHeight);
$("#clouds-frontal img#frontal").css("margin-top", frontalCloudsMargin);

//XTRA CLOUD

var screenWidth = $(window).width();

var margin1 = (screenWidth*7) - 700;
$('#box1 .xtra_cloud').css('left', margin1);

var margin2 = (screenWidth*6) -1350;
$('#box2 .xtra_cloud').css('left', margin2);

var margin3 = (containerWidth*5) - 800;
$('#box3 .xtra_cloud').css('left', margin3);

var margin4 = (containerWidth*4) - 700;
$('#box4 .xtra_cloud').css('left', margin4);

var margin5 = (containerWidth*3) - 650;
$('#box5 .xtra_cloud').css('left', margin5);

var margin6 = (containerWidth*2) - 700;
$('#box6 .xtra_cloud').css('left', margin6);

var margin7 = (containerWidth*1) - 595;
$('#box7 .xtra_cloud').css('left', margin7);
		
//MARGINE TITOLI

var HeightTit = $('.box h1.title').height();

var TitMargin = containerHeight- HeightTit;

var TitFixedMargin01 = TitMargin - 440;
var TitFixedMargin02 = TitMargin - 440;
var TitFixedMargin03 = TitMargin - 420;
var TitFixedMargin04 = TitMargin - 420;
var TitFixedMargin05 = TitMargin - 430;
var TitFixedMargin06 = TitMargin - 410;
var TitFixedMargin07 = TitMargin - 420;
		
$('#box1 h1.title').css('margin-top', TitFixedMargin01);
$('#box2 h1.title').css('margin-top', TitFixedMargin02);
$('#box3 h1.title').css('margin-top', TitFixedMargin03);
$('#box4 h1.title').css('margin-top', TitFixedMargin04);
$('#box5 h1.title').css('margin-top', TitFixedMargin05);
$('#box6 h1.title').css('margin-top', TitFixedMargin06);
$('#box7 h1.title').css('margin-top', TitFixedMargin07);	
		
//ALTEZZA E MARGINI PARTE ONGROUND
var onGroundFix = containerHeight;
if(isiPad){
	$("#on-ground, #contenuto_ajax").css("height", "auto");
	$("#on-ground, #contenuto").css("min-height", "1224px");
	$("#on-ground, #contenuto_ajax").css("overflow", "hidden");
	$("#on-ground").css("width", "100%");
}else{
//$("#on-ground").css("margin-top", containerHeight);
$('#on-ground').css('overflow', 'auto');
$("#on-ground, #contenuto_ajax").css("height", "100%");
$("#on-ground").css("width", containerWidth);
$("#wrapper").css("height", containerHeight);	
}


//DIMENSIONE NUVOLE DI BACKGROUND
$("#clouds-small").css("height", containerHeight);
$("#clouds-small img#bkg").css("height", containerHeight);

var CloudsHeight = $("#clouds-small img#bkg").height();

if(CloudsHeight >= 620){
	
	var cloudsPadding = containerHeight - 620;
	var cloudFixHeight = containerHeight - cloudsPadding;
	
	$("#clouds-small img#bkg").css("height", cloudFixHeight);
	$("#clouds-small").css("padding-top", cloudsPadding);
	$("#clouds-small").css("height", cloudFixHeight);
	
	}else{
		
		$("#clouds-small").css("height", containerHeight);
		$("#clouds-small img#bkg").css("height", containerHeight);
		
		}


//var plane01Left = containerWidth*5;
//$('.plane_leaving#Plane01').css('left', plane01Left);

});//END RESIZE FUNCTION



$(document).ready(function() {  
	

//VARS DEFINITION
var EddieEasing = 'easeOutCubic';
var EddieOutEasing = 'easeOutCubic';
var EddieTime = 1800;	
var EddieSlowTime = 500;

//SCREEN SIZE
var containerHeight = $(window).height();
var containerWidth = $(window).width();

//MS Internet Explorer SUCKS --------------------------------------------------------------------------- wake up bill ---------------------	
if (jQuery.browser.msie) {
 $('#ie_alert, #ie_alert_inner').css('display', 'block');
 
}else{
	$('#ie_alert, #ie_alert_inner').css('display', 'none');	
	}

$('a#close_browser_check').click(function(){
	
	$('#ie_alert_inner p, #browser_icons').animate({opacity:0},600, function(){
	
		$('#ie_alert_inner').animate({opacity:0},600, function(){
			
			$('#ie_alert_inner').css('display','none');
			$('#ie_alert').animate({opacity:0}, 800, function(){
				$('#ie_alert').css('display','none');	
				})	
			
			
			});
		});
	return false;
	});	

if(containerWidth<="1024"){
		
		$(".plane_leaving").removeClass('big');
		$(".plane_leaving").addClass('small');
		
		$("h1.title").removeClass('big');
		$("h1.title").addClass('small');
		
		$(".text").removeClass('big');
		$(".text").addClass('small');
		
		$("a.optional_element").removeClass('big');
		$("a.optional_element").addClass('small');
		
		$(".xtra_cloud").css('display', 'none');
		
		$(".social_icons").removeClass('big');
		$(".social_icons").addClass('small');
		
		$('#splash_paragraph').css('margin-left','-240px');
		$('#triangles, #inner_splash').css('margin-left','-165px');
		$('#splash_footer').css('margin-left','-350px');
		
	}else{
		$(".plane_leaving").removeClass('small');
		$(".plane_leaving").addClass('big');
		
		$("h1.title").removeClass('small');
		$("h1.title").addClass('big');
		
		$(".text").removeClass('small');
		$(".text").addClass('big');
		
		$("a.optional_element").removeClass('small');
		$("a.optional_element").addClass('big');
		
		$(".xtra_cloud").css('display', 'block');
		
		$(".social_icons").removeClass('small');
		$(".social_icons").addClass('big');
		
		$('#splash_paragraph').css('margin-left','-340px');
		$('#triangles, #inner_splash').css('margin-left','-265px');
		$('#splash_footer').css('margin-left','-450px');
		
		}

//var totalWidth = containerWidth*7;

$("li.box").css('width', containerWidth);
//$("ul#mask").css('width', totalWidth);

// iPad check
var isiPad = navigator.userAgent.match(/iPad/i) != null;
if(isiPad){
orientation = Math.abs(window.orientation) == 90 ? 'landscape' : 'portrait';
	
	if(orientation=='0' || orientation=='180'){
		
		var center = (containerWidth/2)-111;
		
		$('#logo').stop().animate({left: 0}, 300, EddieEasing);
		
		$('#logo_splash').stop().animate({left: center}, 300, EddieEasing);
		$('#splash_paragraph').stop().animate({top: 200}, 300, EddieEasing);
		$('#triangles').stop().animate({top: '40%'}, 300, EddieEasing);
		$('#inner_splash').stop().animate({top: '42%'}, 300, EddieEasing);
		$('#splash_paragraph').css('margin-left','-340px');
		$('#triangles, #inner_splash').css('margin-left','-265px');
		$('#splash_footer').css('margin-left','-450px');
		
		
		var containerHeight = $(window).height();
		$('#on-ground, #wrapper').css('height', containerHeight);
		$('#header').stop().animate({top:52}, 500, EddieEasing);
		
		$('#header li.trattino').css('width','10px');
			
			$('.menu_ground li.trattino').not('#footer .menu_ground li.trattino').css('width','15px');
			$('#header, .menu_ground').not('#footer .menu_ground').css('margin-left','-300px');
			$('#header, .menu_ground').not('#footer .menu_ground').css('width','760px');
			$('.menu_ground').not('#footer .menu_ground').css('margin-left','-300px');
			$('.menu_ground').not('#footer .menu_ground').css('width','759px');
			$('.menu_ground').not('#footer .menu_ground').css('margin-top','81px');
		
		
		
		}else if(orientation=='-90' || orientation=='90'){
			
			$('#logo').stop().animate({left: 0}, 300, EddieEasing);
			
			
			$('#logo_splash').stop().animate({left: 0}, 300, EddieEasing);
			$('#splash_paragraph').stop().animate({top: 30}, 300, EddieEasing);
			$('#triangles').stop().animate({top: '25%'}, 300, EddieEasing);
			$('#inner_splash').stop().animate({top: '28%'}, 300, EddieEasing);
			$('#splash_paragraph').css('margin-left','-240px');
			$('#triangles, #inner_splash').css('margin-left','-165px');
			$('#splash_footer').css('margin-left','-350px');
			
			
			var containerHeight = $(window).height();
			$('#on-ground, #wrapper').css('height', containerHeight);
			$('#header').stop().animate({top:52}, 500, EddieEasing);
			
			$('#header li.trattino').css('width','10px');
			$('.menu_ground li.trattino').not('#footer .menu_ground li.trattino').css('width','15px');
			$('#header').css('margin-left','-300px');
			$('#header').css('width','760px');
			$('.menu_ground').not('#footer .menu_ground').css('margin-left','-300px');
			$('.menu_ground').not('#footer .menu_ground').css('width','759px');
			$('.menu_ground').not('#footer .menu_ground').css('margin-top','81px');
			
			
			}
}//iPad

	
	
	
	
// iPad check
var isiPad = navigator.userAgent.match(/iPad/i) != null;

		
//ALTEZZE ELEMENTI SEZIONI
var textHeight = $("#box1 .text").height();
var titleHeight = $("h1.title").height();
var planeHeight = $(".plane_leaving").height();
		
//MARGINE DEFAULT TITOLO
var titleMarginTop = (containerHeight-titleHeight) - planeHeight;
var titleFixedMargin = titleMarginTop - 180;
		
//MARGINE DEFAULT TESTO
var textMarginTop = 20;
		
//APPLICO MARGINI CSS
$("#box1 .text").css("margin-top", textMarginTop);
//$("h1.title").css("margin-top", titleFixedMargin);

//GENERO DIMENSIONI BORDO BIANCO PAGINA
var innerBorderHeight = containerHeight - 40;
var innerBorderWidth = containerWidth -40;
$(".inner_border").css("height", innerBorderHeight);
$(".inner_border").css("width", innerBorderWidth);
		
//ALTEZZA CONTENUTI
$("#content").css("height", containerHeight);
$(".inner").css("height", containerHeight);

$("#splash").css('height', containerHeight);
		


//POSIZIONE NUVOLE FRONTALI
$("#clouds-frontal").css("height", containerHeight);
var frontalCloudsHeight = $("#clouds-frontal img#frontal").height();
var frontalCloudsMargin = (containerHeight - frontalCloudsHeight);
$("#clouds-frontal img#frontal").css("margin-top", frontalCloudsMargin);

//XTRA CLOUD

var screenWidth = $(window).width();

var margin1 = (screenWidth*7) - 700;
$('#box1 .xtra_cloud').css('left', margin1);

var margin2 = (screenWidth*6) -1350;
$('#box2 .xtra_cloud').css('left', margin2);

var margin3 = (containerWidth*5) - 800;
$('#box3 .xtra_cloud').css('left', margin3);

var margin4 = (containerWidth*4) - 700;
$('#box4 .xtra_cloud').css('left', margin4);

var margin5 = (containerWidth*3) - 650;
$('#box5 .xtra_cloud').css('left', margin5);

var margin6 = (containerWidth*2) - 700;
$('#box6 .xtra_cloud').css('left', margin6);

var margin7 = (containerWidth*1) - 595;
$('#box7 .xtra_cloud').css('left', margin7);
		
//MARGINE TITOLI

var HeightTit = $('.box h1.title').height();

var TitMargin = containerHeight- HeightTit;

var TitFixedMargin01 = TitMargin - 440;
var TitFixedMargin02 = TitMargin - 440;
var TitFixedMargin03 = TitMargin - 420;
var TitFixedMargin04 = TitMargin - 420;
var TitFixedMargin05 = TitMargin - 430;
var TitFixedMargin06 = TitMargin - 410;
var TitFixedMargin07 = TitMargin - 420;
		
$('#box1 h1.title').css('margin-top', TitFixedMargin01);
$('#box2 h1.title').css('margin-top', TitFixedMargin02);
$('#box3 h1.title').css('margin-top', TitFixedMargin03);
$('#box4 h1.title').css('margin-top', TitFixedMargin04);
$('#box5 h1.title').css('margin-top', TitFixedMargin05);
$('#box6 h1.title').css('margin-top', TitFixedMargin06);
$('#box7 h1.title').css('margin-top', TitFixedMargin07);	
		
//ALTEZZA E MARGINI PARTE ONGROUND
var onGroundFix = containerHeight;
if(isiPad){
	$("#wrapper").css('height',containerHeight);
	$("#on-ground, #contenuto_ajax").css("height", "auto");
	$("#on-ground, #contenuto").css("min-height", "1224px");
	$("#on-ground, #contenuto_ajax").css("overflow", "hidden");
	$("#on-ground").css("width", "100%");
}else{
//$("#on-ground").css("margin-top", containerHeight);
$('#on-ground').css('overflow', 'auto');
$("#on-ground, #contenuto_ajax").css("height", "100%");
$("#on-ground").css("width", containerWidth);
$("#wrapper").css("height", containerHeight);	
}



//DIMENSIONE NUVOLE DI BACKGROUND
$("#clouds-small").css("height", containerHeight);
$("#clouds-small img#bkg").css("height", containerHeight);

var CloudsHeight = $("#clouds-small img#bkg").height();

if(CloudsHeight >= 620){
	
	var cloudsPadding = containerHeight - 620;
	var cloudFixHeight = containerHeight - cloudsPadding;
	
	$("#clouds-small img#bkg").css("height", cloudFixHeight);
	$("#clouds-small").css("padding-top", cloudsPadding);
	$("#clouds-small").css("height", cloudFixHeight);
	
	}else{
		
		$("#clouds-small").css("height", containerHeight);
		$("#clouds-small img#bkg").css("height", containerHeight);
		
		}
var plane01Left = containerWidth*5;
	
	$('.plane_leaving#Plane01').css('left', plane01Left);
		
//SPLASH HOVER
$('#splash a#air, #splash area#splashflight').mouseover(function(){
	$('#splash .triangle#up').css('z-index','1000002').stop().animate({opacity:'0.8'}, 500);
	$('#splash .triangle#down').css('z-index','1000001').stop().animate({opacity:'0.3'}, 300);
	//$('#splash #logo_up_on').stop().animate({opacity:'1'}, 500);
	//$('#splash #logo_splash').stop().animate({opacity:'0.8'}, 500);
	
	$('#splash a#air, area#splashflight').mouseout(function(){
		$('#splash .triangle#up').css('z-index','1000001').stop().animate({opacity:'0.3'}, 300);
		$('#splash .triangle#down').css('z-index','1000002').stop().animate({opacity:'0.3'}, 300);
		//$('#splash #logo_up_on').stop(true).animate({opacity:'0.3'}, 300);
		//$('#splash #logo_splash').stop(true).animate({opacity:'1'}, 500);
	});
});

$('#splash a#ground, area#splashground').mouseover(function(){
	$('#splash .triangle#down').css('z-index','1000002').stop().animate({opacity:'0.8'}, 500);
	$('#splash .triangle#up').css('z-index','1000001').stop().animate({opacity:'0.3'}, 300);
	//$('#splash #logo_down_on').stop().animate({opacity:'1'}, 500);
	//$('#splash #logo_splash').stop().animate({opacity:'0.8'}, 500);
	
	$('#splash a#ground, area#splashground').mouseout(function(){
		$('#splash .triangle#down').css('z-index','1000001').stop().animate({opacity:'0.3'}, 300);
		$('#splash .triangle#up').css('z-index','1000002').stop().animate({opacity:'0.3'}, 300);
		//$('#splash #logo_down_on').stop(true).animate({opacity:'0.3'}, 300);
		//$('#splash #logo_splash').stop(true).animate({opacity:'1'}, 500);
	});
});


//DRAGGER EFFECT
$('.dragger_container').mouseover(function () {
	$(".dragger").animate( { width: "5px"}, { queue: false, duration: 300 } )
	.animate( { right: '0' }, 0)
	.animate( { backgroundColor: '#660000' }, 200);	
});
			
$('.dragger_container').mouseleave(function () {
	$(".dragger").animate( { width: "5px"}, { queue: false, duration: 500 } )
	.animate( { right: '0' }, 0).animate( { backgroundColor: '#8a7967' }, 100);
});	

//SPLASH CHOOSE

//CHOOSE ON AIR
$('#splash area#splashflight, #inner_splash a#air').click(function(e){
	e.preventDefault();
	
	$('#cloud1').css('opacity','1');
	$('#wrapper').css('opacity','1');
	$('#on-ground').css('opacity','1');
	$('#header').css('opacity','1');
	
		
		//$('.xtra_cloud').animate({opacity:'1'}, 0);
		$('#inner_splash a').animate({opacity:'0'}, 800, function(){
		$('#wrapper').scrollTo( '#box1', 0);
		$('li.box').animate({opacity:'1'}, 0);
			$("#splash .triangle").animate({opacity:'0'}, 800, function(){
			
				$("#splash").animate({opacity:'0'}, 1200, function(){
					$("#splash").css('display', 'none');
					
				});
				$("#splash_footer p").animate({opacity: '0'}, 800, function(){
					$("#splash_footer").css('display','none');
					});
				//DO ONAIR
				$('a#ground_link').animate({opacity: '1'}, 800);
				$('img#bkg').animate({opacity: '1'}, 500, function(){
					$('#call_us').animate({opacity:'1'}, 800);
					$('#social_toggle').animate({opacity:'1'}, 800);
					homeAnimation();
					
				});
			});
		});
	
	$('.arrow_slide').bind('click', moveByArrows);
	$('a.link').bind('click', moveAll);
	return false;
});

//CHOOSE GROUND
$('#splash area#splashground, #inner_splash a#ground').click(function(e){
	e.preventDefault();
	
	$('#cloud1').css('opacity','1');
	$('#wrapper').css('opacity','1');
	$('#on-ground').css('opacity','1');
	$('#header').css('opacity','1');
	
			
		$('#inner_splash a').animate({opacity:'0'}, 800, function(){
		$('#wrapper').scrollTo( '#box1', 0);
		$('li.box').animate({opacity:'1'}, 0);
			
			$("#splash .triangle").animate({opacity:'0'}, 800, function(){
				
				$("#splash_footer p").animate({opacity: '0'}, 800, function(){
					$("#splash_footer").css('display','none');
				});
				
				$("#splash").animate({opacity:'0'}, 1200, function(){
					$("#splash").css('display', 'none');
					
				});	
				
				
				
				//DO ONGROUND
				$('a#air_link').animate({opacity: '1'}, 800);
				$('img#bkg').animate({opacity: '1'}, 0);	
				$('#call_us').animate({opacity:'1'}, 800);
				$('#social_toggle').animate({opacity:'1'}, 800);
				homeAnimation();
				
				
				
				setTimeout(function(){
					$('a.bottom_sensible').css('display','block');
					
						goToGround();
					
				},2500);
			});
		});
	
	//$(document).bind('keydown');
	$('.arrow_slide').bind('click', moveByArrows);
	$('a.link').bind('click', moveAll);
	return false;
});


function homeAnimation(){
$('img#frontal').animate({opacity: '0.8'}, 800); 
 
var plane01Offset = containerWidth*6;	

var isiPad = navigator.userAgent.match(/iPad/i) != null;

if(containerWidth<=1024){
var plane01Dest = plane01Offset + (containerWidth/3);
	
}else{
	var plane01Dest = plane01Offset + (containerWidth/3);	
	}

setTimeout(function(){
	
	var newMargin = containerWidth/3;
	var newMarginCatering = (containerWidth*47)/100;
	var newMarginExecutive = (containerWidth*2)/100;
	var newMarginTrip = (containerWidth*65)/100;
	
	$('.plane_leaving#Plane03').css('margin-left', newMargin);
	$('.plane_leaving#Plane04').css('margin-left', newMarginCatering);
	$('.plane_leaving#Plane05').css('margin-left', newMarginExecutive);
	$('.plane_leaving#Plane06').css('margin-left', newMarginTrip);
	$('.plane_leaving#Plane07').css('margin-left', newMarginTrip);
		
	$('.plane_leaving#Plane02').animate({bottom: '270'}, 0);
	$('.plane_leaving#Plane03').animate({bottom: '60'}, 0);
	$('.plane_leaving#Plane04').animate({bottom: '0'}, 0);
	//$('.plane_leaving#Plane05.big, .plane_leaving#Plane05.small').animate({bottom: '60'}, 0);		
	$('.plane_leaving#Plane01').animate({opacity: '1',left: plane01Dest, bottom: '70'}, EddieTime, EddieOutEasing);
	
	setTimeout(function(){
		$('#box1 h1.title').animate({left: '-520'}, 0);
				$('#box1 h1.title').animate({opacity: '1'}, 500, EddieOutEasing);
				setTimeout(function(){
					$('#box1 .text').animate({left: '200'}, 0);
					$('.box .text').animate({opacity: '0.9'}, 500, EddieOutEasing);
						setTimeout(function(){
								$('.arrow_slide').animate({opacity:'0.8'}, 500);
								$('#arrow_air_ground').animate({opacity:'0.8'}, 500);
							}, 100);
				}, 100);
		}, 100);
	},100);

			$('#box2 .text').animate({opacity: '1',left: '0'}, 0);
			$('#box2 h1.title').animate({opacity: '1',left: '0'}, 0);
			$('#box2 a.optional_element').animate({opacity: '1',left: '0'}, 0);
			$('#box3 .text').animate({opacity: '1',left: '0'}, 0);
			$('#box3 h1.title').animate({opacity: '1',left: '0'}, 0);
			$('#box3 a.optional_element').animate({opacity: '1',left: '0'}, 0);
			$('#box4 .text').animate({opacity: '1',left: '0'}, 0);
			$('#box4 h1.title').animate({opacity: '1',left: '0'}, 0);
			
			$('#box5 .text').animate({opacity: '1',left: '0'}, 0);
			$('#box5 h1.title').animate({opacity: '1',left: '0'}, 0);
			
			$('#box6 .text').animate({opacity: '1',left: '0'}, 0);
			$('#box6 h1.title').animate({opacity: '1',left: '0'}, 0);
			
			$('#box7 .text').animate({opacity: '1',left: '0'}, 0);
			$('#box7 h1.title').animate({opacity: '1',left: '0'}, 0);
}

	
//END HOME ANIMATION


setTimeout(function(){
//PREPARE TO GROUND
if(!isiPad){
$('a#ground_link').mouseover(function(){
	$('#logo_hover_V').stop().animate({opacity:'1'}, 300);
	prepareToGround();
	$(this).click(function(){
		goToGround();
		switchLogoToGround();
	})
});

$('a#air_link').mouseover(function(){
	$('#logo_hover_A').stop().animate({opacity:'1'}, 300);
	resetPrepare();
	$(this).click(function(){
		goToAir();
		switchLogoToAir();
	})
});
$('a#logo_hover_A').mouseover(function(){
	$('#logo_hover_A').stop().animate({opacity:'1'}, 300);
	resetPrepare();
	$(this).click(function(){
		goToAir();
		switchLogoToAir();
	})
});

	$('a#ground_link').mouseout(function(){
		$('#logo_hover_A').stop().animate({opacity:'0'}, 800);
		$('#logo_hover_V').stop().animate({opacity:'0'}, 800);
		prepareToGround();
	});

	$('a#air_link').mouseout(function(){
		$('#logo_hover_A').stop().animate({opacity:'0'}, 800);
		$('#logo_hover_V').stop().animate({opacity:'0'}, 800);
		resetPrepare();
	});
	$('a#logo_hover_A').mouseout(function(){
		$('#logo_hover_A').stop().animate({opacity:'0'}, 800);
		$('#logo_hover_V').stop().animate({opacity:'0'}, 800);
		resetPrepare();
	});
	$('a.logo_link').mouseout(function(){
		$('#logo_hover_A').stop().animate({opacity:'0'}, 800);
		$('#logo_hover_V').stop().animate({opacity:'0'}, 800);
		resetPrepare();
	});
	$('a#logo_hover_V').mouseout(function(){
		$('#logo_hover_A').stop().animate({opacity:'0'}, 800);
		$('#logo_hover_V').stop().animate({opacity:'0'}, 800);
		prepareToGround();
	});
}else{
	$('a#ground_link').mouseover(function(){
	$('#logo_hover_V').stop().animate({opacity:'1'}, 300);
	prepareToGround();
	$(this).click(function(){
		goToGround();
		switchLogoToGround();
	})
});

$('a#air_link').mouseover(function(){
	//$('#logo_hover_A').stop().animate({opacity:'1'}, 300);
	//resetPrepare();
	$(this).click(function(){
		goToAir();
		switchLogoToAir();
	})
});
$('a#logo_hover_A').mouseover(function(){
	//$('#logo_hover_A').stop().animate({opacity:'1'}, 300);
	//resetPrepare();
	$(this).click(function(){
		goToAir();
		switchLogoToAir();
	})
});

	$('a#ground_link').mouseout(function(){
		//$('#logo_hover_A').stop().animate({opacity:'0'}, 800);
		//$('#logo_hover_V').stop().animate({opacity:'0'}, 800);
		//prepareToGround();
	});

	$('a#air_link').mouseout(function(){
		//$('#logo_hover_A').stop().animate({opacity:'0'}, 800);
		//$('#logo_hover_V').stop().animate({opacity:'0'}, 800);
		//resetPrepare();
	});
	$('a#logo_hover_A').mouseout(function(){
		//$('#logo_hover_A').stop().animate({opacity:'0'}, 800);
		//$('#logo_hover_V').stop().animate({opacity:'0'}, 800);
		//resetPrepare();
	});
	$('a.logo_link').mouseout(function(){
		//$('#logo_hover_A').stop().animate({opacity:'0'}, 800);
		//$('#logo_hover_V').stop().animate({opacity:'0'}, 800);
		//resetPrepare();
	});
	$('a#logo_hover_V').mouseout(function(){
		//$('#logo_hover_A').stop().animate({opacity:'0'}, 800);
		//$('#logo_hover_V').stop().animate({opacity:'0'}, 800);
		//prepareToGround();
	});
	}
	
	
	if(!isiPad){
	/*$('a.arrow_to_air').mouseover(function(){
		$('#arrow_air_ground').stop().animate({opacity:'1'}, 0);
		$('#logo_hover_A').stop().animate({opacity:'1'}, 0);
		$('a.arrow_to_air').stop().animate({opacity:'1'}, 800);
		prepareToGround();	
		});*/
		$('a.arrow_to_air').click(function(){
		var containerScrollMargin = $("#contenuto_ajax").scrollTo(0, {duration:1000});
		/*if(containerScrollMargin <= '0'){
			$(".container").animate({top: '0'}, EddieTime, EddieEasing);
			$(".dragger").animate({top: '0'}, EddieTime, EddieEasing);
		}*/		
		goToAir();
		switchLogoToAir();		
		
		
		/*$('a.arrow_to_air').mouseout(function(){
			$('#arrow_air_ground').stop().animate({opacity:'0.8'}, 0);
			$('#logo_hover_A').stop().animate({opacity:'0'}, 800);
			$('a.arrow_to_air').stop().animate({opacity:'0.7'}, 800);
			resetPrepare();	
		});*/
	});
	
	/*$('a.arrow_to_ground').mouseover(function(){
		$('#arrow_air_ground').stop().animate({opacity:'1'}, 0);
		$('#logo_hover_V').stop().animate({opacity:'1'}, 0);
		$('a.arrow_to_ground').stop().animate({opacity:'1'}, 0);
		prepareToGround();	
		});*/
		
		$('a.arrow_to_ground').click(function(){		
		goToGround();
		switchLogoToGround();
		
		
		/*$('a.arrow_to_ground').mouseout(function(){
		$('#arrow_air_ground').stop().animate({opacity:'0.8'}, 0);
		$('#logo_hover_V').stop().animate({opacity:'0'}, 800);
		$('a.arrow_to_ground').stop().animate({opacity:'0.7'}, 800);
		resetPrepare();	
		})*/;
	});
	
	}else{
		
		$('a.arrow_to_air').mouseover(function(){
		$('#arrow_air_ground').stop().animate({opacity:'1'}, 0);
		//$('#logo_hover_A').stop().animate({opacity:'1'}, 0);
		$('a.arrow_to_air').stop().animate({opacity:'1'}, 800);
		//prepareToGround();	
		
		$('a.arrow_to_air').click(function(){
		var containerScrollMargin = $("#contenuto_ajax").scrollTo(0, {duration:1000});
		/*if(containerScrollMargin <= '0'){
			$(".container").animate({top: '0'}, EddieTime, EddieEasing);
			$(".dragger").animate({top: '0'}, EddieTime, EddieEasing);
		}*/		
		goToAir();
		switchLogoToAir();		
		});
		
		$('a.arrow_to_air').mouseout(function(){
			$('#arrow_air_ground').stop().animate({opacity:'0.8'}, 0);
			//$('#logo_hover_A').stop().animate({opacity:'0'}, 800);
			$('a.arrow_to_air').stop().animate({opacity:'0.7'}, 800);
			//resetPrepare();	
		});
	});
	
	$('a.arrow_to_ground').mouseover(function(){
		$('#arrow_air_ground').stop().animate({opacity:'1'}, 0);
		//$('#logo_hover_V').stop().animate({opacity:'1'}, 0);
		$('a.arrow_to_ground').stop().animate({opacity:'1'}, 0);
		prepareToGround();	
		
		$('a.arrow_to_ground').click(function(){		
		goToGround();
		switchLogoToGround();
		});
		
		$('a.arrow_to_ground').mouseout(function(){
		$('#arrow_air_ground').stop().animate({opacity:'0.8'}, 0);
		//$('#logo_hover_V').stop().animate({opacity:'0'}, 800);
		$('a.arrow_to_ground').stop().animate({opacity:'0.7'}, 800);
		resetPrepare();	
		});
	});
		
		}
}, 2000);



//ARROWS HOVER

$('.arrow_slide#sx').mouseover(function(){
	$(this).stop().animate({opacity:'1'}, 0);
	$('.arrow_slide#sx').mouseout(function(){
		$(this).stop(true).animate({opacity:'0.8'}, 880);
		});
	});
$('.arrow_slide#dx').mouseover(function(){
	$(this).stop().animate({opacity:'1'}, 0);
	$('.arrow_slide#dx').mouseout(function(){
		$(this).stop(true).animate({opacity:'0.8'}, 880);
		});
	}); 
	


	/*$('a#get_in_touch').toggle(function() {
	  $('#social_toggle').stop().animate({right:0}, 500, EddieEasing);
	  $('.social_icons.big').stop().animate({right:10}, 500, EddieEasing);
	  
	}, function() {
	  $('#social_toggle').stop().animate({right:-123}, 500, EddieEasing);
	  $('.social_icons.big').stop().animate({right:0}, 500, EddieEasing);
	  
	});*/








	


//ON-GROUND MENU HANDLE

var firstWidth = $('#on-ground a.first').width();
var firstWidthFix = firstWidth + 79;

$('.top_selected_ground').css('width', firstWidthFix);

$('.menu_ground ul li a').click(function(){

	var lavaTo = $(this);
				
		var destWidth = $(lavaTo).width();
		var fixedDestWidth = destWidth + 10;
		
		var menuLeftOffset = $('.menu_ground').not('#footer .menu_ground').offset().left;
		var lavaOffset = $(lavaTo).offset().left;
		
		var leftOffset = lavaOffset - menuLeftOffset - 55;
		
		$('.top_selected_ground').stop().animate({width:fixedDestWidth, left: leftOffset}, 800, 'easeOutCubic');
		
		$('#footer .menu_ground a.ground').removeClass('selected');
		$(this).addClass('selected');
	});



		
//CLICK ARROWS HANDLE
var goToSlide = 1;
//$('.arrow_slide').bind('click', moveByArrows);
function moveByArrows(e) {
	e.preventDefault();
	//$('.arrow_slide').unbind();
	var pointTo = $(this).attr('id');
	
	if(pointTo=="sx"){
		goToSlide--;
		}else if(pointTo=="dx"){
			goToSlide++;
			}else if(pointTo=="dw"){
				goToGround();
				}
	
	if(goToSlide==8){
			goToSlide = 1;
		}
		if(goToSlide==0){
			goToSlide = 7;
		}
		
		var lavaTo = "a#link"+goToSlide;
				
		var destWidth = $(lavaTo).width();
		var fixedDestWidth = destWidth + 10;
		
		
		
		var menuLeftOffset = $('ul#menu').offset().left;
		var lavaOffset = $(lavaTo).offset().left;
		
		var leftOffset = lavaOffset - menuLeftOffset - 8;
		
		$('.top_selected').stop().animate({width:fixedDestWidth, left: leftOffset}, 800, 'easeOutCubic');
	
		var destArrow = "#box" + goToSlide;
		
		//FUNZIONE ANIMAZIONE		
		//3 VARIABILI PER INDIVIDUARE GLI ELEMENTI DA ANIMARE
			var destTitle = destArrow + " h1.title";
			var destText = destArrow + " .text";
			var destOptional = destArrow + " a.optional_element";
			var xtraCloud = destArrow + " .xtra_cloud";
			
			//ELEMENTI DA RIPOSIZIONARE DELLE SLIDE NON DI DESTINAZIONE
			$(".box h1.title").not(destTitle).stop(true).animate({left: '0'}, 2000, EddieEasing);
			$(".box .text").not(destText).stop(true).animate({left: '50'}, EddieTime, EddieEasing);
			$(".box a.optional_element").not(destOptional).stop(true).animate({left: '0'}, EddieTime, EddieEasing);	
			$(".box .xtra_cloud").not(xtraCloud).stop(true).animate({backgroundPosition: '280px 0px'}, 1800, EddieEasing);
					
			//POSIZIONE LIVELLI NUVOLE
		    setPosition(destArrow, '#cloud1', '0px', '100px', '200px', '300px', '400px', '500px', '600px');
			setPosition(destArrow, '#cloud2', '0px', '180px', '280px', '380px', '400px', '500px', '600px');
			
			//3 VARIABILI PER INDIVIDUARE GLI ELEMENTI DELLA SLIDE DI DESTINAZIONE
			var targetTitle = destArrow + ' h1.title';
			var targetText = destArrow + ' .text';
			var targetOptional = destArrow + ' a.optional_element';
			var targetCloud = destArrow + ' .xtra_cloud';
			
			//ANIMAZIONE ELEMENTI
			$(targetTitle).stop().animate({left: '-520'}, EddieTime, EddieEasing);
			$(targetText).stop().animate({left: '200'}, 1600, EddieEasing);
			$(targetOptional).stop().animate({left: '580'}, 1600, EddieEasing);
			$(targetCloud).stop().animate({backgroundPosition: '0px 0px'}, 1800, EddieEasing);
			
			//WRAPPER SCROLL
			$('#wrapper').stop().scrollTo( destArrow, {easing: EddieEasing,duration: EddieTime, onAfter:function(){
				//$('.arrow_slide').bind('click', moveByArrows);
				
				return false;
				}} );
		
		//AUTO SELECTED MENU BUTTON
		var linkSelector = "a#link" + goToSlide;
		$('a.link').removeClass('selected');
		$(linkSelector).addClass('selected');		
}

//CLICK MENU HANDLER
//$('a.link').bind('click', moveAll);
function moveAll(e) {
	e.preventDefault();
	//$('a.link').unbind();
	
	
	
	//HREF DI DESTINAZIONE
	var dest = $(this).attr('href');
		
	//3 VARIABILI PER INDIVIDUARE GLI ELEMENTI DA ANIMARE
	var destTitle = dest + " h1.title";
	var destText = dest + " .text";
	var destOptional = dest + " a.optional_element";
	var xtraCloud = dest + " .xtra_cloud";
			
	//ELEMENTI DA RIPOSIZIONARE DELLE SLIDE NON DI DESTINAZIONE
	$(".box h1.title").not(destTitle).stop(true).animate({left: '0'}, 2000, EddieEasing);
	$(".box .text").not(destText).stop(true).animate({left: '50'}, EddieTime, EddieEasing);
	$(".box a.optional_element").stop(true).not(destOptional).animate({left: '0'}, EddieTime, EddieEasing);	
	$(".box .xtra_cloud").not(xtraCloud).stop(true).animate({backgroundPosition: '280px 0px'}, 1800, EddieEasing);
					
	//POSIZIONE LIVELLI NUVOLE
	setPosition($(this).attr('href'), '#cloud1', '0px', '100px', '200px', '300px', '400px', '500px', '600px');
	setPosition($(this).attr('href'), '#cloud2', '0px', '180px', '280px', '380px', '400px', '500px', '600px');
			
	//3 VARIABILI PER INDIVIDUARE GLI ELEMENTI DELLA SLIDE DI DESTINAZIONE
	var targetTitle = dest + ' h1.title';
	var targetText = dest + ' .text';
	var targetOptional = dest + ' a.optional_element';
	var targetCloud = dest + " .xtra_cloud";
			
	//ANIMAZIONE ELEMENTI
	$(targetTitle).stop().animate({left: '-520'}, EddieTime, EddieEasing);
	$(targetText).stop().animate({left: '200'}, 1600, EddieEasing);
	$(targetOptional).stop().animate({left: '580'}, 1600, EddieEasing);
	$(targetCloud).stop().animate({backgroundPosition: '0px 0px'}, 1800, EddieEasing);	
		
	$('a.link').removeClass('selected');
	$(this).addClass('selected');	
	
	switch(dest){
		case '#box1':
		linkVoice = 1;
		break
		
		case '#box2':
		linkVoice = 2;
		break
		
		case '#box3':
		linkVoice = 3;
		break
		
		case '#box4':
		linkVoice = 4;
		break
		
		case '#box5':
		linkVoice = 5;
		break
		
		case '#box6':
		linkVoice = 6;
		break
		
		case '#box7':
		linkVoice = 7;
		break
		}
	
	lavaLamp(linkVoice);
			
	//WRAPPER SCROLL
	$('#wrapper').stop().scrollTo( $(this).attr('href'), {easing: EddieEasing,duration: EddieTime, onAfter:function(){
		
		//SWITCH LINK CLASSES
		
		//$('a.link').bind('click', moveAll);
		return false; 
		
	}} );

	//GoToSlide per keyboard navigation
	switch(dest){
		
		case '#box1':
		goToSlide = 1;
		return goToSlide;
		break;
		
		case '#box2':
		goToSlide = 2;
		return goToSlide;
		break;
		
		case '#box3':
		goToSlide = 3;
		return goToSlide;
		break;
		
		case '#box4':
		goToSlide = 4;
		return goToSlide;
		break;
		
		case '#box5':
		goToSlide = 5;
		return goToSlide;
		break;
		
		case '#box6':
		goToSlide = 6;
		return goToSlide;
		break;
		
		case '#box7':
		goToSlide = 7;
		return goToSlide;
		break;
		}	 
		
		
		
}
//END CLICK MENU HANDLER

//ON AIR LINK HANDLE

		
		
//KEYBOARD NAVIGATION
var goToSlide = 1;
var disableKeys;
$(document).bind('keydown');		
$(document).keydown(function(e){
/*function moveToBox(e) {*/
	//e.preventDefault();
	//$(document).unbind();
	//$(document).bind('keydown');
	
	switch (e.target.tagName) {  
	    case "INPUT": case "SELECT": case "TEXTAREA": return;  
	  }  
	
	var keyCode = e.keyCode || e.which,
	arrow = {left: 37, up: 38, right: 39, down: 40 };
	switch (keyCode) {
		  	
		//RIGHT ARROW------------------------------------------------------------------------------------------------------------
		case arrow.right:
		goToSlide++;
		      
		//SLIDE DI DESTINAZIONE
		if(goToSlide==8){
			goToSlide = 1;
		}
		if(goToSlide==0){
			goToSlide = 7;
		}
		
		$('.arrow_slide#dx').stop().animate({opacity:'1'}, 10);
		$('.arrow_slide#dx').stop().animate({opacity: '0.8'}, 800 );
		
		var destByKeyboard = "#box" + goToSlide;
		//FUNZIONE ANIMAZIONE
		lavaLamp(goToSlide);		
		goToSlideKeyboard(destByKeyboard);	  
		//AUTO SELECTED MENU BUTTON
		var linkSelector = "a#link" + goToSlide;
		$('a.link').removeClass('selected');
		$(linkSelector).addClass('selected');
		//event.preventDefault();	  
		
		return goToSlide;
		break;
		
		//LEFT ARROW------------------------------------------------------------------------------------------------------------
		case arrow.left:
		goToSlide--;		     
		//SLIDE DI DESTINAZIONE
		if(goToSlide==8){
			goToSlide = 1;
		}
		if(goToSlide==0){
			goToSlide = 7;
		}
		
		$('.arrow_slide#sx').stop().animate({opacity:'1'}, 10);
		$('.arrow_slide#sx').stop().animate({opacity: '0.8'}, 800 );
		
		var destByKeyboard = "#box" + goToSlide;	  
		//FUNZIONE ANIMAZIONE
		lavaLamp(goToSlide);	
		goToSlideKeyboard(destByKeyboard);
		//AUTO SELECTED MENU BUTTON
		var linkSelector = "a#link" + goToSlide;
		$('a.link').removeClass('selected');
		$(linkSelector).addClass('selected');
		//event.preventDefault();
		return goToSlide;
		break;
			  
		//UP ARROW ------------------------------------------------------------------------------------------------------------		      
		case arrow.up:
		setTimeout(function(){
			$('.content').scrollTo(0,{duration:800, easing: 'easeOutCubic'});
			}, 1000);
		
		//SCROLL TO AIR	
			      
		//RIPOSIZIONO ELEMENTI AIR
		goToAir();
		
		//setTimeout(function(){
			//$(document).bind('keydown', moveToBox);
			//}, 1000);
		
		switchLogoToAir();
		//OPACITA' INNER BORDER
		return false;
		break;
		
		//DOWN ARROW------------------------------------------------------------------------------------------------------------
		case arrow.down:
		
		//SCROLL TO GROUND
				      
		//USCITA ELEMENTI AIR
		goToGround();
		
		//setTimeout(function(){
			//$(document).bind('keydown', moveToBox);
			//}, 1000);
		
		//OPACITA' INNER BORDER
		
		return false;
		
		break;
		
		default:
		//alert(keyCode);
		$(document).bind('keydown');
		return false;
		break;
	}	
	
	return false;
});
//End Document.Ready

		
		
function goToAir(){
	
	$('.inner_border').stop().animate({opacity: '1'}, EddieTime);
	
	if(!isiPad){
	
	$('.arrow_slide#sx, .arrow_slide#dx').css('display','block');
	$('.arrow_slide#sx, .arrow_slide#dx').stop().animate({opacity:1}, 1200, function(){
		
		$('.arrow_slide#sx').stop().animate({left:0}, 1000, EddieEasing);
		$('.arrow_slide#dx').stop().animate({right:0}, 1000, EddieEasing);
		
		});
	}else{
		$('.arrow_slide#dx, .arrow_slide#sx').animate({opacity: 1},500);
		}
	
	$('a.arrow_to_ground').stop().animate({height: '55px'}, 0, function(){
	$('#arrow_air_ground').stop().animate({bottom:'5px', backgroundPosition:'0px 0px'}, 1200, EddieEasing);
	});
	$('#social_toggle').stop().animate({bottom:'20px'}, 1000, EddieEasing);
	//$('.social_icons.big').stop().animate({right:0}, 500, EddieEasing);
	$('a#get_in_touch').css('color', 'rgba(0,22,108,.8)');
	$('#wrapper, #on-ground, #cloud1').stop().animate({top: 0}, EddieTime, EddieEasing, function(){		
			$('#on-ground').css('display','none');	
		});	
		
	
	$('.box h1.title').stop().animate({bottom: '0'}, 1200, EddieEasing);
	$('.box .text').stop().animate({bottom: '0'}, 1400, EddieEasing);
	$('.box a.optional_element').stop().animate({bottom: '0'}, 1800, EddieEasing);
	
	$('.plane_leaving#Plane01').stop().animate({bottom: '60'}, EddieTime, EddieEasing);
	$('.plane_leaving#Plane02').stop().animate({bottom: '270'}, EddieTime, EddieEasing);
	$('.plane_leaving#Plane03').stop().animate({bottom: '60'}, EddieTime, EddieEasing);
	$('.plane_leaving#Plane04').stop().animate({bottom: '0'}, EddieTime, EddieEasing);
	$('.plane_leaving#Plane05').stop().animate({bottom: '0'}, EddieTime, EddieEasing);
	$('.plane_leaving#Plane06').stop().animate({bottom: '1'}, EddieTime, EddieEasing);
	$('.plane_leaving#Plane07').stop().animate({bottom: '1'}, EddieTime, EddieEasing);
	$('#header ').stop().animate({top:52}, EddieTime, EddieEasing);	     
	$('#call_us').stop().animate({opacity:1}, 500);	
}		

function goToGround(){
	
	$('#on-ground').css('display','block');
	
	if(!isiPad){
	
	$('.arrow_slide#sx').stop().animate({left:'-60px'}, 1000, EddieEasing, function(){$('.arrow_slide#sx').css('display','none').animate({opacity:0}, 1000)});
	$('.arrow_slide#dx').stop().animate({right:'-60px'}, 1000, EddieEasing, function(){$('.arrow_slide#dx').css('display','none').animate({opacity:0}, 1000)});
	
	}else{
		$('.arrow_slide#dx, .arrow_slide#sx').animate({opacity: 0}, 500);		
		}
		
		
	var highTo = $(window).height();
	
	
	//SCREEN SIZE
var containerHeight = $(window).height();
var containerWidth = $(window).width();
	var arrowDest = containerHeight-55;
	$('a.arrow_to_ground').stop().animate({height: '0'}, 0, function(){
	$('#arrow_air_ground').stop().animate({backgroundPosition:'0px -55px', bottom:arrowDest}, 1200, EddieEasing);
	});
	var socialDest = containerHeight-30;
	$('#social_toggle').stop().animate({bottom:socialDest}, 1850, EddieEasing);

	//$('.social_icons.big').stop().animate({right:0}, 500, EddieEasing);
	
	$('a#get_in_touch').css('color', '#0f0304');
	$('#header ').stop().animate({top:-300}, EddieTime, EddieEasing);
	var highToCloud = highTo - 120;
	$('#cloud1 ').stop().animate({top:-highToCloud}, EddieTime, EddieEasing);
	$('#wrapper, #on-ground').stop().animate({top: -highTo}, EddieTime, EddieEasing, function(){
				$('body').animate({height:highTo},1000, EddieEasing);
		});
	
	$('#call_us').stop().animate({opacity:0}, 400);
	
	$('.box h1.title').stop().animate({bottom: '300'}, 1200, EddieEasing);
	$('.box .text').stop().animate({bottom: '300'}, 1400, EddieEasing);
	$('.box a.optional_element').stop().animate({bottom: '300'}, 1600, EddieEasing);
	
	$('.plane_leaving#Plane01').stop().animate({bottom: '370'}, EddieTime, EddieEasing);
	$('.plane_leaving#Plane02').stop().animate({bottom: '370'}, EddieTime, EddieEasing);
	$('.plane_leaving#Plane03').stop().animate({bottom: '370'}, EddieTime, EddieEasing);
	$('.plane_leaving#Plane04').stop().animate({bottom: '-650'}, EddieTime, EddieEasing);
	$('.plane_leaving#Plane05').stop().animate({bottom: '0'}, EddieTime, EddieEasing);
	$('.plane_leaving#Plane06').stop().animate({bottom: '-650'}, EddieTime, EddieEasing);
	$('.plane_leaving#Plane07').stop().animate({bottom: '-750'}, EddieTime, EddieEasing);
	
	$('.inner_border').stop().animate({opacity: '0'}, EddieTime);
	
	
	switchLogoToGround();
	
	}		 
	
//slide by keyboard	
function goToSlideKeyboard(element_id){
	
	//HREF DI DESTINAZIONE
			
		
			//3 VARIABILI PER INDIVIDUARE GLI ELEMENTI DA ANIMARE
			var destTitle = element_id + " h1.title";
			var destText = element_id + " .text";
			var destOptional = element_id + " a.optional_element";
			var xtraCloud = element_id + " .xtra_cloud";
			
			//ELEMENTI DA RIPOSIZIONARE DELLE SLIDE NON DI DESTINAZIONE
			$(".box h1.title").not(destTitle).stop(true).animate({left: '0'}, 2000, EddieEasing);
			$(".box .text").not(destText).stop(true).animate({left: '50'}, EddieTime, EddieEasing);
			$(".box a.optional_element").not(destOptional).stop(true).animate({left: '0'}, EddieTime, EddieEasing);
			$(".box .xtra_cloud").not(xtraCloud).stop(true).animate({backgroundPosition: '280px 0px'}, 1800, EddieEasing);	
					
			//POSIZIONE LIVELLI NUVOLE
		    setPosition(element_id, '#cloud1', '0px', '100px', '200px', '300px', '400px', '500px', '600px');
			setPosition(element_id, '#cloud2', '0px', '180px', '280px', '380px', '400px', '500px', '600px');
			
			//3 VARIABILI PER INDIVIDUARE GLI ELEMENTI DELLA SLIDE DI DESTINAZIONE
			var targetTitle = element_id + ' h1.title';
			var targetText = element_id + ' .text';
			var targetOptional = element_id + ' a.optional_element';
			var targetxtraCloud = element_id + " .xtra_cloud";
			
			//ANIMAZIONE ELEMENTI
			$(targetTitle).stop().animate({left: '-520'}, EddieTime, EddieEasing);
			$(targetText).stop().animate({left: '200'}, 1600, EddieEasing);
			$(targetOptional).stop().animate({left: '580'}, 1600, EddieEasing);
			$(targetxtraCloud).stop().animate({backgroundPosition: '0px 0px'}, 1900, EddieEasing);
			
			//WRAPPER SCROLL
			$('#wrapper').stop().scrollTo( element_id, {easing: EddieEasing,duration: EddieTime, onAfter:function(){
				//$(document).bind('keydown', moveToBox);
				resetSlide();
				return false;
				}} );
			
}

function lavaLamp(goToVoice){
		
		//MENU LAVA
		var lavaTo = 'a#link' + goToVoice;
				
		var destWidth = $(lavaTo).width();
		var fixedDestWidth = destWidth + 10;
		
		
		
		var menuLeftOffset = $('ul#menu').offset().left;
		var lavaOffset = $(lavaTo).offset().left;
		
		var leftOffset = lavaOffset - menuLeftOffset -16;
		
		$('.top_selected').stop().animate({width:fixedDestWidth, left: leftOffset}, 800, 'easeOutCubic');	
		
		}

//set position nuvole
function setPosition(check, div, p1, p2, p3, p4, p5, p6, p7) {
	
if(check==='#box1')
		{
			$(div).stop().scrollTo(p1, EddieTime, {easing: EddieEasing});
		}
	else if(check==='#box2')
		{
			$(div).stop().scrollTo(p2, EddieTime, {easing: EddieEasing});
		}
	else if(check==='#box3')
		{
			$(div).stop().scrollTo(p3, EddieTime, {easing: EddieEasing});
		}
	else if(check==='#box4')
		{
			$(div).stop().scrollTo(p4, EddieTime, {easing: EddieEasing});
		}
	else if(check==='#box5')
		{
			$(div).stop().scrollTo(p5, EddieTime, {easing: EddieEasing});
		}
	else if(check==='#box6')
		{
			$(div).stop().scrollTo(p6, EddieTime, {easing: EddieEasing});
		}
	else
		{
			$(div).stop().scrollTo(p7, EddieTime, {easing: EddieEasing});
		}
	};
	
	
	
});




//SWITCH LOGO
function switchLogoToAir(){
	
	$('a#ground_link').css('display','block');
   
    	$('a#air_link').stop().animate({opacity:'0'}, 800, function(){
    		$('a#air_link').css('display','none');
    	}); 
    	
    	$('a#ground_link').stop().animate({opacity:'1'}, 800, function(){
    		
    	}); 
   	//HIDE GROUND MENU
	$('#menu').stop().animate({opacity: '1'}, 1500);
	$('ul#menu .top_selected').stop().animate({opacity: '1'}, 1500);
	$('#bottom-top p').stop().animate({opacity: '1'}, 1500);
	$('.menu_ground').stop().animate({opacity: '0'}, 1500);
		      	  
};

function switchLogoToGround(){

	    $('a#air_link').css('display','block');
   
    	$('a#ground_link').stop().animate({opacity:'0'}, 800, function(){
    		$('a#ground_link').css('display','none');
    	}); 
    	
    	$('a#air_link').stop().animate({opacity:'1'}, 800, function(){
    		    	}); 
    
    //HIDE AIR MENU
	$('#menu').stop().animate({opacity: '0'}, 1500);
	$('ul#menu .top_selected').stop().animate({opacity: '0'}, 1500);
	$('#bottom-top p').stop().animate({opacity: '0'}, 1500);
	$('.menu_ground').stop().animate({opacity: '1'}, 1500);
			  
}

function resetSlide(){
	
	//VARS DEFINITION
var EddieEasing = 'easeOutCubic';
var EddieOutEasing = 'easeOutCubic';
var EddieTime = 1800;	
var EddieSlowTime = 500;
	
$('#box2 .text_slide').animate({left:'0'}, 500, EddieEasing);
$('#box3 .text_slide').animate({left:'0'}, 500, EddieEasing);
$('#box4 .text_slide').animate({left:'0'}, 500, EddieEasing);
$('#box5 .text_slide').animate({left:'0'}, 500, EddieEasing);
$('#box6 .text_slide').animate({left:'0'}, 500, EddieEasing);	
$('#box7 .text_slide_contact').animate({left:'0'}, 1000, EddieEasing);

$('#box2 a.slide_link').removeClass('selected');
$('#box2 a.slide_link.first').addClass('selected');

$('#box3 a.slide_link').removeClass('selected');
$('#box3 a.slide_link.first').addClass('selected');

$('#box4 a.slide_link').removeClass('selected');
$('#box4 a.slide_link.first').addClass('selected');

$('#box5 a.slide_link').removeClass('selected');
$('#box5 a.slide_link.first').addClass('selected');

$('#box6 a.slide_link').removeClass('selected');
$('#box6 a.slide_link.first').addClass('selected');

$('#box7 a.slide_link_contact').removeClass('selected');
$('#box7 a.slide_link_contact.first').addClass('selected');
}


function prepareToGround(){
	
	//VARS DEFINITION
var EddieEasing = 'easeOutCubic';
var EddieOutEasing = 'easeOutCubic';
var EddieTime = 1800;	
var EddieSlowTime = 500;
	
	
	$('h1.title').stop().animate({bottom: '3'}, 200, EddieEasing);
	$('.text').stop().animate({bottom: '5'}, 200, EddieEasing);
	
	$('#Plane01').stop().animate({bottom: '68'}, 200, EddieEasing);
	$('#Plane02').stop().animate({bottom: '278'}, 200, EddieEasing);
	$('#Plane03').stop().animate({bottom: '68'}, 200, EddieEasing);
	$('#Plane06').stop().animate({bottom: '0'}, 200, EddieEasing);
	
	$('a.optional_element').stop().animate({bottom: '13'}, 200, EddieEasing);

	}
function resetPrepare(){
	
	//VARS DEFINITION
var EddieEasing = 'easeOutCubic';
var EddieOutEasing = 'easeOutCubic';
var EddieTime = 1800;	
var EddieSlowTime = 500;
	
	$('#Plane01').stop(true).animate({bottom: '60'}, 500, EddieEasing);
	$('#Plane02').stop(true).animate({bottom: '270'}, 500, EddieEasing);
	$('#Plane03').stop(true).animate({bottom: '60'}, 500, EddieEasing);
	$('#Plane06').stop(true).animate({bottom: '0'}, 500, EddieEasing);

	
	$('.text').stop(true).animate({bottom: '0'}, 500, EddieEasing);
	$('h1.title').stop(true).animate({bottom: '0'}, 500, EddieEasing);
	$('a.optional_element').stop(true).animate({bottom: '0'}, 500, EddieEasing);

	}
	
	
	
	
	
	

	      	
