(function () {
	/* ********** DEBUT CONFIG ********** */
	var INTE_CFG = {
			canal: LnkWcb.jQuery('.LnkWcbForm-canal').val() || 'DECOMPRESS0001',
			// 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=550,height=388,' +
				'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+"?CODEBOUTON="+encodeURIComponent(INTE_CFG.canal), 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.useHttps(document.location.protocol === 'https:');
			I.bouton.onChannelState(function (etat, etatOuverture) { // masquer le bouton en canal inactif ou hors-limites
				if (!etat.estActif || !etat.peutRecevoirAppel || etatOuverture === "FERME"  || etatOuverture === "FERIE") {
					$('.LnkWcbForm-trigger').hide();
					I.montrerBouton = false;
				}
				else { 
				$('.LnkWcbForm-trigger').show();
				I.montrerBouton = true;
			
				}
			});
			
			I.bouton.estOuvert();
		}
		catch (exc) {
			LnkLog.log('LnkWcb.inteBtn', exc);
		}
	}

	try {
		$(setupWcbTrigger);
	} catch (ignoredExc) {
		// LnkLog.log('integration LnkWcbBouton', ignoredExc);
	}
})();


