/**
 * @author dnichols
 */
 if(typeof CV=="undefined"||!CV){var CV={}}
 if(typeof CV.WIDGET=="undefined"||!CV.WIDGET){CV.WIDGET={}}
 /**
 * nav - Sets active css class to li parent elements of currently active <a> links.  Uses the current page property from .Net 2.0 or any other method used to set the current page property.
 * Finds matching link within nav and sets it's parent LI to "active". Walks up tree and sets all Ancestor LI's to "Active.  Creates a Tree Navigation effect.
 * @class
 * @property {object} nav Object containing nav properties.
 * @property {object} nav.root root UL element of main navigation.
 * @property {array} nav.links all links within nav.
 * @property {string} activeClass string name of css class used to set LI to active.
 * @property {string} parentActiveClass string name of css class used to set all ancestor LI to active.
 * @property {string} currentPage Link title of the current page found in Web.sitemap config file. Set outside the class instance by a server side variable.
 */
CV.WIDGET.nav = function(ele,loc){
	this.nav = "#"+ele + " a";
	this.currentPage = loc;
	/**
	 * setActiveLinks Iterates through all nav links checks if link title == the current page. if it does then sets the links parent LI to "active". Calls setParentClassName.
	 * @ method
	 */
	this.setActiveLinks = function(){
		var self = this;
		$(this.nav).each(
			function(i,ele){
					var lregexp = new RegExp(ele.href);
					if(lregexp.test(self.currentPage) === true){
							$(ele).parent().addClass("active");
							$(ele).addClass("linkActive");
						}
				}						 
		);
	};
	this.setActiveLinks();
};
