$(document).ready(function() {
	
	
	$('#middle-content ul > li > a').wrap('<span></span>');

	$(".teammember").tipTip({maxWidth: "auto", delay: 0, fadeIn: 0, fadeOut: 0, edgeOffset: -3, enter: refreshme()});
	
	function refreshme() {
		Cufon.replace('#tiptip_content h3', { fontFamily: 'Gotham-Book'});
		Cufon.refresh('#tiptip_content h3');
	}


	$(".nowexperience a, a.vidimgclick").click(function() {
	    $("#vip-shell").animate({marginTop: "-120"}, 1000, function() { $('#corporatevideo').fadeIn(2000, function() { }); });	
		$("#logo").animate({top: "40"}, 1000, function() {  });
		$("#calltoaction").animate({paddingTop: "40"}, 1000, function() { });
		$("#vip-header-inner ul").animate({paddingTop: "40"}, 1000, function() { });
		$('#vip-whitebox').fadeOut(800, function() { });
		$('.vip-rotator-bg').fadeOut(800, function() { });
		$('.vip-rotator-bg-two').fadeOut(800, function() { });
		$("#nowexperienceclick").trigger('click');
		return false;
	});	
	
	
	
	$('#nowexperienceclick').fancybox({
			'type'				: 'iframe',
			'transitionIn'      : 'fade',
			'transitionOut'     : 'fade',
			'width'             : '100%',
			'height'            : '100%',
			'overlayColor'      : '#000',
			'hideOnContentClick' : true,
			'speedIn'           : 500,
			'speedOut'          : 500,
			'overlayOpacity'    : 0.6,
			'padding'           : 1,
			'margin'            : 100,
			'centerOnScroll'    : true,
			'onClosed'          : function() {
								$("#logo").animate({top: "0"}, 1000, function() {  });
								$("#calltoaction").animate({paddingTop: "0"}, 1000, function() { });
								$("#vip-header-inner ul").animate({paddingTop: "0"}, 1000, function() { });
								$('#vip-whitebox').fadeIn(800, function() { });
								$('.vip-rotator-bg-two').fadeIn(800, function() { });
								$("#vip-shell").animate({marginTop: "0"}, 1000, function() { 
								
								});	
			},
			'onCancel'          : function() {
								$("#logo").animate({top: "0"}, 1000, function() {  });
								$("#calltoaction").animate({paddingTop: "0"}, 1000, function() { });
								$("#vip-header-inner ul").animate({paddingTop: "0"}, 1000, function() { });
								$('#vip-whitebox').fadeIn(800, function() { });
								$('.vip-rotator-bg-two').fadeIn(800, function() { });
								$("#vip-shell").animate({marginTop: "0"}, 1000, function() { 
								});	
			}
	});
	
	
	
	$(".tablelink").click(function() {
		var geturl = $(this).children('a').attr('href');
		$(window.location).attr('href', geturl);
	});

	
	$(window).resize(function(){
      	$('.vip-rotator-bg').width($(document).width());
		$('#vip-footer-outer').css("bottom", "0");
    });

	$(".animate-box").click(function() {
		var gethref = $(this).children('.home-box-inner').children('.box-content').children('.button').children('a').attr('href');
		$(window.location).attr('href', gethref);
	});
	
	
	$(".animate-box").hover(
	function() {
		ClosedFooter();
		$(".box-content").hide();
		$(".homepage-box").dequeue();
		$('.homepage-box').addClass('shrink');
		$(this).removeClass('shrink');
		$('div.shrink').stop().animate({ width: "155px" }, 200, function() { });
		$(this).stop().animate({ width: "444px" }, 200, function() {
			
			
			$(this).children(".home-box-inner").children(".box-content").fadeIn('slow');
				
			var bgvis = $('#bg-visible').attr('title');
			var getimage = $(this).children(".sectionbg").attr('title');
			if(bgvis=='false') {
				//$('#bg-visible').attr('title', 'true');
				//$("img#bg").attr("src", getimage);
				//$("img#bg").stop().animate({opacity: "1"}, 1000, function() { });	
			} 
			if(bgvis=='true'||bgvis==''||typeof bgvis == 'undefined') {	
				//$('#bg-visible').attr('title', 'false');
				//$("img#bg2").attr("src", getimage);
				//$("img#bg2").show();
				//$("img#bg").stop().animate({opacity: "0"}, 1000, function() { });	
			} 
			
		});	
		return false;
	});
	
	$("#homepage-sections").mouseover(function() { return false; });
	
	$("#web-outer, #homepage-box-25years").mouseover(function() {
		$(".box-content").hide();
		$('.homepage-box').stop().animate({ width: "252px"}, 150, function() {	
		});		
	});
	

	
	$("#footer-main").live({mouseenter:function(){ ExpandFooter(); }});
	$("#vip-shell").live({mouseenter:function(){ ClosedFooter(); }});
	$(".footer-expanded").live({mouseenter:function(){ ClosedFooter(); }});
	$("#footer-nav").live({mouseenter:function(){ return false; }});
	
	function ExpandFooter() {
		$("#footer").removeClass('footer');
		// going up
		$(".footer-expanded").stop(true,true).fadeIn(100);
		$("#copywrite-bar").stop(true,true).delay(100).fadeIn(100);
		$("#viewfooter").addClass('expanded');
		$("#footer-main").addClass('redmap');
		$("#footer-nav li ul").stop(true,true).slideDown(100, function() {
			$("#footer").addClass('footer');
		});
	}
	function ClosedFooter() {
		 $("#footer").removeClass('footer');
		// going down
		$(".footer-expanded").stop(true,true).fadeOut(300);
		$("#copywrite-bar").stop(true,true).fadeOut(150);
		$("#viewfooter").removeClass('expanded');
		$("#footer-main").removeClass('redmap');
		$("#footer-nav li ul").stop(true,true).slideUp(300, function() {
			$("#footer").addClass('footer');
		});
	}
	
	
	
	
	$("#bg").hover(function() {
		// going down
		$(".footer-expanded").fadeOut(500);
		$("#copywrite-bar").fadeOut(250);
		$("#viewfooter").removeClass('expanded');
		$("#footer-main").removeClass('redmap');
		$("#footer-nav li ul").slideUp(500, function() {
		});
	});
	
	
	
	$(".teamlisting li a").hover(
	function() {
		$('.teamlisting li a img').fadeTo(0, 0.5, function() { });
		$(this).find('.teamimg').fadeTo(0, 1, function() { });
	});
	$(".teamlisting li a").mouseleave(function() {
		$('.teamlisting li a img').fadeTo(0, 1, function() { });
	});
	
	
	
	
	$(".sb-intdropdown ul li").click(function() {
		if($(this).children('div').is(":visible")) {  
			$(".sb-news ul li").removeClass('expanded');
			$(".sb-news ul li").children('div').slideUp(300, function() { });
			return false;
		} else {
			$(".sb-news ul li").removeClass('expanded');
			$(".sb-news ul li").children('div').slideUp(300, function() { });
			$(this).children('div').slideDown(300, function() { });
			$(this).addClass('expanded');
			return false;
		}
	});
	$(".sb-newsss ul li h3 a").click(function() {
		$(".sb-news ul li").removeClass('expanded');
		$(".sb-news ul li").children('div').slideUp(300, function() { });
		$(this).parent('h3').parent('li').children('div').slideDown(300, function() { });
		$(this).parent('h3').parent('li').addClass('expanded');
		return false;
	});

	
	
	$(".header-sectional ul li").each(function() { 
		$(this).addClass("nav-default");
		$(this).removeClass("current-menu-item"); 
		if($(this).hasClass('current-page-ancestor')==true) {
			$(this).removeClass("nav-default");
			$(this).addClass("current-menu-item");
		} else if($(this).hasClass('current_page_item')==true) {
			$(this).removeClass("nav-default");
			$(this).addClass("current-menu-item");
		}
	});	
	$("#leftbar ul li a").each(function() { 
		$(this).addClass("nav-default");
		$(this).removeClass("current-menu-item"); 
	});	
	

	
	
	
	
	
	$("p.nowexperienceee").click(function() {
		$('#vip-rotator').cycle('pause');
		$('#vip-whitebox').fadeOut(800, function() { });
		$('#vip-rotator').fadeOut(800, function() { });
	
	
	    $("#vip-shell").animate({marginTop: "-120"}, 1000, function() { $('#corporatevideo').fadeIn(2000, function() { }); });	
		$("#logo").animate({top: "40"}, 1000, function() {  });
		$("#calltoaction").animate({paddingTop: "40"}, 1000, function() { });
		$("#vip-header-inner ul").animate({paddingTop: "40"}, 1000, function() { });
		
		var player = $("#mediaspace");
		player.sendEvent('LOAD');
		return false;
	});
	
	
	
	var pathname = $('#aircraftparent').attr('title');
	if(typeof pathname != 'undefined') {
		$("#leftbar a[href$='" + pathname + "']").each(function() {
			$(this).removeClass("nav-default");
			$(this).addClass("current-menu-item");
		});	
	} else {
		pathname = window.location.pathname;
		$("#leftbar a[href$='" + pathname + "']").each(function() {
			$(this).removeClass("nav-default");
			$(this).addClass("current-menu-item");
		});	
	}
	
	
	
	
});




var images = new Array();
function preload() {
	for (i = 0; i < preload.arguments.length; i++) {
		images[i] = new Image()
		images[i].src = preload.arguments[i]
	}
}
	
			


// Find A linked to PDF - targt new window
$(document).ready(function() {
$("a[href$='.pdf']").addClass('external').click(function() { window.open($(this).attr('href'), null, "height=600,width=400,status=yes,resizable=yes,toolbar=no,menubar=no,location=no"); return false; });
});
