// Using jQuery...
$(document).ready(function(){
	
	// Event handlers for Visual Aid buttons
	/*$('div#visual_aids a').click(function() {
				
		var classes_to_remove = 'text_size_1 text_size_2 text_size_3';
		
		if ($(this).parent().hasClass('contrast')) {
			classes_to_remove = 'contrast_1 contrast_2 contrast_3';
		}
		
		// Remove any appropriate classes
		$('body').removeClass(classes_to_remove);
		
		// Add the clicked class
		$('body').addClass($(this).attr('href').replace('#', ''));
		
		return false;

	});*/
	
	
	// Set the map up:
	
	// Add our map helper
	var map_helper_markup = '<div id="uk_map_helper"><img src="images/uk_map.png" alt="Uk Map - Select the desired area to find the corresponding HomeBuy Agent website" width="469" height="567" border="0" usemap="#map" /></div>';
	$('#uk_map').before(map_helper_markup);
	
	//click the details goes to same href url
	$('div#uk_map div.region_details').each(function() {
		$(this).bind('click', function() {
			window.location = $('area.' + $(this).attr('id')).attr('href');
		});
	});
	
	
	// Map hovering
	// Using mouseover/mouseout because of IE problem with area elements
	$('area').mouseover(function() {
		$('#' + $(this).attr('class')).show();
	});
	
	// Keyboard: focus accessibility
	$('area').focus(function() {
		$('#' + $(this).attr('class')).show();
	});
	
	$('area').mouseout(function() {
		$('#' + $(this).attr('class')).hide();
	});
	
	// Keyboard: focus accessibility
	$('area').blur(function() {
		$('#' + $(this).attr('class')).hide();
	});
	
	$('div#uk_map div.region_details').mouseover(function() {
		$(this).show();
	});
	
	$('div#uk_map div.region_details').mouseout(function() {
		$(this).hide();
	});
	
	// Use blank map image (the helper map image will still be seen underneath)
	// This ensures the hover divs don't interfere with the image map areas
	
	if (!$('div#wrapper').hasClass('content_page')) {
		$('#uk_map_im').attr('src', $('#uk_map_im').attr('src').replace('uk_map.png','uk_map_blank.png'))
	}
		
});


