// Collection of various scripts used throughout the site

// Obfuscate email address - remove span

	$(document).ready(function(){
		$(".hide").empty();
	});

// Fade navigation 

	$(document).ready(function(){
	
		$("#navigation li:not(.active, li.headlink > ul > li)").animate({	
				opacity:0.4
				},0	
		);
		
		$("#navigation li:not(.active, li.headlink > ul > li)").hoverIntent(function(){
				$(this).stop(true).fadeTo("100", 1.0);
			},function(){
				$(this).stop(true).fadeTo("100", 0.4);
		});
		
		$("#navigation li a").focus(function () {
				$(this).parents("li").stop(true).fadeTo("100", 1.0);		
			});
			
		$("#navigation li a:not(#navigation li.active a, #navigation li ul li a)").blur(function () {
				$(this).parents("li").stop(true).fadeTo("100", 0.4);
		});
		
	});
	
// Dropdown

	$(document).ready(function(){
							   
			$("li.headlink ul").hide();
							   
			function makeTall() { 
					$(this).children("ul").stop(true,true).slideDown(400);
					$(this).stop(true).fadeTo("100", 1.0);
			}
			
			function makeShort() { 
					$(this).children("ul").stop(true,true).slideUp(400);
					if (!$(this).hasClass("active")) { 
						$(this).fadeTo("100", 0.4); 
					} 
			}
							   
			$("li.headlink").hoverIntent({
					sensitivity: 7, 
					interval: 100, 
					over: makeTall, 
					timeout: 300, 
					out: makeShort
				});
			
			$("li.headlink a:not(li.headlink ul li a)").focus(function () {
					$(this).siblings("ul").stop(true,true).slideDown(400);
					$(this).parents("li.headlink").stop(true).fadeTo("100", 1.0);
			});
			
			$("li.headlink ul li:last-child a").blur(function () {
					$(this).parents("ul:first").stop(true,true).slideUp(400);
					$(this).parents("li.headlink:not(.active)").stop(true).fadeTo("100", 0.4);
			});

	});

// Opens link in new window whilst retaining validity

	$(function() {
		$('a[rel*=external]').click( function() {
			window.open(this.href);
			return false;
		});
	});