function sg_btcf_menu() {
	
	$('#mainNav > ul > li:not(.active)').each(function(i) {

		// If the item item has sub ul's wrap them for style
		$(this).find('ul:eq(0)').wrap('<div class="flynav-wrap"><div class="flynav-inner"></div></div>').show();
		
		// Append special class name if the next item is "active"
		if ($(this).next().hasClass('active')) {
			$(this).addClass('nextActive');
		}
		
		var sgtimer = null;
		$(this).hover(
			function() { 
				// Clear the timeout
				clearTimeout(sgtimer); 

				// Hide Siblings Immediately
				var siblings = $(this).siblings('li');
				siblings.find('a:eq(0)').removeClass('navon');
				$('div.flynav-wrap',siblings).hide(); //stop()
				
				// Reveal Current
				$(this).find('a:eq(0)').addClass('navon');
				$('div.flynav-wrap',$(this)).show(); //show(); 
				
			},
			function() { 
				var obj = $('div.flynav-wrap',$(this)); 
				var parent = $(this);
				// Hide after 1/2 second
				sgtimer = setTimeout(function() { parent.find('a:eq(0)').removeClass('navon'); obj.hide(); }, 500); 
			}
		);
		
		//$('#mainNav').mouseout(function() { $('a',$(this)).removeClass('navon'); });
		
	});
	
	// Custom handle for the active item
	var activeObj = $('#mainNav > ul > li.active');
	activeObj.find('ul:eq(0)').wrap('<div class="subnav-wrap"></div>');
	if (activeObj.find('ul').size() > 0) { activeObj.addClass('hasSubnav'); }
	
	// Add special class to ignore bottom border on active w/ subnav

}


function sgImageCaption() {
	$('.imgCaption > img').each(function() {
		var w = $(this).width();
		$(this).parent('.imgCaption').css('width',w + 'px');
	});
}

function sgLinkStyleHandler() {
	
	// PDF's
	$('a[href$=.pdf]').each(function() {
		$(this).addClass('pdf-link').after(' <span class="pdf-notice">(pdf)</span>');
		if ($(this).attr('target') != '_blank') {
			$(this).attr('target','_blank');
		}
	});
	
	// External Links
	$('a[href^=http://], a[href^=https://]').attr('target','_blank');
	
}


$(document).ready(function() {
	//sg_btcf_menu();
	sgImageCaption();
	sgLinkStyleHandler();

});
