/*
* activeClass.js
* @author Jason Ware
* 
* This looks for elements matching the body id + "Nav":
* for instance, if there is a body id of #products and 
* a navigation element with an id of #productsNav, 
* a class of .active will be added to the element.
*
* 9/22/10 - I have added a second selection for tabs that 
* are actually separate sub-pages and use a subpage derived body class
*
* Requires jQuery.
* 
*/

$(document).ready(function() {

	//get the body id
	var bodyId = $('body').attr('id');
	
	//get the second element of the body class string for the tabs
	var bodyClass = $('body').attr('class').split(' ').slice(-1);
	
	//find any element with an id using the convention of the body id plus "Nav"
	var activeNavItem = $('body').find('#' + bodyId+'Nav');
	
	//find any element with an id using the convention of the second body class element plus "Tab"
	var activeTabItem = $('body').find('#' + bodyClass+'Tab');
	
	
	//if either of these exists we'll add a class of "active" to those elements
	$(activeNavItem).addClass('active');
	$(activeTabItem).addClass('active');

});


