if (!umen) { var umen = {}; }
if (!umen.social) { umen.social = {}; }
if (!umen.social.facebook) { umen.social.facebook = {}; }

if (!umen.social.facebook.asyncLoad) {
	umen.social.facebook.getLocale = function (langue) {
		var locale = "";
		if (langue) { langue = langue.toLowerCase(); }
		switch (langue) {
			default:
			case "fr": locale = "fr_CA"; break
			case "en": locale = "en_US"; break // en_CA pas supporte
		}
		return locale;
	}
	umen.social.facebook.queuedActions = [];
	umen.social.facebook.asyncLoad = function (divId, langue) {
		var actions = umen.social.facebook.queuedActions;
		if (!umen.social.facebook.asyncLoad.done) {
			if (!window.fbAsyncInit) {
				window.fbAsyncInit = function () {
					$(document).ready(
						function () {
							umen.social.facebook.asyncLoad.done = true;
							while (actions.length > 0) {
								(actions.pop())();
							}
						}
					);
				};
			}
		}

		if (!umen.social.facebook.asyncLoad.appended) {
			umen.social.facebook.asyncLoad.appended = true;
			var getLocale = umen.social.facebook.getLocale;
			var e = document.createElement('script');
			e.async = true;
			e.src = document.location.protocol + ['//connect.facebook.net/', getLocale(langue), '/all.js'].join('');
			var div = document.getElementById(divId);
			div.id = "fb-root";
			div.appendChild(e);
		}
	};

	umen.social.facebook.execute = function (action) {
		if (action) {
			if (!umen.social.facebook.asyncLoad.done) {
				umen.social.facebook.queuedActions.unshift(action);
			}
			else {
				action();
			}
		}
	};
}


