(function () {
	/* ********** DEBUT CONFIG ********** */
	var INTE_CFG = {
			canal: 'ALLEG0001',
			// global selectors
			trigger: '.LnkWcbForm-trigger', // the trigger is the element that activates the container
			popupFile: 'popup.htm',
			popupName: 'LnkWcbPopup', // This string parameter should not contain any blank space.
			popupAttributes: 'top=320,left=240,width=382,height=380,' +
				'resizable=no,menubar=no,toolbar=no,location=no,status=no'
		},
	/* ********** FIN CONFIG ********** */
		$ = LnkWcb.jQuery,
		I;

	/**
	 * This helper function does the setup of the trigger button (aka "Le Bouton").
	 */
	function setupWcbTrigger() {
		try {
			I = LnkWcb.inteBtn = LnkWcb.inteBtn || {};

			$(INTE_CFG.trigger).click(function () {
				I.POPUP_WIN = window.open(INTE_CFG.popupFile, INTE_CFG.popupName, INTE_CFG.popupAttributes);
			});

			/* ----- Création d'un bouton de base pour gérer uniquement l'apparition du bouton dans cette fenêtre ----- */
			I.bouton = new LnkWcb.Bouton({
				canal: INTE_CFG.canal
			});
			I.bouton.onChannelState(function (etat, etatOuverture) { // activer automatiquement le mode différé
				if (!etat.estActif || !etat.peutRecevoirAppel || etat.estSature) {
					$(INTE_CFG.trigger).hide();
				}
				else {
					$(INTE_CFG.trigger).show();
				}
			});
			I.bouton.estOuvert();
		}
		catch (exc) {
			LnkLog.log('LnkWcb.inteBtn', exc);
		}
	}

	try {
		$(setupWcbTrigger);
	} catch (ignoredExc) {
		// LnkLog.log('integration LnkWcbBouton', ignoredExc);
	}
})();


