(function() {
	
	var YU = YAHOO.util,
		Dom = YU.Dom,
		YS = YU.Selector;
		
	
	function correctProductNav() {
		if(location.pathname.match(/^\/?products/)) {
			var anchors = YS.query('li.active li a', 'PrimaryNavigation'),
				el,
				pathWithDash = location.pathname + '-';
			for(var i = 0, len = anchors.length; i < len; i++) {
				if(pathWithDash == anchors[i].pathname) {
					el = anchors[i];
					break;
				}
			}
			if(el) {			
				Dom.addClass(el.parentNode, 'active');
			}
		}
	}
	
	function correctCartNav() {
		if(location.pathname.match(/^\/?cart/)) {
			var el = YS.query('li > a[href="/shop"]', 'PrimaryNavigation', true);
			if(el) {
				Dom.removeClass(YS.query('li.active', 'PrimaryNavigation'), 'active');				
				Dom.addClass(el.parentNode, 'active');
			}
		}
	}
	
	
	YU.Event.onDOMReady(function() {
		correctProductNav();
		correctCartNav();
	});
	
	
})();
