/*
 * Steven Bower (cc) 2008-2011
 * BPWebDesign http://bpwebdesign.com/
 */

$(function() {
	// Handle external links
	$('a[rel="external"]').click(function() {
		var href = $(this).attr('href');

		// Send external link event to Google Analaytics
		try {
			pageTracker._trackEvent('External Links', href.split(/\/+/g)[1], href);
		} catch (e) {};

		window.open(href,'bp_'+Math.round(Math.random()*11));
		return false;
	});

	// Manage Navigation Controls
	// Bind Events
	$('#navigation ul:hidden').each(function() {
		$(this).prev().click(function() {
			$(this).next().slideToggle('slow');
		});
	});

	// Display sub pages for currently active page
	$('#navigation ul:hidden a').each(function() {
		if (window.location.toString().search($(this).attr('href')) != -1) {
			$(this).parents('ul').show();
		}
	});
});
