/**
 * Js gérant la zone 'partage' des pages du Post
 *
 * @package       lesite
 * @subpackage    tv/js
 * @author        Kris Juillet 2009
 * @author        $Author: kris $
 * @version       $Revision: 41420 $
 * @date          $Date: 2009-07-15 16:44:50 +0200 (Wed, 15 Jul 2009) $
 * @id            $Id: partage.js 41420 2009-07-15 14:44:50Z kris $
 */
if (undefined===window.MIA)
{
   var MIA = {};
}
MIA.Partage =
{
   class_name : 'Partage',
   
   xtor : new Array(10),
   
   anim_en_cours : false,
   
   /**
   * Méthode d'initialisation
   *
   * @author     jeremie
   * @return     void
   * @access     public
   */
   init : function()
   {
      MIA.Partage.xtor[0] = 'AL-282';   // Facebook
      MIA.Partage.xtor[1] = 'AL-286';   // Twitter
      MIA.Partage.xtor[2] = 'AL-283';   // Wikio
      MIA.Partage.xtor[3] = 'AL-279';   // Skyrock
      MIA.Partage.xtor[4] = 'AL-280';   // MySpace
      MIA.Partage.xtor[5] = 'AL-287';   // Yoolink
      MIA.Partage.xtor[6] = 'AL-288';   // Viadeo
      MIA.Partage.xtor[7] = 'AL-281';   // Digg
      MIA.Partage.xtor[8] = 'AL-284';   // Delicious
      MIA.Partage.xtor[9] = 'AL-285';   // YahooBuzz
      MIA.Partage.genererHtml();
   },
   
   
   supprimerAccent : function (str)
   { 
      alert('Avant = ' + str);
      var temp = str.replace(/[àâä]/gi, "a");
      temp = temp.replace(/[éèêë]/gi, "e");
      temp = temp.replace(/[îï]/gi, "i");
      temp = temp.replace(/[ôö]/gi, "o");
      temp = temp.replace(/[ùûü]/gi, "u");
      alert('Apres = ' + temp);
      return temp;
   },  

   
   /**
    * Méthode générant le code html du bloc partage
    *
    * @author     jeremie
    * @return     void
    * @access     public
    */
   genererHtml : function()
   {
      var html = '';
      html += '<div id="volet_partage" style="display:none;">';
      html += '<div class="top_partage">Lien direct <input type="text" value="' + decodeURIComponent(item_permalien) + '" onclick="this.focus();this.select();"/> <a href="" onclick="MIA.Partage.animer(); return false;" class="btn_fermer"><img src="' + MIA.Conf.general.www_medias_url + '/img/partage/btn_fermer.gif" border="0" /></a></div>';
      html += '<div class="corps_partage">';
      html += '<div class="titre_corps_partage">Partager</div>';
      html += '<div id="bloc_liens_partage">';
      
      // Facebook
      html += '<div class="lien_partage">';
      html += '<a href="http://www.facebook.com/sharer.php?u=' + item_url + encodeURIComponent('#xtor=' + MIA.Partage.xtor[0]) + '" target="_blank" onclick="javascript:xt_med(\'C\', \'1\', \'tourner_facebook\', \'N\');"><img src="' + MIA.Conf.general.www_medias_url + '/img/partage/facebook.gif" border="0" /> Facebook</a>';
      html += '</div>';
      
      // Twitter
      html += '<div class="lien_partage">';
      html += '<a href="http://twitter.com/timeline/home?status=RT @LePost : ' + unescape(item_twitter_titre) + ' ' + item_twitter_url + '" target="_blank" onclick="javascript:xt_med(\'C\', \'1\', \'tourner_twitter\', \'N\');"><img src="' + MIA.Conf.general.www_medias_url + '/img/partage/twitter.gif" border="0" /> Twitter</a>';
      html += '</div>';
      
      // Wikio
      html += '<div class="lien_partage">';
      html += '<a href="http://www.wikio.fr/vote?url=' + item_url + encodeURIComponent('#xtor=' + MIA.Partage.xtor[2]) + '" target="_blank" onclick="javascript:xt_med(\'C\', \'1\', \'tourner_wikio\', \'N\');"><img src="' + MIA.Conf.general.www_medias_url + '/img/partage/wikio.gif" border="0" /> Wikio</a>';
      html += '</div>';
      
      // Live
      html += '<div class="lien_partage">';
      html += '<a href="https://favorites.live.com/quickadd.aspx?marklet=1&top=1&url=' + item_url + encodeURIComponent('#xtor=' + MIA.Partage.xtor[3]) + '" target="_blank" onclick="javascript:xt_med(\'C\', \'1\', \'tourner_live\', \'N\');"><img src="' + MIA.Conf.general.www_medias_url + '/img/partage/live.gif" border="0" /> Live</a>';
      html += '</div>';
      
      // MySpace
      html += '<div class="lien_partage">';
      html += '<a href="http://www.myspace.com/Modules/PostTo/Pages/?c=' + item_url + encodeURIComponent('#xtor=' + MIA.Partage.xtor[4]) + '&t=' + encodeURIComponent(item_titre) + '" target="_blank" onclick="javascript:xt_med(\'C\', \'1\', \'tourner_myspace\', \'N\');"><img src="' + MIA.Conf.general.www_medias_url + '/img/partage/myspace.gif" border="0" /> MySpace</a>';
      html += '</div>';
      
      // Yoolink
      html += '<div class="lien_partage">';
      html += '<a href="http://www.yoolink.fr/post/tag?site_id=287665&url_value=' + item_url  + encodeURIComponent('#xtor=' + MIA.Partage.xtor[5]) + '&title=' + item_titre + '" target="_blank" onclick="javascript:xt_med(\'C\', \'1\', \'tourner_yoolink\', \'N\');"><img src="' + MIA.Conf.general.www_medias_url + '/img/partage/yoolink.gif" border="0" /> Yoolink</a>';
      html += '</div>';
      
      // Viadeo
      html += '<div class="lien_partage">';
      html += '<a href="http://www.viadeo.com/shareit/share/?url=' + item_url  + encodeURIComponent('#xtor=' + MIA.Partage.xtor[6]) + '&title=' + item_titre + '&urllanguage=fr&urlaffiliate=31122&overview=' + item_description + '" target="_blank" onclick="javascript:xt_med(\'C\', \'1\', \'tourner_viadeo\', \'N\');"><img src="' + MIA.Conf.general.www_medias_url + '/img/partage/viadeo.gif" border="0" /> Viadeo</a>';
      html += '</div>';
      
      // Digg
      html += '<div class="lien_partage">';
      html += '<a href="http://digg.com/submit?phase=2&url=' + item_url  + encodeURIComponent('#xtor=' + MIA.Partage.xtor[7]) + '&title=' + item_titre + '" target="_blank" onclick="javascript:xt_med(\'C\', \'1\', \'tourner_digg\', \'N\');"><img src="' + MIA.Conf.general.www_medias_url + '/img/partage/digg.gif" border="0" /> Digg</a>';
      html += '</div>';
      
      // Delicious
      html += '<div class="lien_partage">';
      html += '<a href="http://del.icio.us/post?url=' + item_url  + encodeURIComponent('#xtor=' + MIA.Partage.xtor[8]) + '&title=' + item_titre + '&notes=' + item_description + '" target="_blank" onclick="javascript:xt_med(\'C\', \'1\', \'tourner_delicious\', \'N\');"><img src="' + MIA.Conf.general.www_medias_url + '/img/partage/delicious.gif" border="0" /> Del.ico.us</a>';
      html += '</div>';
      
      // YahooBuzz
      html += '<div class="lien_partage">';
      html += '<a href="http://buzz.yahoo.com/buzz?publisherurn=' + item_url  + encodeURIComponent('#xtor=' + MIA.Partage.xtor[9]) + '&headline=' + encodeURIComponent(item_titre) + '&summary=' + encodeURIComponent(item_description) + '" target="_blank" onclick="javascript:xt_med(\'C\', \'1\', \'tourner_yahoobuzz\', \'N\');"><img src="' + MIA.Conf.general.www_medias_url + '/img/partage/yahoobuzz.png" border="0" /> YahooBuzz</a>';
      html += '</div>';

      html += '</div>';
      html += '</div>';
      html += '</div>';
      document.write(html);
      document.getElementById('btn_partage').style.cursor = 'pointer';
      YAHOO.util.Event.addListener('btn_partage', 'click', MIA.Partage.animer);
   },
   
   
   /**
    * Méthode permettant d'afficher / de masquer le bloc de partage
    *
    * @author     jeremie
    * @return     void
    * @access     public
    */
   animer : function()
   {
      var div_partage = document.getElementById('volet_partage');
      
      if (MIA.Partage.anim_en_cours == false)
      {
         if (div_partage.style.display == 'block')
         {
            MIA.Partage.anim_en_cours = true;
            
            var attributes = { 
               height: { to: 1 }
            }; 
            var anim_fermeture = new YAHOO.util.Motion('volet_partage', attributes, 0.4, YAHOO.util.Easing.easeOut); 
            anim_fermeture.animate();
            
            anim_fermeture.onComplete.subscribe(function() {
                  div_partage.style.display = 'none';
                  MIA.Partage.anim_en_cours = false;
            });
            
         }
         else
         {
            MIA.Partage.anim_en_cours = true;
            
            div_partage.style.display = 'block';
            var attributes = { 
               height: { to: 88 }
            }; 
            var anim_ouverture = new YAHOO.util.Motion('volet_partage', attributes, 0.4, YAHOO.util.Easing.easeOut); 
            anim_ouverture.animate();
            
            anim_ouverture.onComplete.subscribe(function() {
                  MIA.Partage.anim_en_cours = false;
            });
         }
      }
   }
}
MIA.Partage.init();              
