LINEUKCOM.pages.sector = {
	init: function() {
		// Convert "/work/sectors/slug/" to ('', 'work', 'sectors', 'slug', '').
		var pathname = window.location.pathname.split('/');
		// Get the sector slug.
		var sectorSlug = pathname[pathname.length - 2];

		var clientLinks = jQuery('#sector_clients a');
		// When the use hovers over any of the links to clients, the nearby
		// image changes to a screen shot of that client's web site.
		clientLinks.hover(LINEUKCOM.pages.sector.swapImage, function() {});
		// Add a query string to each of the client links.  This identifies
		// which sector the user has come from, so the approriate image can be
		// displayed by default.
		clientLinks.each(function () {
			$(this).attr('href', $(this).attr('href') + '?sector=' + sectorSlug);
		})
	},

	swapImage: function() {
		var anchor = jQuery(this);
		var image = jQuery('img:hidden', anchor);
		if (image.length) {
			jQuery('#sector_clients img:visible').fadeOut(200);
			image.fadeIn(200, function() {
				jQuery('#sector_clients li').removeClass('on');
				anchor.parent('li').addClass('on');
			});
		}
	}
}

jQuery(document).ready(LINEUKCOM.pages.sector.init);