$(function() {
	$('a[rel*=ext]').click( function() { window.open(this.href); return false; });
	
	$('a[rel*=int]').click(function() {
    if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'') && location.hostname == this.hostname) {
			var $target = $(this.hash);
			$target = $target.length && $target
			|| $('[name=' + this.hash.slice(1) +']');
			if ($target.length) {
				var targetOffset = $target.offset().top;
				$('html,body').animate({scrollTop: targetOffset}, 1000);
				return false;
			}
		}
  });
	
	$('body').css( 'padding-bottom', '0' );
	
	$('li.drop a strong').append('<span>&nbsp;</span>');
	
	$('li.drop #mega-drop').append('<span class="bottom">&nbsp;</span>');
	
	$('li.drop').hover( 
		function () { $(this).children('a').addClass('hovering');
									$(this).children('#mega-drop').show();
								},
		function () { $(this).children('a').removeClass('hovering');
									$(this).children('#mega-drop').hide();
	});
	
	$('ol li').each(function (index, value) {
		
		$(this).prepend('<span>#' + ( index + 1 ) + '</span>');
		$(this).children('span').css({ 'margin-top' : '-' + parseInt( $(this).children('span').height() / 2 ) + 'px' });
		
	});
	
	$('a').hover(function () { $(this).css({ 'opacity' : 0.8 }); }, function () { $(this).css({ 'opacity' : 1 }); });
	
	$('ul#accordion ul').hide();
	
	$('ul#accordion li.revealed ul').show();
	
	$('ul#accordion li a.has-children').click(function (e) {
		
		e.preventDefault();
		
		$(this).parent('li').addClass('revealed');
		
		$(this).parent('li').siblings('li').removeClass('revealed');
		
		$('ul#accordion li').not('.revealed').children('ul').slideUp('slow');
		
		$('ul#accordion li.revealed ul').slideDown('slow');
		
	});
	
	$('ul#accordion li a').not('.has-children').click(function () { window.location = $(this).attr('href'); });
	$('ul#accordion li ul li a').not('.has-children').click(function () { window.location = $(this).attr('href'); });
	
	$('.staff-member img').hover(function () {
					
			$(this).siblings('.tooltip').fadeIn('fast');
			
	 }, function () {
			
			$(this).siblings('.tooltip').hide();
			
	 });
	
});
