$(document).ready(function() {
	// open links marked external in new windows
	$('a[rel="external"]').click( function() {
		window.open( $(this).attr('href') );
		return false;
	});

	// add extra black to bottom of content if not enough content to fill to bottom of page
	jQuery.event.add(window, "load", resizeFrame);
	jQuery.event.add(window, "resize", resizeFrame);
	
	function resizeFrame() 
	{
	    var browser_height = $(window).height()-260; // remove logo height from browser height
	    var content_height = $('#content').height();

		if(content_height<browser_height) {
			$('#content').css('height', browser_height);
		}
	}

	// Detect current page filename in order to highlight appropriate main-menu button
	var filenameLength = location.pathname.length - (location.pathname.lastIndexOf("/")+1);
	var page = location.pathname.substr(location.pathname.lastIndexOf("/")+1, filenameLength);
	if (page=="index" || page=="") { page="home"; }

	// Add 'current' class for detected page to appropriate main-menu button
	$('ul#menu .' + page + ' a').addClass('current');

});
