(function ($) {
	$(document).ready(function () {

    	/* handler for url prefixes; NSCR-10689 */
		$('#nscrHeaderWrapper a').each(function(indexOf) {
			var link = $(this).attr('href');
			if (link.indexOf('/') == 0) {
				$(this).attr('href','http://www.nascar.com' + link);
			}
		});

		// Delayed mouseout.
		$('.region-header .menu-name-primary-links > ul > li').hover(function() {
			  // Stop the timer.
			  clearTimeout(this.sfTimer);
			  // Give the link an active class.
			  $(this).addClass('active')
				// Immediately hide nephew lists.
				.siblings('li').removeClass('active').children('ul').css({display: 'none'});
			  // Display child lists.
			  $('> ul', this).css({display: 'block'});
		}, function() {
			// Start the timer.
			var self = $(this);
			this.sfTimer = setTimeout(function() {
				self.removeClass('active').children('ul').css({display: 'none'});
			}, 400);
		});

    	if (location.href.indexOf('/video/') != -1) {
    		$(".primary-link-4").parent().addClass('active-trail');
        }
  	});
})(jQuery);

