(function($){
	$.fn.dmnav = function(options) {

		debug(this);
		
		var $opts = $.extend({}, $.fn.dmnav.defaults, options);
		
		return this.each(function() {
			$this = $(this);
			
			var $o = $.meta ? $.extend({}. $opts, $this.data()) : $opts;
			var $curPath = window.location.pathname; // full path of page
			var $splitPath = $curPath.split("/"); // split path on /
			var $curPage = $splitPath[$splitPath.length-1];
			if($curPage == "") $curPage = $splitPath[$splitPath.length-2] + "/"; 
			var $activeLink = $('a[href$="'+$curPath.toLowerCase()+'"]');
			
			var $activeSection = $activeLink.closest('ul');
			var $curTier = $activeSection.attr('class');
			
			//alert($curPath);
			//alert($curTier);
						
			switch($curTier)
			{
				case "tier-one":					
					var $childUL = $activeLink.parent().find('.tier-two');
					$activeLink.closest('.nav-title').addClass('nav-title-selected');
					$activeLink.addClass('active-link');
					$childUL.show('slow');
					break;
				case "tier-two":
					var $childUL = $activeLink.siblings('.tier-three');
					$activeLink.addClass('active-link');
					$activeLink.closest('.nav-title').addClass('nav-title-selected');
					$activeSection.addClass('active-section').show('slow');
					$childUL.show('slow');
					break;
				case "tier-three":
					$activeLink.closest('.nav-title').addClass('nav-title-selected');
					$activeLink.addClass('active-link');
					$activeSection.show('slow').parents('ul').eq(0).show('slow');
					break;
			}
		
		});
	
	};
	
	function debug($obj) {
    	if (window.console && window.console.log)
      		window.console.log('hilight selection count: ' + $obj.size());
  	};
	
	//
	// plugin defaults
	//
	$.fn.dmnav.defaults = {
		color: '#ffffff',
		curpage: ''
  	};
})(jQuery);
