$(document).ready(function() {
	
	
	
	// add EXCLAMATION POINT to current page's SITENAV link
	// eg: Portfolio ->becomes-> Portfolio!
	
	// $('body#home #sitenav .home-nav a:first, body#portfolio #sitenav .portfolio-nav a:first, body#blog-front #sitenav .blog-nav a:first').append('!');

	
	
	// first, something totally unrelated to navigation. I apologize.
	// Awesomepersands!
	$("h2:contains('&'), h3:contains('&'), h4:contains('&'), h5:contains('&'), #branding li:contains('&'), #focus-items p:contains('&'), .mission p:contains('&'), a.thickbox:contains('&'), #bio p:contains('&')").contents().each(function() {
		if( this.nodeType == 3 ) {
			$(this).replaceWith( this .nodeValue .replace( /&/g, "<abbr title='and' class='amp'>&</abbr>" ));
		}
	});
	
	
	// SITENAV MENU and HOVER NOTE setup
	$('#sitenav li:has(div), #sitenav li:has(a.thickbox)').addClass('has-overlay'); // add a common class to sitenav items with overlays
	$('#sitenav .thickbox').append('<span class="sitenav-overlay hover-overlay">overlays page</span>'); // create thickbox link tootips
	$('#sitenav li .menu, .hover-overlay').hide(); // hide all popup effects as soon as possible, to be shown/hidden by the user with the functions below
	
	
	
	
	
	
	// REMOVE LINK TITLES of sitenav tabs on hover, because they compete with my custom overlays
	$('.has-overlay a, #sitenav h1 a').hover(function(){
		$(this).removeAttr('title');
	},function(){
		// need to restore titles on mouseout
	});
	
	
	
	
	
	// OVERLAY NOTE
	// $('.thickbox, .blog-nav').hover(function(){
	$('.blog-nav').hover(function(){
		$(this).find('.sitenav-overlay').show();
		$(this).find('a:first').css({'backgroundColor':'#0f5376'});
	},function(){
		$(this).find('.sitenav-overlay').fadeOut(150);
		$(this).find('a:first').css({'backgroundColor':'transparent'});
	});
	
	
	
	
	// add FAVICON to EXTERNAL links
	// assumes target has a favicon.ico, which we display as favicon.png
	// this is probably a dumb thing to do for some reason I'm not aware of yet.

	// DEACTIVATED - these links are too transient to want to stick them in the nav, so i've removed them.
	
	// $('#sitenav .links a[href^="http://"]').filter(function(){
	//      return this.hostname && this.hostname !== location.hostname;
	//    }).each(function() {
	//      var link = $(this);
	//      var faviconURL = link.attr('href').replace(/^(http:\/\/[^\/]+).*$/, '$1') +'/favicon.ico';
	//      var faviconIMG = $('<img src="favicon.png" alt="" />')['prependTo'](link);
	//      var extImg = new Image();
	//      extImg.src = faviconURL;
	//      if (extImg.complete) faviconIMG.attr('src', faviconURL);
	//      else extImg.onload = function() { faviconIMG.attr('src', faviconURL); };
	// });
	// 


	// add BODY class="js"
	$('body').addClass('js');
	

	
});

