(function($) {
	$(document).ready(function() {
		var path = 'templates/lwwf/images/feature-box@id@.jpg';

		function bind() {
			$('#featureBox').mouseover(function(e) {
				var el = $(e.target);									
				if (el.closest('.nav').length > 0) {	
					var id = el.closest('li').attr('id').match(/\d+/g).shift();	
					$(this).find('.figure img').attr('src', path.replace(/@id@/, id));
				};
			});
		};
		
		function preload() {
			for (var i = 1; i<=7; i++) {
				(function() {
					var img = new Image();
					var indx = i;
					img.onload = function () {
						if (indx === 7) {
							bind();
						};
					};
					img.src = path.replace(/@id@/, i);
				})();
			};
		}
		
		preload();
		
	});
})(jQuery);