$(document).ready(function() {
	/* open links with rel="external" in new window and amend link title */
	$('a[rel*="external"]').each(function() {
		var title = $(this).attr('title') ? $(this).attr('title') + ' (opens in a new tab or window)' : 'This link will open in a new tab or window';
		$(this).attr('title',title).click(function() {
			window.open($(this).attr('href'));
			return false;
		});
	});
	
	$('#menu li ul').hide();

	$('#menu li a').hover(function() {
		if($(this).parent().find('ul')) {
			$(this).parent().find('ul').show();
		};
	}, function() {
		$(this).parent().find('ul').hide();
	});

	$('#menu li ul').hover(function() {
		$(this).show();
	}, function() {
		$(this).hide();
	});
	
	$('#menu>li').hover(function() {
		if($(this).find('ul.sub').eq(0).length) {
			$(this).find('a').eq(0).css('background-position', 'bottom left');
		};
	}, function() {
		if($(this).find('ul.sub').eq(0).length) {
			$(this).find('a').eq(0).css('background-position', 'top left');
		};
	});
	
	Cufon.replace('h1, h2, .replace', { fontFamily: 'Apercu' });
	Cufon.now();
	
});
