// JavaScript Document
var automotiveExternalLink = "_blank";
var Automotive = {
	External_Links: function() {
		// tag external links
		$("a[href^='http']").attr('rel','external');
		
		// make all "file" and external links open in a new window
		$("a[rel='file'], a[rel='external']").attr('target','_blank');
		
		// change the title of new-window links
		// $("a[rel='external']").attr('title', 'This link opens in a new window');
		// $('body.eng a[rel="external"], body.eng a[rel="file"]').attr('title','This link opens in a new window');
		// $('body.fra a[rel="external"], body.fra a[rel="file"]').attr('title','Ce lien ouvre dans une nouvelle fenêtre');
	},
	External_Docs: function() {
		$("a[href^='/_docs/']").attr('target','_blank');
	},
	LocalScroll: function() {
		$('a[href*=#]').click(function() {
			if (location.pathname.replace(/^\//,'') == this.pathname.replace(/^\//,'')
				&& location.hostname == this.hostname) {
				var $target = $(this.hash);
				$target = $target.length && $target 
				|| $('[name=' + this.hash.slice(1) +']');
				if ($target.length) {
					var targetOffset = $target.offset().top;
					$('html,body')
					.animate({scrollTop: targetOffset}, 2000);
					return false;
				}
			}
		});
	}
}

$(document).ready(function(){
	Automotive.External_Links();
	Automotive.External_Docs();
	Automotive.LocalScroll();
});
