
// Jean 06/08/2009 (création de ce fichier)

//var SocialEngine.Language = SocialEngineAPI.Language();

var jeton_10_01_2011 = true;

SocialEngineAPI.Profile = new Class({

  // Class
  Implements: [Options],

  tabIbTimeout: Array(),
  ibTimeout: null,
  ibTimeoutH: null,
  isOnMouseOver: false,
  largeurInfoBulle : 600,
  hauteurInfoBulle : 125,

  lastInfoBulleContent : null,
  lastUserName : null,
  lastUserId : null,

  // Properties
  Base: {},


  options: {
    'ajaxURL' : 'profile_ajax.php',
    'ajaxMethod' : 'post',
    'ajaxSecure' : false,

    'defaultView' : false
  },


  userExists: false,

  userInfo: {},

  infoBulle_hide: function()
   {
    clearTimeout(this.ibTimeout);
    clearTimeout(this.ibTimeoutH);
    this.ibTimeoutH = setTimeout("if (!SocialEngine.Profile.isOnMouseOver) SocialEngine.Profile.infoBulle_hide_suite();", 200);
   },

  infoBulle_hide_suite: function()
   {
/*
    $('infobulle_user').innerHTML = '';
    $('infobulle_user').style.visibility = 'hidden';
    $('infobulle_user').style.display = 'none';
*/
    $('infobulle_user').fade('out');
    setTimeout("$('infobulle_user').innerHTML = ''; $('infobulle_user').style.visibility = 'hidden'; $('infobulle_user').style.display = 'none'", 300);
   },

  infoBulle_show: function(username, userID, timeout, ev, webtvID, eventID)
   {
    var x, y;
    if (ev && ev.x!=null && ev.y!=null) { x = ev.x; y = ev.y; }
    if (ev && ev.clientX!=null && ev.clientY!=null) { x = ev.clientX; y = ev.clientY; }

    clearTimeout(this.ibTimeout);
    clearTimeout(this.ibTimeoutH);
    this.ibTimeout = setTimeout("SocialEngine.Profile.infoBulle_show_suite("+ (username ? "'"+ username +"'" : "null") +", "+ (userID ? userID : "null") +","+ x +","+ y +','+ (webtvID ? webtvID : "null") + (eventID ? ", "+ eventID : "") +");", timeout != null ? timeout : 200);
   },

  infoBulle_show_suite: function(username, userID, x, y, webtvID, eventID)
   {
    // Image d'attente...
    $('infobulle_user').style.width = '200px';
    $('infobulle_user').innerHTML = "<div onmouseover='SocialEngine.Profile.isOnMouseOver = true;'"
                                       +" onmouseout='SocialEngine.Profile.isOnMouseOver = false; SocialEngine.Profile.infoBulle_hide();' "
                                       +" class='infobulle_wait_content'>"
                                       +"<img src='/"+ SocialEngine.Profile.options.subdir +"images/icons/loading2.gif' alt='Quelques instants...' width='32' height='32' border='0' /></div>";
    this.positionneInfoBulle(x, y);
    this.rendVisibleInfoBulle();

    // Si on vient tout juste de récupérer l'info demandée
    if (this.lastUserName == username && username != null  ||  this.lastUserId == userID && userID != null)
     {
      $('infobulle_user').innerHTML = this.lastInfoBulleContent;
      $('infobulle_user').style.width = this.largeurInfoBulle +'px';
      this.positionneInfoBulle(x, y);
      return;
     }

    // Ajax
    var bind = this;
    var request = new Request.JSON({
      'method' : 'post',
      'url' : this.options.ajaxURL,
      'data' : {
        'task' : 'get_user_infos',
        'username' : username,
        'user_id' : userID,
         // Jean 22/02/2011
        'webtv_id' : webtvID,
        'from_admin' : SocialEngine.Profile.options.fromAdmin ? "1" : "0"
      },
      'onComplete':function(responseObject)
      {
        if( $type(responseObject)!="object" || !responseObject.result || responseObject.result=="failure" )
         {
          if (responseObject && responseObject.is_debug) alert(responseObject.error);
          /*
          else alert(SocialEngine.Language.Translate(3000153));
          */
         }
        else
         {
           var userInfos = responseObject.infos;

           strHtml = "<div onmouseover='SocialEngine.Profile.isOnMouseOver = true;' onmouseout='SocialEngine.Profile.isOnMouseOver = false; SocialEngine.Profile.infoBulle_hide();' "
                        +' class="infobulle_content'
                        + (userInfos && userInfos['user_just_prospect'] == 1 ? ' infobulle_content_prospect' : '')
                        + (userInfos && userInfos['is_company'] == 1 ? ' infobulle_content_account' : '') +'"'
                        +" style='"+ (isIE ? ' margin-left: 3px;' : '') +"'>";
           if (!userInfos)
            {
             $('infobulle_user').innerHTML = strHtml +'<center><b><big>?</big></b></center></div>';
             $('infobulle_user').style.width = '100px';
             SocialEngine.Profile.positionneInfoBulle(x, y);
             return;
            }

           // Jean 27/08/2009 : le "status"
           if (userInfos['status'] && userInfos['status'] != "")
             strHtml += '<div style="position: absolute; padding: 48px 0px 0px 17px; width: 200px; color: #000; font: lighter 11px/1.3 Arial,sans-serif; text-decoration: none; text-align: center;">'
                          +'<div style="background: url(/'+ SocialEngine.Profile.options.subdir +'images/phylactere.gif) no-repeat top;">'
                            +'<div style="position: absolute; width: 192px; padding-top: 21px; text-align: right;">'
                               +'<a href="javascript:;" onclick="this.parentNode.parentNode.parentNode.style.display = \'none\';" style="font-size: 13px; text-decoration: none; font-weight: normal;">x</a>'
                            +'</div>'
                            +'<div style="padding: 30px 8px 0; font-size: 10px;">'+ userInfos['status'] +'</div>'
                          +'</div>'
                          +'<div style="background: url(/'+ SocialEngine.Profile.options.subdir +'images/phylactere.gif) no-repeat bottom; overflow: hidden; height: 11px;">&nbsp;</div>'
                        +'</div>';

           strHtml += '<table cellpadding="2" width="100%" border="0">';

           strHtml += '<tr>';
           strHtml += '<td valign="top" style="width: 60px; padding: 0px;">';
           strHtml += '<a href="/'+ userInfos['username'] +'--'+ to_url(userInfos['displayname']) +'"';
           strHtml += '>';
           strHtml += '<img src="'+ userInfos['photo_src'] +'" class="photo" style="display: block; margin-left: auto; margin-right: auto;" width="60" height="60" border="0"';
           // Jean 05/01/2011
           if (userInfos['i_am_com_manager'] || SocialEngine.Profile.options.fromAdmin)
             strHtml += ' title="Info CM : user n°'+ userInfos['user_id'] +'"';
           strHtml += ' /></a>';

           // Jean 11/03/2011 : lien vers infobulle "format slide"
           strHtml += '<div style="padding-top: 10px; width: 60px; text-align: center;">';

           strHtml += '<a href="javascript:;"'
                     +  ' onclick="SocialEngine.Profile.infoBulle_hide_suite(); TB_show(SocialEngine.Language.Translate(3511175), \''+ (SocialEngine.Profile.options.fromAdmin ? '../' : '') +'profile.php?user='+ userInfos['username'] +'&vcard&TB_iframe=true&height=600&width=800\', \'\', \'./images/trans.gif\');">'
                     // "Carte de visite grand format"
                     +'<img hspace="5" align="absmiddle" title="'+ SocialEngine.Language.Translate(3511175) +'" border="0" src="/'+ SocialEngine.Profile.options.subdir +'images/icons/full_screen.png" width="16" height="16" /></a>';

           strHtml += '<a href="javascript:;"'
                     +  ' onclick="SocialEngine.Profile.infoBulle_hide_suite(); TB_show(SocialEngine.Language.Translate(3511175), \''+ (SocialEngine.Profile.options.fromAdmin ? '../' : '') +'profile.php?user='+ userInfos['username'] +'&vcard_print&TB_iframe=true&height=600&width=800\', \'\', \'./images/trans.gif\');">'
                     // "Version imprimable"
                     +'<img hspace="5" align="absmiddle" title="'+ SocialEngine.Language.Translate(3510493) +'" border="0" src="/'+ SocialEngine.Profile.options.subdir +'images/icons/sociable/printer.png" width="16" height="16" /></a>';

           strHtml += '</div>';

           strHtml += '</td>';
           strHtml += '<td valign="top">';

           strHtml += '<table cellpadding="3" width="100%" border="0">';

           strHtml += '<tr><td colspan="2" style="padding: 0px; font-weight: bold; font-size: 12px;" valign="top">';

           strHtml += '<a target="_blank" href="/'+ userInfos['username'] +'--'+ to_url(userInfos['displayname']) +'"';
           //if (userInfos['i_am_com_manager']) strHtml += ' title="user id : '+ userInfos['user_id'] +'"';
           strHtml += '>'+ userInfos['displayname'] +'</a>';

           // Les CM ont accès à la modification contextuelle de tous les users
           if (userInfos['i_am_com_manager'] || SocialEngine.Profile.options.fromAdmin)
            {
             strHtml += '<a style="float: right;" href="javascript:;" onclick="userEdit('+ userInfos['user_id'] +');"';
             // "Modifier"
             strHtml +=   ' title="'+ SocialEngine.Language.Translate(3000245) +'">';
             strHtml += '<img src="images/icons/event_edit16.gif" border="0" style="width: 16px; height: 16px;" align="absmiddle" />';
             strHtml += '</a>';
            }

           strHtml += '<span style="float: right; font-size: 10px; font-weight: normal;"><i>';

           // Jean 24/02/2010 : Pour les CM, on indique clairement si les utilisateurs sont désactivés
           if (userInfos['i_am_com_manager'] || SocialEngine.Profile.options.fromAdmin)
            {
             if (userInfos['user_enabled'] == "NO" && userInfos['user_just_prospect'] == 0 && userInfos['is_company'] == 0)
              {
               // "État :"
               strHtml += '<font style="font-size: 14px;"><font class="com_manager">'+ SocialEngine.Language.Translate(3000728) +'</font> ';
                        // "Désactivé"
               strHtml += '<font style="color: #AA0000; font-weight: bold;">'+ SocialEngine.Language.Translate(1137) +'</font>&nbsp;</font> / ';
              }

             // Jean 22/08/2011 : si ce user est un contact/prospect
             else if (userInfos['user_just_prospect'] == 1)
              {
               // "Contact / Prospect"
               strHtml += '<font class="infobulle_type infobulle_type_prospect">';
               strHtml +=  SocialEngine.Language.Translate(3511624) +'&nbsp;</font> ';
              }

             // Jean 22/08/2011 : si ce user est une entreprise ("compte")
             else if (userInfos['is_company'] == 1)
              {
               // "Compte / société"
               strHtml += '<font class="infobulle_type infobulle_type_account">';
               strHtml +=  SocialEngine.Language.Translate(20000) +'&nbsp;</font> ';
              }
            }

           // Jean 08/09/2009 : nombre d'amis
           if (userInfos['is_company'] == 0 && userInfos['user_just_prospect'] == 0)
            {
             strHtml += userInfos['nb_friends'] +' '+ SocialEngine.Language.Translate(3000844);

             // Jean 16/11/2009 : date de création
             if (userInfos['signupdate'] != "")
               strHtml += ', '+ SocialEngine.Language.Translate(850) +' '+ userInfos['signupdate'];

             // Jean 27/08/2009 : date de dernière connexion
             if (userInfos['lastlogindate'] != "")
               strHtml += ', '+ SocialEngine.Language.Translate(906) +' '+ userInfos['lastlogindate'];
            }
           else
            {
             // Jean 23/08/2011 - "créé(e) le %1$s par %2$s"
             if (userInfos['signupdate'] != "")
               strHtml += '<font class="infobulle_created_by">'+ SocialEngine.Language.TranslateFormatted(3511627, [userInfos['created_date'], userInfos['created_by']]) +'</font>';
            }

           strHtml += '</i></span>';

           strHtml += '</td></tr>';

           // "Fait partie des %1$s" (user level)
           strHtml += '<tr><td valign="top" align="left" colspan="2"><i>'
                    + SocialEngine.Language.TranslateFormatted(3000827,['<a href="/'+ SocialEngine.Profile.options.subdir +'search_advanced.php?user_level='+ userInfos['level_id'] +'">'+ userInfos['profile'].toLowerCase() +'</a>']);

           // Jean 19/05/2010 -  / comité éditorial
           if (userInfos['user_belongs_comity'] == '1')
             strHtml += ' / <font style="color: #DD0000; font-weight: bold;">'+ SocialEngine.Language.Translate(3510265).toLowerCase() +'</font>';

           // Jean 17/06/2010 -  / utilisateur certifié
           if (userInfos['user_is_certifed'] == '1')
             strHtml += ' <div style="float: right; color: #1B5C8D;"><img src="images/icons/verified-account.png" align="absmiddle" /> '+ SocialEngine.Language.Translate(3510615) +'</div>';

           strHtml += '</i>';
           strHtml += '</td></tr>';

           // Boutons de buz
           strHtml += '<tr><td><td align="right">';
           for (var lib in userInfos['buz'])
            {
             if (userInfos['buz'][lib][0])
               strHtml += '&nbsp;<a'+ (userInfos['buz'][lib][0].match(/^mailto\:/i) ? '' : ' target="_blank"') +' href="'+ userInfos['buz'][lib][0] +'">'
                         +'<img align="absmiddle" title="'+ lib +'\r\r'+ userInfos['buz'][lib][0] +'" border="0"'
                         +' src="/'+ SocialEngine.Profile.options.subdir +'images/socialnetwork/noir_et_blanc/'+ userInfos['buz'][lib][1] +'" style="width: 25px;" /></a>';
            }
           strHtml += '</td></tr>';

           cpt = 0;
           for (var lib in userInfos['profile_values'])
            {
             if (userInfos['profile_values'][lib])
               strHtml += "<tr><td valign='top' align='right' style='width: 140px;'"+ (userInfos.for_com_managers && userInfos.for_com_managers[lib] == "1" ? 'class=com_manager' : '') +">"
                        + lib +"&nbsp;: </td>"
                        + '<td valign="top">'
                          + '<font '+ (userInfos.for_com_managers && userInfos.for_com_managers[lib] == "1" ? 'class=com_manager' : 'color=black') +'>'
                          + userInfos['profile_values'][lib].replace(/\n/g,'<br>') +'</font>'
                        + '</td></tr>';
             // On laisse la place pour l'éventuel phylactère
             /*
             if (cpt++ == 1 && userInfos['status'] != "")
               strHtml += "<tr><td colspan='2' style='height: 50px;'></td></tr>";
             */
            }
           strHtml += '<tr><td colspan="2">';

           strHtml += '<div style="float: right;">';
           strHtml += '<div align="right" style="margin-top: 15px;">';

           var cptLiensCtxels = 0;

           // Jean 27/08/2009 : on désactive les interrations avec cet utilisateur si on est dans la console d'admin,
           // car on peut s'être logué à la place de qq d'autre
           if (!SocialEngine.Profile.options.fromAdmin && userInfos['is_company'] == 0 && userInfos['user_just_prospect'] == 0 && isLogged)
            {
             // Lien "Envoyer un message"
             if (userInfos['message_enabled'] == "1")
             {
              strHtml += '<a href="javascript:;" onclick="SocialEngine.Profile.infoBulle_hide_suite(); TB_show(SocialEngine.Language.Translate(784), \''+ (SocialEngine.Profile.options.fromAdmin ? '../' : '') +'user_messages_new.php?to_user='+ escape(userInfos['username']) +'&to_id='+ userInfos['username'] +'&TB_iframe=true&height=590&width=550\', \'\', \'./images/trans.gif\');">';
              strHtml += '<img src="images/icons/newmessage16.gif" align="absmiddle" border="0" />&nbsp;';
              strHtml += SocialEngine.Language.Translate(839) +'</a>';
              cptLiensCtxels ++;
             }
             // Lien "Ajouter à mes contacts"
             if (userInfos['friend_enabled'] == "1")
             {
              if (cptLiensCtxels == 1 || cptLiensCtxels == 2)
                strHtml += '&nbsp;&nbsp;&nbsp;';
              else if (cptLiensCtxels == 3)
                { strHtml += '<br />'; cptLiensCtxels = 0; }
              strHtml += '<a href="javascript:;" onclick="SocialEngine.Profile.infoBulle_hide_suite(); TB_show(SocialEngine.Language.Translate(876), \''+ (SocialEngine.Profile.options.fromAdmin ? '../' : '') +'user_friends_manage.php?user='+ escape(userInfos['username']) +'&TB_iframe=true&height=350&width=450\', \'\', \'./images/trans.gif\');">';
              strHtml += '<img src="images/icons/action_addfriend.gif" align="absmiddle" border="0" />&nbsp;';
              strHtml += SocialEngine.Language.Translate(838) +'</a>';
              cptLiensCtxels ++;
             }

            // Jean 17/11/2009 : Pour les CM, lien "Inviter sur ce tournage" dans le contexte d'un event
            var can_invite_this_event = userInfos['can_invite'] == "1" && parent.objTournage && parent.objTournage.guests_and_speakers && parent.objTournage.guests_and_speakers.indexOf('#'+ userInfos['user_id'] +'#') == -1
            if (can_invite_this_event)
             {
              if (cptLiensCtxels == 1 || cptLiensCtxels == 2)
                strHtml += '&nbsp;&nbsp;&nbsp;';
              else if (cptLiensCtxels == 3)
                { strHtml += '<br />'; cptLiensCtxels = 0; }
              strHtml += '<a href="javascript:;" onclick="parent.SocialEngine.Event.oneMemberInviteSend('+ userInfos['user_id'] +','+ (webtvID ? webtvID : 'null') + (eventID ? ','+ eventID : '') +');">';
              strHtml += '<img src="images/icons/message_outbox16.gif" align="absmiddle" border="0" />&nbsp;';
              strHtml += SocialEngine.Language.Translate(3510054) +'</a>';
              cptLiensCtxels ++;
             }

            // Jean 18/11/2009 : Pour les CM et les contributeurs membres, lien "Inviter à un tournage" en dehors du contexte d'un event
            if (userInfos['can_invite'] == "1")
             {
              if (cptLiensCtxels == 1 || cptLiensCtxels == 2)
               strHtml += '&nbsp;&nbsp;&nbsp;';
              else if (cptLiensCtxels == 3)
               { strHtml += '<br />'; cptLiensCtxels = 0; }
              strHtml += '<a href="javascript:;" onclick="parent.SocialEngine.Profile.inviteToOneEvent_list('+ userInfos['user_id'] +'); //SocialEngine.Profile.infoBulle_hide_suite();">';
              strHtml += '<img src="images/icons/message_outbox16.gif" align="absmiddle" border="0" />&nbsp;';
              // L'inviter à un (autre) tournage
              strHtml += SocialEngine.Language.Translate(parent.objTournage ? 3510134 : 3510056) +'</a>';
              cptLiensCtxels ++;
             }
            } // fin "si pas dans super admin"


          // Jean 05/11/2010 : Pour les CM et les contributeurs membres, lien pour exporter cet utilisateur
          if (userInfos['i_am_com_manager'] || SocialEngine.Profile.options.fromAdmin)
           {
            if (cptLiensCtxels == 1 || cptLiensCtxels == 2)
             strHtml += '&nbsp;&nbsp;&nbsp;';
            else if (cptLiensCtxels == 3)
             { strHtml += '<br />'; cptLiensCtxels = 0; }
            strHtml += '<a href="javascript:;" class="com_manager" onclick="parent.SocialEngine.Profile.exportUser('+ userInfos['user_id'] + (userInfos['level_id'] == userInfos['soc_level_id'] ? ', null, '+ userInfos['soc_level_id'] : '') +');">';
            strHtml += '<img src="images/icons/admin_subnetworks16.gif" align="absmiddle" border="0" />&nbsp;';
            // "L'exporter vers une autre webtv"
            strHtml += SocialEngine.Language.Translate(3510777) +'</a>';
            cptLiensCtxels ++;
           }


          // Jean 25/08/2011 : Pour les CM Webcastory, lien "Envoyer vers le CRM Webcastory"
          if (userInfos['i_am_com_manager'] && !userInfos['is_extranet'] && (userInfos['i_am_webcastory'] || SocialEngine.Profile.options.fromAdmin))
           {
            if (cptLiensCtxels == 1 || cptLiensCtxels == 2)
             strHtml += '&nbsp;&nbsp;&nbsp;';
            else if (cptLiensCtxels == 3)
             { strHtml += '<br />'; cptLiensCtxels = 0; }

            // "Exporté le %1$s vers le CRM Webcastory"
            if (userInfos['is_on_crm_webcastory_since_txt'])
             {
              strHtml += '<a class="com_manager" style="font-weight: bold; font-size: 11px; color: #FF6B24;"'
                          +' href="'+ (userInfos['profile_url_on_crm_webcastory']) +'" target="_blank">';
              strHtml += '<img src="images/icons/admin_levels16.gif" align="absmiddle" border="0" />&nbsp;';
              strHtml += userInfos['is_on_crm_webcastory_since_txt'] +'</a>';
             }
            // "Envoyer vers le CRM Webcastory"
            else
             {
              strHtml += '<a href="javascript:;" class="com_manager" onclick="parent.SocialEngine.Profile.exportUser('+ userInfos['user_id'] +', '+ userInfos['extranet_webtv_id'] +', '+ userInfos['prospect_level_id'] +', 1);">';
              strHtml += '<img src="images/icons/admin_levels16.gif" align="absmiddle" border="0" />&nbsp;';
              strHtml += SocialEngine.Language.Translate(3511642) +'</a>';
             }

            cptLiensCtxels ++;
           }


          // Jean 07/12/2009 : pour lancer l'édition d'un message de bienvenue
          if (userInfos['i_am_com_manager'] && userInfos['is_company'] == 0 && userInfos['user_just_prospect'] == 0)
           {
            if (cptLiensCtxels == 1 || cptLiensCtxels == 2)
              strHtml += '&nbsp;&nbsp;&nbsp;';
            else if (cptLiensCtxels == 3)
              { strHtml += '<br />'; cptLiensCtxels = 0; }

            strHtml += '<a class="com_manager" href="javascript:;" onclick="parent.SocialEngine.Profile.envoyerMessageBienvenue('+ userInfos['user_id'] +'); //SocialEngine.Profile.infoBulle_hide_suite();">';
            strHtml += '<img src="images/icons/chat_chat16.gif" align="absmiddle" border="0" />&nbsp;';

            // Jean 30/01/2010 : "Message de bienvenue envoyé le XXXXXX"
            if (userInfos['user_welcome_date'])
              strHtml += '<font style="font-size: 8pt;" class="com_manager">'+ SocialEngine.Language.TranslateFormatted(3510170,[userInfos['user_welcome_date']]) +'</font>';
            else
              strHtml += SocialEngine.Language.Translate(3510099);

            strHtml += '</a>';
            cptLiensCtxels ++;
           }

          // Jean 07/12/2009 : pour "Éditer" (pour aller dans l'édition en mode "super admin" de l'utilisateur)
          if (userInfos['i_am_the_boss'])
           {
            if (cptLiensCtxels == 1 || cptLiensCtxels == 2)
              strHtml += '&nbsp;&nbsp;&nbsp;';
            else if (cptLiensCtxels == 3)
              { strHtml += '<br />'; cptLiensCtxels = 0; }

            cptLiensCtxels ++;
           }

           strHtml += '</div>';
           strHtml += '</div>';
           strHtml += '</td></tr>';
           strHtml += '</table></td></tr></table>';
           strHtml += '</div>';

           $('infobulle_user').innerHTML = strHtml;
           $('infobulle_user').style.width = SocialEngine.Profile.largeurInfoBulle +'px';
           if ($('infobulle_user').offsetHeight)
             SocialEngine.Profile.hauteurInfoBulle = $('infobulle_user').offsetHeight;
           SocialEngine.Profile.positionneInfoBulle(x, y);

           // Scroll auto sur zone des chaînes
           

           // On retient pour la prochaine fois...
           SocialEngine.Profile.lastInfoBulleContent = strHtml;
           SocialEngine.Profile.lastUserName = userInfos['username'];
           SocialEngine.Profile.lastUserId = userInfos['user_id'];
         }
      }
    });

    request.send();
  },

  // Jean 22/07/2010 : infobulle de thématique
  infoBulleGroupCat_show: function(groupcat_id, timeout, ev, webtvID, sectionBarTdId, justPreLoad)
   {
    var x, y;
    if (ev && ev.x!=null && ev.y!=null) { x = ev.x; y = ev.y; }
    if (ev && ev.clientX!=null && ev.clientY!=null) { x = ev.clientX; y = ev.clientY; }

    if (y) y += 10;

    if (!justPreLoad)
     {
      clearTimeout(this.ibTimeout);
      clearTimeout(this.ibTimeoutH);
     }
    this.ibTimeout = setTimeout("SocialEngine.Profile.infoBulleGroupCat_show_suite("+ (groupcat_id ? "'"+ groupcat_id +"'" : "null") +","+ x +","+ y +','+ (webtvID ? webtvID : "null") +','+ (sectionBarTdId ? '\''+ sectionBarTdId +'\'' : 'null') +','+ (justPreLoad ? 'true' : 'null') +");", timeout != null ? timeout : 200);
   },

  lastInfoBulleGroupCatContent: new Array(),

  infoBulleGroupCat_show_suite: function(groupcat_id, x, y, webtvID, sectionBarTdId, justPreLoad)
   {
    // Image d'attente...
    if (!justPreLoad)
     {
      $('infobulle_user').style.width = '200px';
      $('infobulle_user').innerHTML = "<div onmouseover='SocialEngine.Profile.isOnMouseOver = true;'"
                                         +" onmouseout='SocialEngine.Profile.isOnMouseOver = false; SocialEngine.Profile.infoBulle_hide();' "
                                         +" class='"+ (sectionBarTdId ? 'infobulle_wait_content_section' : 'infobulle_wait_content') +"'>"
                                         +"<img src='/"+ SocialEngine.Profile.options.subdir +"images/icons/loading2.gif' alt='Quelques instants...' width='32' height='32' border='0' /></div>";
      this.positionneInfoBulle(x, y);
      this.rendVisibleInfoBulle(80);

      if (sectionBarTdId && $(sectionBarTdId))
       {
        var tab_sections = $('section_container');
        $('infobulle_user').style.left = getLeft(tab_sections) +'px';
        $('infobulle_user').style.top = (getTop(tab_sections) + tab_sections.offsetHeight) +'px';
        $('infobulle_user').style.width = tab_sections.offsetWidth +'px';
       }

      // Jean 27/06/2011
      $('infobulle_user').className = sectionBarTdId ? 'infobulle_container_section' : 'infobulle_container';
     }

    // Si on est déjà allé chercher le contenu de cette infobulle, inutile de déclencher de nouveau un dialogue Ajax
    if (groupcat_id != null && this.lastInfoBulleGroupCatContent[groupcat_id +'_'+ sectionBarTdId])
     {
      this.remplitInfoBulle(this.lastInfoBulleGroupCatContent[groupcat_id +'_'+ sectionBarTdId], x, y, sectionBarTdId);
     }
    else
     {
      // Ajax
      var bind = this;
      var request = new Request.JSON({
        'method' : 'post',
        'url' : this.options.ajaxURL,
        'data' : {
          'task' : 'get_groupcat_infos',
          'groupcat_id' : groupcat_id,
           // Jean 22/02/2011
          'webtv_id' : webtvID,
          'from_admin' : this.options.fromAdmin ? "1" : "0"
        },
        'onComplete':function(responseObject)
        {
          if( $type(responseObject)!="object" || !responseObject.result || responseObject.result=="failure" )
           {
            if (responseObject && responseObject.is_debug) alert(responseObject.error);
           }
          else
           {
             var groupCatInfos = responseObject.groupcat_infos;
             var groupCatChannels = responseObject.groupcat_channels;

             strHtml = "<div onmouseover='SocialEngine.Profile.isOnMouseOver = true;' onmouseout='SocialEngine.Profile.isOnMouseOver = false; SocialEngine.Profile.infoBulle_hide();' "
                          +" class='"+ (sectionBarTdId ? "infobulle_content_for_section" : "infobulle_content infobulle_thema_content") +"'"
                          +" style='"+ (isIE ? ' margin-left: 3px;' : '') + (sectionBarTdId ? '' : 'width: 770px;') +"'>";
             if (!groupCatInfos)
              {
               $('infobulle_user').innerHTML = strHtml +'<center><b><big>?</big></b></center></div>';
               $('infobulle_user').style.width = '100px';
               bind.positionneInfoBulle(x, y);
               return;
              }

             strHtml += '<table cellpadding="0" cellspacing="0" width="100%" border="0">';
             strHtml += '<tr><td valign="top">';

             strHtml += '<table cellpadding="3" cellspacing="0" width="100%" border="0">';

             var dejeEcritTitre = false;

             // Titre de la thématique
             var themeTitle = '<a class="infobulle_channel_title" href="/'+ bind.options.subdir +'themes/'+ groupCatInfos['groupcat_id'] +'/0/'+ to_url(groupCatInfos['groupcat_title']) +'"><b><font size=4>&rarr;</font> '+ groupCatInfos['groupcat_title'] +'</b></a>';

             if (groupCatInfos['groupcat_vignette'] || groupCatInfos['groupcat_desc'] || true)
              {
               strHtml += '<tr><td colspan="2" valign="top">';
               // Si vignette thématique
               if (groupCatInfos['groupcat_vignette'])
                 strHtml += '<img style="float: left; margin-right: 4px;" border="0" src="/'+ bind.options.subdir + (bind.options.fromAdmin ? '../' : '') +'images/vignettes/groupcats/mini_'+ groupCatInfos['groupcat_vignette'] +'" />';
               strHtml += themeTitle;
               dejeEcritTitre = true;

               /*
               // Si texte de description
               if (groupCatInfos['groupcat_desc'])
                 strHtml += '<div style="padding-top: 6px;">'+ groupCatInfos['groupcat_desc'] +'</div>';
               strHtml += '</td></tr>';
               */
              }

             // Liste des chaînes rangées dans cette section
             if (groupCatChannels.length > 0)
              {
               /*
               // "Chaînes rangées dans cette section :" / "Chaînes rangées dans la section « %1$s » :"
               strHtml += '<tr><td colspan="2" class="infobulle_channel_list_title">';
               strHtml += '<div>'+ (dejeEcritTitre ? SocialEngine.Language.Translate(3510738) : SocialEngine.Language.TranslateFormatted(3511428, [themeTitle])).replace(/ /g, '&nbsp;') +'</div>'; // 3510738 3511429
               strHtml += '</td></tr>';
               */

               strHtml += '<tr><td colspan="2"><div id="DIV_infobulle_channel_list">';

               strHtml += '<table cellpadding="3" cellspacing="0" width="100%" border="0" class="infobulle_channel_list">';

               // "Aller voir toutes les chaînes de la section « %1$s »..."
               if (groupCatChannels.length > 5)
                {
                 strHtml += '<tr>';
                 strHtml += '<td valign="top" colspan="2" class="infobulle_channel_other_items_link">';
                 //strHtml +=  '<a href="/'+ bind.options.subdir +'themes/'+ groupCatInfos['groupcat_id'] +'/0&force/'+ to_url(groupCatInfos['groupcat_title']) +'">';
                 strHtml +=  '<a href="/'+ bind.options.subdir +'themes/'+ groupCatInfos['groupcat_id'] +'/0/'+ to_url(groupCatInfos['groupcat_title']) +'">';
                 strHtml +=  SocialEngine.Language.TranslateFormatted(3510741, [groupCatInfos['groupcat_title']]) +'</a>';
                 strHtml += '</td>';
                 strHtml += '</tr>';
                }

               for (var i=0; i<groupCatChannels.length; i++)
                {
                 // "Aller voir toutes les chaînes de la section « %1$s »..."
                 if (i >= 5)
                  {
                   strHtml += '<tr>';
                   strHtml += '<td valign="top" colspan="2" class="infobulle_channel_other_items_link">';
                   strHtml +=  '<a href="/'+ bind.options.subdir +'themes/'+ groupCatInfos['groupcat_id'] +'/0/'+ to_url(groupCatInfos['groupcat_title']) +'">';
                   strHtml +=  SocialEngine.Language.TranslateFormatted(3510741, [groupCatInfos['groupcat_title']]) +'</a>';
                   strHtml += '</td>';
                   strHtml += '</tr>';
                   break;
                  }
                 var channel = groupCatChannels[i];
                 strHtml += '<tr class="infobulle_channel_item">';
                 strHtml += '<td valign="top" colspan="2" class="infobulle_channel_item_title">';
                 strHtml += '<a href="'+ (bind.options.fromAdmin ? '../' : '') +'channel/'+ channel['group_id'] +'/'+ to_url(channel['group_title']) +'">';
                 if (channel['group_photo'] && channel['group_photo'] != '')
                   strHtml +=  '<img border="0" src="/'+ bind.options.subdir + (bind.options.fromAdmin ? '../' : '') + channel['group_photo'] +'" style="width: 60px; height: 60px; margin-right: 10px;" align="left" />';
                 strHtml +=  '<b>'+ channel['group_title'] +'</b></a>';
                 strHtml +=  '<br />'+ channel['group_desc'];
                 strHtml += '</td>';
                 strHtml += '</tr>';
                }
               strHtml += '</table></div>';
              }

             strHtml += '</td></tr></table>';
             strHtml += '</td>';

             // Liste des sujets relatifs à cette section (séparés en 3 catégories)
             var suggestions = responseObject.groupcat_last_sugggestions;
             var beingPrepared = responseObject.groupcat_next_events;
             var finishedEvents = responseObject.groupcat_lasts_events;

             if (suggestions.length > 0 || beingPrepared.length > 0 || finishedEvents.length > 0)
              {
               strHtml += '<td valign="top" class="infobulle_last_subjects">';
               strHtml += '<table cellpadding="3" cellspacing="0" width="100%" border="0">';

               // "Derniers sujets diffusés dans cette section :"
               if (finishedEvents.length > 0)
                {
                 strHtml += '<tr><td colspan="2" valign="top" class="infobulle_channel_list_title"><div>';
                 strHtml += SocialEngine.Language.Translate(3511430).replace(/ /g, '&nbsp;');
                 strHtml += '</div></td></tr>';
                 strHtml += '<tr><td class="infobulle_event_list">';
                 strHtml += '<ul>';
                 for (var i=0; i<finishedEvents.length; i++)
                  {
                   strHtml += '<li>';
                   strHtml += '<a href="'+ finishedEvents[i]['event_url'] +'">'+ finishedEvents[i]['event_title'] +'</a>';
                   if (finishedEvents[i]['event_html_options'])
                     strHtml += '<div class="infobulle_event_options">'+ finishedEvents[i]['event_html_options'] +'</div>';
                   strHtml += '</li>';
                  }
                 strHtml += '</ul>';
                 strHtml += '</td></tr>';
                }

               // "Derniers sujets proposés dans cette section :"
               if (suggestions.length > 0)
                {
                 strHtml += '<tr><td colspan="2" valign="top" class="infobulle_channel_list_title"><div>';
                 strHtml += SocialEngine.Language.Translate(3511433).replace(/ /g, '&nbsp;');
                 strHtml += '</div></td></tr>';
                 strHtml += '<tr><td class="infobulle_event_list">';
                 strHtml += '<ul>';
                 for (var i=0; i<suggestions.length; i++)
                  {
                   strHtml += '<li>';
                   strHtml += '<a href="'+ suggestions[i]['event_url'] +'">'+ suggestions[i]['event_title'] +'</a>';
                   if (suggestions[i]['event_html_options'])
                     strHtml += '<div class="infobulle_event_options">'+ suggestions[i]['event_html_options'] +'</div>';
                   strHtml += '</li>';
                  }
                 strHtml += '</ul>';
                 strHtml += '</td></tr>';
                }

               // "Sujets co-produits dans cette section (en cours de préparation) :"
               if (beingPrepared.length > 0)
                {
                 strHtml += '<tr><td colspan="2" valign="top" class="infobulle_channel_list_title"><div>';
                 strHtml += SocialEngine.Language.Translate(3511434).replace(/ /g, '&nbsp;');
                 strHtml += '</div></td></tr>';
                 strHtml += '<tr><td class="infobulle_event_list">';
                 strHtml += '<ul>';
                 for (var i=0; i<beingPrepared.length; i++)
                  {
                   strHtml += '<li>';
                   strHtml += '<a href="'+ beingPrepared[i]['event_url'] +'">'+ beingPrepared[i]['event_title'] +'</a>';
                   if (beingPrepared[i]['event_html_options'])
                     strHtml += '<div class="infobulle_event_options">'+ beingPrepared[i]['event_html_options'] +'</div>';
                   strHtml += '</li>';
                  }
                 strHtml += '</ul>';
                 strHtml += '</td></tr>';
                }

               strHtml += '</table>';
               strHtml += '</td>';
              }

             strHtml += '</tr></table>';
             strHtml += '</div>';

             // On retient pour la prochaine fois...
             bind.lastInfoBulleGroupCatContent[groupcat_id +'_'+ sectionBarTdId] = strHtml;
             if (!justPreLoad)
               bind.remplitInfoBulle(strHtml, x, y, sectionBarTdId);
           }
        }
      });
      request.send();
     }
  },

  remplitInfoBulle: function(html, x, y, sectionBarTdId)
  {
   $('infobulle_user').innerHTML = html;
   $('infobulle_user').style.width = SocialEngine.Profile.largeurInfoBulle +'px';
   if ($('infobulle_user').offsetHeight)
     this.hauteurInfoBulle = $('infobulle_user').offsetHeight;

   this.positionneInfoBulle(x, y);

   this.currentSectionMenuID = sectionBarTdId;

   if (sectionBarTdId && $(sectionBarTdId))
    {
     var tab_sections = $('section_container');
     $('infobulle_user').style.left = getLeft(tab_sections) +'px';
     $('infobulle_user').style.top = (getTop(tab_sections) + tab_sections.offsetHeight) +'px';
     $('infobulle_user').style.width = tab_sections.offsetWidth +'px';
    }
   else
     $('infobulle_user').style.width = '780px';
  },

  positionneInfoBulle : function(x, y)
   {
       var hauteurDoc = typeof( window.innerHeight ) == 'number' ? window.innerHeight : document.documentElement.clientHeight;
       if (hauteurDoc == 0) hauteurDoc = document.documentElement.offsetHeight;
       var largeurDoc = typeof( window.innerWidth ) == 'number' ? window.innerWidth : document.documentElement.clientWidth;
       if (largeurDoc == 0) largeurDoc = document.documentElement.offsetWidth;

       var scrollTop = isIE || isFirefox ? document.documentElement.scrollTop : document.body.scrollTop;
       if (scrollTop == 0) scrollTop = document.body.scrollTop;
       var scrollLeft = isIE || isFirefox ? document.documentElement.scrollLeft : document.body.scrollLeft;
       var depasseAdroite = (x + SocialEngine.Profile.largeurInfoBulle) > largeurDoc;
       var depasseAgauche = (x - SocialEngine.Profile.largeurInfoBulle) < 0;
       var depasseEnBas = (y + SocialEngine.Profile.hauteurInfoBulle) > hauteurDoc;
       var depasseEnHaut = (y - SocialEngine.Profile.hauteurInfoBulle) < 0;
       var diffWidthAvecAttente = SocialEngine.Profile.largeurInfoBulle - $('infobulle_user').offsetWidth;
       var diffHeightAvecAttente = SocialEngine.Profile.hauteurInfoBulle - $('infobulle_user').offsetHeight;

       if (!depasseAdroite)
         $('infobulle_user').style.left = (x + scrollLeft + 5) +'px';
       else if (!depasseAgauche)
         $('infobulle_user').style.left = (x + scrollLeft + diffWidthAvecAttente - SocialEngine.Profile.largeurInfoBulle - 35) +'px';
       else
         $('infobulle_user').style.left = (scrollLeft + diffWidthAvecAttente + 5) +'px';

//alert(y +"+"+ SocialEngine.Profile.hauteurInfoBulle +">"+ hauteurDoc)

       if (!depasseEnBas)
         $('infobulle_user').style.top = (y + scrollTop + 10) +'px';
       else if (!depasseEnHaut)
         $('infobulle_user').style.top = (y + scrollTop + diffHeightAvecAttente - SocialEngine.Profile.hauteurInfoBulle - 10) +'px';
       else
         $('infobulle_user').style.top = (scrollTop + diffHeightAvecAttente + 5) +'px';
    },

  rendVisibleInfoBulle: function(opacityLevel)
   {
    $('infobulle_user').style.visibility = 'inherit';
    $('infobulle_user').style.display = 'inline';
    $('infobulle_user').setStyle('opacity', opacityLevel ? opacityLevel : 0);
    $('infobulle_user').fade('in');
/*
*/
   },


  currentInvitedID: 0,

  // Jean 18/11/2009 : Pour afficher une liste de tournages auxquels inviter telle personne
  inviteToOneEvent_list: function(user_id)
   {
    SocialEngine.Profile.infoBulle_hide_suite();
    this.currentInvitedID = user_id;

    selectedEventIdForInvite = null;
    selectedUserIdForInvite = user_id;

    if (htmlMesTournages)
     {
      //$("zone_invite_liste_tournages").innerHTML = htmlMesTournages;
     }
    else
     {
      $("imgLoadingMyTournages").style.display = "inline";

      // Ajax
      var bind = this;
      var request = new Request.JSON({
        'method' : 'post',
        'url' : this.options.ajaxURL,
        'data' : {
          'task' : 'get_my_tournages',
          'user_id' : user_id
        },
        'onComplete':function(responseObject)
        {
          if( $type(responseObject)!="object" || !responseObject.result || responseObject.result=="failure" )
           {
            if (responseObject && responseObject.is_debug) alert(responseObject.error);
           }
          else
           {
            var myTournages = responseObject.event_list;
            //var strHtml = '<script>var Tips1 = new Tips($$(\'.Tips1\'));</script>';
            //var Tips1 = new Tips($$('.Tips1'));

            var strHtml = '';
            var _l = '<br /> &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; ';

            for (var i=0; i<myTournages.length; i++)
             {
              var event = myTournages[i]['event'];
              strHtml += '<div style="padding-top: 10px; ">'
                        +'<input onclick="selectedEventIdForInvite = '+ event['event_info']['event_id'] +';"'
                              +' type="radio"'
                              +' name="event_id"'
                              +' value="'+ event['event_info']['event_id'] +'" />'
                       + '<label class="Tips1'
                              // Jean 14/12/2010 : si mode brouillon
                              +(!event['event_info']['event_datepublished'] ? ' com_manager' : '')
                              + '"'
                              +' onclick="this.previousSibling.checked = true; selectedEventIdForInvite = '+ event['event_info']['event_id'] +';"'
                              +' title="N°'+ event['event_info']['event_id'] +'\n..............................\n'+ event['event_info']['event_summary'].replace(/\"/g,'&#34;')
                          +'"> '

                       + (event['event_info']['event_date_start'] && event['event_info']['event_datedated'] ?
                            getDateStr(event['event_info']['event_date_start'] * 1000) : '')

                       + (event.event_parent ?
                              _l + '<i style="color: #777777;">'+ event.event_parent.event_info.event_title.replace(/\n/g,'<br>') +' :</i>' : '')

                       + _l + (event.event_parent ? ' &nbsp; &nbsp; &nbsp; ' : '') + event['event_info']['event_title'].replace(/\n/g,'<br>') +'</label>'

                       // Jean 14/12/2010 : lien vers event
                       + '&nbsp; <a href="/event/'+ event['event_info']['event_id'] +'" target="_blank">'
                       + '<img src="images/icons/admin_logout16.gif" align="absmiddle" border="0" width="8" /></a>'
                       + '</div>'
              }

            if (myTournages.length == 0)
              $("zone_invite_liste_tournages").innerHTML = '<i>('+ SocialEngine.Language.Translate(3000654) +')</i>';
            else
              $("zone_invite_liste_tournages").innerHTML = strHtml;

           if ( ! (isIE && iframe_company) )
             Tips1 = new Tips($$('.Tips1'));

            htmlMesTournages = strHtml;
  /*
             $('inviteOneUser_buttons_memberInviteSend').style.display = 'inline';
             $('inviteOneUser_loading_memberInviteSend').style.display = 'none';
  */
           }
          $("imgLoadingMyTournages").style.display = "none";

          TB_init();
          TB_show(SocialEngine.Language.Translate(3510056), '#TB_inline?height=520&width=900&inlineId=displayshowlistforinvite', '', '../images/trans.gif');
        }
      });

      request.send();
     }

    TB_show(SocialEngine.Language.Translate(3510056), '#TB_inline?height=520&width=900&inlineId=displayshowlistforinvite', '', '../images/trans.gif');
   },


  // Jean 13/12/2009 : composition d'un message de bienvenue
  envoyerMessageBienvenue: function(user_id)
   {
    this.envoyerMessageType('manual_welcoming', user_id);
   },

  // Jean 24/02/2010 - composition d'un message type
  envoyerMessageType: function(systememail_name, user_id)
   {
    //$("imgLoadingMyTournages").style.display = "inline";

    // Ajax
    var bind = this;
    var request = new Request.JSON({
      'method' : 'post',
      'url' : this.options.ajaxURL,
      'data' : {
        'task' : 'message_type',
        'systememail_name' : systememail_name,
        'user_id' : user_id
      },
      'onComplete':function(responseObject)
      {
        if( $type(responseObject)!="object" || !responseObject.result || responseObject.result=="failure" )
         {
          if (responseObject && responseObject.is_debug) alert(responseObject.error);
         }
        else
         {
          // On ouvre une pop-up de message
          TB_show(SocialEngine.Language.Translate(3000967), (SocialEngine.Profile.options.fromAdmin ? '../' : '') +'user_messages_new.php?to_user='+ escape(responseObject.username) +'&to_id='+ escape(responseObject.username) +'&message_type&TB_iframe=true&height=700&width=950', '', './images/trans.gif');

          // On attend son chargement avant de de pouvoir interagir avec elle
          setTimeout("SocialEngine.Profile.envoyerMessageType_suite()", 200);

          SocialEngine.Profile.infoBulle_hide_suite();

          SocialEngine.Profile.systememailName = systememail_name;
          SocialEngine.Profile.corpsMessage = responseObject.corps_message;
          SocialEngine.Profile.sujetMessage = responseObject.sujet_message;
         }
      }
    });

    request.send();
   },

   envoyerMessageType_suite: function()
    {
     // tant que la fenêtre n'est pas prête, on retente
     if (!$('TB_iframeContent') || !$('TB_iframeContent').contentWindow || !$('TB_iframeContent').contentWindow.iAmReady)
      {
       setTimeout("SocialEngine.Profile.envoyerMessageType_suite();", 100);
       return;
      }

      // Jean 25/05/2010 - Pour renseigner la table se_users une fois le message parti
      if ( SocialEngine.Profile.systememailName == 'manual_incitation')
        $('TB_iframeContent').contentWindow.document.getElementById('is_incitation_message').value = '1';
      else if (SocialEngine.Profile.systememailName == 'manual_complete_profile')
        $('TB_iframeContent').contentWindow.document.getElementById('is_complete_profile_message').value = '1';
      else if (SocialEngine.Profile.systememailName == 'manual_welcoming')
        $('TB_iframeContent').contentWindow.document.getElementById('is_welcome_message').value = '1';
      // Jean 10/01/2011
      if ( SocialEngine.Profile.systememailName == 'to_contrib_actif')
        $('TB_iframeContent').contentWindow.document.getElementById('is_contrib_proposal_message').value = '1';
      // Jean 21/01/2011
      if ( SocialEngine.Profile.systememailName == 'contrib_proposal')
        $('TB_iframeContent').contentWindow.document.getElementById('is_contrib_proposal_bis_message').value = '1';

      // Corps + sujet du message
      $('TB_iframeContent').contentWindow.setSubjectAndBody(SocialEngine.Profile.sujetMessage, SocialEngine.Profile.corpsMessage.replace(/\r?\n/g, "<br>"), true);
    },

    // Jean 05/11/2010 : export user vers autre webtv
    exportUser: function(userID, targetWebtvID, targetLevelID, sendToCRM)
     {
      SocialEngine.Profile.infoBulle_hide_suite();

      // Niveau utilisateur par défaut : visiteur
      if (!targetLevelID)
        targetLevelID = 2;

      // Valeurs par défaut
      SocialEngine.export_user_id = userID;
      SocialEngine.export_webtv_id = targetWebtvID;
      SocialEngine.export_level_id = targetLevelID;
      SocialEngine.send_to_crm = sendToCRM;

      // Ajax
      var bind = this;
      var request = new Request.JSON({
        'method' : 'post',
        'url' : this.options.ajaxURL,
        'data' : {
          'task' : 'webtv_list_for_user_export',
          'user_id' : userID
        },
        'onComplete':function(responseObject)
        {
          if( $type(responseObject)!="object" || !responseObject.result || responseObject.result=="failure" )
           {
            if (responseObject && responseObject.is_debug) alert(responseObject.error);
           }
          else
           {
            var html = '';

            // On construit la liste des webtv vers lesquelles exporter cet utilisateur
            //-----------------------------------------------------------------------
            html += '<select onchange="SocialEngine.export_webtv_id = this.value;">';
            html += '<option value=""></option>';

            // On construit la liste des user levels
            for (var i=0; i<responseObject.webtv_list.length; i++)
             {
              html += '<option value="'+ responseObject.webtv_list[i].webtv_info.webtv_id +'"';
              if (responseObject.webtv_list[i].webtv_info.user_already_exported)
                html += ' style="color: #CCCCCC;"';
              if (responseObject.webtv_list[i].webtv_info.webtv_id == targetWebtvID)
                html += ' selected';
              html += '>'+ responseObject.webtv_list[i].webtv_info.webtv_title +'</option>';
             }
            html += '</select>';

            // Jean 25/08/2011 : on peut choisir le user level de destination
            //-----------------------------------------------------------------------
            // "Exporter en tant que"
            html += '<span id="zone_export_dest_level_id">';
            html += '&nbsp; '+ SocialEngine.Language.Translate(3511643) +' :';

            html += '<select onchange="SocialEngine.export_level_id = this.value;">';
            html += '<option value=""></option>';

            for (var i=0; i<responseObject.user_levels.length; i++)
             {
              html += '<option value="'+ responseObject.user_levels[i].level_id +'"';
              if (responseObject.user_levels[i].level_id == targetLevelID)
                html += ' selected';
              html += '>'+ responseObject.user_levels[i].level_name +'</option>';
             }
            // Si on exporte une société, alors on ajoute le user_level ad hoc
            if (targetLevelID && targetLevelID == 10)
              html += '<option value="10" selected>Company</option>';
            html += '</select></span><br />';
            //-----------------------------------------------------------------------

            $('zoneListeChoixWebtvForUserExport').innerHTML = html;
            $('params_export').style.display = sendToCRM ? 'none' : 'block';

            // Si on exporte une société, alors inutile de pouvoir choisir le user_level
            $('zone_export_dest_level_id').style.display = targetLevelID && targetLevelID == 10 ? 'none' : 'inline';

            $('zoneResultExportUser').style.display = 'none';
            $('imgLoadingExportUser').style.display = 'none';
            if (SocialEngine.send_to_crm)
              $('btn_valid_export').style.display = '';
            TB_init();
            // "Envoyer vers le CRM Webcastory" / "L'exporter vers une autre webtv"
            TB_show(SocialEngine.Language.Translate(sendToCRM ? 3511642 : 3510777), '#TB_inline?height=130&width=680&inlineId=displaywebtvlistforexport', '', '../images/trans.gif');
           }
        }
      });
      request.send();
     },

    exportUserConfirm: function()
     {
      var userID = SocialEngine.export_user_id;

      // Image d'attente
      $('imgLoadingExportUser').style.display = 'block';

      /*
      TB_init();
      // "L'exporter vers une autre webtv"
      TB_show(SocialEngine.Language.Translate(3510777), '#TB_inline?height=300&width=600&inlineId=displaywebtvlistforexport', '', '../images/trans.gif');
      */

      var dest_webtv_id = SocialEngine.export_webtv_id;
      var target_level_id = SocialEngine.export_level_id;

      // Ajax
      var bind = this;
      var request = new Request.JSON({
        'method' : 'post',
        'url' : this.options.ajaxURL,
        'data' : {
          'task' : 'user_export',
          'user_id' : userID,
          'dest_webtv_id' : dest_webtv_id,
          'target_level_id' : target_level_id
        },
        'onComplete':function(responseObject)
        {
          if( $type(responseObject)!="object" || !responseObject.result || responseObject.result=="failure" )
           {
            if (responseObject && responseObject.is_debug) alert(responseObject.error);
           }
          else
           {
            $('zoneResultExportUser').style.display = 'block';
            $('zoneResultExportUser').innerHTML = responseObject.result_txt;
            $('imgLoadingExportUser').style.display = 'none';
            if (SocialEngine.send_to_crm)
              $('btn_valid_export').style.display = 'none';
            TB_init();
            // "L'exporter vers une autre webtv"
            TB_show(SocialEngine.Language.Translate(3510777), '#TB_inline?height=250&width=680&inlineId=displaywebtvlistforexport', '', '../images/trans.gif');
           }
        }
      });
      request.send();
     },

    // Jean 27/01/2011 : vérification "manuelle" d'un compte utilisateur
    manualVerif: function(userID)
     {
      // Image d'attente
      $('loading_manual_verif').style.display = 'block';

      // Ajax
      var bind = this;
      var request = new Request.JSON({
        'method' : 'post',
        'url' : this.options.ajaxURL,
        'data' : {
          'task' : 'manual_verif',
          'user_id' : userID
        },
        'onComplete':function(responseObject)
        {
          if( $type(responseObject)!="object" || !responseObject.result || responseObject.result=="failure" )
           {
            $('loading_manual_verif').style.display = 'none';
            if (responseObject && responseObject.is_debug) alert(responseObject.error);
            else alert('Aucun changement ne semble avoir été opéré...');
           }
          else
           {
            $('loading_manual_verif').style.display = 'none';
            $('zone_warning_user_not_verified').fade('out');
           }
        }
      });
      request.send();
     },

   // Jean 24/05/2011
   annihileScammer: function(userID, userDisplayName)
    {
      // "Êtes-vous sûr que %1$s est un "scammer" ? [...]"
      if (!confirm(SocialEngine.Language.TranslateFormatted(3511366, [userDisplayName])))
       return;

      // Image d'attente
      $('loading_annihile_scammer').style.display = 'block';

      // Ajax
      var bind = this;
      var request = new Request.JSON({
        'method' : 'post',
        'url' : this.options.ajaxURL,
        'data' : {
          'task' : 'annihile_scammer',
          'user_id' : userID
        },
        'onComplete':function(responseObject)
        {
          if( $type(responseObject)!="object" || !responseObject.result || responseObject.result=="failure" )
           {
            $('loading_annihile_scammer').style.display = 'none';
            if (responseObject && responseObject.is_debug) alert(responseObject.error);
            else alert('Aucun changement ne semble avoir été opéré...');
           }
          else
           {
            $('loading_annihile_scammer').style.display = 'none';
            $('TD_annihile_scammer').style.color = '#D90000';
            $('TD_annihile_scammer').style.padding = '10px 5px 30px 5px';
            $('TD_annihile_scammer').style.border = '1px solid #C12828';
            $('TD_annihile_scammer').innerHTML = responseObject.result;
            //$('TR_annihile_scammer').fade('out');
           }
        }
      });
      request.send();
     },

    // Jean 25/07/2011 : pour dire qu'un user a souscrit
    setSubscUser: function(userID, subscOffer, subscByUserId)
     {
      // Image d'attente
      $('loading_user_subsc').style.display = 'block';

      // Ajax
      var bind = this;
      var request = new Request.JSON({
        'method' : 'post',
        'url' : this.options.ajaxURL,
        'data' : {
          'task' : 'set_subsc_user',
          'user_id' : userID,
          'user_subsc_offer' : subscOffer,
          'user_subsc_set_by' : subscByUserId
        },
        'onComplete':function(responseObject)
        {
          if( $type(responseObject)!="object" || !responseObject.result || responseObject.result=="failure" )
           {
            $('loading_user_subsc').style.display = 'none';
            if (responseObject && responseObject.is_debug) alert(responseObject.error);
            else alert('Aucun changement ne semble avoir été opéré...');
           }
          else
           {
            $('loading_user_subsc').style.display = 'none';
            //$('zone_warning_user_not_verified').fade('out');
            $('zone_user_subsc_period').style.display = subscOffer != '' ? 'block' : 'none';
           }
        }
      });
      request.send();
     },

    // Jean 06/01/2012 : bascule un profil CRM en membre de la plateforme
    switchCrmMember: function(userID, switchToMember, eventID)
     {
      var imgLoading = $('img_loading_switch_member_'+ userID);
      if (imgLoading) imgLoading.style.display = 'inline';

      // On propose un mot de passe d'identification pour ce user à transformer en "membre"
      if (switchToMember)
       {
        // <lang>
        var password = prompt('Modifier ou valider ici le mot de passe d\'identification pour ce user :', randomcode(6));
        if (password == null)
         {
          if (imgLoading) imgLoading.style.display = 'none';
          return;
         }
       }

      // Ajax
      var bind = this;
      var request = new Request.JSON({
        'method' : 'post',
        'url' : this.options.ajaxURL,
        'data' : {
          'task' : 'member_switch',
          'user_id' : userID,
          'to_member' : (switchToMember ? '1' : '0'),
          'password' : password
        },
        'onComplete':function(responseObject)
         {
          if( $type(responseObject)!="object" || !responseObject.result || responseObject.result=="failure" )
           {
            if (responseObject.error) alert(responseObject.error); // alert(responseObject && responseObject.error ? responseObject.error : 'Erreur côté serveur !');
            else alert(bind.Base.Language.Translate(3000153));
           }
          else
           {
            if (imgLoading)
              imgLoading.style.display = 'none';
            // <lang>
            if (responseObject.result_code == -1)
              alert("Une erreur est survenue ! (Vérifier l'existence d'une adresse email pour ce user");
            else if (SocialEngine.Event && SocialEngine.Event.getProspects)
              SocialEngine.Event.getProspects(eventID);
           }
         }
      });

      request.send();
    }

  });

