// jQuery version of the nav listeners, for use with blank template.
jQuery(document).ready(function ($){

	var navTabOn = function (ev) {
		$(this).addClass('activeNav');
	};

	var navTabOff = function (ev) {
		$(this).removeClass('activeNav');
	};

	// Attach hover behavior to the tabs.
	$('.navTab').hover(navTabOn, navTabOff);


    // Navigation tracking.
    $('.catItemLink').each(function(){
        var $el = $(this);

		$el.click(function(ev){
			// Bubbling must be allowed to continue.  Will stop it in trackNav if necessary.
			
			var header = $el.parents('.navCat').children('.navHeader'), pid = '';

			if (header) {
				pid = header.text();
			}
			
			// Click event
			var trackData = $(this).text().replace(/[\f\r\n]/g,'') || $(this).attr('rel');

			var newWindow = (this.readAttribute('target') == "_blank") ? 1 : 0;
			trackNav(this.href, "Nav - " + pid+" - "+ trackData, newWindow, ev);

		});
	});

	$('.entBigPromoLink, .comBigPromoLink').each(function(){
        var $el = $(this);

		$el.click(function(ev){
			// Bubbling must be allowed to continue.  Will stop it in trackNav if necessary.
			
			// Click event
			var trackData = this.id || this.readAttribute('rel');
			var newWindow = (this.readAttribute('target') == "_blank") ? 1 : 0;
			trackNav(this.href, "Nav - " + trackData, newWindow, ev);
		});
	});

});
