/*
* M Oakley 
* Set the last breadcrumb.
*
* Rules:
* If there is top nav on the site:
* - If there is a left nav in the On state, display the top nav as the breadcrumbs hyperlinked.
* - If there is no left nav in the On state, display the top nav as the breadcrumb unlinked
*
* If there is no top nav on the site:
* - If there is no left nav in the On state, don't add a breadcrumb at all (ie. remove the #lastcrumb)
* - If the current page is a top level left nav, and is On, display it in the breadcrumb, but not hyperlinked
* - Otherwise, display the hyperlinked 1st level nav in the breadcrumb
*/
$(document).ready(function(){

  if ( $('#topnav').length ) {
		// the top nav button, wrapped in jQuery
    var $topnavButton = $('#topnav li.current > a');

		( $('ul#leftnav a.current').length == 0) ? $('#lastcrumb').append( $topnavButton.clone().text() )  : $('#lastcrumb').append($topnavButton.clone()) ;

	}
	else {
    // the 1st level nav button, wrapped in jQuery
    var $leftnavButton = $('a.current').parents('ul#leftnav > li').children('a');

    // if true, you must be on Contacts, Webmaster, News, or some feature page that doesn't exist in the left nav.
    // else, append a breadcrumb.
    ($leftnavButton.length == 0 ) ? $('#lastcrumb').remove() : $('#lastcrumb').append($leftnavButton.clone());
	}
});

