$(function(){
	// breadcrumbs
	var breadcrumbs = $('div#breadcrumbs');
	// append directory
	if (location.protocol == 'http:') {
		var curDir = location.pathname.substring(0,location.pathname.lastIndexOf('/')).split('/').pop();
		if (curDir) breadcrumbs.append(' &gt; <a href="./">' + curDir + '</a>');
	}
	// apend page title
	var pageTitle = $('div#mainContent h2:first').text();
	if (pageTitle) {
		breadcrumbs.append(' &gt; ' + pageTitle);
	}
	
	// replace email addresses (spam protection)
	$('.email-replace').each(function(){
		var address = $(this).text().replace(/DOT/g,'.').replace('AT','@');
		$(this).html('<a href="mailto:'+address+'">'+address+'</a>');
	});
	$(window).resize(function(){
		// prevent nav from scrolling too far to left on small windows
		if ($(window).width() < $('div#container').width()) {
			$('div#menucontainer').css('left', $('div#container').offset().left + ($('div#container').width() / 2));
		} else {
			$('div#menucontainer').css('left', '50%');
		}
	});
});
