/*
  UTILITY FUNCTION TO BUILD UP A TABBED PANEL
  params:
  container_id: id of tabs macro container 
  tabs_container_class: tabs button list container's class; all tab buttons should have a 'rel' attribute holding ID of tab to show 
  tabs_class: tabs container's class; all tab elements should have a 'ID' attribute
*/
// création de l'objet FTVi
var FTVi = {};


FTVi.showDisclaimer = function(id)
{
    $('#disclaimer_' + id).hide();
    $('#image_' + id).show();
};

FTVi.printPage = function()
{
    FTVi.auth.setCookieMinute("FTViPrintPage", true, 1);
    var FTViPrintPage = window.open(document.URL);
    FTViPrintPage.focus();
};

$(document).ready(function() 
{
    var scrollDuring = 1000; /* Duree du Scroll 1000 = 1seconde */
    var scrollBegin = 10; /* Hauteur entre l'ancre le scroll */
    if (document.getElementById('commentsDiv')) {
        $('#commentsDiv').click(function(){
        var $targetid = $('#reactionsBlock');
        if($targetid.length){
            var targetOffset = $targetid.offset().top - scrollBegin;
            $('html,body').animate({scrollTop:targetOffset}, scrollDuring);
            return false;
        }
    })};
});

/*
FTVi.addRightCol = function()
{
    var now = Math.round((new Date()).getTime() / 1000);
    
    var addRightColCookie = unescape(FTVi.auth.getCookie('addRightColCookie'));
    
    if (!addRightColCookie.match(';;')) {
        var addDisplay = 'android';
        var addDisplayTime = now - 300;
    } else {
        var tabCookie = addRightColCookie.split(';;');
        var addDisplay = tabCookie[0];
        var addDisplayTime = tabCookie[1];
    }
    
    var diffTime = now - addDisplayTime;
    if (diffTime >= 0) {
        if (addDisplay == 'android') {
            var html = '<span>Publicité</span><a target="_blank" href="http://itunes.apple.com/fr/app/francetv-info/id348684697?mt=8"><img id="addRightColImg" border="0" src="/info/skin/www/img/temp/appIphone.png" /></a>';
            FTVi.auth.delCookie("addRightColCookie");
            var newCookieName = 'iphone';
        } else if (addDisplay == 'iphone') {
            var html = '<span>Publicité</span><a target="_blank" href="https://market.android.com/details?id=fr.francetv.apps.info"><img id="addRightColImg" border="0" src="/info/skin/www/img/temp/appAndroid.png" /></a>';
            FTVi.auth.delCookie("addRightColCookie");
            var newCookieName = 'android';
        }
        var newCookieTime = now + 300;
        FTVi.auth.setCookieMinute("addRightColCookie", newCookieName + ';;' + newCookieTime, 10);
    } else {
        if (addDisplay == 'iphone') {
            var html = '<span>Publicité</span><a target="_blank" href="http://itunes.apple.com/fr/app/francetv-info/id348684697?mt=8"><img id="addRightColImg" border="0" src="/info/skin/www/img/temp/appIphone.png" /></a>';
        } else if (addDisplay == 'android') {
            var html = '<span>Publicité</span><a target="_blank" href="https://market.android.com/details?id=fr.francetv.apps.info"><img id="addRightColImg" border="0" src="/info/skin/www/img/temp/appAndroid.png" /></a>';
        }
    }
    $('#addRightCol').html(html);
};
*/
function breakingNews()
{
    var feed = breakingNewsFeedUrl;
    var cookiePrintPage = FTVi.auth.getCookie('FTViPrintPage');
    $.get(breakingNewsFeedUrl, function(data) 
    {
         // var breakingNews = data.breaking-news; ne fonctionne pas on passe par la méthode array
        var breakingNews = data['breaking-news'];
        var breakingNewsCount = breakingNews.length;
        
        if (breakingNewsCount > 0 && !cookiePrintPage) {
            var breakingNewsDisplay = breakingNews[0];
            var breakingNewsDisplayTitle = breakingNewsDisplay.title;
            var breakingNewsDisplaysharedUrl = breakingNewsDisplay.sharedUrl;
            
            $('#breakingNewsTitle').click(function(){document.location.href = breakingNewsDisplaysharedUrl;});
            $('#breakingNewsTitle').css('cursor', 'pointer');
            $('#breakingNewsTitle').html(breakingNewsDisplayTitle);
            $('#breakingNewsBanner').show();
        } else {
            FTVi.auth.delCookie('FTViPrintPage');
            $('#breakingNewsBanner').hide();
        }
    });
}

// Envoi d un article par mail
FTVi.sendArticleByMail = function()
{
    if (!titleArticle) {
        var titleArticle = document.title;
    }
    var sendArticlename = $('#sendArticlename').val();
    var sendArticleEmailFrom = $('#sendArticleEmailFrom').val();
    var sendArticleEmailTo = $('#sendArticleEmailTo').val();
    
    if (sendArticlename.length < 1 || sendArticleEmailFrom.length < 1 || sendArticleEmailTo.length < 1)
    {
        alert("Merci de remplir tous les champs.");
        return;
    }
    
    $('#sendArticleWaitingMessage').show();
    $.post(sendArticleByMailUrl, 
        {url : document.URL,
        title : titleArticle,
        name : $('#sendArticlename').val(),
        emailTo : $('#sendArticleEmailTo').val(),
        emailFrom : $('#sendArticleEmailFrom').val(),
        type : 'share'}, 
        function(data) 
        {
            var status = data.status;
            var message = data.message;
            if (status == 'OK')
            {
                $('#sendArticleWaitingMessage').hide();
                slideUp('emailContainer');
                $('#contributionBanner').html('<div class="container"><div class="text">Votre message a été envoyé à son destinataire</div></div>');
                $('#contributionBanner').show();
                setTimeout(function(){ slideUp('contributionBanner', 'off')}, 5000);
            }
            else
            {
                $('#sendArticleWaitingMessage').hide();
                alert("Erreur lors de l'envoi, merci de vérifier les informations.");
                return;
            }
        }
    );
}
FTVi.post = {
contentId: null,
commentCallBackUrl: null, 
postCallback: function() {
  if(FTVi.post.commentCallBackUrl&&FTVi.post.contentId) {
    $.post(FTVi.post.commentCallBackUrl,
         {content: FTVi.post.contentId},
           function(data){
           var status = data.status;
               var message = data.message;});
}}}

function makeTabs(container_id, tabs_container_class, tabs_class) {
  $('#'+container_id+' .'+tabs_container_class+' li[rel]').click(
    function() {
      showTab(this,container_id, tabs_container_class, tabs_class);
    }
  );
}
function showTab(element, container_id, tabs_container_class, tabs_class) {
  $('#'+container_id+' .'+tabs_container_class+' td[rel]').removeClass('sel');
  $('#'+container_id+' .'+tabs_class).hide();

  $(element).addClass('sel');
  $('#'+$(element).attr('rel')).show();
}
/*$(document).ready(
  function() {
    // makeTabs('reactionsBlock','tabs','tab');      
  }
);*/

//CSS BROWSER SELECTOR
/* CSS Browser Selector v0.4.0 (Nov 02, 2010) Rafael Lima (http://rafael.adm.br) http://rafael.adm.br/css_browser_selector License: http://creativecommons.org/licenses/by/2.5/ Contributors: http://rafael.adm.br/css_browser_selector#contributors */
function css_browser_selector(u){var ua=u.toLowerCase(),is=function(t){return ua.indexOf(t)>-1},g='gecko',w='webkit',s='safari',o='opera',m='mobile',h=document.documentElement,b=[(!(/opera|webtv/i.test(ua))&&/msie\s(\d)/.test(ua))?('ie ie'+RegExp.$1):is('firefox/2')?g+' ff2':is('firefox/3.5')?g+' ff3 ff3_5':is('firefox/3.6')?g+' ff3 ff3_6':is('firefox/3')?g+' ff3':is('gecko/')?g:is('opera')?o+(/version\/(\d+)/.test(ua)?' '+o+RegExp.$1:(/opera(\s|\/)(\d+)/.test(ua)?' '+o+RegExp.$2:'')):is('konqueror')?'konqueror':is('blackberry')?m+' blackberry':is('android')?m+' android':is('chrome')?w+' chrome':is('iron')?w+' iron':is('applewebkit/')?w+' '+s+(/version\/(\d+)/.test(ua)?' '+s+RegExp.$1:''):is('mozilla/')?g:'',is('j2me')?m+' j2me':is('iphone')?m+' iphone':is('ipod')?m+' ipod':is('ipad')?m+' ipad':is('mac')?'mac':is('darwin')?'mac':is('webtv')?'webtv':is('win')?'win'+(is('windows nt 6.0')?' vista':''):is('freebsd')?'freebsd':(is('x11')||is('linux'))?'linux':'','js']; c = b.join(' '); h.className += ' '+c; return c;}; css_browser_selector(navigator.userAgent);

// STYLE SWITCHER
/*
function setActiveStyleSheet(title) {
  var i, a, main;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title")) {
      a.disabled = true;
      if(a.getAttribute("title") == title) a.disabled = false;
    }
  }
  var title = getActiveStyleSheet();
  createCookie("style", title, 365);
}

function getActiveStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1 && a.getAttribute("title") && !a.disabled) return a.getAttribute("title");
  }
  return null;
}

function getPreferredStyleSheet() {
  var i, a;
  for(i=0; (a = document.getElementsByTagName("link")[i]); i++) {
    if(a.getAttribute("rel").indexOf("style") != -1
       && a.getAttribute("rel").indexOf("alt") == -1
       && a.getAttribute("title")
       ) return a.getAttribute("title");
  }
  return null;
}

function createCookie(name,value,days) {
  if (days) {
    var date = new Date();
    date.setTime(date.getTime()+(days*24*60*60*1000));
    var expires = "; expires="+date.toGMTString();
  }
  else expires = "";
  document.cookie = name+"="+value+expires+"; path=/";
}

function readCookie(name) {
  var nameEQ = name + "=";
  var ca = document.cookie.split(';');
  for(var i=0;i < ca.length;i++) {
    var c = ca[i];
    while (c.charAt(0)==' ') c = c.substring(1,c.length);
    if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
  }
  return null;
}

window.onload = function(e) {
  var cookie = readCookie("style");
  var title = cookie ? cookie : getPreferredStyleSheet();
  setActiveStyleSheet(title);
}

window.onunload = function(e) {
  
}

var cookie = readCookie("style");
var title = cookie ? cookie : getPreferredStyleSheet();
setActiveStyleSheet(title);
*/

// CLOSE DIV ONMOUSEOUT
function addToggling(nobj1){
    var obj = document.getElementById(nobj1);
    if (obj) {
        obj.onmouseover = function() {
            this.className = 'on'
        }
        obj.onmouseout = function() {
            this.className = 'off';
        }
    }
}

// FOOTER ANIMATION

 // vars to handle script behaviour
  // scrolling speed (in millisecs)
  var _ROTATOR_SPEED_MS = 5000;
 // end

 // script core vars (don't change/remove!)
var news_timer;

/**
  core function: shows some article by it's element ID (ordinal number)

  @param mixes id ID of article to show, with prefix stripped (eg, if article's ID are like article1, article2, ..., articleN id param will be 1, 2, ..., N
*/
 function _showArticle(id, auto) {
    if(auto == undefined)
    auto = false;
    $('#ticker .article').hide().addClass('off');
    $('#ticker #article'+id).fadeIn('slow').removeClass('off');

  
  if(auto) {
    if(news_timer)
      $.clearTimer(news_timer);
    news_timer = $.timer(_ROTATOR_SPEED_MS,showArticleNextAuto);
  }
  
 }

/**
  utility function: shows next article (or first, if current is last)
*/
 function showArticleNextAuto() {
  showArticleNext(true);
 }
 function showArticleNext(auto) {
  if(auto == undefined)
    auto = false;
    var toShow       = $('#ticker .article:visible').next('div.article');
    
    if(toShow[0]) {
      toShow = $(toShow);
      _showArticle(toShow.attr("id").replace('article',''), auto);
    }
    else {
      showArticleFirst( auto);
    }
 }

 /**
  utility function: shows previous article (or last, if current is first)
*/
 function showArticlePrev(auto) {
  if(auto == undefined)
    auto = false;
    var toShow       = $('#ticker .article:visible').prev('div.article');
    
    if(toShow[0]) {
      toShow = $(toShow);
      _showArticle(toShow.attr("id").replace('article',''),auto);
    }
    else {
      showArticleLast(auto);
    }
 }

 /**
  utility function: shows first article
*/
 function showArticleFirst(auto) {
  if(auto == undefined)
    auto = false;
    var toShow       = $('#ticker .article:first');
    if(toShow) {
      toShow = $(toShow);
      _showArticle(toShow.attr("id").replace('article',''),auto);
    }
 }

 /**
  utility function: shows last article
*/
 function showArticleLast(auto) {
  if(auto == undefined)
    auto = false;
    var toShow       = $('#ticker .article:last');
    if(toShow) {
      toShow = $(toShow);
      _showArticle(toShow.attr("id").replace('article',''),auto);
    }
 }

 /**
  script init, on page ready
*/
/* $(document).ready(
  function() {
  }
);*/

/*
 * jQuery Timer Plugin
 * @modified    2009 giuspe <giuspe@gmail.com>
 */ 

jQuery.timer = function(time,func,callback){
  var a = {timer:setTimeout(func,time),callback:null}
  if(typeof(callback) == 'function'){a.callback = callback;}
  return a;
};

jQuery.clearTimer = function(a){
  clearTimeout(a.timer);
  if(typeof(a.callback) == 'function'){a.callback();};
  return this;
};

// PORTFOLIO ANIMATION

  /**
    script init, on page ready
  */
  var rotator1;
  var rotator2;
  $(document).ready(
    function() {
    }
  );

//WINDOW CLOSE ANIMATIONS - two types
function fadeOut(idX, classX) {
  if($('#'+idX).size() > 0) {
    $('#'+idX).animate(
      {
        opacity: 0,
        height: '0px',
        width: '0px'
      },
      500,
      function() {
        if(classX != undefined) {
          $('#'+idX).addClass(classX);
        }
      }
    );
  }
}
function slideUp(idX, classX) {
  if($('#'+idX).size() > 0) {
    $('#'+idX).animate(
      {
        opacity: 0,
        height: '0px'
      },
      1000,
      function() {
        if(classX != undefined) {
          $('#'+idX).addClass(classX);
        }
      }
    );
  }
}
function slideDown(idX, classX) {
  $('#'+idX).animate(
    {
      opacity: 100,
      height: '100%'
    },
    1000,
    function() {
      if(classX != undefined) {
        $('#'+idX).addClass(classX);
      }
    }
  );
}


// JQUERY AUTOGROW TEXT AREA

//Private variables
var colsDefault = 0;
var rowsDefault = 0;
//var rowsCounter = 0;

//Private functions
function setDefaultValues(txtArea)
{
  colsDefault = txtArea.cols;
  rowsDefault = txtArea.rows;
  //rowsCounter = document.getElementById("rowsCounter");
}

function bindEvents(txtArea)
{
  txtArea.onkeyup = function() {
    grow(txtArea);
  }
}

//Helper functions
function grow(txtArea)
{
    var linesCount = 0;
    var lines = txtArea.value.split('\n');

    for (var i=lines.length-1; i>=0; --i)
    {
        linesCount += Math.floor((lines[i].length / colsDefault) + 1);
    }

    if (linesCount >= rowsDefault)
        txtArea.rows = linesCount + 1;
  else
        txtArea.rows = rowsDefault;
  //rowsCounter.innerHTML = linesCount + " | " + txtArea.rows;
}

//Public Method
jQuery.fn.autoGrow = function(){
  return this.each(function(){
    setDefaultValues(this);
    bindEvents(this);
  });
};


// VIDEO CAROUSEL
/*
 function handles the complete process of showing a video block.

  params:
   element: clicked element (use 'this' on call)
  group: number of group to show (starting from 1)
    container_id: id video block macro-container

*/
function showSliderGroup(element, group, container_id) {
  /* script configuration values */
  // elements in each 'page'
var slider_visible_elements = 3;
  // px of margin for last page slider (to show cropping of previous element)
var last_page_slider_margin = -198;
  // speed of page sliding (in ms)
var page_change_slide_speed_ms = 350;


  if(element) {
    var current_group = parseInt($('#'+container_id+' .sel').attr('rel'));
    
    if(group == 'down') {
      if(current_group > 1) {
        var prev = $('#'+container_id+' .dot[rel="'+(current_group-1)+'"]');
      showSliderGroup(prev, current_group-1, container_id);
      return;
      }
      else {
        return
      }
    }
    else if(group == 'up') {
    if(current_group < $('#'+container_id+' .dot').size()) {
        var next = $('#'+container_id+' .dot[rel="'+(current_group+1)+'"]');
      showSliderGroup(next, current_group+1, container_id);
      return;
    }
    else {
        return
      } 
    }

    if(group < 1)
    group = 1;

  if(current_group != group) {
    if(current_group > group) {
      var slide_direction = 'left';
    }
    else {
      var slide_direction = 'right';
    }
      var _total_number = $('#'+container_id+' .videoBlock').size();

      var primo = (group - 1) * slider_visible_elements + 1;

      if(_total_number < primo) {
      showSliderGroup($('#'+container_id+' .dot:first'), 1, container_id);
      return;
      }
      else {
        // class handling

      $('#'+container_id+' .leftArrow').removeClass('off');
      $('#'+container_id+' .rightArrow').removeClass('off');
      
        if(primo == 1)
        $('#'+container_id+' .leftArrow').addClass('off');
        else
        $('#'+container_id+' .leftArrow').removeClass('off');

        if(_total_number >= (primo + slider_visible_elements)) {
        $('#'+container_id+' .rightArrow').removeClass('off');
        if(parseInt($('#'+container_id+' .slider').css('marginLeft')) != 0)
          $('#'+container_id+' .slider').css('marginLeft','0px');
        }
        else {
        $('#'+container_id+' .rightArrow').addClass('off');
        $('#'+container_id+' .slider').css(
          {
            marginLeft: 
             function(index, value) {
                 return parseInt(value) + last_page_slider_margin;
              } 
          }
        );
        }

        $('#'+container_id+' .dot').removeClass('sel');
        $(element).addClass('sel');

        // element handling
      $('#'+container_id+' .videoBlock').addClass('hidden').css('display','none');

      var delta = _total_number - primo;
      if(delta < slider_visible_elements) {
        var _subdelta = slider_visible_elements - delta;
        primo = primo - _subdelta + 1;  
      }

      // to show crop of previous element
      if(primo + slider_visible_elements > _total_number)
        primo = primo - 1;
      
      $("<div id='fake_slider' style='padding-top: 0px; width: "+($('#'+container_id+' #video1').width()*slider_visible_elements)+"px;' class='videoBlock'></div>").appendTo('#'+container_id+' .slider');

      
      for(i = primo; i < (primo + slider_visible_elements + 1); i++) {
          if($('#'+container_id+' #video'+i)) {
            $('#'+container_id+' #video'+i).removeClass('hidden').appendTo('#fake_slider').css('display','block');
          }
      }
      $('#fake_slider').show(
        "slide", 
        { direction: slide_direction }, 
        page_change_slide_speed_ms, 
        function() {
           $('#fake_slider .videoBlock').unwrap();
        }
      );
    }
    }
  }
}

/**
 * Fonction de "surcharge" de Xiti pour définir la page sur laquelle on se trouve  
 * @param label		le nom du clic
 * @returns
 */

FTVi.countClick = function(label) {
    var url = new String(window.location.pathname);
    
    var reg_home = new RegExp("\/info\/*$", "gi");
    
    var reg_les_titres = new RegExp("\/info\/titres\/*$", "gi");

    var reg_plus_commentes = new RegExp("\/info\/plus-commentes\/*$", "gi");
    var reg_plus_envoyes = new RegExp("\/info\/plus-envoyes\/*$", "gi");

    var reg_region = new RegExp("\/info\/regions\/*$", "gi");
    var reg_domtom = new RegExp("\/info\/dom-tom\/*$", "gi");

    var reg_images = new RegExp("\/info\/images\/videos\/*$", "gi");
    var reg_slideswhows = new RegExp("\/info\/images\/slideshows\/*$", "gi");

    var reg_content = new RegExp("\/info\/[a-z\-0-9]*_[0-9]*\.html$", "gi");

    var reg_topic = new RegExp("\/info\/[a-z\-0-9]+\/*$", "gi");
    
    var prefixe = '';
    
    if (reg_topic.test(url)) {
        prefixe = 'topic';
    }
    
    if (reg_home.test(url)) {
        prefixe = 'home';
    }
    
    if (reg_les_titres.test(url)) {
        prefixe = 'lestitres';
    }
    
    if (reg_plus_commentes.test(url) || reg_plus_envoyes.test(url)) {
        prefixe = 'lestops';
    }
    
    if (reg_region.test(url) || reg_domtom.test(url)) {
        prefixe = 'lesregions';
    }
    
    if (reg_images.test(url) || reg_slideswhows.test(url)) {
        prefixe = 'lesimages';
    }
    
    if (reg_content.test(url)) {
        prefixe = 'content';
    }
    
    //alert('Résultat :' + "\n" + ' - label = ' + label + "\n" + ' - url = ' + url + "\n" + ' - Prefixe = ' + prefixe);
    return xt_click(this,'C', '19', prefixe + '_' + label, 'N');
};

/**
 * Classe de génération de contenu HTML
 */
FTVi.html = {};

// Popup d'aide
FTVi.html.genererCommentCaMarche = function()
{
    if (!document.getElementById('instructionsContainer'))
    {
        var code_html = '';
	    
        code_html += '<div id="instructionsContainer" style="height: 0px; opacity: 0; overflow: hidden;">';
        code_html += '   <div class="instructions">';
        code_html += '      <div class="title">Prenez les commandes de votre info</div>';
        code_html += '      <div class="close"><a onclick="slideUp(\'instructionsContainer\'); return false;" href="#"></a></div>';
        code_html += '      <div class="frame">';
        code_html += '         <div class="leftCol">';
        code_html += '            <p class="leftTitle">FTVi, c’est cinq canaux d\'information</p>';
        code_html += '            <ul>';
        code_html += '               <li class="enDirect">';
        code_html += '                  <div class="icon"></div>';
        code_html += '                  <strong>Pour savoir ce qui se passe maintenant</strong>';
        code_html += '                  Toutes les infos livrées minute par minute dans de courts messages';
        code_html += '               </li>';
        code_html += '               <li class="lesTitres">';
        code_html += '                  <div class="icon"></div>';
        code_html += '                  <strong>Pour connaître l\'actu du jour</strong>';
        code_html += '                  Les infos les plus importantes développées par la rédaction';
        code_html += '               </li>';
        code_html += '               <li class="lesTops">';
        code_html += '                  <div class="icon"></div>';
        code_html += '                  <strong>Pour découvrir ce qui fait le buzz</strong>';
        code_html += '                  Les infos les plus partagées et les plus commentées';
        code_html += '               </li>';
        code_html += '               <li class="lesRegions">';
        code_html += '                  <div class="icon"></div>';
        code_html += '                  <strong>Pour suivre ce qui se passe en région</strong>';
        code_html += '                  L\'info des rédactions du réseau France Télévisions';
        code_html += '               </li>';
        code_html += '               <li class="lesImages">';
        code_html += '                  <div class="icon"></div>';
        code_html += '                  <strong>Pour voir l\'actu plein écran</strong>';
        code_html += '                  Les infos en vidéos et en diaporamas';
        code_html += '               </li>';
        code_html += '            </ul>';
        code_html += '         </div>';
        code_html += '         <div class="rightCol">';
        code_html += '            <div class="rightTitle">Et aussi</div>';
        code_html += '            <div class="image"></div>';
        code_html += '            <a target="_blank" href="http://itunes.apple.com/fr/app/francetv-info/id348684697?mt=8" class="btn">Télécharger l\'app IPhone</a>';
        code_html += '            <a target="_blank" href="https://market.android.com/details?id=fr.francetv.apps.info" class="btn">Télécharger l\'app Android</a>';
        code_html += '            <div class="comingSoon">Bientôt sur tablettes et télévision connectée</div>';
        code_html += '         </div>';
        code_html += '      </div>';
        code_html += '   </div>';
        code_html += '</div>';
        
        $('body').append(code_html);
    }
};

// Box de connexion/identification
FTVi.html.genererLoginBox = function()
{
    if (!document.getElementById('loginBoxContainer'))
    {
        var code_html = '';
        
        code_html += '<div id="loginBoxContainer" class="accountInfo" style="display: none;">';
        code_html += '   <div class="loginBox">';
        code_html += '      <div class="title">Se connecter</div>';
        code_html += '      <div class="close"><a href="#" onclick="slideUp(\'loginBoxContainer\'); return false;"></a></div>';
        code_html += '      <div class="ltCol">';
        code_html += '         <div class="subtitle">Se connecter à FTVi</div>';
        code_html += '         <label>Email</label>';
        code_html += '         <input type="text" id="piEmail" name="email" class="txtInput"/>';
        code_html += '         <label>Mot de passe</label>';
        code_html += '         <input type="password" id="piPassword" name="password" class="txtInput" />';
        code_html += '         <a href="#" class="forgot">Mot de passe oublié ?</a> ';
        code_html += '         <div class="buttons">';
        code_html += '            <input type="button" class="connect" onclick="FTVi.auth.loginPi(false);" value="Se connecter" />';
        code_html += '            <a href="/info/user/profile/" class="createAcct">Créer mon compte</a> ';
        code_html += '         </div>';
        code_html += '      </div>';
        code_html += '      <div class="rtCol">';
        code_html += '         <div class="subtitle">Se connecter avec un autre compte</div>';
        code_html += '         <a href="#" onclick="FTVi.auth.loginFacebook(); return false;" class="facebook">Facebook</a>';
        code_html += '         <a href="#" onclick="FTVi.auth.loginTwitter(); return false;" class="twitter">Twitter</a>';
        code_html += '         <!--a href="#" class="leClub">Le Club</a-->';
        code_html += '      </div>';
        code_html += '   </div>';
        code_html += '</div>';
        
        $('body').append(code_html);
    }
};

// Message d'alerte
FTVi.html.genererAlerte = function()
{
    if (!document.getElementById('breakingNewsBanner'))
    {
       var code_html = '';
       
       code_html += '<div id="breakingNewsBanner" style="display: none;">';
       code_html += '   <div class="container">';
       code_html += '      <div class="title">Flash info</div>';
       code_html += '      <div class="text" id="breakingNewsTitle"></div>';
       code_html += '      <a onclick="slideUp(\'breakingNewsBanner\',\'off\'); return false;" class="close " href="#">Fermer</a>';
       code_html += '   </div>';
       code_html += '</div>';
       
       $(code_html).insertAfter($('#header'));
    }
};

// Message du site
FTVi.html.genererMessage = function()
{
    if (!document.getElementById('contributionBanner'))
    {
       var code_html = '';
       
       code_html += '<div id="contributionBanner">';
       code_html += '   <div class="container">';
       code_html += '      <div class="text">Votre compte est maintenant créé !</div>';
       code_html += '   </div>';
       code_html += '</div>';
       
       $(code_html).insertAfter($('#header'));
    }
};

// Popup d'envoi par email
FTVi.html.genererFormulaireEnvoiEmail = function()
{
    if (!document.getElementById('emailContainer'))
    {
       var code_html = '';
       
       code_html += '<div id="emailContainer" style="display: none; overflow: hidden;">';
       code_html += '   <div class="emailBox">';
       code_html += '      <div class="title">Envoyer cet article</div>';
       code_html += '      <div class="close"><a onclick="slideUp(\'emailContainer\'); return false;" href="#"></a></div>';
       code_html += '      <form>';
       code_html += '         <label>Votre  nom</label>';
       code_html += '         <input id="sendArticlename" type="text" class="txtInput" />';
       code_html += '         <label>Votre adresse email</label>';
       code_html += '         <input id="sendArticleEmailFrom" type="text" class="txtInput" />';
       code_html += '         <label>L\'adresse de votre destinataire</label>';
       code_html += '         <input id="sendArticleEmailTo" type="text" class="txtInput" />';
       code_html += '         <input type="button" onclick="FTVi.sendArticleByMail();" value="Envoyer" class="btn">';
       code_html += '      </form>';
       code_html += '      <p id="sendArticleWaitingMessage" style="display: none; border: solid 1px red; padding: 10px; color: red; font-weight: bold; background-color: #fff; z-index: 100; position: absolute; top: 125px; left: 80px;">Envoi en cours, merci de patienter&hellip;</p>';
       code_html += '   </div>';
       code_html += '</div>';
       
       $('body').append(code_html);
    }
};

// Le footer
FTVi.html.genererFooter = function()
{
    var code_html = '';
    
    code_html += '<div id="footer">';
    code_html += '   <div class="container">';
    code_html += '      <ul class="icons">';
    code_html += '         <li class="facebook"><a target="_blank" href="http://www.facebook.com/francetvinfo">Facebook</a></li>';
    code_html += '         <li class="twitter"><a target="_blank" href="http://twitter.com/#!/francetvinfo">Twitter</a></li>';
    code_html += '         <li class="rss"><a href="/info/rss/">Rss</a></li>';
    code_html += '         <li class="smartphone"><a target="_blank" href="https://market.android.com/details?id=fr.francetv.apps.info">smartphone</a></li>';
    code_html += '         <li class="iPhone"><a target="_blank" href="http://itunes.apple.com/fr/app/francetv-info/id348684697?mt=8">iPhone</a></li>';
    code_html += '         <!--li class="iPad"><a href="#">iPad</a></li-->';
    code_html += '      </ul>';
    code_html += '      <ul class="siteLinks">';
    code_html += '         <li class="copyright">© 2011 <span style="cursor: pointer;" onclick="window.open(\'http://www.francetelevisions.fr/\');">France Télévisions</span></li>';
    code_html += '         <li><a href="/info/nous-contacter/">Nous contacter</a></li>';
    code_html += '         <li><a href="/info/qui-sommes-nous/">Qui sommes-nous?</a></li>';
    code_html += '         <li><a href="/info/mentions-legales/">Mentions légales</a></li>';
    code_html += '         <li><a href="http://www.ftv-publicite.fr/">France Télévisions Publicité</a></li>';
    code_html += '         <li><a href="/info/sitemap/index.html">Index</a></li>';
    code_html += '      </ul>';
    code_html += '      <ul class="franceTVMenu">';
    code_html += '         <li class="sports"><a href="http://sport.francetv.fr/">FranceTV.sports</a></li>';
    code_html += '         <li class="geopolis"><a href="http://geopolis.france2.fr/">Geopolis</a></li>';
    code_html += '         <li class="cultureBox"><a href="http://culturebox.france3.fr/">CultureBox</a></li>';
    code_html += '         <li class="france2"><a href="http://www.france2.fr/">France</a></li>';
    code_html += '         <li class="france3"><a href="http://www.france3.fr/">France</a></li>';
    code_html += '         <li class="france4"><a href="http://www.france4.fr/">France</a></li>';
    code_html += '         <li class="france5"><a href="http://www.france5.fr/">France</a></li>';
    code_html += '         <li class="franceO"><a href="http://www.franceo.fr/">France</a></li>';
    code_html += '      </ul>';
    code_html += '      <div class="logo"><a href="#"><img src="/info/skin/www/img/lgo/logo_footer.png" border="0"></a></div>';
    code_html += '   </div>';
    code_html += '</div>';
    
    document.write(code_html);
};

// Le header
FTVi.html.genererHeader = function()
{
    var code_html = '';
    code_html += '<div id="header">';
    code_html += '   <div class="container">';
    code_html += '      <div id="personalInfo" onmouseover="this.className=\'on\';" onmouseout="this.className=\'off\';">';
    code_html += '         <span href="#" class="signup" onclick="$(\'#loginBoxContainer\').show(); slideDown(\'loginBoxContainer\'); return false;">';
    code_html += '            S\'inscrire / Se connecter';
    code_html += '         </span>';
    code_html += '      </div>';
    code_html += '      <div class="social">';
    code_html += '         <div class="fb"><iframe src="//www.facebook.com/plugins/like.php?href=http%3A%2F%2Fwww.facebook.com%2Ffrancetvinfo&amp;send=false&amp;layout=button_count&amp;width=100&amp;show_faces=true&amp;action=like&amp;colorscheme=light&amp;font&amp;height=21&amp;appId=256070767774322" scrolling="no" frameborder="0" style="border:none; overflow:hidden; width:100px; height:21px;" allowTransparency="true"></iframe></div>';
    code_html += '         <div class="twt"><a href="https://twitter.com/francetvinfo" class="twitter-follow-button" data-show-count="false" data-lang="fr" data-show-screen-name="false">Suivre @francetvinfo</a></div>';
    code_html += '         <div class="ggl"><div class="g-plusone" data-size="medium" data-count="false" data-href="http://www.francetv.fr/info/"></div></div>';    
    code_html += '      </div>';
    code_html += '      <ul class="franceTVMenu">';
    code_html += '         <li class="france1"><a href="http://www.la1ere.fr" onclick="FTVi.countClick(\'header_groupe_france1\');"></a></li>';
    code_html += '         <li class="france2"><a href="http://www.france2.fr" onclick="FTVi.countClick(\'header_groupe_france2\');"></a></li>';
    code_html += '         <li class="france3"><a href="http://www.france3.fr" onclick="FTVi.countClick(\'header_groupe_france3\');"></a></li>';
    code_html += '         <li class="france4"><a href="http://www.france4.fr" onclick="FTVi.countClick(\'header_groupe_france4\');"></a></li>';
    code_html += '         <li class="france5"><a href="http://www.france5.fr" onclick="FTVi.countClick(\'header_groupe_france5\');"></a></li>';
    code_html += '         <li class="franceO"><a href="http://www.franceo.fr" onclick="FTVi.countClick(\'header_groupe_france6\');"></a></li>';
    code_html += '      </ul>';
    code_html += '      <div class="logo"><a href="/info/" onclick="FTVi.countClick(\'header_logo\');"><img src="/info/skin/www/img/lgo/logo.png" border="0"></a></div>';

    document.write(code_html);
};

// La navigation
FTVi.html.genererNavigation = function(home)
{
    var code_html = '';
    code_html += '      <ul id="topMenu">';
    code_html += '         <li id="menuFrance" class="off">';
    code_html += '            <a href="/info/france" onmouseover="document.getElementById(\'menuFrance\').className=\'on\';" onclick="FTVi.countClick(\'header_nav_france\');">France</a>';
    code_html += '            <div class="rolloverTop"></div>';
    code_html += '            <ul>';
    code_html += '               <li><a href="/info/politique/" onclick="FTVi.countClick(\'header_nav_politique\');">Politique</a></li>';
    code_html += '               <li><a href="/info/societe/" onclick="FTVi.countClick(\'header_nav_societe\');">Société</a></li>';
    code_html += '               <li><a href="/info/faits-divers/" onclick="FTVi.countClick(\'header_nav_faitsdivers\');">Faits divers</a></li>';
    code_html += '               <li><a href="/info/justice/" onclick="FTVi.countClick(\'header_nav_justice\');">Justice</a></li>';
    code_html += '            </ul>';
    code_html += '         </li>';
    code_html += '         <li id="menuMonde" class="off">';
    code_html += '            <a href="/info/monde" onmouseover="document.getElementById(\'menuMonde\').className=\'on\';" onclick="FTVi.countClick(\'header_nav_monde\');">Monde</a>';
    code_html += '            <div class="rolloverTop"></div>';
    code_html += '            <ul>';
    code_html += '               <li><a href="/info/afrique/" onclick="FTVi.countClick(\'header_nav_afrique\');">Afrique</a></li>';
    code_html += '               <li><a href="/info/ameriques/" onclick="FTVi.countClick(\'header_nav_ameriques\');">Amériques</a></li>';
    code_html += '               <li><a href="/info/asie-pacifique/" onclick="FTVi.countClick(\'header_nav_asiepacifique\');">Asie-Pacifique</a></li>';
    code_html += '               <li><a href="/info/europe/" onclick="FTVi.countClick(\'header_nav_europe\');">Europe</a></li>';
    code_html += '               <li><a href="/info/proche-orient/" onclick="FTVi.countClick(\'header_nav_procheorient\');">Proche-Orient</a></li>';
    code_html += '               <li><a href="/info/environnement/" onclick="FTVi.countClick(\'header_nav_environnement\');">Environnement</a></li>';
    code_html += '            </ul>';
    code_html += '         </li>';
    code_html += '         <li id="menuEco" class="off">';
    code_html += '            <a href="/info/eco" onmouseover="document.getElementById(\'menuEco\').className=\'on\';" onclick="FTVi.countClick(\'header_nav_eco\');">Eco</a>';
    code_html += '            <div class="rolloverTop"></div>';
    code_html += '            <ul>';
    code_html += '               <li><a href="/info/tendances/" onclick="FTVi.countClick(\'header_nav_tendances\');">Tendances</a></li>';
    code_html += '               <li><a href="/info/entreprises/" onclick="FTVi.countClick(\'header_nav_entreprises\');">Entreprises</a></li>';
    code_html += '               <li><a href="/info/marches/" onclick="FTVi.countClick(\'header_nav_marches\');">Marchés</a></li>';
    code_html += '               <li><a href="/info/immobilier/" onclick="FTVi.countClick(\'header_nav_immobilier\');">Immobilier</a></li>';
    code_html += '            </ul>';
    code_html += '         </li>';
    code_html += '         <li id="menuSports" class="off">';
    code_html += '            <a href="/info/sports/" onmouseover="document.getElementById(\'menuSports\').className=\'on\';" onclick="FTVi.countClick(\'header_nav_sports\');">Sports</a>';
    code_html += '            <div class="rolloverTop"></div>';
    code_html += '            <ul>';
    code_html += '               <li><a href="/info/foot/" onclick="FTVi.countClick(\'header_nav_foot\');">Foot</a></li>';
    code_html += '               <li><a href="/info/rugby/" onclick="FTVi.countClick(\'header_nav_rugby\');">Rugby</a></li>';
    code_html += '               <li><a href="/info/f1/" onclick="FTVi.countClick(\'header_nav_f1\');">F1</a></li>';
    code_html += '            </ul>';
    code_html += '         </li>';
    code_html += '         <li id="menuDecouvertes" class="off">';
    code_html += '            <a href="/info/decouverte" onmouseover="document.getElementById(\'menuDecouvertes\').className=\'on\';" onclick="FTVi.countClick(\'header_nav_decouvertes\');">Découvertes</a>';
    code_html += '            <div class="rolloverTop"></div>';
    code_html += '            <ul>';
    code_html += '               <li><a href="/info/sciences/" onclick="FTVi.countClick(\'header_nav_sciences\');">Sciences</a></li>';
    code_html += '               <li><a href="/info/sante/" onclick="FTVi.countClick(\'header_nav_sante\');">Santé</a></li>';
    code_html += '               <li><a href="/info/animaux/" onclick="FTVi.countClick(\'header_nav_animaux\');">Animaux</a></li>';
    code_html += '               <li><a href="/info/bizarre/" onclick="FTVi.countClick(\'header_nav_bizarre\');">Bizarre</a></li>';
    code_html += '            </ul>';
    code_html += '         </li>';
    code_html += '         <li id="menuBuzz" class="off">';
    code_html += '            <a href="/info/culture-buzz/" onmouseover="document.getElementById(\'menuBuzz\').className=\'on\';" onclick="FTVi.countClick(\'header_nav_buzz\');">Buzz+</a>';
    code_html += '            <div class="rolloverTop"></div>';
    code_html += '            <ul>';
    code_html += '               <li><a href="/info/medias/" onclick="FTVi.countClick(\'header_nav_medias\');">Médias</a></li>';
    code_html += '               <li><a href="/info/cinema/" onclick="FTVi.countClick(\'header_nav_cinema\');">Cinéma</a></li>';
    code_html += '               <li><a href="/info/musiques/" onclick="FTVi.countClick(\'header_nav_musique\');">Musique</a></li>';
    code_html += '               <li><a href="/info/expos/" onclick="FTVi.countClick(\'header_nav_expos\');">Expos</a></li>';
    code_html += '               <li><a href="/info/internet/" onclick="FTVi.countClick(\'header_nav_internet\');">Internet</a></li>';
    code_html += '            </ul>';
    code_html += '         </li>';
    code_html += '         <li id="menuSmiley" class="off">';
    code_html += '            <a href="#" onmouseover="document.getElementById(\'menuSmiley\').className=\'on\';" onclick="FTVi.countClick(\'header_nav_smiley\');">Smiley</a>';
    code_html += '            <div class="rolloverTop"></div>';
    code_html += '            <ul>';
    code_html += '               <li><a href="/info/meteoroscope/" onclick="FTVi.countClick(\'header_nav_meteo\');">Météo</a></li>';
    code_html += '            </ul>';
    code_html += '         </li>';
    code_html += '         <li class="search">';
    code_html += '            <form method="get" action="/info/recherche/">';
    code_html += '               <input type="text" class="inputBox" value="Recherchez"  onblur="if(this.value==\'\'){this.value=\'Recherchez\'}" onfocus="if (this.value==\'Recherchez\') {this.value=\'\'}" name="request" />';
    code_html += '               <input type="image" src="/info/skin/www/img/icn/icn_search.gif" class="btn" />';
    code_html += '            </form>';
    code_html += '         </li>';
    code_html += '      </ul>';
    code_html += '   </div>';
    code_html += '</div>';

    document.write(code_html);
};

// Le menu
FTVi.html.genererMenu = function(on)
{
	var code_html = '';
    code_html += '<div id="leftColumn">';
    code_html += '   <ul id="leftMenu">';
    code_html += '      <li class="direct' + (on == 'direct' ? ' sel' : '') + '"><a href="/info/" onclick="FTVi.countClick(\'menu_en_direct\');">En direct</a></li>';
    code_html += '      <li class="une' + (on == 'home' ? ' sel' : '') + '"><a href="/info/titres/" onclick="FTVi.countClick(\'menu_les_titres\');">En une</a></li>';
    code_html += '      <li class="tops' + (on == 'tops' ? ' sel' : '') + '"><a href="/info/plus-commentes/" onclick="FTVi.countClick(\'menu_les_tops\');">Les tops</a></li>';
    code_html += '      <li class="regions' + (on == 'regions' ? ' sel' : '') + '"><a href="/info/regions/" onclick="FTVi.countClick(\'menu_les_regions\');">Les regions</a></li>';
    code_html += '      <li class="ecrans' + (on == 'screens' ? ' sel' : '') + '"><a href="/info/images/videos" onclick="FTVi.countClick(\'menu_les_images\');">Les images</a></li>';
    code_html += '      <li class="instructions"><span onclick="slideDown(\'instructionsContainer\'); return false;">Comment ça marche</span></li>';
    code_html += '   </ul>';
    code_html += '</div>';

    document.write(code_html);
};

// Barre d'outils
FTVi.html.genererBarreOutils = function(contentType, nbComments, position)
{
    var code_html = '';
    code_html += '<div class="tools' + (position == 'bas' ? ' tools_bas' : '') + '">';
    if (contentType == 'slideshow') {
        code_html += '<div class="navigate">Naviguez avec votre clavier</div>';
    }
    code_html += '   <div class="facebook"><div class="fb-like" data-send="true" data-layout="button_count" data-width="130" data-show-faces="false" data-action="recommend"></div></div>';
    code_html += '   <div class="google"><div class="g-plusone" data-size="medium"></div></div>';
    code_html += '   <div class="twitter"><a href="https://twitter.com/share" class="twitter-share-button" data-via="francetvinfo" data-lang="fr" data-related="francetvinfo">Tweeter</a></div>';
    code_html += '   <div id="commentsDiv" class="comments"><a href="#">' + nbComments + '<span><b>Réactions</b></span></a></div>';
    code_html += '   <div class="send"><a href="javascript:void(0);" onclick="$(\'#emailContainer\').show(); slideDown(\'emailContainer\'); return false;" titre_article="\'+titlePage+\'"><span><b>Envoyer par mail</b></span></a></div>';
    code_html += '   <div class="print"><a href="#" onclick="FTVi.printPage(); return false;"><span><b>Imprimer</b></span></a></div>';
    code_html += '</div>';
    
    document.write(code_html);
};

// Bloc de pub "La campagne à vélo" / ou Twitter
FTVi.html.genererBlocPub = function()
{
	//var minute = (new Date()).getMinutes();
	
	var code_html = '';
	
	/*if (minute < 20 || minute > 40)
	{*/
		code_html += '<div class="lacampagneavelo">';
		code_html += '   <a onclick="FTVi.countClick(\'cd_campagne\');" href="https://www.facebook.com/lacampagneavelo" target="_blank">';
		code_html += '      <img src="/info/skin/www/img/temp/la-campagne-a-velo.jpg" width="300" height="70" />';
		code_html += '   </a>';
		code_html += '</div>';
	/*}
	else
	{
		code_html += '<div id="followTwitter">';
		code_html += '<!--[if IE 7]><div></div><![endif]-->';
		code_html += 'Suivez-nous sur <a target="_blank" href="http://twitter.com/#!/francetvinfo">Twitter<br />';
		code_html += '<img width="140" height="26" src="/info/skin/www/img/icn/icn_twitter.png" alt="Twitter" /></a>';
		code_html += '</div>';
	}*/
	
	document.write(code_html);
};


$(document).ready(function() 
{
    // Popup promo Facebook 
	FTVi.Fb.genererPromoHtml();
	
	// Généreation de HTML  
    FTVi.html.genererCommentCaMarche();
    FTVi.html.genererLoginBox();
    FTVi.html.genererAlerte();
    FTVi.html.genererMessage();
    FTVi.html.genererFormulaireEnvoiEmail();

    // Highlit de sous menu
    addToggling('menuFrance');
    addToggling('menuMonde');
    addToggling('menuEco');
    addToggling('menuSports');
    addToggling('menuDecouvertes');
    addToggling('menuBuzz');
    addToggling('menuSmiley');
    
    // pour ie et chrome qui gardent en cache la page précédente car on ne change pas d'url, on impose la css de print en stylesheet
    var cookiePrintPage = FTVi.auth.getCookie('FTViPrintPage');
    if (cookiePrintPage) {
        if($.browser.msie) {
            var head = document.getElementsByTagName('head')[0];
            var css = document.createElement('link');
            css.setAttribute("rel", "stylesheet");
            css.setAttribute("href", "/info/skin/www/css/print.css");
            css.setAttribute("type", "text/css");
            head.appendChild(css);
        } else {
            $('#breakingNewsBanner').hide();
            $('<link rel="stylesheet" type="text/css" href="/info/skin/www/css/print.css" />').appendTo($('head'));
        }
        /*window.print();*/
        FTVi.auth.delCookie('FTViPrintPage');
    }

    //FTVi.addRightCol();
    //setTimeout('FTVi.addRightCol()', 300000); // on change la pub toutes les 5 minutes
});


/**
 * Librairie "Right Column"
 */
FTVi.rightColumn = {};
FTVi.rightColumn.loadBlocks = function (blocks) {
	for (var cpt = 0 ; cpt < blocks.length ; cpt ++) {
	    // Ajout div "encadrante" du bloc
        // OK, attente akamaï => $('#rightColumn').append('<div id="rightColumn_' + cpt + '"></div>');
        
        // On charge le bloc
        var chargerBloc = function(block, cpt) {
            $.ajax({
                url: block['url'],
                success: function(data) {                   
                    // Chargement du HTML dans la page
                    // OK, attente akamaï$ => (data).appendTo('#rightColumn_' + cpt);
                    $('#rightColumn_' + cpt).html(data);
                    // Appel de callback éventuelle
                    if (block['callback'] != '') {
                        eval('FTVi.rightColumn.' + block['callback'] + '()');
                    }
                }
            });
        };
        chargerBloc(blocks[cpt], cpt);
    }
};
// Callback pour le bloc "Les titres"
FTVi.rightColumn.feedHome = function () {
    // On supprime 1 titre
    if ((typeof content_id != 'undefined') && ($('#content_' + content_id).length > 0)) {
        $('#content_' + content_id).remove();
    } else {
        $('#titresBlock .article').last().remove();
    }
    // Facebook
    $("#titresBlock .article").each(function() {
        var node = $(this);
         if($(this).find(".facebook").size() > 0) {
             fb_url = 'http://api.facebook.com/method/fql.query?query=';
             fb_sql = 'select total_count,like_count,comment_count,share_count,click_count from link_stat where url=';
             $.ajax({ url: fb_url + encodeURI(fb_sql + '\'' + $(this).children("a").attr("href")) + '\'' + '&format=json', async  : true, dataType: 'json', success: function(datas){ node.find(".facebook").html(datas[0].total_count); }});
         }
     });
};
//Callback pour le bloc "Les Tops"
FTVi.rightColumn.topHome = function () {
    // Facebook
    $("#lesTopsBlock .article").each(function() {
        var node = $(this);
         if($(this).find(".facebook").size() > 0) {
             fb_url = 'http://api.facebook.com/method/fql.query?query=';
             fb_sql = 'select total_count,like_count,comment_count,share_count,click_count from link_stat where url=';
             $.ajax({ url: fb_url + encodeURI(fb_sql + '\'' + $(this).children("a").attr("href")) + '\'' + '&format=json', async  : true, dataType: 'json', success: function(datas){ node.find(".facebook").html(datas[0].total_count); }});
         }
     });
};
// On bouge dans le bloc "Live"
FTVi.rightColumn.feedLive = function () {
    var html = '<li class="article" onclick="' + $('#cdSlideEnDirect li:last').attr('onclick') + '">' + $('#cdSlideEnDirect li:last').html() + '</li>';
    $('#cdSlideEnDirect li:last').animate({opacity: 0}, 700).fadeOut('slow', function() {$(this).remove();});
    $('#cdSlideEnDirect').prepend(html);
};
setInterval(function(){ FTVi.rightColumn.feedLive(); }, 3000);


/**
 * Librairie "Tools" / Cookie
 */
FTVi.Tools = {};
FTVi.Tools.cookie = {};
/**
 * @description          Méthode statique de creation de cookie
 * @param {string}       name       nom du cookie
 * @param {string}       value      valeur du cookie
 * @param {string}       seconds    nombre de secondes de persistance du cookie
 */
FTVi.Tools.cookie.createCookie = function(name,value,seconds)
{
	var expires;
    if (seconds) {
        var date = new Date();
        date.setTime(date.getTime()+(seconds*1000));
        expires = "; expires="+date.toGMTString();
    } else { 
        expires = "";
    }
    document.cookie = name+"="+value+expires+"; path=/";
};
	
/**
 * @description           Méthode statique de lecture de cookie
 * @param  {string}       name       nom du cookie
 * @return {string}       valeur du cookie
 */
FTVi.Tools.cookie.readCookie = function(name)
{
   var nameEQ = name + "=";
   var ca = document.cookie.split(';');
   for(var i=0;i < ca.length;i++) {
      var c = ca[i];
      while (c.charAt(0)==' ') c = c.substring(1,c.length);
      if (c.indexOf(nameEQ) == 0) return c.substring(nameEQ.length,c.length);
   }
   return false;
};

/**
 * Méthode statique d'effacement de cookie
 *
 * @description           Méthode statique d'effacement de cookie
 * @method                eraseCookie
 * @param  {string}       name       nom du cookie
 * @return {string}       valeur du cookie
 * @public
 * @static
 */
FTVi.Tools.cookie.eraseCookie = function(name)
{
   var date = new Date;
   date.setFullYear(date.getFullYear()-1);
   FTVi.Tools.cookie.createCookie(name,"",date);
};

/**
 * Méthode statique de récupération des noms des cookies posés
 *
 * @description           Méthode statique de récupération des noms des cookies posés
 * @method                getCookiesNames
 * @return {array}        tableau des noms des cookies
 * @public
 * @static
 */
FTVi.Tools.cookie.getCookiesNames = function()
{
   var tab_cookies_names = new Array();
   var ca = document.cookie.split(';');
   for(var i=0;i < ca.length;i++) {
      var c = ca[i];
      var tab_nom_val = c.split('=');
      var nom = tab_nom_val[0];
      while (nom.charAt(0)==' ') nom = nom.substring(1,nom.length);
      tab_cookies_names.push(nom);
   }
   return tab_cookies_names;
};
