/* Package lmd_lib
 * Generated on 2011-10-31T09:47:54+01:00
 * /jelec.js
 * /abonnes/services_abonnes.js
 * /lmd/init.js
 * /lmd/connection.js
 * /lmd/layout/menu.js
 * /lmd/layout/colright.js
 * /lmd/layout/header.js
 * /lmd/conf/layout/colright.js
 * /lmd/reaction/live.js
 * /lmd/element/toolbar.js
 * /lib/jquery/plugin/jquery.tinyTips.js
 * /lmd/social/facebook.js
 * /lmd/element/link_decorator.js
 */


/* ----- start file /jelec.js ----- */
/**
 * Ouverture du jelec
 */
function ouvrir_jelec(aaaammjj, cahier, double_page)
{
   var now = new Date();
   var ext = '?';
   if(cahier)
   {
      ext = ext + 'cahier=' + cahier;
   }
   
   if(double_page)
   {
      if(cahier)
      {
         ext = ext + '&';
      }
      ext = ext + 'double_page_direct=' + double_page;
   }
   var wd = window.open('http://www.lemonde.fr/journalelectronique/donnees/libre/'+aaaammjj+'/index.html' + ext, 'jelec'+now.getTime(), 'status=no,width='+screen.width+',height='+screen.height+',scrollbar=no,resizable=yes');
   wd.moveTo(0,0);

   if(document.all)
   {
      if (navigator.userAgent.toLowerCase().indexOf('mac') != -1)
      {
         wd.resizeTo(screen.availWidth, screen.availHeight);
      }
   }
   else
   {
      wd.outerHeight = screen.availHeight;
      wd.width = screen.availWidth;
   }

   wd.focus();
}

/* ----- start file (subscribers) /abonnes/services_abonnes.js ----- */
if (undefined===window.MIA)
{
   var MIA = {};
}

MIA.Class_ServicesAbonnes = MiaClass.inherits(
{
   construct : function()
   {
      // Array view information from the user (previously read from the cookie info_user_web)
      this._infoInUserCookie = null;
      
      this._majAjaxEnclenchee = false;
      
      // list of callback (which are called after the maj es AJAX cookies)
      this._callbackSuccesFonctionsMaj = new Array();
   },
   
   /*
    * Test existence of personal cookie (or single subscriber authenticates)
    * @acces : public
    */
   testerExistenceCookiePerso : function()
   {
      var val_cook_temp = GetCookie('info_user_web');
      var val_cook_id   = GetCookie('tdb_user_id');
      var dtstamp = new Date();
      var tstamp = dtstamp.getTime();

      if (((val_cook_temp != null) && (val_cook_temp != "")) && ((val_cook_id != null) && (val_cook_id != ""))) 
      {
         try
         {  
            $evaluation_cookie = eval("(" + val_cook_temp + ")");
         }
         catch (e)
         {
            //si on a un ancien cookie le test repond false, on considere alors que le cookie n existe pas
            return false;
         }
         if (typeof $evaluation_cookie['info_usr'] != undefined)
            return true;
      } 
      return false;
   },
   
   
   /*
    * Adding content to a topic to the cookie info_user_web
    */ 
   addInfoInUserCookie : function(rubrique, clef, valeur)
   {
      if (! this.testerExistenceCookiePerso())
         return 0;

      var info  = this.getInfoInUserCookie();
   
      if (typeof info[rubrique] == 'undefined')
      {
         info[rubrique] = {};
      }
      info[rubrique][clef] = valeur + "";
      
      
      //setting the cookie
      SetCookieTdb ('info_user_web', $.toJSON(info), 0);
      return info;
   },
   
   /*
    * Getter for the content of the cookie info_user_web
    */
   getInfoInUserCookie : function ()
   {
      if (this._infoInUserCookie == null)
      {
         this.chargerInfoDeUserCookie();
      }
      return this._infoInUserCookie;
   },
   
   /*
    * Recovery of personal cookie info
    * @acces : public
    */ 
   chargerInfoDeUserCookie : function()
   {
      var val_cook_temp = GetCookie('info_user_web');
      this._infoInUserCookie = eval("(" + val_cook_temp + ")");
   },
   
   /*
    * Callback in case of success of the update of the cookie by PHP
    * @acces : private
    */
   _callbackSuccesMajServices : function (html)
   {
      var ct = 0;
      this._majAjaxEnclenchee = false;  
      //set different days of the HTML interface
      for (ct = 0; ct < this._callbackSuccesFonctionsMaj.length; ct++)
      {
         this._callbackSuccesFonctionsMaj[ct]();
      
      }
      //this.mettreAjourOreillePersoGold();
      //this.activerBlocAbonnePremium();
   },
   
   /*
    * Adding a function to updates from the interface after the cookie maj
    * [ cf : _callbackSuccesMajServices() ]
    * @acces : private
    */
   ajouterFonctionMaj : function(func)
   {
      this._callbackSuccesFonctionsMaj.push(func);
   },
   
   /*
    * Callback in the event of failure to update the cookie by PHP
    * @acces : private
    */
   _callbackEchecMajServices : function (XMLHttpRequest, textStatus, errorThrown)
   {
      //{ alert( "maj Billing Error: " + errorThrown + ' ' + textStatus  + '.' ); }
   },
   
   /*
    * Call Ajah to a php page updating subscribers cookies
    * @acces : public
    */
   mettreAJourServices : function()
   {
      if (! this.testerExistenceCookiePerso()) 
      {
         var user_id = GetCookie('tdb_user_id');
         var closure = this;
         if ((user_id != null) && (user_id != "")) 
         {
            // call ajax
            //it is informed that a maj enclanchee
            this._majAjaxEnclenchee = true;            
            var url_maj_service = "/services/maj_services.html";
            $.ajax({
                     url: url_maj_service,
                     cache: false,
                     success: 
                        function(html) {closure._callbackSuccesMajServices(html);},
                     error:
                        function(XMLHttpRequest, textStatus, errorThrown)
                           {closure._callbackEchecMajServices(XMLHttpRequest, textStatus, errorThrown);} });
         }
      }
   },
   
   testerMiseAJourAjaxEnclenchee : function(str)
   {
      return this._majAjaxEnclenchee;
   },
   
   testerExistenceInfo : function (str)
   {
      // is forced to read.
      this.getInfoInUserCookie();
      
      return(  typeof this._infoInUserCookie != 'undefined' && 
               (this._infoInUserCookie != null) && 
               typeof this._infoInUserCookie[str] != 'undefined');
   }
});

// Call for updating services
MIA.ServicesAbonnes = new MIA.Class_ServicesAbonnes();
MIA.ServicesAbonnes.mettreAJourServices();
/* ----- start file /lmd/init.js ----- */
/**
 * Le Monde
 * Sets the namespace of the project isthmos
 * @author berge
 */

if(typeof LMD == "undefined" || !LMD){
    /**
     * the namespace of the project isthmos
     * @namespace the namespace of the project isthmos
     */
    var LMD = {};
};
/* ----- start min file /lmd/connection.js ----- */
LMD.Connection=Class.extend({init:function(){}});LMD.Connection.COOKIE_CONNECTION="tdb_user_abo";LMD.Connection.COOKIE_USER_INFO="info_user_web";LMD.Connection.COOKIE_WORDPRESS="wordpress_domain";LMD.Connection.COOKIE_SHARED_USER="shared_user";LMD.Connection.urlDestAbo="";LMD.Connection.urlDestPub="";LMD.Connection.isConnected=function(){return $.cookie(LMD.Connection.COOKIE_CONNECTION)!=null};
LMD.Connection.isSharedUser=function(){return LMD.Connection.isConnected()&&$.cookie(LMD.Connection.COOKIE_SHARED_USER)!=null};LMD.Connection.hasBlog=function(){return $.cookie(LMD.Connection.COOKIE_WORDPRESS)!=null};LMD.Connection.getBlogUser=function(){return $.cookie(LMD.Connection.COOKIE_WORDPRESS)};LMD.Connection.getUserInfos=function(){var a=$.cookie(LMD.Connection.COOKIE_USER_INFO),b={};a!=null&&a!=""&&(b=$.parseJSON(a));return b};
LMD.Connection.hasUserInfos=function(){var a=LMD.Connection.getUserInfos();return typeof a.info_user!="undefined"&&a.info_user};

/* ----- start file /lmd/connection.js ----- */
/**
 * Isthmos
 * connecting users to the isthmos.gr
 * @author berge
 */
 
/**
 * Connection
 * @class Connection
 */
LMD.Connection = Class.extend(
{
   /**
    * @scope LMD.Connection
    */
   
   /**
    * Constructeur
    */
   init : function()
   {
   
   }
});

/**
 * Name of the login cookie
 * @static
 * @type string
 */
LMD.Connection.COOKIE_CONNECTION = 'tdb_user_abo';

/**
 * Cookie name of user information
 * @static
 * @type string
 */
LMD.Connection.COOKIE_USER_INFO = 'info_user_web';

/**
 * Cookie name wordpress
 * @static
 * @type string
 */
LMD.Connection.COOKIE_WORDPRESS = 'wordpress_domain';

/**
 * Cookie name shared user 
 * @static
 * @type string
 */
LMD.Connection.COOKIE_SHARED_USER = 'shared_user';

/**
 * Url destination subscriber
 * @type string
 */
LMD.Connection.urlDestAbo = "";

/**
 * Url destination visitor
 * @type string
 */
LMD.Connection.urlDestPub = "";

/**
 * Test if the user is logged or not 
 * @static
 * @returns {boolean}
 */
LMD.Connection.isConnected = function()
{
   return $.cookie(LMD.Connection.COOKIE_CONNECTION) != null;
};

/**
 * Test if the user is a shared user
 * @static
 * @returns {boolean}
 */
LMD.Connection.isSharedUser = function()
{
   return LMD.Connection.isConnected() && $.cookie(LMD.Connection.COOKIE_SHARED_USER) != null;
};

/**
 * Test if the user possible a blog
 * @static
 * @returns {boolean}
 */
LMD.Connection.hasBlog = function()
{
   return $.cookie(LMD.Connection.COOKIE_WORDPRESS) != null;
};


/**
 * RÃ©cupÃ¨re l'utilisateur blog
 * @static
 * @returns {string}
 */
LMD.Connection.getBlogUser = function()
{
   return $.cookie(LMD.Connection.COOKIE_WORDPRESS);
};

/**
 * Retourne le cookie d'information utilisateur
 * @static
 * @returns {object}
 */
LMD.Connection.getUserInfos = function()
{
   var cookie = $.cookie(LMD.Connection.COOKIE_USER_INFO);
   var jsonData = {};
   
   if(cookie != null && cookie != '')
   {
      jsonData = $.parseJSON(cookie);
   }
   
   return jsonData;
};

/**
 * Teste si l'utilisateur a des informations
 * @static
 * @returns {boolean}
 */
LMD.Connection.hasUserInfos = function()
{
   var userInfos = LMD.Connection.getUserInfos();
   
   return (typeof userInfos.info_user != "undefined" && userInfos.info_user);
};

/* ----- start file /lmd/layout/menu.js ----- */
/**
 * Menu
 * the main menu of the site
 * @author berge
 */

if(typeof LMD.Layout == "undefined" || !LMD.Layout){
    /**
     * Le namespace du layout
     * @namespace Le namespace du layout
     */
    LMD.Layout = {};
};

LMD.Layout.X = {};

LMD.Layout.X.Click = {
   niveau2: "",
   chapitre: "",
   clickTag: "",
   setNiveau2: function(level2){LMD.Layout.X.Click.niveau2=level2;},
   setChapitre: function(chap){LMD.Layout.X.Click.chapitre=chap;},
   setClickTag: function(c){LMD.Layout.X.ClickTag=c;},
   getChapitreF: function(){return (LMD.Layout.X.Click.chapitre?LMD.Layout.X.Click.chapitre+"::":"");},
   getNiveau2: function(l2_def){l2_def||(l2_def=""); return (LMD.Layout.X.Click.niveau2 ? LMD.Layout.X.Click.niveau2 : l2_def);},
   renderClickTag: function(c){return LMD.Layout.X.Click.getChapitreF()+c;}
};

/**
 * Le Menu
 * @class Menu
 */
LMD.Layout.Menu = Class.extend(
{
   /**
    * @scope LMD.Layout.Menu
    */
   
   /**
    * Url de debrief
    * @type string
    */
   debriefUrl : "",
   
   /**
    * Constructeur
    * @param {string} debriefUrl Url du debrief
    */
   init : function(debriefUrl, pagePersoUrl)
   {
      this.debriefUrl = debriefUrl;
         
      //Affichage de la partie abonnÃ©
      if(LMD.Connection.isConnected())
      {
        
         //Affichage du debrief
         if(this.isOpenSync() || $.cookie(LMD.Layout.Menu.COOKIE_DEBRIEF_CLOSE) == null)
         {
            this.showDebrief();
         }
         
         this.removeOpenSync();
         this.addCloseCookie();
      }

      $(".lien_debrief > a").click($.proxy(function(e){$(e.currentTarget).parent().find('ul').hide();$(e.currenTarget).parent().removeClass('sfHover'); this.toggleDebrief();return false;}, this));
      $("a.lien_debrief").click($.proxy(function(e){$(e.currentTarget).parents('ul.niveau2').hide();this.toggleDebrief();return false;}, this));
      
   },
   
   /**
    * Added download ¢ Ches dynamic IE9
    * @param {object} data DonnÃ©es
    */
   addDynamicMsTask : function(data)
   {
      try {
         if (window.external != undefined && window.external.msIsSiteMode())
         {
             var g_ext = window.external;
             g_ext.msSiteModeClearJumpList();
             g_ext.msSiteModeCreateJumpList("Τώρα");
             for(var i=0,il=data.length;i<il;i++)
             {
                var no_entities_nom = $("<div>").html(data[i].nom).text();
                g_ext.msSiteModeAddJumpListItem(no_entities_nom, data[i].url, "../imgs/turtle-48x48.png");
             }
         }
     }
     catch (ex) {}
   },
   
   /**
    * Posse cookie synchronized opening ©
    * @returns {boolean}
    */
   isOpenSync : function()
   {
      return $.cookie(LMD.Layout.Menu.COOKIE_DEBRIEF_OPEN) != null;
   },
   
   /**
    * Add the cookie synchronized opening e
    */
   addOpenSync : function()
   {
      $.cookie(LMD.Layout.Menu.COOKIE_DEBRIEF_OPEN, "1");
   },
   
   /**
    * Removes the synchronized opening © e
    */
   removeOpenSync : function()
   {
      $.cookie(LMD.Layout.Menu.COOKIE_DEBRIEF_OPEN, null);
   },
   
   /**
    * A link to rollOver
    * @event
    * @param {object} e EvÃ¨nement
    */
   onHoverLink : function(e)
   {
      var idAr = $(e.currentTarget).parent().attr("id").split('-');
      var id = Number(idAr[idAr.length - 1]);
      this.show(id);
   },
   
      
   /**
    * Affichage du debrief
    * @returns {boolean}
    */
   showDebrief : function()
   {
      //No display on personal pages are © edition
      if (  document.location.href.indexOf('/admin/', 0) >= 0 ||
            document.location.href.indexOf('/contre_enquete/', 0) >= 0 ||
            document.location.href.indexOf('/thematique/', 0) >= 0 ||
            document.location.href.indexOf('/collection/', 0) >= 0 )
      {
         return 0;
      }
      
      if($("#debrief-container").html() == "")
      {
         $.get(this.debriefUrl, null, $.proxy(this.getDebriefCallBack, this));
      }
      else
      {
         $("#debrief-container").slideDown();
      }
   },
   
   /**
    * At the reception data © ra
    * @param {object} data 
    * @param {string} textStatus Status
    */
   getDebriefCallBack : function(data, textStatus)
   {
      $("#debrief-container").html(data).addClass("level3").slideDown();
   },
   
   /**
    * Masquer le debrief
    */
   hideDebrief : function()
   {
      $("#debrief-container").slideUp();
   },
   
   /**
    * Added cookie closing
    */
   addCloseCookie : function()
   {
      $.cookie(LMD.Layout.Menu.COOKIE_DEBRIEF_CLOSE, '1', {expires: 3});
   },
   
   toggleDebrief : function()
   {
      if($("#debrief-container:hidden").length)
      {
         this.showDebrief();
      }
      else
      {
         this.hideDebrief();
      }
   }
});

/**
 * Name of the cookie debrief
 * @type string
 */
LMD.Layout.Menu.COOKIE_DEBRIEF_OPEN = 'cqjl_open';

/**
 * cookie debrief
 * @type string
 */
LMD.Layout.Menu.COOKIE_DEBRIEF_CLOSE = 'cqjl_close';

/* ----- start min file /lmd/layout/colright.js ----- */
if(typeof LMD.Layout=="undefined"||!LMD.Layout)LMD.Layout={};
if(typeof LMD.Layout.ColRight!="undefined"||!LMD.Layout.ColRight)LMD.Layout.ColRight=Class.extend({uri:null,tags:[],pubUniqueNumber:0,descriptor:null,typeBlocIds:null,maxVisibleHeight:0,inRequest:false,completeLoad:false,lazyloadOn:false,debugOn:false,optimiserInlines:true,paused:false,pauseStart:null,retryTimer:null,init:function(a,b){if(a!==null)this.uri=a;if(b!==null)this.tags=b;this.typeBlocIds=this.getBlocTypes();this.activeLazyload();this.checkUrlParams();MIA.log("[INIT]")},activeLazyload:function(){$.browser.msie||
this.lazyload()},activeOptimInlineBlocs:function(){if($.browser.msie)this.optimiserInlines=false},checkUrlParams:function(){var a=MIA.Util.getQueryParams();a.lazyload=="true"&&this.lazyload();a.debug=="true"&&this.debug()},start:function(){$.get(this.uri,null,$.proxy(this.getDescriptorCallBack,this),"json");return this},getBlocTypes:function(){var a=LMD.Conf.Layout.ColRight.tagTypeLibelleToId.niveau_0,b=this.tags.filter(function(b){return b.S_typeTagId==a}).pop(),b=b?b.S_urlFriendly:"unknown";switch(b){case "sport":case "idees":case "voyage":return LMD.Conf.Layout.ColRight.typeBlocByTagUrlFriendly[b];
default:return LMD.Conf.Layout.ColRight.typeBlocByTagUrlFriendly["*"]}},getDescriptorCallBack:function(a,b){MIA.log("> getDescriptorCallBack");if(a&&b=="success")this.descriptor=a,this.hideInlineBlocks(),this.render(),$(window).scroll($.proxy(this.onWindowScrolling,this))},hideInlineBlocks:function(){this.descriptor.blocks.forEach(function(a){a.metadata.resource=="inline"&&$("#colDroite > div").each(function(){$(this).attr("uri")==a.metadata.uri&&$(this).hide()})})},onWindowScrolling:function(){this.render()},
render:function(){MIA.log("[RENDER]");!this.inRequest&&!this.completeLoad&&!this.paused&&(!this.lazyloadOn||this.getVisibleHeight()>this.getInsertedBlocksHeight())&&this.getNextBlock()},getVisibleHeight:function(){$window=$(window);var a=$window.scrollTop()+$window.height()-$("#colDroite").offset().top;if(this.maxVisibleHeight<a)this.maxVisibleHeight=a;return this.maxVisibleHeight+LMD.Conf.Layout.ColRight.adjustLazyLoad},getInsertedBlocksHeight:function(){for(var a=0,b=$("#colDroite *[processed=true]"),
c=0,d=b.length,e;c<d;c++){var f=b.eq(c);f.attr("cached_height")?e=parseInt(f.attr("cached_height"),10):(e=f.outerHeight(true))&&f.attr("cached_height",e);a+=e+15}return a},getNextBlock:function(){if(!this.paused)if(this.inRequest=true,MIA.log("[GET BLOCK] : "),MIA.log(this.typeBlocIds),this.typeBlocIds.length==0){MIA.log("[EMPTY ORDER]");for(var a=0,b=this.descriptor.blocks.length;a<b;a++)if(d=this.descriptor.blocks[a],typeof d.status=="undefined"){MIA.log("[UNINSERTED BLOCK REQUEST]");this.requestBlock(d);
return}this.finish()}else{var c=this.typeBlocIds.shift(),d;if(c==1)this.insertPub(),this.inRequest=false,this.render();else{a=0;for(b=this.descriptor.blocks.length;a<b;a++)if(d=this.descriptor.blocks[a],d.metadata.type==LMD.Conf.Layout.ColRight.typeBlocIdToName[c]&&(typeof d.status=="undefined"||d.status=="retried")){this.requestBlock(d);return}this.getNextBlock()}}},getRandomBlock:function(a){for(var b,c=0,d=[],e,f=new Date,g=0,i=a.metadata.randomBlocks.length;g<i;g++){e=a.metadata.randomBlocks[g];
b=[];for(var h=Number(e.metadata.weight);h>0;h--)b.push(g);d=d.concat(b);c+=Number(e.metadata.weight)}return a.metadata.randomBlocks[d[f.getTime()%c]]},requestBlock:function(a){a.status="requested";a.metadata.random=="1"&&(a=this.getRandomBlock(a));if(typeof a.value=="string"&&a.value.length>0)this.processBlock(a,a.value);else if(a.metadata.resource=="distant")MIA.log("[REQUEST] remote >"+a.metadata.uri),$.ajax({url:a.metadata.uri,data:null,dataType:"html",timeout:LMD.Conf.Layout.ColRight.remoteTimeout,
success:$.proxy(function(b){this.processBlock(a,b)},this),error:$.proxy(function(b,c){this.processBlock(a,"<\!-- error XHR : "+c+"--\>")},this)});else if(a.metadata.resource=="inline"){MIA.log("[REQUEST] inline > "+a.metadata.uri);var b=this,c=false;$("#colDroite > div").each(function(){$(this).attr("uri")==a.metadata.uri&&(c=true,b.processBlock(a,this))});if(!c)MIA.log("[ERROR] inline bloc "+a.metadata.uri+" does not exist. check /api/.. uri Vs inline uri."),a.status="received"}},processBlock:function(a,
b){MIA.log("[BLOCK RECEIVED] : "+a.metadata.uri+" ("+a.metadata.type+")");a.value=b;a.status="received";try{this.insertBlock(a)}catch(c){a.status="inserted"}this.inRequest=false;this.render()},insertBlock:function(a){if(this.isThereAnySpaceLeft()){a.status="inserted";if(a.metadata.resource=="inline"){MIA.log("[BLOCK INSERT] : moving inline bloc "+a.metadata.type);var b=$(a.value);if(this.optimiserInlines)$(a.value).show().moveIn("#colDroite"),b.attr("processed","true");else{var c=b.html();b.remove();
$("#colDroite").append('<div processed="true" uri="'+a.metadata.uri+'">'+c+"</div>")}}else MIA.log("[BLOCK INSERT] : appending distant bloc "+a.metadata.type),$("#colDroite").append('<div processed="true" uri="'+a.metadata.uri+'">'+a.value+"</div>");this.putUnprocessedToEnd()}else MIA.log("[BLOCK INSERT] : cannot insert"),this.requeueBloc(a),this.waitSpace()},waitSpace:function(){MIA.log("[PAUSED]");this.paused=true;this.pauseStart=(new Date).getTime();this.retryTimer=setInterval($.proxy(this.retryTimerTick,
this),LMD.Conf.Layout.ColRight.retryTimerValue)},retryTimerTick:function(){MIA.log("[RETRY TIMER TICK]");this.isThereAnySpaceLeft()?(MIA.log("[SPACE LEFT : unpaused]"),this.paused=false,this.getNextBlock(),clearInterval(this.retryTimer)):(new Date).getTime()-this.pauseStart>LMD.Conf.Layout.ColRight.retryTimeout&&(MIA.log("[CLEAR TIMER]"),clearInterval(this.retryTimer),this.finish())},requeueBloc:function(a){MIA.log("[BLOCK REQUEUE] "+a.metadata.type);this.typeBlocIds.unshift(this.typeNametoId(a.metadata.type));
a.status="retried";MIA.log(this.typeBlocIds)},typeNametoId:function(a){for(var b=0,c=LMD.Conf.Layout.ColRight.typeBlocIdToName.length;b<c;b++)if(a==LMD.Conf.Layout.ColRight.typeBlocIdToName[b])return b;return false},insertPub:function(){MIA.log("[BLOCK INSERT] : pub");var a=$("#colDroite > .pub[processed!=true]").first();a&&(a.moveIn("#colDroite"),a.attr("processed","true"))},putUnprocessedToEnd:function(){MIA.log("[PUB TO END]");$("#colDroite > [processed!=true]").each(function(){$(this).moveIn("#colDroite")})},
finish:function(){for(MIA.log("[FINISH]");$("#colDroite > .pub[processed!=true]").length!=0;)this.insertPub();$("#colDroite > [processed!=true]").hide();this.completeLoad=true;$(window).unbind("scroll",$.proxy(this.onWindowScrolling,this))},lazyload:function(a){typeof a=="undefined"&&(a=true);this.lazyloadOn=a;return this},debug:function(a){typeof a=="undefined"&&(a=true);this.debugOn=a;MIA.debug=a;return this},isThereAnySpaceLeft:function(){var a,b;a=$(".col_gauche").length?$(".col_gauche"):$("#LM_content");
b=$("#colDroite");a=a.length&&b.length?a.outerHeight()+LMD.Conf.Layout.ColRight.marge:"unlimited";b=b.outerHeight();MIA.log("isThereAnySpaceLeft : "+b+" < "+a+" ?");return a=="unlimited"||b<a}});
if(typeof LMD.Layout.ColRight.LesPlus=="undefined"||!LMD.Layout.ColRight.LesPlus)LMD.Layout.ColRight.LesPlus=Class.extend({init:function(){new MIA.Ui.Tab("lesPlusBlock","lesplus");$("#lesPlusBlock .since-links a").click(function(){return false});var a={over:$.proxy(this.onHoverSince,this),timeout:500,out:function(){}};$("#lesPlusBlock .since-links a").hoverIntent(a)},onHoverSince:function(a){$(a.target).parent().find("a").removeClass("active");$(a.target).addClass("active");$(a.target).parent().parent().find(".since-content").hide();
$(a.target.hash).show()}});
if(typeof LMD.Layout.ColRight.Sondage=="undefined"||!LMD.Layout.ColRight.Sondage)LMD.Layout.ColRight.Sondage=Class.extend({endSondage:0,cookieName:"",noVoteContent:"",voteContent:"",init:function(){},generate:function(){!this.endSondage&&$.cookie(this.cookieName)!="1"?$("#sondage-block-container").html(this.noVoteContent):$("#sondage-block-container").html(this.voteContent);$("#sondage-block-container form").submit($.proxy(this.validForm,this))},validForm:function(){if($("#sondage-block-container form input[type=radio]:checked").length>0)return $.cookie(this.cookieName,
1,{expires:7,domain:"lemonde-dev.fr"}),xt_med("C",$("#sondage-block-container .click-level").html(),$("#sondage-block-container .click-marquer").html(),"N"),true;else alert(MIA.Util.utf8_decode("Veuillez s\u00e9lectionner une r\u00e9ponse."));return false}});
if(typeof LMD.Layout.ColRight.Blogs=="undefined"||!LMD.Layout.ColRight.Blogs)LMD.Layout.ColRight.Blogs=Class.extend({dataObjects:null,dataId:null,blockHeight:null,init:function(a,b){$("#blogContentId").ready($.proxy(function(){this.dataObjects=$.parseJSON(a);this.dataId=this.dataObjects.map(function(a){return a.id});this.blockHeight=Number(b);this.generate();$("#blogContentId").scroll($.proxy(this.generate,this))},this))},generate:function(){$("#blogContentId");var a=$("#blogContentId").scrollTop(),
b=a+$("#blogContentId").height(),c,d,e=0,f=this.dataObjects.filter($.proxy(function(g){g=this.dataId.indexOf(g.id);if(g<=4)return true;c=g*this.blockHeight;e+=this.blockHeight;d=c+this.blockHeight;return c>=a&&c<b||d>a&&d<b},this));f.forEach(function(a){$("<img />").bind("load",function(){$("#"+a.id).attr("src",a.src).show();$("#"+a.id+"Throbber").hide()}).attr("src",a.src)});this.dataObjects=this.dataObjects.notIn(f)}});
if(typeof LMD.Layout.ColRight.MoreInfoSingleton=="undefined"||!LMD.Layout.ColRight.MoreInfoSingleton)LMD.Layout.ColRight.MoreInfoSingleton={instance:null,loaded:false,getInstance:function(){if(null==LMD.Layout.ColRight.MoreInfoSingleton.instance)LMD.Layout.ColRight.MoreInfoSingleton.instance=new LMD.Layout.ColRight.MoreInfo;return LMD.Layout.ColRight.MoreInfoSingleton.instance}};
if(typeof LMD.Layout.ColRight.MoreInfo=="undefined"||!LMD.Layout.ColRight.MoreInfo)LMD.Layout.ColRight.MoreInfo=Class.extend({dispatcher:null,init:function(){this.dispatcher=new LMD.Layout.ColRight.MoreInfoEventDispatcher},go:function(a){a=$("#blockRightCallTagItem_"+a);a.length&&a.parents("li").hide();$(".liste_simple li","#blockRightCallTag_Id").length-a.length===0&&$("#blockRightCallTag_Id").remove()},load:function(){}});
if(typeof LMD.Layout.ColRight.MoreInfoEvent=="undefined"||!LMD.Layout.ColRight.MoreInfoEvent)LMD.Layout.ColRight.MoreInfoEvent=MIA.Event.extend({}),LMD.Layout.ColRight.MoreInfoEvent.LOADED="loaded",LMD.Layout.ColRight.MoreInfoEventDispatcher=MIA.EventDispatcher.extend({});

/* ----- start file /lmd/layout/colright.js ----- */
/**
 * ColRight
 * Everything concerning the right column, 
 * and some scripts © s call for some blocks (to outsource)
 * @author berge
 */

if(typeof LMD.Layout == "undefined" || !LMD.Layout){
    /**
     * The namespace's layout
     * @namespace The namespace's layout
     */
    LMD.Layout = {};
};

if(typeof LMD.Layout.ColRight != "undefined" || !LMD.Layout.ColRight){
   /**
   * Assembly features of the new right-hand column
   * Setting up pages :
   * - Elements
   * 
   * @class ColRight
   */
   LMD.Layout.ColRight = Class.extend(
   {
      /**
      * @scope LMD.Layout.ColRight
      */
      
      /**
      * Url © da ending flow of coldte
      * @type string
      */
      uri : null,
      
      /**
      * Tableau de tags de contexte
      * @type array
      */
      tags : [],
      
      /**
      * unique number tied to the pub
      * @type int
      */
      pubUniqueNumber : 0,
      
      /**
      * the descriptor
      * @type object
      */
      descriptor : null,
      
      /**
      * Types de blocs
      * @type array
      */
      typeBlocIds : null,
      
      /**
      * Size of the right column visible
      * @type int
      */
      maxVisibleHeight : 0,
      
      /**
      * You being required ·
      * @type boolean
      */
      inRequest : false,
      
      /**
      * full load
      * @type boolean
      */
      completeLoad : false,
      
      /**
      * Activation of lazyload
      * @type boolean
      */
      lazyloadOn : false,
      
      /**
      * Debug active or not
      * @type boolean
      */
      debugOn : false,
      
      /**
      * Optimisation blocs inline
      * @type boolean
      */
      optimiserInlines : true,
      
      /**
       * Pausing of the system I
       */
      paused : false,
      
      /**
       * Time at which the break da © tired
       */
      pauseStart : null,
      
      /**
       * timer that tries to launch the system myself every X seconds
       */
      retryTimer : null,
      
      /**
      * Constructeur
      * @param {string}   uri   Url du flux dÃ©finissant la coldte
      * @param {array}    tags  Table of context tags
      */
      init : function(uri, tags)
      {
         if(uri !== null){ this.uri = uri; }
         if(tags !== null){ this.tags = tags; }
         
         this.typeBlocIds = this.getBlocTypes();
         
         this.activeLazyload();
         //this.activeOptimInlineBlocs();
         this.checkUrlParams();
         
         MIA.log('[INIT]');
      },
      
      /**
      * Activation du lazyload depending on the browser
      * the lazyload is activated by da © © if we have not found in IE
      */
      activeLazyload : function()
      {
         if(!$.browser.msie)
         {
            this.lazyload();
         }
      },

      /**
      * Enabling optimization browser webkit / gecko
      * we look at the contents page.
      * IE: bp aliasing when moving blocks (the aliasing problem link apparaÃ only ® t
      * when changing the opacity
      */
      activeOptimInlineBlocs : function ()
      {
         if ($.browser.msie)
            this.optimiserInlines = false;
      },

      /**
      * Look-settings in the url to put the lazyload or debug
      * - ?debug=true pour le mode debug
      * - ?lazyload=true pour le chargement lazyload
      */
      checkUrlParams : function()
      {
         var $_GET = MIA.Util.getQueryParams();
         
         if($_GET['lazyload'] == "true")
         {
            this.lazyload();
         }
         
         if($_GET['debug'] == "true")
         {
            this.debug();
         }
      },
      
      /**
      * Fonction de dÃ©marrage
      * @returns {LMD.Layout.ColRight}
      */
      start : function()
      {
         $.get(this.uri, null, $.proxy(this.getDescriptorCallBack, this), 'json');
         
         return this;
      },
      
      /**
      * Depending on the tag level 0, this function will look in conf block types can be displayed in the right neck.
      * 
      * @param      tags     tableau des tags liÃ©s Ã  l'Ã©lÃ©ment
      * @returns    {array}  array[id, id, ..., id] id des types de blocs.
      */
      getBlocTypes : function()
      {
         var typeTagIdN0 = LMD.Conf.Layout.ColRight.tagTypeLibelleToId['niveau_0'];
         var tagN0 = this.tags.filter(function (tag) { return tag['S_typeTagId'] == typeTagIdN0; }).pop();
         var tagN0UrlFriendly = (tagN0) ? tagN0['S_urlFriendly'] : 'unknown';

         switch (tagN0UrlFriendly) {
            case 'sport' :
            case 'idees' :
            case 'voyage':
               return LMD.Conf.Layout.ColRight.typeBlocByTagUrlFriendly[tagN0UrlFriendly];
               break;
            default :
               return LMD.Conf.Layout.ColRight.typeBlocByTagUrlFriendly['*'];
               break;
         }
         
         return ;
      },
      
      /**
      * AppelÃ© lors de la rÃ©ception du descripteur
      * @param {object} data DonnÃ©es retournÃ©es
      * @param {string} textStatus Status
      */
      getDescriptorCallBack : function(data, textStatus)
      {
         MIA.log('> getDescriptorCallBack');
         
         if(data && textStatus == "success")
         {
            this.descriptor = data;
            
            //On cache les blocs inline pour crÃ©er une nouvelle colonne
            this.hideInlineBlocks();
            
            //Premier rendu de la colonne
            this.render();
            
            //EvÃ¨nement sur scroll
            $(window).scroll($.proxy(this.onWindowScrolling, this));
         }
      },
      
      /**
      * Permet de cacher les blocs inline
      */
      hideInlineBlocks : function()
      {
         this.descriptor.blocks.forEach(function (bloc)
         {
            if (bloc.metadata.resource == 'inline')
            {
               $("#colDroite > div").each(function (index)
               {
                  if ($(this).attr('uri') == bloc.metadata.uri)
                  {
                     $(this).hide();
                     //$(this).css('opacity', 0);
                  }
               });
            }
         });
      },
      
      /**
      * Au scroll sur l'objet window
      * @param {object} e EvÃ¨nement
      */
      onWindowScrolling : function(e)
      {
         this.render();
      },
      
      /**
      * Moteur de rendu de la colonne de droite
      */
      render : function()
      {
         MIA.log('[RENDER]');
         
         if(!this.inRequest && !this.completeLoad && !this.paused)
         {
            if(!this.lazyloadOn || (this.getVisibleHeight() > this.getInsertedBlocksHeight()))
            {
               this.getNextBlock();
            }
         }
      },
      
      /**
      * Renvoit la taille de la colonne visible
      * @returns {int}
      */ 
      getVisibleHeight : function()
      {
         $window = $(window);
         var visibleHeight = $window.scrollTop() + $window.height() - $("#colDroite").offset().top;
         
         if(this.maxVisibleHeight < visibleHeight)
         {
            this.maxVisibleHeight = visibleHeight;
         }
         
         return this.maxVisibleHeight + LMD.Conf.Layout.ColRight.adjustLazyLoad;
      },
      
      /**
      * Renvoit la taille de tous les blocs insÃ©rÃ©s
      * @returns {int}
      */
      getInsertedBlocksHeight : function()
      {
         var totalHeight = 0;
         
         var processedBlocks = $("#colDroite *[processed=true]");
         for(var i=0,il=processedBlocks.length,h;i<il;i++)
         {
            var b = processedBlocks.eq(i);
            if (b.attr("cached_height"))
            {
               h = parseInt(b.attr("cached_height"), 10);
            }
            else
            {
               h = b.outerHeight(true);
               if (h)
                  b.attr("cached_height", h);
            }
            totalHeight += h + 15; // marge moyenne.
         }
         
         return totalHeight;
      },
      
      /**
      * RÃ©cupÃ©ration du bloc suivant
      */
      getNextBlock : function()
      {
         if(this.paused)
         {
            return ;
         }
         
         this.inRequest = true;
         
         MIA.log('[GET BLOCK] : ');
         MIA.log(this.typeBlocIds);
         

         if(this.typeBlocIds.length == 0)
         {
            MIA.log('[EMPTY ORDER]');
            
            for(var i=0,il=this.descriptor.blocks.length;i<il;i++)
            { 
               block = this.descriptor.blocks[i];
               
               if(typeof block.status == "undefined")
               {
                  MIA.log('[UNINSERTED BLOCK REQUEST]');
                  
                  this.requestBlock(block);
                  return ;
               }
            }
            
            this.finish();
            return ;
         }
         
         var nextBlockTypeId = this.typeBlocIds.shift();
         var block;
         
         if(nextBlockTypeId == 1)
         {
            this.insertPub();
            
            this.inRequest = false;
            
            this.render();
            
            return ;
         }
         else
         {         
            for(var i=0,il=this.descriptor.blocks.length;i<il;i++)
            { 
               block = this.descriptor.blocks[i];
               
               if(block.metadata.type == LMD.Conf.Layout.ColRight.typeBlocIdToName[nextBlockTypeId] && (typeof block.status == "undefined" || block.status == "retried"))
               {
                  this.requestBlock(block);
                  return ;
               }
            }
            
            this.getNextBlock();
         }
      },
      
      /**
       * Retourne un bloc dans le bloc alÃ©atoire
       * @param {array} block Le bloc
       * @returns {array} Le bloc choisit alÃ©atoirement
       */
      getRandomBlock : function(block)
      {
         var fill_tmp_array, weight_sum = 0, random_block_tmp_array = [], random_block_tmp, d = new Date();
         
         for(var i=0,il=block['metadata']['randomBlocks'].length;i<il;i++)
         {
            random_block_tmp = block['metadata']['randomBlocks'][i];
            
            fill_tmp_array = [];
            for(var j=Number(random_block_tmp['metadata']['weight']);j>0;j--)
            {
               fill_tmp_array.push(i);
            }
            
            random_block_tmp_array = random_block_tmp_array.concat(fill_tmp_array);
            weight_sum += Number(random_block_tmp['metadata']['weight']);
         }
         
         return block['metadata']['randomBlocks'][random_block_tmp_array[d.getTime() % weight_sum]];
      },
      
      /**
      * Appel d'un bloc
      * @param {object} bloc L'objet bloc Ã  appeler
      */
      requestBlock : function(bloc)
      {
         bloc.status = 'requested';
         
         //Gestion des blocs randoms
         if(bloc.metadata.random == '1')
         {
            bloc = this.getRandomBlock(bloc);
         }
         
         if(typeof bloc.value == "string" && bloc.value.length > 0)
         {
            this.processBlock(bloc, bloc.value);
            return ;
         }
         
         if (bloc.metadata.resource == 'distant')
         {
            MIA.log('[REQUEST] remote >' + bloc.metadata.uri);
            
            $.ajax({
               url: bloc.metadata.uri,
               data: null,
               dataType: 'html',
               timeout: LMD.Conf.Layout.ColRight.remoteTimeout,
               success: $.proxy(function (data)
               {
                  this.processBlock(bloc, data); 
               }, this),
               error : $.proxy(function (XMLHttpRequest, textStatus, errorThrown)
               {
                  this.processBlock(bloc, '<!'+ '-- error XHR : ' + textStatus + '-' + '->');
               }, this)
            });
         }
         else if (bloc.metadata.resource == 'inline')
         {
            MIA.log('[REQUEST] inline > ' + bloc.metadata.uri);
            
            var pthis = this;
            var inline = false;
            $("#colDroite > div").each(function (index)
            {
               if ($(this).attr('uri') == bloc.metadata.uri)
               {
                  inline = true;
                  pthis.processBlock(bloc, this);
               }
            });
            // gestion de l'erreur : decoordination entre HTML et JS flux.
            if (!inline) {
               MIA.log('[ERROR] inline bloc ' + bloc.metadata.uri + ' does not exist. check /api/.. uri Vs inline uri.');
               bloc.status = 'received';
            }
         }
      },

      /**
      * Fonction appelÃ©e aprÃ¨s la rÃ©ception d'un bloc
      * @param {objet} bloc Le bloc
      * @param {string} value Html du bloc
      */
      processBlock : function(bloc, value)
      {
         MIA.log('[BLOCK RECEIVED] : ' + bloc.metadata.uri + ' (' + bloc.metadata.type +')');
         
         //Stockage du HTML du bloc
         bloc.value = value;
         bloc.status = 'received';
         
         try {
            this.insertBlock(bloc);
         } catch (e) {
            bloc.status = 'inserted'; // failover.
         }
         
         this.inRequest = false;
         
         this.render();
      },
      
      /**
      * Insertion d'un bloc ou dÃ©placement (inline)
      * Bloc marketing ou editorial
      * L'insertion est dÃ©pendante de la taille de .col_gauche et .col_droite
      * 
      * @param {object}   bloc  Bloc Ã  insÃ©rer
      */
      insertBlock : function(bloc)
      {
         if (this.isThereAnySpaceLeft())
         {
            bloc.status = 'inserted';
            
            if (bloc.metadata.resource == 'inline')
            {
               MIA.log('[BLOCK INSERT] : moving inline bloc ' + bloc.metadata.type);
               var $inline_bloc = $(bloc.value);
               
               if (this.optimiserInlines)
               {
                  //$(bloc.value).css('opacity', 1).moveIn("#colDroite"); 
                  $(bloc.value).show().moveIn("#colDroite");
                  $inline_bloc.attr('processed', 'true');
               }
               else
               {
                  var s = $inline_bloc.html();
                  $inline_bloc.remove();
                  $("#colDroite").append('<div processed="true" uri="'+bloc.metadata.uri+'">'+s+'</div>');
               }
            }
            else
            {
               MIA.log('[BLOCK INSERT] : appending distant bloc ' + bloc.metadata.type);
               
               $("#colDroite").append('<div processed="true" uri="'+bloc.metadata.uri+'">'+bloc.value+'</div>');
            }

            this.putUnprocessedToEnd();
         }
         else
         {
            MIA.log('[BLOCK INSERT] : cannot insert');
            this.requeueBloc(bloc);
            this.waitSpace();
         }
      },
      
      /**
       * Mise en attente, et dÃ©clenchement d'un minuteur qui va voir
       * si de l'espace se libÃ¨re
       */
      waitSpace : function()
      {
         MIA.log("[PAUSED]");
         this.paused = true;
         this.pauseStart = new Date().getTime();
         this.retryTimer = setInterval($.proxy(this.retryTimerTick, this), LMD.Conf.Layout.ColRight.retryTimerValue);
      },
      
      /**
       * Le minuteur qui va voir si de l'espace se libÃ¨re appelle cette
       * fonction. Elle regarde si de l'espace est apparu pour le relancer
       * Elle intÃ¨gre aussi un timeout
       */
      retryTimerTick : function()
      {
         MIA.log("[RETRY TIMER TICK]");
         
         if(this.isThereAnySpaceLeft())
         {
            MIA.log("[SPACE LEFT : unpaused]");
            this.paused = false;
            this.getNextBlock();
            clearInterval(this.retryTimer);
            return ;
         }
         
         if(new Date().getTime() - this.pauseStart > LMD.Conf.Layout.ColRight.retryTimeout)
         {
            MIA.log("[CLEAR TIMER]");
            clearInterval(this.retryTimer);
            this.finish();
         }
      },
      
      /**
       * Remet le bloc dans la file d'attente
       * @param {object} bloc Bloc Ã  rÃ©insÃ©rer dans la file d'attente
       */
      requeueBloc : function(bloc)
      {
         MIA.log('[BLOCK REQUEUE] ' + bloc.metadata.type);
         var typeId = this.typeNametoId(bloc.metadata.type);
         this.typeBlocIds.unshift(typeId);
         bloc.status = "retried";
         MIA.log(this.typeBlocIds);
      },
      
      /**
       * Trouve l'id du type de bloc Ã  partir du nom du type de bloc
       * @param {string} name Le nom du type de bloc
       * @returns {int|boolean} Retourne l'id du type de bloc
       * ou bien false si aucun n'a Ã©tÃ© trouvÃ©
       */
      typeNametoId : function(name)
      {
         for(var i=0,il=LMD.Conf.Layout.ColRight.typeBlocIdToName.length;i<il;i++)
         {
            if(name == LMD.Conf.Layout.ColRight.typeBlocIdToName[i])
            {
               return i;
            }
         }
         
         return false;
      },
      
      /**
      * Insertion d'une publicitÃ©
      * les publicites sont encadrees par des descripteurs : <div class="pub" processed="..." container="...">
      * processed = true/false => publicite deja utilisee dans la colonne
      * container = iframe => publicite a charger dynamiquement.
      */
      insertPub : function()
      {
         MIA.log('[BLOCK INSERT] : pub');
         
         var pub = $('#colDroite > .pub[processed!=true]').first();
         
         if (pub)
         {
            pub.moveIn("#colDroite");
            //pub.css('opacity', 1);
            pub.attr('processed', 'true');
         }
      },

      /**
      * Place les publicitÃ©s non gÃ©rÃ©s Ã  la fin de la colonne
      */
      putUnprocessedToEnd : function()
      {
         MIA.log("[PUB TO END]");
         
         $('#colDroite > [processed!=true]').each(function()
         {
            $(this).moveIn("#colDroite");
         });
      },
      
      /**
      * MÃ©thode appelÃ©e en fin de chargement
      */
      finish : function()
      {
         MIA.log('[FINISH]');
         
         while($('#colDroite > .pub[processed!=true]').length != 0)
         {
            this.insertPub();
         }
         
         $('#colDroite > [processed!=true]').hide();
         
         this.completeLoad = true;
         $(window).unbind('scroll', $.proxy(this.onWindowScrolling, this));
      },
      
      /**
      * Activation du lazyload
      * @param {boolean} val Valeur
      * @returns {LMD.Layout.ColRight}
      */
      lazyload : function(val)
      {
         if(typeof val == "undefined"){ val = true; }
         this.lazyloadOn = val;
         
         return this;
      },
      
      /**
      * Activation ou dÃ©sactivation du debug
      * @param {boolean} val Valeur
      * @returns {LMD.Layout.ColRight}
      */
      debug : function(val)
      {
         if(typeof val == "undefined"){ val = true; }
         this.debugOn = val;
         MIA.debug = val;
         
         return this;
      },
      
      /**
      * Teste la longueur de l'article pour savoir s'il reste de la place
      * pour afficher la colonne de droite
      * @returns boolean
      */
      isThereAnySpaceLeft : function()
      {
         var $col_gauche, $col_droite;
         
         if ($(".col_gauche").length)
            $col_gauche = $(".col_gauche");
         else
            $col_gauche = $("#LM_content");
         
         $col_droite = $("#colDroite");
         
         var maxHeight = ($col_gauche.length && $col_droite.length) ? $col_gauche.outerHeight() + LMD.Conf.Layout.ColRight.marge : "unlimited";
         
         var blocs_height = $col_droite.outerHeight();
         
         MIA.log('isThereAnySpaceLeft : ' + blocs_height + ' < ' + maxHeight + ' ?');
         
         return maxHeight == "unlimited" || blocs_height < maxHeight;
      }
   });
}

if(typeof LMD.Layout.ColRight.LesPlus == "undefined" || !LMD.Layout.ColRight.LesPlus){
   /**
   * Les Plus
   * @class LesPlus
   */
   LMD.Layout.ColRight.LesPlus = Class.extend(
   {
      /**
      * @scope LMD.Layout.ColRight.LesPlus
      */
      
      /**
      * Constructeur
      */
      init : function()
      {
         //Initialisation des onglets
         new MIA.Ui.Tab("lesPlusBlock", "lesplus");
         
         $("#lesPlusBlock .since-links a").click(function(){ return false; });
         
         var configHi = {    
                  over: $.proxy(this.onHoverSince, this), // function = onMouseOver callback (REQUIRED)    
                  timeout: 500, // number = milliseconds delay before onMouseOut    
                  out: function(){} // function = onMouseOut callback (REQUIRED)    
            };
         
         $("#lesPlusBlock .since-links a").hoverIntent(configHi);
      },
      
      /**
      * Au click sur la section depuis
      * @event
      * @param {object} event EvÃ¨nement
      */
      onHoverSince : function(event)
      {
         $(event.target).parent().find('a').removeClass('active');
         $(event.target).addClass('active');
         $(event.target).parent().parent().find(".since-content").hide();
         
         $(event.target.hash).show();
      }
      
   });
}

if(typeof LMD.Layout.ColRight.Sondage == "undefined" || !LMD.Layout.ColRight.Sondage){
   /**
   * Sondage
   * @class Sondage
   */
   LMD.Layout.ColRight.Sondage = Class.extend(
   {
      /**
      * @scope LMD.Layout.ColRight.Sondage
      */
      
      /**
      * Sondage terminÃ© ou non
      * @public
      * @type int
      */
      endSondage : 0,
      
      /**
      * Nom du cookie
      * @public
      * @type string
      */
      cookieName : "",
      
      /**
      * Contenu si l'utilisateur n'a pas votÃ©
      * @public
      * @type string
      */
      noVoteContent : "",
      
      /**
      * Contenu si l'utilisateur a votÃ©
      * @public
      * @type string
      */
      voteContent : "",
      
      /**
      * Constructeur
      */
      init : function()
      {  
         
      },
      
      /**
      * GÃ©nÃ©ration du bloc
      */
      generate : function()
      {
         if(!this.endSondage && $.cookie(this.cookieName) != "1")
         {
            $("#sondage-block-container").html(this.noVoteContent);
         }
         else
         {
            $("#sondage-block-container").html(this.voteContent);
         }
         
         //EvÃ¨nement sur le submit
         $("#sondage-block-container form").submit($.proxy(this.validForm, this));
      },
      
      /**
      * Permet de contrÃ´ler si la personne a choisit au moins une rÃ©ponse
      * @event
      * @parem {object} e EvÃ¨nement
      * @returns {boolean}
      */
      validForm : function(e)
      {
         if($("#sondage-block-container form input[type=radio]:checked").length > 0)
         {
            $.cookie(this.cookieName, 1, {expires: 7, domain: 'lemonde-dev.fr'});
            xt_med("C", $("#sondage-block-container .click-level").html(), $("#sondage-block-container .click-marquer").html(), "N");
            return true;
         }
         else
         {
            alert(MIA.Util.utf8_decode("Veuillez sÃ©lectionner une rÃ©ponse."));
         }
         
         return false;
      }
   });
}

if(typeof LMD.Layout.ColRight.Blogs == "undefined" || !LMD.Layout.ColRight.Blogs){
   /**
   * Sondage
   * @class Sondage
   */
   LMD.Layout.ColRight.Blogs = Class.extend(
   {
      /**
      * @scope LMD.Layout.ColRight.Blogs
      */
      
      /**
      * DonnÃ©es des objets
      * @type object
      */
      dataObjects : null,
      
      /**
      * DonnÃ©es des id
      * @type object
      */
      dataId : null,
      
      /**
      * Hauteur des blocs images
      * @type int
      */
      blockHeight : null,
      
      /**
      * Constructeur
      * @param {string} data DonnÃ©es brutes
      * @param {int} height Hauteur
      */
      init : function(data, height)
      {
         $('#blogContentId').ready($.proxy(function()
         {
            this.dataObjects = $.parseJSON(data);
            this.dataId = this.dataObjects.map(function(obj){return obj.id;});
            this.blockHeight = Number(height);
            this.generate();
            
            $('#blogContentId').scroll($.proxy(this.generate, this));
            
         }, this));
      },
      
      /**
      * GÃ©nÃ©ration des images
      */
      generate : function()
      {
         var blogContent = $('#blogContentId');
         var minHeight = $('#blogContentId').scrollTop();
         var maxHeight = minHeight + $('#blogContentId').height();
         
         var nodeMinHeight, nodeMaxHeight;
         var sumClientHeight = 0;
         
         var displayObjects = this.dataObjects.filter($.proxy(function(obj)
         {
            
            var index = this.dataId.indexOf(obj.id);
            if (index <= 4)
               return true;
            nodeMinHeight = index * this.blockHeight;
            sumClientHeight = sumClientHeight + this.blockHeight;
            nodeMaxHeight = nodeMinHeight + this.blockHeight;
            
            return ( (nodeMinHeight >= minHeight && nodeMinHeight < maxHeight) || (nodeMaxHeight > minHeight && nodeMaxHeight < maxHeight) );
         }, this));
         
         displayObjects.forEach(function(obj)
         {
            $("<img />").bind("load", function () {
               $("#" + obj.id).attr("src", obj.src).show();
               $("#" + obj.id + "Throbber").hide();
            }).attr("src", obj.src);
         });
         
         this.dataObjects = this.dataObjects.notIn(displayObjects);
      }
   });
}

if(typeof LMD.Layout.ColRight.MoreInfoSingleton == "undefined" || !LMD.Layout.ColRight.MoreInfoSingleton){
   /**
   * Singleton les + d'infos
   */
   LMD.Layout.ColRight.MoreInfoSingleton = {
         
      /**
      * @scope LMD.Layout.ColRight.MoreInfoSingleton
      */
         
      /**
      * Instance de MoreInfo
      * @type LMD.Layout.ColRight.MoreInfo
      */
      instance: null,
      
      /**
      * ChargÃ© ou non
      * @type boolean
      */
      loaded: false,
      
      /**
      * RÃ©cupÃ¨re l'instance du singleton
      */
      getInstance: function()
      {
         if(null == LMD.Layout.ColRight.MoreInfoSingleton.instance){
            LMD.Layout.ColRight.MoreInfoSingleton.instance = new LMD.Layout.ColRight.MoreInfo();
         }
         return LMD.Layout.ColRight.MoreInfoSingleton.instance;
      }
   };
}

if(typeof LMD.Layout.ColRight.MoreInfo == "undefined" || !LMD.Layout.ColRight.MoreInfo){
   /**
   * Les + d'infos
   * @class MoreInfo
   */
   LMD.Layout.ColRight.MoreInfo = Class.extend(
   {
      /**
       * @scope LMD.Layout.ColRight.MoreInfo
       */
      
      /**
       * The dispatcher event
       * @type LMD.Layout.ColRight.MoreInfoEventDispatcher
       */
      dispatcher: null,
      
            
      init: function()
      {
         this.dispatcher = new LMD.Layout.ColRight.MoreInfoEventDispatcher;      
      },
      
      /**
       * Start block
       */
      go : function(elementId, nbItems)
      {
         var currentElement = $("#blockRightCallTagItem_" + elementId);
         if(currentElement.length)
         {
            currentElement.parents('li').hide();
         }

         var totalElement = $('.liste_simple li', '#blockRightCallTag_Id');
         var displayedElement = totalElement.length - currentElement.length;

         if(displayedElement === 0)
         {
            $('#blockRightCallTag_Id').remove();
         }
      },
      
      /**
       * Load // Just for compatibility
       */
      load : function()
      {}
   });
}

if(typeof LMD.Layout.ColRight.MoreInfoEvent == "undefined" || !LMD.Layout.ColRight.MoreInfoEvent)
{
   LMD.Layout.ColRight.MoreInfoEvent = MIA.Event.extend({});
   LMD.Layout.ColRight.MoreInfoEvent.LOADED = "loaded";
   LMD.Layout.ColRight.MoreInfoEventDispatcher = MIA.EventDispatcher.extend({});
}

/* ----- start file /lmd/layout/header.js ----- */
/**
 * Header
 * Tous les scripts qui concernent le header
 * @author berge
 */

if(typeof LMD.Layout == "undefined" || !LMD.Layout){
    /**
     * Le namespace du layout
     * @namespace Le namespace du layout
     */
    LMD.Layout = {};
};

if(typeof LMD.Layout.Header == "undefined" || !LMD.Layout.Header){
    /**
     * Le namespace du header
     * @namespace Le namespace du header
     */
    LMD.Layout.Header = {};
};

/**
 * Classe qui gÃ¨re l'Ã©pinglage du site sous IE9
 * @class IE9
 */
LMD.Layout.Header.IE9 = Class.extend(
{
   /**
    * @scope LMD.Layout.Header.IE9
    */
   
   /**
    * Constructeur
    */
   init : function()
   {},
   
   /**
    * DÃ©marrage du script
    */
   start : function()
   {
      var k = this;
      
      $(function(){
         if($.browser.msie && $.browser.version.substring(0,1) == "9" && $('body').css('background-position') == "0% 0%"
         && $.cookie(LMD.Layout.Header.IE9.IE9_CALL_COOKIE) == null)
         {
            try {
               if (!window.external.msIsSiteMode()) {
                  $('body').prepend('<div class="appel_ie9"><div class="wrap"><img class="msPinSite" src="/medias/www/img/ie9_pin/bar/pin_site.png"/><span>' + 'Vous pouvez glisser cette icÃ´ne dans la barre des tÃ¢ches pour Ã©pingler le site.'.utf8_decode() + '</span></div><div class="close_appel_ie9">Fermer <span class="close_glyph">&#215;</span></div></div><div class="appel_ie9_shadow"></div>');
                  $('.close_appel_ie9').click($.proxy(k.onClickClose, k));
               }
            }
            catch (e) {}
         }
      });
   },
   
   onClickClose : function()
   {
      $('.appel_ie9, .appel_ie9_shadow').slideUp();
      $.cookie(LMD.Layout.Header.IE9.IE9_CALL_COOKIE, '1', {expires: 7});
   },
   
   showAlert : function()
   {
      this.flashWindow();
      this.setOverlayIcon("alert");
   },
   
   hideAlert : function()
   {
      this.clearOverlayIcon();
   },
   
   flashWindow : function()
   {
      try
      {
         if (window.external.msIsSiteMode())
         {
             window.external.msSiteModeActivate();
         }
     }
     catch (ex) {}
   },
   
   setOverlayIcon : function(type)
   {
      try
      {
         if (window.external.msIsSiteMode())
         {
            if(type == "alert")
            {
               window.external.msSiteModeSetIconOverlay("/medias/www/img/ie9_pin/icons/ico_alerte.ico", "Alerte");
            }
         }
      }
      catch (e) {}
   },
   
   clearOverlayIcon : function()
   {
      try
      {
         if (window.external.msIsSiteMode())
         {
            window.external.msSiteModeClearIconOverlay();
         }
      }
      catch (e) {}
   }
});

/**
 * Nom du cookie de l'appel IE9
 * @type string
 */
LMD.Layout.Header.IE9.IE9_CALL_COOKIE = 'ie9_call';

/**
 * Instance
 * @type LMD.Layout.Header.IE9
 */
LMD.Layout.Header.IE9.instance = null;

/**
 * Singleton
 * @returns LMD.Layout.Header.IE9
 */
LMD.Layout.Header.IE9.getInstance = function()
{
   if(!LMD.Layout.Header.IE9.instance)
   {
      LMD.Layout.Header.IE9.instance = new LMD.Layout.Header.IE9();
   }
   
   return LMD.Layout.Header.IE9.instance;
};

/**
 * Classe qui gÃ¨re la pop-up d'invitation Ã  visiter un site mobile
 * @class Mobile
 */
LMD.Layout.Header.Mobile = Class.extend(
{
   /**
    * @scope LMD.Layout.Header.Mobile
    */
   
   /**
    * Sur un device apple
    * @param {boolean}
    */
   appleDevice : false,
   
   /**
    * Constructeur
    */
   init : function()
   {
      var userAgent = navigator.userAgent;
   
      // Liste des supports mobiles
      var devices = new Array(
                     "Android",
                     "Blackberry",
                     "Blazer",
                     "Handspring",
                     "iPhone",
                     "iPod",
                     "iPad",
                     "Kyocera",
                     "LG",
                     "Motorola",
                     "Nokia",
                     "Palm",
                     "PlayStation Portable",
                     "Samsung",
                     "Smartphone",
                     "SonyEricsson",
                     "Symbian",
                     "WAP",
                     "Windows CE"
                   );
      
      var phoneHtml;
   
      for(i=0,il=devices.length; i<il; i++)
      {
         if(userAgent.indexOf(devices[i]) != -1)
         {
            //Device apple
            if(devices[i] == "iPhone" || devices[i] == "iPad" || devices[i] == "iPod")
            {
               this.appleDevice = true;
               this.switchSrcSvg('#header_logo img#logo_une');
               $('body').addClass('apple_mobile');
            }
         }
      }
   },
   
   /**
    * Passage de l'image en SVG
    * @param {string} selector SÃ©lecteur jQuery
    */
   switchSrcSvg : function(selector)
   {
      if($(selector).length)
      {
         var prevSrc = $(selector).attr("src");
         prevSrc = prevSrc.substr(0, prevSrc.length - 3);
         var srcSvg = prevSrc + 'svg';
         $(selector).attr("src", srcSvg);
      }
   },
   
   /**
    * Passage de l'image en SVG pour les background
    * @param {string} selector SÃ©lecteur jQuery
    */
   switchBgSvg : function(selector)
   {
      if($(selector).length)
      {
         var prevSrc = $(selector).css("background-image");
         prevSrc = prevSrc.substr(0, prevSrc.length - 5);
         var srcSvg = prevSrc + 'svg");';
         $(selector).css("background-image", srcSvg);
      }
   }
});

/* ----- start file /lmd/conf/layout/colright.js ----- */
/**
 * Configuration de la colonne de droite
 * @author berge
 */

if(typeof LMD.Conf == "undefined" || !LMD.Conf){
   /**
    * Le namespace de la config
    * @namespace Le namespace de la config
    */
   LMD.Conf = {};
};

if(typeof LMD.Conf.Layout == "undefined" || !LMD.Conf.Layout){
   /**
    * Le namespace de la config du layout
    * @namespace Le namespace de la config du layout
    */
   LMD.Conf.Layout = {};
};

if(typeof LMD.Conf.Layout.ColRight == "undefined" || !LMD.Conf.Layout.ColRight){
   /**
    * Le namespace de la config de la colonne de droite
    * @namespace Le namespace de la config de la colonne de droite
    */
   LMD.Conf.Layout.ColRight = {};
};

/**
 * Mappage des types de blocs
 * @public
 * @static
 * @type array
 */
LMD.Conf.Layout.ColRight.typeBlocIdToName = [ null, 'pub', 'editorial', 'EA', 'marketing' ];

/**
 * Ordre d'affichage des blocs
 * @public
 * @static
 * @type object
 */
LMD.Conf.Layout.ColRight.typeBlocByTagUrlFriendly = {
      'sport' : [1, 2, 1, 2, 4, 2, 4, 2, 2, 1, 4, 1],
      'idees' : [1, 2, 1, 2, 3, 2, 4, 3, 2, 1, 2, 4, 1],
      'voyage' : [1, 2, 1, 3, 4, 2, 4, 4, 1, 2, 4, 4, 1],
      '*' : [1, 2, 1, 3, 4, 3, 2, 1, 4, 2, 2, 1]
   };

/**
 * Mappage des tags
 * @public
 * @static
 * @type object
 */
LMD.Conf.Layout.ColRight.tagTypeLibelleToId = {
   'niveau_0' : 5,
   'format' : 4,
   'categorie' : 2,
   'evenement' : 1,
   'topic' : 3
};

/**
 * Timeout pour le chargement des blocs en remote
 * @public
 * @static
 * @type int
 */
LMD.Conf.Layout.ColRight.remoteTimeout = 5000;

/**
 * Ajustement du lazyload en pixel
 * a 0 le lazyload est basÃ© sur la vision de l'utilisateur
 * on anticipe de 300 pixels sa vision
 * @public
 * @static
 * @type int
 */
LMD.Conf.Layout.ColRight.adjustLazyLoad = 300;

/**
 * Marge
 * La taille de la colonne de gauche estimÃ©e = taille rÃ©elle + marge
 * @public
 * @static
 * @type int
 */
LMD.Conf.Layout.ColRight.marge = 150;

/**
 * Valeur du minuteur qui tente de voir si de la place s'est libÃ©rÃ©
 * @public
 * @static
 * @type int
 */
LMD.Conf.Layout.ColRight.retryTimerValue = 800;

/**
 * Valeur du dÃ©lai Ã  partir duquel on considÃ¨re qu'il n'y aura
 * plus de nouvel espace
 * @public
 * @static
 * @type int 
 */
LMD.Conf.Layout.ColRight.retryTimeout = 5000;
/* ----- start file /lmd/reaction/live.js ----- */
/**
 * Le Monde
 * Partie rÃ©actions
 * Classe permettant la mise Ã  jour du compteur des rÃ©actions sur toutes les pages en lazyload
 * Tous les Ã©lÃ©ments possÃ©dant la classe "live_reactions" sont parsÃ©s et modifiÃ©s Ã  la volÃ©e
 * Plusieurs champs data doivent Ãªtre renseignÃ©s :
 * - data-id {int} (obligatoire) L'id de l'Ã©lÃ©ment
 * - data-callback {string} (facultatif) Un callback spÃ©cifique Ã  exÃ©cuter
 * Exemple : 
 * <span class="live_reaction" data-id="1022" data-callback="customCallBack"></span>
 * @author berge
 */

if(typeof LMD.Reaction == "undefined" || !LMD.Reaction){
    /**
     * Le namespace Reaction
     * @namespace Le namespace Reaction
     */
    LMD.Reaction = {};
};

/**
 * Classe de mise Ã  jour des rÃ©actions
 * @class Live
 */
LMD.Reaction.Live = Class.extend(
{
   /**
    * @scope LMD.Reaction.Live
    */
   
   /**
    * RÃ©glages
    * - lazyload {boolean} ExÃ©cution en lazyload ou non
    * - format {string} Le format appliquÃ© '$' permet d'ajouter des variables
    *  (par dÃ©faut "$count")
    */
   settings : {},
   
   cache : [],
   
   
   /**
    * Constructeur
    */
   init : function()
   {
      this.settings.format = "$count";
      this.settings.lazyload = true;
   },
   
   /**
    * DÃ©marrage du script
    */
   start : function()
   {
      var k = this;
      
      if(this.settings.lazyload)
      {
         var settings = {
               threshold    : 0,
               failurelimit : 0,
               event        : "scroll",
               effect       : "show",
               container    : window
           };
      
         var elements = $('.live_reaction');
         
         $(settings.container).bind("scroll", function(event)
         {
            var counter = 0;
            elements.each(function() {
                if ($.abovethetop(this, settings) ||
                    $.leftofbegin(this, settings)) {
                        /* Nothing. */
                } else if (!$.belowthefold(this, settings) &&
                    !$.rightoffold(this, settings)) {
                        $(this).trigger("appear");
                } else {
                    if (counter++ > settings.failurelimit) {
                        return false;
                    }
                }
            });
            /* Remove from array so it is not looped next time. */
            var temp = $.grep(elements, function(element) {
                return !element.loaded;
            });
            elements = $(temp);
        });
         
         $('.live_reaction').one("appear", function() {
            if (!this.loaded)
            {
               var z = this;
               var id = $(this).data('id') + "";
               
               if(typeof k.cache[id] != "undefined" && k.cache[id])
               {
                  if($(this).data('callback') && $(this).data('callback') != "")
                  {
                     var cbdata = {};
                     cbdata.executed = false;
                     cbdata.callback = $(this).data('callback');
                     cbdata.scope = z;
                     
                     k.cache[id].callbacks.push(cbdata);
                  }
                  
                  if(k.cache[id].data)
                  {
                     k.getCountCallBack(k.cache[id].data, "success");
                  }
                  
                  this.loaded = true;
                  return ;
               }
               
               k.cache[id] = {};
               k.cache[id].data = null;
               k.cache[id].callbacks = [];
               
               var idl = id.length;
               var jqxr = $.get('/api/1/reaction/' + id.substring(idl - 2, idl - 1) + '/' + id.substring(idl - 1, idl) + '/' + id + '/count/', $.proxy(k.getCountCallBack, k), 'json');
               
               if($(this).data('callback') && $(this).data('callback') != "")
               {
                  var cbdata = {};
                  cbdata.executed = false;
                  cbdata.callback = $(this).data('callback');
                  cbdata.scope = z;
                  
                  k.cache[id].callbacks.push(cbdata);
               }
               
               this.loaded = true;
            };
         });
      }
      else
      {
         $('.live_reaction').each( function() {
            if (!this.loaded)
            {
               var z = this;
               var id = $(this).data('id') + "";
               
               if(typeof k.cache[id] != "undefined" && k.cache[id])
               {
                  if($(this).data('callback') && $(this).data('callback') != "")
                  {
                     var cbdata = {};
                     cbdata.executed = false;
                     cbdata.callback = $(this).data('callback');
                     cbdata.scope = z;
                     
                     k.cache[id].callbacks.push(cbdata);
                  }
                  
                  if(k.cache[id].data)
                  {
                     k.getCountCallBack(k.cache[id].data, "success");
                  }
                  
                  this.loaded = true;
                  return ;
               }
               
               k.cache[id] = {};
               k.cache[id].data = null;
               k.cache[id].callbacks = [];
               
               var idl = id.length;
               var jqxr =  $.get('/api/1/reaction/' + id.substring(idl - 2, idl - 1) + '/' + id.substring(idl - 1, idl) + '/' + id + '/count/', $.proxy(k.getCountCallBack, k), 'json');
               
               if($(this).data('callback') && $(this).data('callback') != "")
               {
                  var cbdata = {};
                  cbdata.executed = false;
                  cbdata.callback = $(this).data('callback');
                  cbdata.scope = z;
                  
                  k.cache[id].callbacks.push(cbdata);
               }
               
               this.loaded = true;
            };
         });
      }
   },
   
   /**
    * RÃ©cupÃ©ration d'un comptage
    */
   getCount : function(id, cb)
   {
      if(typeof this.cache[id] != "undefined" && this.cache[id])
      {
         if(typeof cb == "function")
         {
            var cbdata = {};
            cbdata.executed = false;
            cbdata.callback = cb;
            cbdata.scope = this;
            
            this.cache[id].callbacks.push(cbdata);
         }
         
         if(this.cache[id].data)
         {
            this.getCountCallBack(this.cache[id].data, "success");
         }
         
         return ;
      }
      
      this.cache[id] = {};
      this.cache[id].data = null;
      this.cache[id].callbacks = [];
      
      var idl = id.length;
      var jqxr =  $.get('/api/1/reaction/' + id.substring(idl - 2, idl - 1) + '/' + id.substring(idl - 1, idl) + '/' + id + '/count/', $.proxy(this.getCountCallBack, this), 'json');
      
      if(typeof cb == "function")
      {
         var cbdata = {};
         cbdata.executed = false;
         cbdata.callback = cb;
         cbdata.scope = this;
         
         this.cache[id].callbacks.push(cbdata);
      }
   },
   
   /**
    * Callback Ã©xÃ©cuter Ã  chaque fois qui 
    * permet de mettre Ã  jour le nombre de rÃ©action
    * @param data {object} DonnÃ©es
    * @pram textStatus {string} Statut
    */
   getCountCallBack : function(data, textStatus)
   {
      if(textStatus == "success" && typeof data != "undefined" && data)
      {
         if(data.length)
         {
            data = data[0];
         }
         
         if(data.count > 0)
         {
            this.cache[data.id].data = data;
            
            var finalStr = this.settings.format;
            
            for(var i in data)
            {
               var reg = new RegExp("\\$" + i, "g");
               finalStr = finalStr.replace(reg, data[i]);
            }
            
            
            $('.live_reaction:data("id=' + data.id + '")').html(finalStr);
            
            if(this.cache[data.id].callbacks.length)
            {
               for(var i=0,il=this.cache[data.id].callbacks.length;i<il;i++)
               {
                  var cb = this.cache[data.id].callbacks[i];
                  
                  if(cb.executed)
                  {
                     continue;
                  }
                  
                  if(typeof cb.callback == "string")
                  {
                     eval(cb.callback).call(cb.scope, data);
                  }
                  else if(typeof cb.callback == "function")
                  {
                     cb.callback.call(cb.scope, data);
                  }
                  cb.executed = true;
               }
            }
         }
      }
   }
});

/**
 * Instance
 * @type LMD.Reaction.Live
 */
LMD.Reaction.Live.instance = null;

/**
 * Singleton
 * @returns LMD.Reaction.Live
 */
LMD.Reaction.Live.getInstance = function()
{
   if(!LMD.Reaction.Live.instance)
   {
      LMD.Reaction.Live.instance = new LMD.Reaction.Live();
   }
   
   return LMD.Reaction.Live.instance;
};
/* ----- start file /lmd/element/toolbar.js ----- */
/**
 * Le Monde
 * Partie Element
 * Barre d'outils
 * @author berge
 */

if(typeof LMD.Element == "undefined" || !LMD.Element){
    /**
     * Le namespace Element
     * @namespace LMD.Element
     */
    LMD.Element = {};
};

/**
 * Toolbar
 * @class LMD.Element.Toolbar
 */
LMD.Element.Toolbar = Class.extend(
{
   baseHtml : "",
   isLoading : false,
   
   init : function()
   {},
   
   start : function()
   {
      if(this.baseHtml == "" && !this.isLoading)
      {
         $.get('/element/toolbar.html', null, $.proxy(this.onToolbarLoaded, this));
         this.isLoading = true;
      }
      else if(this.baseHtml != "")
      {
         this.placeToolbar();
      }
   },
   
   initSize : function()
   {
      var toolbarWidth = $('.toolbar').width();
      if(toolbarWidth > 700)
      {
         $('.toolbar .slides .droit').width(300);
         $('.toolbar .slides .gauche').width(toolbarWidth - 380);
         return ;
      }
      
      $('.toolbar .slides .gauche').width(toolbarWidth - 230);
   },
   
   initImprimer : function()
   {
      if(typeof LMD.Element.Toolbar.params.imprimer == "undefined" || !LMD.Element.Toolbar.params.imprimer.active)
      {
         $('.toolbar .tool.imprimer').hide();
         return ;
      }
      
      var k = this;
      $('.toolbar .tool.imprimer a').attr("href", LMD.Element.Toolbar.params.imprimer.link);
      $('.toolbar .tool.imprimer a').click(function(event)
      {
         var toolbar = $(event.currentTarget).parents('.toolbar');
         var position = k.getPosition(toolbar);
         
         k.xtMed("Imprimez", position);
      });
   },
   
   initEnvoyer : function()
   {
      if(typeof LMD.Element.Toolbar.params.envoyer == "undefined" || !LMD.Element.Toolbar.params.envoyer.active)
      {
         $('.toolbar .tool.envoyer').hide();
         return ;
      }
      
      var k = this;
      $('.toolbar .tool.envoyer a').attr("href", LMD.Element.Toolbar.params.envoyer.link);
      $('.toolbar .tool.envoyer a').click(function(event)
      {
         var toolbar = $(event.currentTarget).parents('.toolbar');
         var position = k.getPosition(toolbar);
         
         k.xtMed("Email", position);
      });
   },
   
   initReagir : function()
   {
      if(typeof LMD.Element.Toolbar.params.reagir == "undefined" || !LMD.Element.Toolbar.params.reagir.active)
      {
         $('.toolbar .tool.reagir').hide();
         return ;
      }
   },
   
   initClasser : function()
   {
      if(typeof LMD.Element.Toolbar.params.classer == "undefined" || !LMD.Element.Toolbar.params.classer.active)
      {
         $('.toolbar .tool.classer').hide();
         return ;
      }
      
      if(LMD.Element.Toolbar.params.abonnes)
      {
         $('.toolbar .tool.classer a').click($.proxy(this.onClickClasser, this));
         $('.toolbar .tool.classer a').addClass("no_fav");
         this.checkFav();
      }
   },

   initPartager : function()
   {
      if(typeof LMD.Element.Toolbar.params.partager == "undefined" || !LMD.Element.Toolbar.params.partager.active)
      {
         $('.toolbar .share, .toolbar .label_share').hide();
         return;
      }
      
      $('.share li').show();
      
      //On cache Viadeo
      $('.share li.viadeo').hide();
   },
   
   initFacebookLike : function()
   {
      if(typeof LMD.Element.Toolbar.params.facebook == "undefined" || !LMD.Element.Toolbar.params.facebook.active)
      {
         return ;
      }
      
      var onLike = function()
      {
         FB.Event.subscribe('edge.create', function(href, widget)
         {
            LMD.Element.Toolbar.getInstance().xtMed("FacebookLike", "TopOrBottom");
         });
      };
      
      if(typeof LMD.Social != "undefined" && typeof LMD.Social.Facebook != "undefined")
      {
         LMD.Social.Facebook.getInstance().addCallback(onLike);
      }
      
      $('.share_position').append('<fb:like action="recommend" send="true" show_faces="true" width="540" href="' + this.getPageUrl(null, false) + '"></fb:like>');
      LMD.Social.Facebook.getInstance().render($('.share_position').get(0));
   },
   
   initGooglePlus : function()
   {
      if(typeof LMD.Element.Toolbar.params.google_plus == "undefined" || !LMD.Element.Toolbar.params.google_plus.active)
      {
         return ;
      }
      
      $('.toolbar .share').append('<li class="google_plus" data-tooltip="Partagez sur Google+"><div class="g-plusone" data-size="small" data-count="true" data-callback="googlePlusToolbarCallBack" data-href="' + this.getPageUrl(null, false) + '"></div></li>');
      $('.toolbar .share .google_plus').tinyTips('data-tooltip');
   },
   
   onClickGooglePlus : function(element)
   {
      LMD.Element.Toolbar.getInstance().xtMed("GooglePlus", "TopOrBottom");
   },
   
   checkFav : function()
   {
      var id_crypt = GetCookie('tdb_user_id');
      var url = "/api/1/user/classer/$1/$2/$3.html";
      url = url.replace('$1', id_crypt[id_crypt.length - 1]);
      url = url.replace('$2', id_crypt[id_crypt.length - 2]);
      url = url.replace('$3', id_crypt);
      
      $.get(url, null, $.proxy(this.checkFavCallback, this),'json');
   },
   
   checkFavCallback : function(data, textStatus)
   {
      if(textStatus != "success" || !data)
      {
         return ;
      }
      
      for (i = 0; i < data['ids'].length; i++)
      {
         if(LMD.Element.Toolbar.params.item.id == data['ids'][i])
         {
            $('.toolbar .tool.classer a').addClass("in_fav").removeClass("no_fav");
            return ;
         }
      }
   },
   
   onClickClasser : function(event)
   {
      var currentToolbar = $(event.currentTarget).parents('.toolbar');
      this.toggleFav(currentToolbar);
      
      var position = this.getPosition(currentToolbar);
      this.xtMed("Classez", position);

      return false;
   },
   
   toggleFav : function(toolbar)
   {
      toolbar.find('.classer_results div').hide();
      
      if($('.toolbar .tool.classer a').hasClass("in_fav"))
      {
         this.addToFav();
         $('.toolbar .tool.classer a').addClass("no_fav").removeClass("in_fav");
         if (LMD.Element.Toolbar.params.classer && LMD.Element.Toolbar.params.classer.texte_suppression !== null)
         {
            $('.classer_results .remove span').html(LMD.Element.Toolbar.params.classer.texte_suppression);
         }
         toolbar.find('.classer_results .remove').show();
      }
      else
      {
         this.addToFav();
         $('.toolbar .tool.classer a').addClass("in_fav").removeClass("no_fav");
         if (LMD.Element.Toolbar.params.classer && LMD.Element.Toolbar.params.classer.texte_ajout !== null)
         {
            $('.classer_results .add span').html(LMD.Element.Toolbar.params.classer.texte_ajout);
         }
         toolbar.find('.classer_results .add').show();
      }
      
      return false;
   },
   
   addToFav : function()
   {
      var data = {};
      data.mode = 'add_elem';
      data.item_id = LMD.Element.Toolbar.params.item.id;
      
      var jsonParams = 'params=' + $.toJSON(data);
      
      $.get("/api/1/user/classeur/", jsonParams, $.proxy(this.addToFavCallback, this), 'json');
   },
   
   addToFavCallback : function(data, textStatus)
   {
      if(textStatus != "success" || !data || !data.success)
      {
         //error
      }
   },
   
   removeFromFav : function()
   {
      this.addToFav(); // ??? FranÃ§ois API ?
   },
   
   initAbonnezVous : function()
   {
      if(LMD.Element.Toolbar.params.abonnes)
      {
         $('.toolbar .abo_link').hide();
      }
      else
      {
         var k = this;
         $('.toolbar .abo_link').click(function(event)
         {
            var toolbar = $(event.currentTarget).parents('.toolbar');
            var position = k.getPosition(toolbar);
            
            k.xtMed("AbonnezVous", position);
         });
      }
   },
   
   getPageUrl : function(xtor, urlencode)
   {
      var url = 'http://www.lemonde.fr' + window.location.pathname;
      
      if(typeof xtor == "string")
      {
         url += "#xtor=" + xtor;
      }
      
      if(typeof urlencode == "boolean")
      {
         if(urlencode == false)
         {
            return url;
         }
      }
      
      return url.url_encode();
   },
   
   getPosition : function(toolbar)
   {
      var index = $('.toolbar').index(toolbar);
      
      switch(index)
      {
         case 0 :
            return "Top";
         break;
         case 1 :
            return "Bottom";
         break;
      }
      
      return "Top";
   },
   
   initReactionLive : function()
   {
      if(typeof LMD.Element.Toolbar.params.reagir == "undefined" || !LMD.Element.Toolbar.params.reagir.active)
      {
         return ;
      }

      $('.toolbar .live_reaction').data("id", LMD.Element.Toolbar.params.item.id);
      $('.slide_down.reagir .reaction_link').html(LMD.Element.Toolbar.params.reagir.link);
      $('.slide_down.reagir .reaction_link .live_reaction').data("id", LMD.Element.Toolbar.params.item.id);
      
      toolbarNoCommentLiveCallBack = function(data)
      {
         if(data)
         {
            $(this).parents(".no_comment").removeClass("no_comment").addClass("comment");
            
            if(data.count <= 4)
            {
               $('.slide_down.reagir .reaction_link').hide();
            }
         }
      };
      
      var reacLive = LMD.Reaction.Live.getInstance();
      reacLive.settings.lazyload = false;
      reacLive.start();
   },
   
   onToolbarLoaded : function(data, textStatus)
   {
      this.isLoading = false;
      
      if(textStatus != "success" || !data)
      {
         return ;
      }
      
      this.baseHtml = data;
      this.placeToolbar();
   },
   
   placeToolbar : function()
   {
      $('.outils_position').html(this.baseHtml);
      
      this.initRestrictAbo();
      
      this.initReactionLive();
      this.initPartager();
      this.initEvents();
      this.initSize();
      this.initForms();
      this.initPubs();
      
      this.initAbonnezVous();
      this.initClasser();
      this.initImprimer();
      this.initEnvoyer();
      this.initReagir();
      this.initFacebookLike();
      this.initGooglePlus();
   },
   
   initRestrictAbo : function()
   {
      if(typeof LMD.Element.Toolbar.params.item != "undefined" && typeof LMD.Element.Toolbar.params.item.restrict_abo != "undefined" && LMD.Element.Toolbar.params.item.restrict_abo)
      {
         LMD.Element.Toolbar.params.partager = false;
         LMD.Element.Toolbar.params.facebook = false;
         LMD.Element.Toolbar.params.google_plus = false;
      }
   },
   
   initPubs : function()
   {
      if(!LMD.Element.Toolbar.params.abonnes)
      {
         $('.toolbar .toolbar_pub').each(function()
         {
            var index = $('.toolbar .toolbar_pub').index(this);
            
            if($('.toolbar_pub_inline').length > index && $('.toolbar_pub_inline').eq(index).find('div').length)
            {
               $(this).append('<span class="label_sponso">SponsorisÃ©s par</span>');
               $('.toolbar_pub_inline').eq(index).find('div').css("width", "auto").moveIn($(this));
            }
         });
      }
   },
   
   initForms : function()
   {
      $('.toolbar input[name=url_zop]').val('http://abonnes.lemonde.fr' + window.location.pathname);
      $('.toolbar input[name=url]').val('http://www.lemonde.fr' + window.location.pathname);
   },
   
   initEvents : function()
   {
      if(!LMD.Element.Toolbar.params.abonnes)
      {
         $('.toolbar .tool.slider').click($.proxy(this.onSliderClick, this));
      }
      $('.toolbar .tool a, .toolbar .share a').tinyTips('title');
      $('.toolbar .share li a').click($.proxy(this.onClickShare, this));
   },
   
   xtMed : function(type, position)
   {
      xt_click('C',LMD.Layout.X.Click.getNiveau2(),LMD.Layout.X.Click.renderClickTag('Outil_' + position + '_' + type),'N');
      return false;
   },
   
   onClickShare : function(event)
   {
      var currentTarget = $(event.currentTarget);
      var currentTargetDom = currentTarget.get(0);
      var currentToolbar = currentTarget.parents('.toolbar');
      var parentLi = currentTarget.parents('li');
      
      var url = '';
      var params = {};
      
      var position = this.getPosition(currentToolbar);
      
      if(parentLi.hasClass('facebook'))
      {
         this.xtMed("Facebook", position);
         //On utilise encore le sharer.php pour le moment, en attendant de rÃ©gler le pb de l'appli
         //LMD.Social.Facebook.getInstance().postOnWall(this.getPageUrl(null, false));
         //return ;
         url = 'http://www.facebook.com/sharer.php?u=' + this.getPageUrl();
      }
      else if(parentLi.hasClass('twitter'))
      {
         this.xtMed("Twitter", position);
         url = "http://twitter.com/share?related=lemondefr&via=lemondefr&lang=fr&text=" + LMD.Element.Toolbar.params.item.title + "&url=" + this.getPageUrl(LMD.Element.Toolbar.params.twitter.xtor);
         params.width = 550;
         params.height = 420;
      }
      else if(parentLi.hasClass('linkedin'))
      {
         this.xtMed("LinkedIn", position);
         url = "http://www.linkedin.com/shareArticle?mini=true&url=" + this.getPageUrl(LMD.Element.Toolbar.params.linkedin.xtor) + "&title=" + LMD.Element.Toolbar.params.item.title + "&source=LeMonde.fr";
         params.width = 550;
         params.height = 340;
      }
      else if(parentLi.hasClass('viadeo'))
      {
         this.xtMed("Viadeo", position);
         url = "http://www.viadeo.com/shareit/share/?url=" + this.getPageUrl(LMD.Element.Toolbar.params.viadeo.xtor) + "&title=" + LMD.Element.Toolbar.params.item.title + "&urllanguage=fr&urlaffiliate=245";
         window.open(url);
         return false;
      }
      
      this.openPopupShare(url, params);
      
      return false;
   },
   
   openPopupShare : function(url, params)
   {
      var width = (typeof params.width != "undefined") ? params.width : 650;
      var height = (typeof params.height != "undefined") ? params.height : 430;
      var left = ($(window).width() - width) / 2;
      var top = ($(window).height() - height) / 2;
      
      var params = 'width=' + width + ',height=' + height + ',top=' + top + ',left=' + left;
      params += ",location=no,resizable=yes,status=no,titlebar=no,toolbar=no";
      
      window.open(url, 'toolbar_share_popup', params);
   },
   
   onSliderClick : function(event)
   {
      var currentTarget = $(event.currentTarget);
      var currentToolbar = currentTarget.parents('.toolbar');
      var sliderType = currentTarget.data("slider");
      var currentSlider = currentToolbar.find('.slide_down.' + sliderType);
      
      if(!currentSlider.length)
      {
         return false;
      }

      /* pour certaines sÃ©quences, on ne veut pas afficher le bloc abo pour les
       * rÃ©actions mais suivre l'ancre */
      if (sliderType === 'reagir' && LMD.Element.Toolbar.params.reagir.slides !== undefined && LMD.Element.Toolbar.params.reagir.slides.afficher === 'false')
      {
         return true;
      }
      
      if(currentSlider.is(":visible"))
      {
         currentSlider.hide();
         currentToolbar.data("sliderOpened", false);
         return false;
      }
      
      currentToolbar.find('.slide_down').hide();
      
      if(!currentToolbar.data("sliderOpened"))
      {
         currentSlider.show();
      }
      else
      {
         currentSlider.show();
      }
      
      currentToolbar.data("sliderOpened", true);
      
      return false;
   }
});

googlePlusToolbarCallBack = function (element)
{
   LMD.Element.Toolbar.getInstance().onClickGooglePlus(element);
};

/**
 * Instance
 * @type LMD.Element.Toolbar
 */
LMD.Element.Toolbar.instance = null;
LMD.Element.Toolbar.params = {};

/**
 * Singleton
 * @returns LMD.Element.Toolbar
 */
LMD.Element.Toolbar.getInstance = function()
{
   if(!LMD.Element.Toolbar.instance)
   {
      LMD.Element.Toolbar.instance = new LMD.Element.Toolbar();
   }
   
   return LMD.Element.Toolbar.instance;
};

/* ----- start file /lib/jquery/plugin/jquery.tinyTips.js ----- */
/***********************************************************/
/*                    tinyTips Plugin                      */
/*                      Version: 1.0                       */
/*                      Mike Merritt                       */
/*                 Updated: Feb 4th, 2010                  */
/***********************************************************/

(function($){  
   $.fn.tinyTips = function (supCont) {
      
      /* User settings
      **********************************/
      
      // Enter the markup for your tooltips here. The wrapping div must have a class of tinyTip and 
      // it must have a div with the class "content" somewhere inside of it.
      var tipFrame = '<div class="tinyTip"><div class="content"></div></div>';
      
      // Speed of the animations in milliseconds - 1000 = 1 second.
      var animSpeed = 300;
      
      /***************************************************************************************************/
      /* End of user settings - Do not edit below this line unless you are trying to edit functionality. */
      /***************************************************************************************************/
      
      // Global tinyTip variable;
      var tinyTip;
      var tText;
      
      // When we hover over the element that we want the tooltip applied to
      $(this).hover(function() {
      
         // Inject the markup for the tooltip into the page and
         // set the tooltip global to the current markup and then hide it.
         $('body').append(tipFrame);
         tinyTip = $('div.tinyTip');
         tinyTip.hide();
         
         // Grab the content for the tooltip from the title attribute (or the supplied content) and
         // inject it into the markup for the current tooltip. NOTE: title attribute is used unless
         // other content is supplied instead.
         var tipCont = $(this).attr(supCont);
         
         $('.tinyTip .content').html(tipCont);
         tText = $(this).attr('title');
         $(this).attr('title', '');
         
         // Offsets so that the tooltip is centered over the element it is being applied to but
         // raise it up above the element so it isn't covering it.
         var yOffset = tinyTip.height() + 12;
         var xOffset = 2;
         
         // Grab the coordinates for the element with the tooltip and make a new copy
         // so that we can keep the original un-touched.
         var pos = $(this).offset();
         var nPos = pos;
         
         // Add the offsets to the tooltip position
         nPos.top = pos.top - yOffset;
         nPos.left = pos.left - xOffset;
         
         // Make sure that the tooltip has absolute positioning and a high z-index, 
         // then place it at the correct spot and fade it in.
         tinyTip.css('position', 'absolute').css('z-index', '1000');
         tinyTip.css(nPos).show();
         
      }, function() {
         
         $(this).attr('title', tText);
      
         // Fade the tooltip out once the mouse moves away and then remove it from the DOM.
         $('div.tinyTip').fadeOut(animSpeed, function() {
            $(this).remove();
         });
         
      });
      
   }

})(jQuery);
/* ----- start file /lmd/social/facebook.js ----- */
/**
 * Le Monde
 * Partie Social
 * Facebook
 * @author berge
 */

if(typeof LMD.Social == "undefined" || !LMD.Social){
    /**
     * Le namespace Social
     * @namespace Social
     */
    LMD.Social = {};
};

/**
 * Social Facebook
 * @class LMD.Social.Facebook
 */
LMD.Social.Facebook = Class.extend(
{
   /**
    * Callbacks
    * @type array
    */
   callbacks : [],
   
   loading : false,
   
   callbackExecuted : false,
   
   /**
    * Constructeur
    */
   init : function()
   {},
   
   /**
    * Poster sur le mur
    */
   postOnWall : function(link)
   {
      if(typeof FB == "undefined")
      {
         var fct = function()
         {
            LMD.Social.Facebook.getInstance().postOnWall(link);
         };
         
         this.addCallback(fct);
         return ;
      }
      
      FB.ui({method: 'feed', link: link});
   },
   
   /**
    * Rendu FBML d'une partie
    */
   render : function(element)
   {
      if(typeof FB != "undefined")
      {
         if(typeof element != "undefined")
         {
            FB.XFBML.parse(element);
         }
         else
         {
            FB.XFBML.parse();
         }
      }
      else
      {
         this.loadFacebook();
      }
   },
   
   /**
    * Ajout d'un callback
    */
   addCallback : function(fct)
   {
      if(typeof FB != "undefined")
      {
         fct.call(this);
      }
      else
      {
         this.callbacks.push(fct);
      }
   },
   
   /**
    * ExÃ©cution des callbacks
    */
   executeCallbacks : function()
   {
      if(typeof FB == "undefined" || this.callbackExecuted)
      {
         return ;
      }
      
      for(var i=0,il=this.callbacks.length;i<il;i++)
      {
         var cb = this.callbacks[i];
         if(typeof cb != "function")
         {
            continue ;
         }
         
         cb.call(this);
      }
      
      this.callbackExecuted = true;
   },
   
   /**
    * Chargement de Facebook
    */
   loadFacebook : function()
   {
      if(this.loading || typeof window.fbAsyncInit != "undefined")
      {
         return ;
      }
      
      this.loading = true;
      
      window.fbAsyncInit = function(){
         FB.init({appId: '166878320861', status:true,cookie:true,xfbml:true});
         LMD.Social.Facebook.getInstance().onFacebookLoaded();
      };
      
      $('body').append('<div id="fb-root"></div>');
      
      $(function(){
         var e = document.createElement('script'); e.async = true;
         e.src = document.location.protocol + '//connect.facebook.net/fr_FR/all.js';
         document.getElementById('fb-root').appendChild(e); 
      });
   },
   
   /**
    * AppelÃ© lorsque Facebook est chargÃ©
    */
   onFacebookLoaded : function()
   {
      this.executeCallbacks();
   }
});

/**
 * Instance
 * @type LMD.Element.Toolbar
 */
LMD.Social.Facebook.instance = null;

/**
 * Singleton
 * @returns LMD.Element.Toolbar
 */
LMD.Social.Facebook.getInstance = function()
{
   if(!LMD.Social.Facebook.instance)
   {
      LMD.Social.Facebook.instance = new LMD.Social.Facebook();
   }
   
   return LMD.Social.Facebook.instance;
};
/* ----- start file /lmd/element/link_decorator.js ----- */
var listLinkHover;
$(function() {
   $(".listLink").hover(
      function (event) {
         var e = event;
         listLinkHover = window.setTimeout(
            function () {
               e.target.style.textDecoration = "underline";
               e.target.style.cursor = "pointer";
            },
            500
         );
      },
      function (event) {
         window.clearTimeout(listLinkHover);
         event.target.style.textDecoration = "none";
         event.target.style.cursor = "text";
      }
   );
   $(".listLink").click(
      function (event) {
         window.open(event.target.href);
      }
   );
});
