$(function() {
	if ($('#map').css("background-position-x"))
	{
		var background_pos = $('#map').css("background-position-x") + " " + $('#map').css("background-position-y")
	}
	else
	{
		var background_pos = $('#map').css("background-position")
	}

	$('#map').addClass('loading');
	$('#map > a').hide();

	var img = new Image();
	$(img).load(function ()
	{
		$(this).hide()
		$('#map').removeClass('loading').append(this);
		$('#map > a').show();
		$('#map').hide();
		$('#map').fadeIn();

	}).attr('src', 'fileadmin/template/main/images/layout/world.jpg');

	function map_reset()
	{
		$('#map').css({backgroundPosition : background_pos});
	}

	function map_hover(a, pos)
	{
		a.removeClass('map_rollover');
		$('#map').css({backgroundPosition : pos});
	}

	$('#Africa').hover(
		function() {
			map_hover($(this), '-550px 0px');
		}, map_reset
	);

	$('#NorthAmerica').hover(
		function() {
			map_hover($(this), '-550px -525px');
		}, map_reset
	);

	$('#SouthAmerica').hover(
		function() {
			map_hover($(this), '0px -525px');
		}, map_reset
	);

	$('#Europe').hover(
		function() {
			map_hover($(this), '-1650px 0px');
		}, map_reset
	);

	$('#Asia').hover(
		function() {
			map_hover($(this), '-1100px 0px');
		}, map_reset
	);

	$('#Australia').hover(
		function() {
			map_hover($(this), '-1100px -525px');
		}, map_reset
	);
});
