/*
	Any site-specific scripts you might have.
	Note that <html> innately gets a class of "no-js".
	This is to allow you to react to non-JS users.
	Recommend removing that and adding "js" as one of the first things your script does.
	Note that if you are using Modernizr, it already does this for you. :-)
*/

(function($){
    $.fn.subNavDisplay = function() {
		
		return this.each(function() {
			$(this).find('li:nth-child(1) a, li:nth-child(2) a, li:nth-child(4) a, li:nth-child(5) a').mouseover(
			
				function () {
					$(this).parents('header').next('div.subNav').stop().animate({ 
						"top": "0px"
					}, 300, function(){
						$(this).find('ul.subNavList').addClass("hidden");
						$(this).find('ul.subNavTeamStores').addClass("hidden");
					});
				}
			);
			
            $(this).find('li:nth-child(3)').mouseover(
			
				function () {
					
					$(this).parents('header').next('div.subNav').find('ul.subNavTeamStores').addClass("hidden");
					
					$(this).parents('header').next('div.subNav').stop().animate({ 
						"top": "20px"
					}, 300, function(){
						$(this).find('ul.subNavList').removeClass("hidden");
					});
					
					$(this).parents('header').next('div.subNav').mouseenter(
						function () {
						}).mouseleave (function(){
							$(this).stop().animate({
								"top": "0px"		   
							},300);
						}	 
					);
				}
			);
			
			
			
			

        });
		
   };
})(jQuery);


/* Function for external Links */

$(function() {
    $('a[rel*=external]').click( function() {
        window.open(this.href);
        return false;
    });
});

/* Function for Moving between Services */

(function($){

	$.fn.autoscroll = function() {
		
		return this.each(function(){
			
			//Cache DOM Elements					  
			
			var $this = $(this), // The Anchor Tag
			$body = $('body'),
			$scroll = ($.browser.mozilla || $.browser.msie) ? $('html') : $body,
			anchor = $this.attr('href'),
			$section = $(anchor);
			
			
			//Verify that we have a place to link to
			
			if($section.length > 0) {
				
				$this.click(function(event){
					event.preventDefault();
					$scroll.animate({scrollLeft: $section.offset().left}, 1000, "swing", function(){
						$scroll.animate({scrollTop: 0},500, "swing" );
						window.location.hash = anchor;
					});
				});
			}
			
		});
		
	};



})(jQuery);

