/* ------------------------------ */
/* Experts map */
/* ------------------------------ */
jQuery.fn.preloadMap = function() {
	this.each(function() {
		jQuery("<img>").attr("src", $(this).parent().data('mapPath') + $(this).attr('class') + '.png');
	});
	return this;
}

$(document).ready(function() {
	$('.url-experts map, .url-local map').data('mapPath', $('.url-experts map, .url-local map').prev('img').attr('src').replace('ukMap.png', ''));

	$('.url-experts map area, .url-local map area')
		.preloadMap()
		.click(function() {
			window.location = $('#sidebar-left li a.' + $(this).attr('class')).attr('href');
			return false;
		})
		.mouseover(function() {
			$(this)
				.parent()
				.prev('img')
				.attr('src',
					$(this).parent().data('mapPath') + $(this).attr('class') + '.png'
				);
			$('#sidebar-left li a.' + $(this).attr('class')).addClass('active');
		})
		.mouseout(function() {
			$(this)
				.parent()
				.prev('img')
				.attr('src',
					$(this).parent().data('mapPath') + 'ukMap.png'
				);
			$('#sidebar-left li a.' + $(this).attr('class')).removeClass('active');
		});

		$('.url-experts #sidebar-left .block-donut_location_list a, .url-local #sidebar-left .block-donut_location_list a')
			.hover(
				function() {
					$('.url-experts map area, .url-local map area.' + $(this).attr('class'))
						.filter('area.' + $(this).attr('class'))
						.parent()
						.prev('img')
						.attr('src',
							$('.url-experts map, .url-local map').data('mapPath') + $(this).attr('class') + '.png'
						);
				},
				function() {
					$('.url-experts map area, .url-local map area.' + $(this).attr('class'))
						.parent()
						.prev('img')
						.attr('src',
							$('.url-experts map, .url-local map').data('mapPath') + 'ukMap.png'
						);
				}
			);
});
/* ------------------------------ */
/* END Experts map */
/* ------------------------------ */
