jQuery(function() {
	swfobject.embedSWF(modPhoneNumbersVars.swfPath, "worldMapContainer",
			modPhoneNumbersVars.flashWidth, modPhoneNumbersVars.flashHeight,
			"9.0.0", "expressInstall.swf");
});

var positions = {
	EU : {
		x : 420,
		y : 600,
		z : 9
	},
	NA : {
		x : 1100,
		y : 400,
		z : 4
	},
	SA : {
		x : 1120,
		y : -120,
		z : 6
	},
	AS : {
		x : -100,
		y : 240,
		z : 6
	},
	AF : {
		x : 420,
		y : 60,
		z : 6
	},
	OC : {
		x : -400,
		y : -60,
		z : 6
	},
	0 : {
		x : 480,
		y : 280,
		z : 1
	},
	AN : {
		x : 480,
		y : 280,
		z : 1
	}
};

var FWM_options = {
	autodisplay : true,
	draggableMap : false,
	oceanColor : '0xFFFFFF',
	showInfoBox : false,
	dragInfo : false,
	lblPrefix : '',
	countryScale : 1,
	zoomMax : 15,
	selectedColor : '0xB3CDEF',
	displayList : false,
	statusDefault : {
		lbl : 'Unknown',
		clr : '0xCCCCCC'
	}
};

var FWM_statuses = [ {
	code : 0,
	lbl : 'No Information',
	clr : '0xFFFFFF',
	desc : 'There is no information for this country'
}, {
	code : 1,
	lbl : '',
	clr : '0x99B7DF',
	desc : ''
} ]


function modPhoneNumbersInitialize() {
	jQuery('.worldMapInfo').show();
	jQuery('div.mod_phoneNumbers .phoneNumbersCountriesList').hide();
	jQuery('div.mod_phoneNumbers #worldMapContinents').change(
			function() {
				var continent = jQuery(this).val();
				document.getElementById('worldMapContainer').setPosition(
						positions[continent]);
			});
	jQuery('div.mod_phoneNumbers #worldMapCountries').change(
			function() {
				var country = jQuery(this).val().toUpperCase();
				var htmlCountry = jQuery('#country' + country);				
				var continentCode = htmlCountry.find('.continent').val();
				var continent = continentCode;
				jQuery('div.mod_phoneNumbers #worldMapContinents').val(
						continent).change();
				displayCountryInfo(country);
				document.getElementById('worldMapContainer').setCurrentCountry(
						country);
			});
}

function displayCountryInfo(country) {
	var htmlCountry = jQuery('#country' + country);
	var continent = htmlCountry.find('.continent').val();
	jQuery('div.mod_phoneNumbers #worldMapContinents').val(continent).change();
	var html = '';
	jQuery('.worldMapCountryInfo').html(htmlCountry.html());
	jQuery('.worldMapCountryInfo h3').css('backgroundImage',htmlCountry.css('backgroundImage'));
	jQuery('div.mod_phoneNumbers .phoneNumbersRegionsList li.region').hover(function(){
		jQuery(this).next().show();
	},function(){
		jQuery(this).next().hide();
	});
}

function FWM_ready() {
	modPhoneNumbersInitialize();
	document.getElementById('worldMapContainer').setOptions(FWM_options);
	document.getElementById('worldMapContainer').setStatuses(FWM_statuses);
	document.getElementById('worldMapContainer').setCountryList(
			modPhoneNumbersVars.countryList);
	document.getElementById('worldMapContainer').displayCountries();
	document.getElementById('worldMapContainer').displayZoom(false);
	var continent = jQuery('div.mod_phoneNumbers #worldMapContinents').val();
	document.getElementById('worldMapContainer').setPosition(
			positions[continent]);
}

function FWM_clickOnCountry(obj) {
	var country = obj.code.toUpperCase();
	jQuery('#worldMapCountries').val(country).focus();
	displayCountryInfo(country);
}

function FWM_log(obj) {
	alert(obj);
}
