/**
 * Class WeekEvent
 */
function cWeekEvent(pnAgendaID, psCoords, psType, psTitle, psDescription, psURL, pbStartPreviousWeek, pbEndNextWeek, psBubbleURL, psStyleBackground, psStyleTextColor, pbPrivate)
{
  this.m_nAgendaID = pnAgendaID;
  this.m_asCoords = psCoords;
  this.m_sType = psType;
  this.m_sTitle = psTitle;
  this.m_sDescription = psDescription;
  this.m_sURL = psURL + "&agpacc=" + pnAgendaID;
  this.m_sStyleBackground = psStyleBackground;
  this.m_sStyleTextColor = psStyleTextColor;
  
  this.m_oDivs = new Array();
  this.m_oContentDivs = new Array();
  
  this.m_bStartPreviousWeek = pbStartPreviousWeek;
  this.m_bEndNextWeek = pbEndNextWeek;

  var nLength = this.m_asCoords.events.length;
  for (nCurrent = 0; nCurrent < nLength; nCurrent++)
  {
    this.m_oDivs[nCurrent] = $(document.createElement("div"));

    // Bulle au survol de la case
    var oDivContent = document.createElement("div");
    oDivContent.setAttribute("style", "cursor: pointer;");
    
    // Pas de bulle au survol si l'evt est privé
    if(!pbPrivate)
    {
      oDivContent.setAttribute("onmouseout", "closeAjaxBubble();");
      oDivContent.setAttribute("onmouseover", "getAjaxBubble(event, '" + psBubbleURL + "');");
      oDivContent.setAttribute("onclick", "document.location.href = '" + this.m_sURL + "'");
    }
    
    this.m_oContentDivs[nCurrent] = $(oDivContent);
    
    this.m_oDivs[nCurrent].append(this.m_oContentDivs[nCurrent]);
    $("#agenda_block" + this.m_nAgendaID).append(this.m_oDivs[nCurrent]);
    
    var sTitle = '';

    // Si l'evenement est sur plus d'une journée
    if (nLength > 1)
    {
      // Si on est pas sur le dernier jour
      if (nCurrent < nLength - 1)
      {
        sTitle += this.HourToString(this.m_asCoords.events[nCurrent].hour, this.m_asCoords.events[nCurrent].minute) + '...';
      }
      else
      {
        var oDate = new Date();
        oDate.setHours(this.m_asCoords.events[nCurrent].hour);
        oDate.setMinutes(this.m_asCoords.events[nCurrent].minute + this.m_asCoords.events[nCurrent].size);
        sTitle += this.HourToString(this.m_asCoords.events[nCurrent].hour, this.m_asCoords.events[nCurrent].minute);
        sTitle += ' - ' + this.HourToString(oDate.getHours(), oDate.getMinutes());
      }
    }
    else
    {
      if (this.m_asCoords.events[nCurrent].size > cWeekAgenda.CONST_CELL_DURATION)
      {
        var oDate = new Date();
        oDate.setHours(this.m_asCoords.events[nCurrent].hour);
        oDate.setMinutes(this.m_asCoords.events[nCurrent].minute + this.m_asCoords.events[nCurrent].size);
        sTitle += this.HourToString(this.m_asCoords.events[nCurrent].hour, this.m_asCoords.events[nCurrent].minute);
        sTitle += ' - ' + this.HourToString(oDate.getHours(), oDate.getMinutes());
      }
      else
      {
        sTitle += this.HourToString(this.m_asCoords.events[nCurrent].hour, this.m_asCoords.events[nCurrent].minute);
        sTitle += ' - ' + this.m_sTitle;
      }
    }

    var sLink = '';
    if(!pbPrivate) sLink = "<a class='multi' href='" + this.m_sURL + "'>";
    sLink += sTitle;
    if(!pbPrivate) sLink += "</a>";
    
    this.m_oContentDivs[nCurrent].append("<strong>" + sLink + "<strong>");
    this.m_oContentDivs[nCurrent].append("<div>" + this.m_sType + "</div>");
    this.m_oContentDivs[nCurrent].append("<div>" + this.m_sTitle + "</div>");
    this.m_oContentDivs[nCurrent].append("<small>" + this.m_sDescription + "</small>");
  }
}

cWeekEvent.prototype.ControlConflictDate = function (poEvent)
{
  nCountA = this.m_asCoords.events.length;
  nCountB = poEvent.m_asCoords.events.length;

  // On contrôle chaque jour de présence de l'évènement
  for (nIndexA = 0; nIndexA < nCountA; nIndexA++)
  {
    for (nIndexB = 0;nIndexB < nCountB; nIndexB++)
    {
      bConflict = false;

      // S'il s'agit du même jour
      if (this.m_asCoords.events[nIndexA].day == poEvent.m_asCoords.events[nIndexB].day)
      {
        nDebutA = this.m_asCoords.events[nIndexA].hour*60+this.m_asCoords.events[nIndexA].minute;
        nFinA = this.m_asCoords.events[nIndexA].hour*60+this.m_asCoords.events[nIndexA].minute+this.m_asCoords.events[nIndexA].size;
        nDebutB = poEvent.m_asCoords.events[nIndexB].hour*60+poEvent.m_asCoords.events[nIndexB].minute;
        nFinB = poEvent.m_asCoords.events[nIndexB].hour*60+poEvent.m_asCoords.events[nIndexB].minute+poEvent.m_asCoords.events[nIndexB].size;

        // Si le début de B est entre le début de A et sa fin, il y a conflit
        if (nDebutB >= nDebutA && nDebutB < nFinA) bConflict = true;

        // Si le début de A est entre le début de B et sa fin, il y a conflit
        if (nDebutA >= nDebutB && nDebutA < nFinB) bConflict = true;

        // S'il y a conflit
        if (bConflict)
        {
          this.m_asCoords.events[nIndexA].m_nCountConflict = this.m_asCoords.events[nIndexA].m_nCountConflict + 1;
          poEvent.m_asCoords.events[nIndexB].m_nCountConflict = poEvent.m_asCoords.events[nIndexB].m_nCountConflict + 1;
          this.m_asCoords.events[nIndexA].m_nPositionConflict = this.m_asCoords.events[nIndexA].m_nPositionConflict + 1;
        }
      }
    }
  }
}

cWeekEvent.prototype.HourToString = function(pnHour, pnMinute)
{
  var sHour = '';
  if (pnHour < 10) sHour += '0'
  sHour += pnHour;
  sHour +=  ':'
  if (pnMinute < 10) sHour += '0'
  sHour += pnMinute;
  return sHour;
}

cWeekEvent.prototype.Draw = function()
{
  var nLength = this.m_asCoords.events.length;
  for (nCurrent = 0; nCurrent < nLength; nCurrent++)
  {
    // si le jour de l'événement est un samedi ou dimanche et que l'on affiche pas le weekeend
    // on ignore l'affichage de l'événement
    if(this.m_asCoords.events[nCurrent].day >= cWeekAgenda.CONST_NBDAY)
      continue;
    
    this.m_oDivs[nCurrent].css("height", ((this.m_asCoords.events[nCurrent].size / cWeekAgenda.CONST_CELL_DURATION) * cWeekAgenda.CONST_CELL_HEIGHT) + "px");
    this.m_oDivs[nCurrent].css("top", ((this.m_asCoords.events[nCurrent].hour - cWeekAgenda.CONST_HOUR_START) * (2 * cWeekAgenda.CONST_CELL_HEIGHT) + (this.m_asCoords.events[nCurrent].minute / cWeekAgenda.CONST_CELL_DURATION) * cWeekAgenda.CONST_CELL_HEIGHT + cWeekAgenda.CONST_CELL_HEADER_HEIGHT) + "px");

    // On gère la superposition des evenements
    // Pour le calcul des tailles, on enléve 2% à la taille de la case et on décale d'1% supplémentaire pour centrer
    if (this.m_asCoords.events[nCurrent].m_nCountConflict > 0)
    {
      nWidth = (2 * (cWeekAgenda.CONST_COLUMN_WIDTH - 2)) / (this.m_asCoords.events[nCurrent].m_nCountConflict + 2);
      nDecalage = (nWidth / 2) * this.m_asCoords.events[nCurrent].m_nPositionConflict;
    }
    else
    {
      nWidth = cWeekAgenda.CONST_COLUMN_WIDTH - 2;
      nDecalage = 1;
    }

    this.m_oDivs[nCurrent].css("right", (Math.abs(this.m_asCoords.events[nCurrent].day - cWeekAgenda.CONST_NBDAY) * (cWeekAgenda.CONST_COLUMN_WIDTH) + nDecalage) + "%");
    this.m_oDivs[nCurrent].css("width", nWidth + "%");
    this.m_oDivs[nCurrent].css("position", "absolute");
    this.m_oDivs[nCurrent].css("z-index", "1");

    this.m_oContentDivs[nCurrent].addClass("agenda_weekevent");
    this.m_oContentDivs[nCurrent].css("background-color", this.m_sStyleBackground);
    this.m_oContentDivs[nCurrent].css("color", this.m_sStyleTextColor);
    this.m_oContentDivs[nCurrent].css("height", (((this.m_asCoords.events[nCurrent].size / cWeekAgenda.CONST_CELL_DURATION) * cWeekAgenda.CONST_CELL_HEIGHT) - 4) + "px");
    if (nLength > 1)
    {
      if (nCurrent != 0 || this.m_bStartPreviousWeek)
      {
        this.m_oContentDivs[nCurrent].append($(document.createElement("div")).addClass("agenda_from_previousday"));
      }

      if (nCurrent < nLength - 1 || this.m_bEndNextWeek)
      {
        this.m_oContentDivs[nCurrent].append($(document.createElement("div")).addClass("agenda_continue_nextday"));
      }
    }
  }
}

/**
 * Class WeekMultiEvent
 */
function cWeekMultiEvent(pnAgendaID, psCoords, psType, psTitle, psDescription, psURL, pbStartPreviousWeek, pbEndNextWeek, psBubbleURL, psStyleBackground, psStyleTextColor, pbPrivate)
{
  this.m_nAgendaID = pnAgendaID;
  this.m_asCoords = psCoords;
  this.m_sType = psType;
  this.m_sTitle = psTitle;
  this.m_sDescription = psDescription;
  this.m_sURL = psURL + "&agpacc=" + pnAgendaID;
  this.m_sStyleBackground = psStyleBackground;
  this.m_sStyleTextColor = psStyleTextColor;
  
  this.m_oDivs = new Array();
  this.m_oContentDivs = new Array();
  
  this.m_bStartPreviousWeek = pbStartPreviousWeek;
  this.m_bEndNextWeek = pbEndNextWeek;
  
  var nLength = this.m_asCoords.events.length;
  for (nCurrent = 0; nCurrent < nLength; nCurrent++)
  {
    this.m_oDivs[nCurrent] = $(document.createElement("div"));
    
    // Bulle au survol de la case
    var oDivContent = document.createElement("div");
    oDivContent.setAttribute("style", "cursor: pointer;");
    
    if(!pbPrivate)
    {
      oDivContent.setAttribute("onmouseout", "closeAjaxBubble();");
      oDivContent.setAttribute("onmouseover", "getAjaxBubble(event, '" + psBubbleURL + "');");
      oDivContent.setAttribute("onclick", "document.location.href = '" + this.m_sURL + "'");
    }
    
    this.m_oContentDivs[nCurrent] = $(oDivContent);
    
    this.m_oDivs[nCurrent].append(this.m_oContentDivs[nCurrent]);
    $("#agenda_container" + this.m_nAgendaID).append(this.m_oDivs[nCurrent]);
    
    var sLink = '';
    if(!pbPrivate) sLink = "<a class='multi' href='" + this.m_sURL + "'>";
    //sLink += this.m_sType;
    sLink += this.m_sTitle;
    if(!pbPrivate) sLink += "</a>";
    this.m_oContentDivs[nCurrent].append(sLink);
  }
}

cWeekMultiEvent.prototype.ControlConflictDate = function (poEvent)
{
  nCountA = this.m_asCoords.events.length;
  nCountB = poEvent.m_asCoords.events.length;

  // On contrôle chaque jour de présence de l'évènement
  for (nIndexA = 0; nIndexA < nCountA; nIndexA++)
  {
    for (nIndexB = 0;nIndexB < nCountB; nIndexB++)
    {
      bConflict = false;

      // S'il s'agit du même jour
      if (this.m_asCoords.events[nIndexA].day == poEvent.m_asCoords.events[nIndexB].day)
      {
        nDebutA = this.m_asCoords.events[nIndexA].hour*60+this.m_asCoords.events[nIndexA].minute;
        nFinA = this.m_asCoords.events[nIndexA].hour*60+this.m_asCoords.events[nIndexA].minute+this.m_asCoords.events[nIndexA].size;
        nDebutB = poEvent.m_asCoords.events[nIndexB].hour*60+poEvent.m_asCoords.events[nIndexB].minute;
        nFinB = poEvent.m_asCoords.events[nIndexB].hour*60+poEvent.m_asCoords.events[nIndexB].minute+poEvent.m_asCoords.events[nIndexB].size;

        // Si le début de B est entre le début de A et sa fin, il y a conflit
        if (nDebutB >= nDebutA && nDebutB < nFinA && this.m_asCoords.events[nIndexA].user == poEvent.m_asCoords.events[nIndexB].user) bConflict = true;

        // Si le début de A est entre le début de B et sa fin, il y a conflit
        if (nDebutA >= nDebutB && nDebutA < nFinB && this.m_asCoords.events[nIndexA].user == poEvent.m_asCoords.events[nIndexB].user) bConflict = true;

        // S'il y a conflit
        if (bConflict)
        {
          this.m_asCoords.events[nIndexA].m_nCountConflict = this.m_asCoords.events[nIndexA].m_nCountConflict + 1;
          poEvent.m_asCoords.events[nIndexB].m_nCountConflict = poEvent.m_asCoords.events[nIndexB].m_nCountConflict + 1;
          this.m_asCoords.events[nIndexA].m_nPositionConflict = this.m_asCoords.events[nIndexA].m_nPositionConflict + 1;
        }
      }
    }
  }
}

cWeekMultiEvent.prototype.Draw = function()
{
  var nLength = this.m_asCoords.events.length;
  for (nCurrent = 0; nCurrent < nLength; nCurrent++)
  {
   // si le jour de l'événement est un samedi ou dimanche et que l'on affiche pas le weekeend
    // on ignore l'affichage de l'événement
    if(this.m_asCoords.events[nCurrent].day >= cWeekMultiAgenda.CONST_NBDAY)
      continue;
    
    // Hauteur de l'événement
    var nCurrentDay = this.m_asCoords.events[nCurrent].day;
    if(nCurrentDay == 0)
      nCurrentDay = 6;
    else
      nCurrentDay--;
    
    // On gère la superposition des evenements
    if (this.m_asCoords.events[nCurrent].m_nCountConflict > 0)
    {
      nRatio = this.m_asCoords.events[nCurrent].m_nCountConflict + 1;
      nHeight = cWeekMultiAgenda.CONST_CELL_HEIGHT / 2;
      nDecalage = (5 * this.m_asCoords.events[nCurrent].m_nPositionConflict) + 5;
    }
    else
    {
      nHeight = cWeekMultiAgenda.CONST_CELL_HEIGHT - 10;
      nDecalage = 5;
    }
    
    this.m_oDivs[nCurrent].css("top", (cWeekMultiAgenda.CONST_CELL_HEADER_HEIGHT + (cWeekMultiAgenda.CONST_CELL_HEIGHT * nCurrentDay * cWeekMultiAgenda.CONST_USERS_NB) + (cWeekMultiAgenda.CONST_CELL_HEIGHT * this.m_asCoords.events[nCurrent].pos) + nDecalage) + cWeekMultiAgenda.CONST_CELL_DAY_SEPARATOR * (nCurrentDay * 2 + 1) + "px");
    
    // Position de la case de l'événement
    var nCoordRight = ((cWeekMultiAgenda.CONST_HOUR_END - this.m_asCoords.events[nCurrent].hour - 1) - (this.m_asCoords.events[nCurrent].minute / 60)) * cWeekMultiAgenda.CONST_COLUMN_WIDTH;
    if((this.m_asCoords.events[nCurrent].size / 60) > 0) nCoordRight -= (this.m_asCoords.events[nCurrent].size / 60 - 1) * cWeekMultiAgenda.CONST_COLUMN_WIDTH;
    this.m_oDivs[nCurrent].css("right", nCoordRight + "%");
    
    // Taille de la case événement
    var nWidth = this.m_asCoords.events[nCurrent].size / 60 * cWeekMultiAgenda.CONST_COLUMN_WIDTH;
    this.m_oDivs[nCurrent].css("width", nWidth + "%");
    
    this.m_oDivs[nCurrent].css("position", "absolute");
    this.m_oDivs[nCurrent].css("z-index", "1");
    
    this.m_oContentDivs[nCurrent].addClass("agenda_weekevent");
    this.m_oContentDivs[nCurrent].css("background-color", this.m_sStyleBackground);
    this.m_oContentDivs[nCurrent].css("color", this.m_sStyleTextColor);
    this.m_oContentDivs[nCurrent].css("height", nHeight + "px");
  }
}

/**
 * Class MonthEvent
 */
function cMonthEvent(pnAgendaID, psCoords, psType, psTitle, psDescription, psURL, psBubbleURL, psStyleBackground, psStyleTextColor, pbPrivate)
{
  this.m_nAgendaID = pnAgendaID;
  this.m_asCoords = psCoords;
  this.m_sType = psType;
  this.m_sTitle = psTitle;
  this.m_sDescription = psDescription;
  this.m_sURL = psURL + "&agpacc=" + pnAgendaID;
  this.m_sStyleBackground = psStyleBackground;
  this.m_sStyleTextColor = psStyleTextColor;
  this.m_bPrivate = pbPrivate;
  this.m_sBubbleURL = psBubbleURL;
  
  this.m_oDivs = new Array();
  this.m_oContentDivs = new Array();
}

cMonthEvent.prototype.ControlConflictDate = function (poEvent)
{
  nCountA = this.m_asCoords.events.length;
  nCountB = poEvent.m_asCoords.events.length;
  
  // On contrôle chaque jour de présence de l'événement
  for (nIndexA = 0; nIndexA < nCountA; nIndexA++)
  {
    for (nIndexB = 0;nIndexB < nCountB; nIndexB++)
    {
      bConflict = false;
      
      var dEventDateStartA = new Date(this.m_asCoords.events[nIndexA].start * 1000);
      var dEventDateEndA = new Date(this.m_asCoords.events[nIndexA].end * 1000);
      
      var dEventDateStartB = new Date(poEvent.m_asCoords.events[nIndexB].start * 1000);
      var dEventDateEndB = new Date(poEvent.m_asCoords.events[nIndexB].end * 1000);
      
      // S'il s'agit du même jour
      if (poEvent.m_asCoords.events[nIndexB].m_bDisplay && this.m_asCoords.events[nIndexA].m_bDisplay && this.m_asCoords.events[nIndexA].day == poEvent.m_asCoords.events[nIndexB].day)
      {
        // 0 = matin | 1 = après-midi
        nDebutA = 0;
        if(dEventDateStartA.getHours() > 12 || (dEventDateStartA.getHours() == 12 && dEventDateStartA.getMinutes() > 30)) nDebutA = 1;
        
        nFinA = 0;
        if(dEventDateEndA.getHours() > 12 || (dEventDateEndA.getHours() == 12 && dEventDateEndA.getMinutes() > 30)) nFinA = 1;
        
        nDebutB = 0;
        if(dEventDateStartB.getHours() > 12 || (dEventDateStartB.getHours() == 12 && dEventDateStartB.getMinutes() > 30)) nDebutB = 1;
        
        nFinB = 0;
        if(dEventDateEndB.getHours() > 12 || (dEventDateEndB.getHours() == 12 && dEventDateEndB.getMinutes() > 30)) nFinB = 1;

        // Détection de conflit
        if(this.m_asCoords.events[nIndexA].user == poEvent.m_asCoords.events[nIndexB].user && (nDebutA == nDebutB || nDebutA == nFinB)) bConflict = true;
        if(this.m_asCoords.events[nIndexA].user == poEvent.m_asCoords.events[nIndexB].user && (nFinA == nDebutB || nFinA == nFinB)) bConflict = true;
        
        // S'il y a conflit
        if (bConflict)
        {
          if(this.m_asCoords.events[nIndexA].start > poEvent.m_asCoords.events[nIndexB].start)
            this.m_asCoords.events[nIndexA].start = poEvent.m_asCoords.events[nIndexB].start;
          
          if(this.m_asCoords.events[nIndexA].end < poEvent.m_asCoords.events[nIndexB].end)
            this.m_asCoords.events[nIndexA].end = poEvent.m_asCoords.events[nIndexB].end;
          
          poEvent.m_asCoords.events[nIndexB].m_bDisplay = false;
          
          this.m_asCoords.events[nIndexA].m_nCountConflict = this.m_asCoords.events[nIndexA].m_nCountConflict + 1;
          poEvent.m_asCoords.events[nIndexB].m_nCountConflict = poEvent.m_asCoords.events[nIndexB].m_nCountConflict + 1;
          this.m_asCoords.events[nIndexA].m_nPositionConflict = this.m_asCoords.events[nIndexA].m_nPositionConflict + 1;
        }
      }
    }
  }
}

cMonthEvent.prototype.Draw = function()
{
  var CONST_WEEK = 604800;
  
  var dAgendaStart = new Date(cMonthAgenda.m_nTimeStart);
  
  var nLength = this.m_asCoords.events.length;
  for (nCurrent = 0; nCurrent < nLength; nCurrent++)
  {
    // Ignore l'événement s'il n'est pas affiché
    if(!this.m_asCoords.events[nCurrent].m_bDisplay)
      continue;
    
    var dEventDateStart = new Date(this.m_asCoords.events[nCurrent].start * 1000);
    
    //  si le jour de l'événement est un samedi ou dimanche et que l'on affiche pas le weekeend
    // on ignore l'affichage de l'événement
    if(dEventDateStart.getDay() > cMonthAgenda.CONST_NBDAY)
      continue;
    
    sType = this.m_sType;
    if (this.m_asCoords.events[nCurrent].m_nCountConflict > 0)
    {
      if(!this.m_bPrivate)
      {
        this.m_sBubbleURL += '&agpds=' + this.m_asCoords.events[nCurrent].start;
        this.m_sBubbleURL += '&agpde=' + this.m_asCoords.events[nCurrent].end;
        this.m_sBubbleURL += '&agpaid=' + g_nCurrentAgenda;
        this.m_sBubbleURL += "&multiple=1";
      }
      
      sType = "Evénements multiples";
    }
    
    this.m_oDivs[nCurrent] = $(document.createElement("div"));
    
    // Bulle au survol de la case
    var oDivContent = document.createElement("div");
    oDivContent.setAttribute("style", "cursor: pointer;");
    
    // Si l'evt est privé => pas de survol
    if(!this.m_bPrivate)
    {
      oDivContent.setAttribute("onmouseout", "closeAjaxBubble();");
      oDivContent.setAttribute("onmouseover", "getAjaxBubble(event, '" + this.m_sBubbleURL + "');");
      
      if(this.m_asCoords.events[nCurrent].m_nCountConflict == 0)
        oDivContent.setAttribute("onclick", "document.location.href = '" + this.m_sURL + "'");
    }
    
    // Si evt multiple => pas de lien pour modifier l'evt
    if(this.m_asCoords.events[nCurrent].m_nCountConflict != 0)
      this.m_sURL = 'javascript:';
    
    this.m_oContentDivs[nCurrent] = $(oDivContent);
    
    this.m_oDivs[nCurrent].append(this.m_oContentDivs[nCurrent]);
    $("#agenda_container" + this.m_nAgendaID).append(this.m_oDivs[nCurrent]);
    
    // En-tête de l'evt
    var sLink = '';
    if(!this.m_bPrivate) sLink = "<a class='multi' href='" + this.m_sURL + "'>";
    sLink += sType;
    if(!this.m_bPrivate) sLink += "</a>";
    this.m_oContentDivs[nCurrent].append(sLink);
    
    // Position de la ligne d'insertion
    var nCurrentWeek = -1;
    var nWeek = cMonthAgenda.m_nTimeStart / 1000;
    while(nWeek <= this.m_asCoords.events[nCurrent].start)
    {
      nWeek += CONST_WEEK;
      nCurrentWeek++;
    }
   
    // Détecte si l'événement a lieu en matinée
    var dEventDateStart = new Date(this.m_asCoords.events[nCurrent].start * 1000);
    var dEventDateEnd = new Date(this.m_asCoords.events[nCurrent].end * 1000);
    
    var bMorning = (dEventDateStart.getHours() < 12 || (dEventDateStart.getHours() == 12 && dEventDateStart.getMinutes() <= 30));
    var bEveningEnd = (dEventDateEnd.getHours() > 12 || (dEventDateStart.getHours() == 12 && dEventDateStart.getMinutes() > 30));
    
    var nDecalageWidth = 0;
    if(bMorning) nDecalageWidth = cMonthAgenda.CONST_COLUMN_WIDTH;
    
    // Au mois il n'y a pas de superposition, mais un regroupement d'événement
    if (this.m_asCoords.events[nCurrent].m_nCountConflict > 0)
      this.m_oContentDivs[nCurrent].addClass("agenda_regrouped");
    
    nHeight = cMonthAgenda.CONST_CELL_HEIGHT - 10;
    nDecalage = 6;
    
    this.m_oDivs[nCurrent].css("height", nHeight + "px");
    this.m_oDivs[nCurrent].css("top", (cMonthAgenda.CONST_CELL_HEADER_HEIGHT + (cMonthAgenda.CONST_CELL_HEIGHT * nCurrentWeek * cMonthAgenda.CONST_USERS_NB) + (cMonthAgenda.CONST_CELL_HEIGHT * this.m_asCoords.events[nCurrent].pos) + cMonthAgenda.CONST_CELL_WEEK_SEPARATOR * (nCurrentWeek * 2 + 1) + nDecalage) + "px");
    
    // Position de la case de l'événement
    var nDay = dEventDateStart.getDay();
    if(nDay == 0) nDay = 7;
    
    var nRight = Math.abs(nDay - cMonthAgenda.CONST_NBDAY) * (100 / (cMonthAgenda.CONST_NBDAY * 2) * 2) + nDecalageWidth;
    if(bMorning && bEveningEnd) nRight -= cMonthAgenda.CONST_COLUMN_WIDTH;
    this.m_oDivs[nCurrent].css("right", (nRight) + "%");
    
    // Taille de la case événement
    var nWidth = (dEventDateEnd.getDate() - dEventDateStart.getDate() + 1) * (cMonthAgenda.CONST_COLUMN_WIDTH * 2);
    if(!bMorning) nWidth -= cMonthAgenda.CONST_COLUMN_WIDTH;
    if(!bEveningEnd) nWidth -= cMonthAgenda.CONST_COLUMN_WIDTH;
    this.m_oDivs[nCurrent].css("width", nWidth + "%");
    
    this.m_oDivs[nCurrent].css("position", "absolute");
    this.m_oDivs[nCurrent].css("z-index", "1");
    
    this.m_oContentDivs[nCurrent].addClass("agenda_weekevent");
    this.m_oContentDivs[nCurrent].css("height", nHeight + "px");
    if (this.m_asCoords.events[nCurrent].m_nCountConflict == 0)
    {
      this.m_oContentDivs[nCurrent].css("background-color", this.m_sStyleBackground);
      this.m_oContentDivs[nCurrent].css("color", this.m_sStyleTextColor);
    }
  }
}
