String.prototype.trim = function() {
	return this.replace(/^\s+|\s+$/g,"");
}
String.prototype.ltrim = function() {
	return this.replace(/^\s+/,"");
}
String.prototype.rtrim = function() {
	return this.replace(/\s+$/,"");
}
$(document).ready(function() {
	//jDebug("jQuery Ready");
	//alert("jquery in lhnav ready");
	//$('#secondary-nav ul.dropdown').hide();
	$('#secondary-nav ul:first').show();
	$('#secondary-nav ul.expanded').show();
	$('#secondary-nav li.heading').click(function(){
		//jDebugClear();
		var id = $(this).attr('id').trim();
		var idName = '#secondary-nav #' + id;
		//jDebug("clicked: " + $(this).attr('id'));
		//jDebug("Menu heading '" + idName + "' clicked, is id '" + id + "'");
		
		if($(idName).hasClass('nochildren')){
			//jDebug(idName + " has no children");
			//If we have no children, we are just a button. Follow the link.
			return true;
		}else{
			//jDebug(idName + " DOES have children");
			//So we're not just a button. Therefore, we should hide all other dropdowns, 
			//remove the expanded arrow, then apply them to ourselves only.
			$('#secondary-nav ul.dropdown').hide();
			$('#secondary-nav a').removeClass('expanded');
			$('a.section-heading', this).addClass('expanded');
			var idName = 'ul.' + id;

			$(idName).show();
			
			return false;
		}
		});
	//alert("jquery in lhnav complete");
});