//ActivePage v0.1
//jQuery Plug-in used to add .selected class to the li parent of every <a>'s href which matches window.location
// Steve Wenrich (sawenri@sandia.gov) 8/23/2011

(function( $ ){
  $.fn.ActivePage = function() {
	
	var pathName = window.location.pathname;
	
	$("a[href='" +pathName+ "']").parent('li').addClass("current");
	
	var ancestry = pathName.split('/');
	
	var ancestorPath = "";
	
	for(i=0; i<ancestry.length; i++){
		//console.log(ancestry[i]);
		$("a[href='" +ancestry[i]+ "']").parent('li').addClass("current");
		$("a[href='" +ancestry[i]+ "/']").parent('li').addClass("current");
		$("a[href='" +ancestry[i]+ "/index.html']").parent('li').addClass("current");
		$("a[href='" +ancestry[i]+ "/index.htm']").parent('li').addClass("current");
		$("a[href='" +ancestry[i]+ "/index.php']").parent('li').addClass("current");
		$("a[href='" +ancestry[i]+ "/default.html']").parent('li').addClass("current");
		$("a[href='" +ancestry[i]+ "/default.htm']").parent('li').addClass("current");
		$("a[href='" +ancestry[i]+ "/default.asp']").parent('li').addClass("current");
		$("a[href='" +ancestry[i]+ "/default.aspx']").parent('li').addClass("current");
		
		ancestorPath += ancestry[i];
	
		$("a[href='" +ancestorPath+ "']").parent('li').addClass("current");
		$("a[href='" +ancestorPath+ "/']").parent('li').addClass("current");
		$("a[href='" +ancestorPath+ "/index.html']").parent('li').addClass("current");
		$("a[href='" +ancestorPath+ "/index.htm']").parent('li').addClass("current");
		$("a[href='" +ancestorPath+ "/index.php']").parent('li').addClass("current");
		$("a[href='" +ancestorPath+ "/default.html']").parent('li').addClass("current");
		$("a[href='" +ancestorPath+ "/default.htm']").parent('li').addClass("current");
		$("a[href='" +ancestorPath+ "/default.asp']").parent('li').addClass("current");
		$("a[href='" +ancestorPath+ "/default.aspx']").parent('li').addClass("current");
		
		ancestorPath += "/";
	}
	

  };
})( jQuery );
