// Runs when the DOM has been loaded
$(document).ready(function() {
	// Check if map exists
	if($('#middle_east_map')) {
		// Loop through each AREA in the imagemap
		$('#middle_east_map area').each(function() {
			// Assign different events for Apple mobile devices
			if(navigator.userAgent.search('(iPhone)|(iPod)|(iPad)') == -1) {
				// Assigning an action to the mouseover event
				$(this).mouseover(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('fast');
				});
				
				// Assigning an action to the mouseout event
				$(this).mouseout(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeOut('fast');
				});
			}
			else {
				// Assigning an action to the click event
				$(this).click(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('slow');
					$('#'+country_id).fadeOut('slow');
				});
			}
		});
		
	}
	if($('#map')) {
		// Loop through each AREA in the imagemap
		$('#map area').each(function() {
			// Assign different events for Apple mobile devices
			if(navigator.userAgent.search('(iPhone)|(iPod)|(iPad)') == -1) {
				// Assigning an action to the mouseover event
				$(this).mouseover(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('fast');
				});
				
				// Assigning an action to the mouseout event
				$(this).mouseout(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeOut('fast');
				});
			}
			else {
				// Assigning an action to the click event
				$(this).click(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('slow');
					$('#'+country_id).fadeOut('slow');
				});
			}
		});
	}
	if($('#africa_map')) {
		// Loop through each AREA in the imagemap
		$('#africa_map area').each(function() {
			// Assign different events for Apple mobile devices
			if(navigator.userAgent.search('(iPhone)|(iPod)|(iPad)') == -1) {
				// Assigning an action to the mouseover event
				$(this).mouseover(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('fast');
				});
				
				// Assigning an action to the mouseout event
				$(this).mouseout(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeOut('fast');
				});
			}
			else {
				// Assigning an action to the click event
				$(this).click(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('slow');
					$('#'+country_id).fadeOut('slow');
				});
			}
		});
	}
	if($('#south_america_map')) {
		// Loop through each AREA in the imagemap
		$('#south_america_map area').each(function() {
			// Assign different events for Apple mobile devices
			if(navigator.userAgent.search('(iPhone)|(iPod)|(iPad)') == -1) {
				// Assigning an action to the mouseover event
				$(this).mouseover(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('fast');
				});
				
				// Assigning an action to the mouseout event
				$(this).mouseout(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeOut('fast');
				});
			}
			else {
				// Assigning an action to the click event
				$(this).click(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('slow');
					$('#'+country_id).fadeOut('slow');
				});
			}
		});
	}
	if($('#central_america_map')) {
		// Loop through each AREA in the imagemap
		$('#central_america_map area').each(function() {
			// Assign different events for Apple mobile devices
			if(navigator.userAgent.search('(iPhone)|(iPod)|(iPad)') == -1) {
				// Assigning an action to the mouseover event
				$(this).mouseover(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('fast');
				});
				
				// Assigning an action to the mouseout event
				$(this).mouseout(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeOut('fast');
				});
			}
			else {
				// Assigning an action to the click event
				$(this).click(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('slow');
					$('#'+country_id).fadeOut('slow');
				});
			}
		});
	}
	if($('#north_america_map')) {
		// Loop through each AREA in the imagemap
		$('#north_america_map area').each(function() {
			// Assign different events for Apple mobile devices
			if(navigator.userAgent.search('(iPhone)|(iPod)|(iPad)') == -1) {
				// Assigning an action to the mouseover event
				$(this).mouseover(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('fast');
				});
				
				// Assigning an action to the mouseout event
				$(this).mouseout(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeOut('fast');
				});
			}
			else {
				// Assigning an action to the click event
				$(this).click(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('slow');
					$('#'+country_id).fadeOut('slow');
				});
			}
		});
	}
	if($('#europe_map')) {
		// Loop through each AREA in the imagemap
		$('#europe_map area').each(function() {
			// Assign different events for Apple mobile devices
			if(navigator.userAgent.search('(iPhone)|(iPod)|(iPad)') == -1) {
				// Assigning an action to the mouseover event
				$(this).mouseover(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('fast');
				});
				
				// Assigning an action to the mouseout event
				$(this).mouseout(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeOut('fast');
				});
			}
			else {
				// Assigning an action to the click event
				$(this).click(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('slow');
					$('#'+country_id).fadeOut('slow');
				});
			}
		});
	}
	if($('#asia_map')) {
		// Loop through each AREA in the imagemap
		$('#asia_map area').each(function() {
			// Assign different events for Apple mobile devices
			if(navigator.userAgent.search('(iPhone)|(iPod)|(iPad)') == -1) {
				// Assigning an action to the mouseover event
				$(this).mouseover(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('fast');
				});
				
				// Assigning an action to the mouseout event
				$(this).mouseout(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeOut('fast');
				});
			}
			else {
				// Assigning an action to the click event
				$(this).click(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('slow');
					$('#'+country_id).fadeOut('slow');
				});
			}
		});
	}
	if($('#australia_map')) {
		// Loop through each AREA in the imagemap
		$('#australia_map area').each(function() {
			// Assign different events for Apple mobile devices
			if(navigator.userAgent.search('(iPhone)|(iPod)|(iPad)') == -1) {
				// Assigning an action to the mouseover event
				$(this).mouseover(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('fast');
				});
				
				// Assigning an action to the mouseout event
				$(this).mouseout(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeOut('fast');
				});
			}
			else {
				// Assigning an action to the click event
				$(this).click(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('slow');
					$('#'+country_id).fadeOut('slow');
				});
			}
		});
	}
	if($('#world_map')) {
		// Loop through each AREA in the imagemap
		$('#world_map area').each(function() {
			// Assign different events for Apple mobile devices
			if(navigator.userAgent.search('(iPhone)|(iPod)|(iPad)') == -1) {
				// Assigning an action to the mouseover event
				$(this).mouseover(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('fast');
				});
				
				// Assigning an action to the mouseout event
				$(this).mouseout(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeOut('fast');
				});
			}
			else {
				// Assigning an action to the click event
				$(this).click(function(e) {
					var country_id = $(this).attr('id').replace('area_', '');
					$('#'+country_id).fadeIn('slow');
					$('#'+country_id).fadeOut('slow');
				});
			}
		});
	}
	
	
});
