var NSERC = {
	Body_Classes: function() {
		// parse the URL and add classes to the body
		var Sections = window.location.href.split('http://').join('').split('/');
		for( var i = 1; i < Sections.length-1; i++ ) {
			$('body').addClass(Sections[i]);
		}
	},
	
	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
		$('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');
		
	},
	
	Table_Hover: function() {
		// hover table rows
		$('.DataTable2 tr, .ListTable tr, .TableList tr, .ProgramList tr, .News tr').hover(
			function () {
				$(this).addClass('over');
			}, 
			function () {
				$(this).removeClass('over');
			}
		);
		
		// click table rows with links
		$('.ListTable tr, .TableList tr, .ProgramList tr').click( function() {
			var Target_URL = $(this).find('a').attr('href');
			if( Target_URL ) {
				location.href = ( Target_URL );
			}
		});
	}
}



$(document).ready(function(){
	NSERC.External_Links();
	NSERC.Body_Classes();
	
	NSERC.Table_Hover();
	
});
