document.write('<style type="text/css">\
<!--\
A:ACTIVE, A:LINK, A:VISITED { text-decoration: none; }\
A:HOVER { text-decoration: underline; }\
-->\
</style>');

function mel(l,e,h,j,d,g){a="<a href=\"";b="mai";c="lto:";f="@FRIENDS";o="<img src=\"/visuelfg2/at.gif\" width=16 height=16 border=0 align=middle>";i=".";k="\">";m="</a>";n="?body=Supprimez FRIENDS dans l\'adresse Email du destinataire / Remove FRIENDS in the Email destination address";if(l){document.write(a+b+c+d+e+f+g+h+i+j+n+k+l+m);}else{document.write(a+b+c+d+e+f+g+h+i+j+n+k+d+e+o+g+h+i+j+m);}}

// Initialisation du navigateur
NN = (document.layers) ? 1:0;
IE = (document.all) ? 1:0;
VISIBLE = NN ? 'show' : 'visible';
HIDDEN  = NN ? 'hide' : 'hidden';

// Gestion du scenario
currentText = 0;
futureText = 0;
currentTcAlt = 0;
scenarioState = 0;
paramScenario = 0;
TELECOMMANDE_SCENARIO = 1;
TELE_SCENARIO = 2;
TEXTE_SCENARIO = 4;

// Gestion du diaporama
imgList = new Array();
imagesDiv = 0;
currentDiapo = 0;
endDiapo = 0;
diapoReady = 0;
diapoRun = 0;
diapoFirst = 0;
diapoTimeout = 0;

// Gestion de la télé
detailsList = new Array();
currentTitle = 0;
currentDetails = 3;
futureTitle = 0;
printTitle = 0;
printTitleDetails = 0;
FICHE_TITLE = 1;
ROLE_TITLE = 2;
EPISODES_TITLE = 4;
RESUME_TITLE = 8;
BESTOF_TITLE = 16;
CONTACT_TITLE = 32;
QUI_TITLE = 64;
PRINCIPE_TITLE = 128;
MODEDEMPLOI_TITLE = 256;

// Définition de la classe divObject
function divObject(id)
{
  if (NN)
  {
    this.css = document.layers[id];
    this.x   = this.css.left;
    this.y   = this.css.top;
  }
  else
  {
    this.css = document.all[id].style;
    this.x   = this.css.pixelLeft;
    this.y   = this.css.pixelTop;
  }

  this.name = id;
  this.obj = id + "Object";
  eval(this.obj + "=this");
  this.moveBy = divObjectMoveBy;
  this.moveTo = divObjectMoveTo;
  this.move   = divObjectMove;
  this.show   = divObjectShow;
  this.hide   = divObjectHide;
  this.state  = 0;
}

function divObjectMoveBy(x, y)
{
  this.x += x;
  this.y += y;
  this.css.top = this.y;
  this.css.left = this.x;
}

function divObjectMoveTo(x, y)
{
  this.x = x;
  this.y = y;
  this.css.left = x;
  this.css.top = y;
}

function divObjectMove(destX, destY, speed, stepX, stepY, showHide, clipRect)
{
  this.x += stepX;
  this.y += stepY;

  if ((stepX == 0) && (destX != this.x))
  {
     destX = this.X;
  }

  if ((stepY == 0) && (destY != this.y))
  {
     destY = this.y;
  }

  if (stepX > 0)
  {
    if (this.x > destX)
      this.x = destX;
  }
  else
  {
    if (this.x < destX)
      this.x = destX;
  }

  if (stepY > 0)
  {
    if (this.y > destY)
      this.y = destY;
  }
  else
  {
    if (this.y < destY)
      this.y = destY;
  }
  var x = this.x;
  var y = this.y;
  switch(clipRect)
  {
    case 1:
      // rect du bottom
      if (destY > y)
        bottomVal = destY - y - 33;
      else
        bottomVal = 387 - (y - destY);
      $chaine = "rect(auto, auto, " + bottomVal + ", auto)";
      this.css.clip = $chaine;
      break;

    case 2:
      // rect du right
      if (destX > x)
        rightVal = (destX - x) - 9;
      else
        rightVal = 261 - (x - destX);
      $chaine = "rect(auto, " + rightVal + ", auto, auto)";
      this.css.clip = $chaine;
      break;

    case 3:
      // rect du left
      if (destX > x)
        leftVal = destX - x;
      else
        leftVal = 261 - (x - destX) + 9;
      $chaine = "rect(auto, auto, auto, " + leftVal + ")";
      this.css.clip = $chaine;
      break;
  }

  if (showHide == 1)
  {
    this.show();
    showHide = 0;
  }

  this.moveTo(x, y);

  if ((this.x != destX) || (this.y != destY))
  {
    param = this.obj + ".move(" + destX + ", " + destY + ", " + speed + ", " + stepX + ", " + stepY + ", " + showHide + ", " + clipRect + ")";
    setTimeout(param, speed);
  }
  else
  {
    if (clipRect)
        this.css.clip = 'rect(auto, auto, auto, auto)';
    if (showHide == 2)
    {
      this.hide();
      showHide = 0;
    }
    scenario();
  }
}

function divObjectShow()
{
  this.css.visibility = VISIBLE;
}

function divObjectHide()
{
  this.css.visibility = HIDDEN;
}

// Définition de la classe imgObject
function imgObject(name)
{
  this.name = name;
  this.image = 0;
  this.show = imgObjectShow;
}

function diapoTrans()
{
  if ((IE) && (diapoTransition != "OUI") && (imageDiapo.filters) && (imageDiapo.filters.blendTrans))
  {
    imageDiapo.filters.blendTrans.stop();
    imageDiapo.filters.blendTrans.apply();
  }
}

function imgObjectShow()
{
  imagesDiv.show();
  diapoTrans();
  imageDiapo.src = this.name;
}

function charge()
{
  // mosaiqueDiv.show();
  focus();
}

// Vie de la telecommande
function telecommandeLaunch(param)
{
  if (param == 3)
  {
    diapoStop();
    param = 0;
  }
  if ((telecommandeDiv.x == 810) && ((param == 0) || (param == 1)))
    telecommandeDiv.move(450, 60, 5, -40, 0, 1, 0);
  else if ((telecommandeDiv.x == 450) && ((param == 0) || (param == 2)))
  {
    if (currentTcAlt != 0)
    {
      tcAltDiv[currentTcAlt].hide();
    }
    if (teleDiv.x == 26)
    {
      paramScenario = 2;
      scenarioState = TELECOMMANDE_SCENARIO | TELE_SCENARIO | TEXTE_SCENARIO;
      scenario();
    }
    else
      telecommandeDiv.move(810, 60, 5, 40, 0, 2, 0);
  }
  //return false;
}

function tcLaunch(param)
{
  diapoStop();
  teleTitleView(0);
  teleNavView(2);
  if (scenarioState == 0)
  {
    switch (param)
    {
      case 1:
        // Mosaique
        paramScenario = 2;
        scenarioState = TELECOMMANDE_SCENARIO | TELE_SCENARIO | TEXTE_SCENARIO;
        scenario();
        imagesDiv.hide();
        break;

      case 2:
        // Précédente
        if ((imagesDiv.css.visibility == VISIBLE) && (imgList.length > 0))
        {
          currentDiapo--;
          if (currentDiapo < 1)
            currentDiapo = 1;
          diapoImage(currentDiapo);
        }
        else
        {
          document.location.href = "fg2.php?nav=avant";
        }
        break;

      case 3:
        // Suivante
        if ((imagesDiv.css.visibility == VISIBLE) && (imgList.length > 0))
        {
          currentDiapo++;
          if (currentDiapo >= imgList.length)
            currentDiapo = imgList.length - 1;
          diapoImage(currentDiapo);
        }
        else
        {
          document.location.href = "fg2.php?nav=apres";
        }
        break;

      case 4:
        // Chercher
        scenarioState = TELECOMMANDE_SCENARIO | TELE_SCENARIO | TEXTE_SCENARIO;
        futureText = chercherDiv;
        paramScenario = 1;
        scenario();
        break;

      case 5:
        // Détails
        if (printTitleDetails)
          printTitle = printTitleDetails;
        scenarioState = TELE_SCENARIO | TEXTE_SCENARIO;
        futureTitle = teleFicheDiv;
        futureText = detailsList[1];
        if ((detailsList[1] == 0) && (detailsList.length > 3))
        {
          futureText = detailsList[3];
          futureTitle = 0;
        }
        paramScenario = 1;
        scenario();
        break;

      case 6:
        // Invités
        scenarioState = TELECOMMANDE_SCENARIO | TELE_SCENARIO | TEXTE_SCENARIO;
        futureText = invitesDiv;
        paramScenario = 1;
        scenario();
        break;

      case 7:
        // Aide
        if (printTitleDetails == 0)
          printTitleDetails = printTitle;
        printTitle = PRINCIPE_TITLE | MODEDEMPLOI_TITLE;
        scenarioState = TELECOMMANDE_SCENARIO | TELE_SCENARIO | TEXTE_SCENARIO;
        futureTitle = telePrincipeDiv;
        futureText = aideList[1];
        paramScenario = 1;
        scenario();
        break;

      case 8:
        // Episodes
        document.location.href = "fg2.php?nav=episodes";
        break;

      case 9:
        // Perso
        scenarioState = TELE_SCENARIO | TEXTE_SCENARIO;
        futureText = persoDiv;
        paramScenario = 1;
        scenario();
        break;

      case 10:
        // Best Of
        document.location.href = "fg2.php?nav=bestof";
        break;

      case 11:
        // Contact
        if (printTitleDetails == 0)
          printTitleDetails = printTitle;
        printTitle = CONTACT_TITLE | QUI_TITLE;
        scenarioState = TELE_SCENARIO | TEXTE_SCENARIO;
        futureTitle = teleContactDiv;
        futureText = contactList[1];
        paramScenario = 1;
        scenario();
        break;

      case 12:
        // Flash
        diapoReady = 1;
        imagesDiv.show();
        diapoTrans();
        imageDiapo.src = "image.php";
        scenarioState = TELECOMMANDE_SCENARIO | TELE_SCENARIO | TEXTE_SCENARIO;
        paramScenario = 2;
        scenario();
        break;
    }
  }
  //return false;
}

function tcAltOut(param)
{
  if ((param >= 1) && (param <= 12) && (telecommandeDiv.x == 450))
  {
    tcAltDiv[param].hide();
    currentTcAlt = 0;
  }
  //return true;
}

function tcAltOver(param)
{
  if ((param >= 1) && (param <= 12) && (telecommandeDiv.x == 450))
  {
    tcAltDiv[param].show();
    currentTcAlt = param;
  }
  //return true;
}

// Vie de la tele
function teleLaunch(param)
{
  if ((teleDiv.x == -376) && ((param == 0) || (param == 1)))
     teleDiv.move(26, 72, 5, 40, 0, 1, 0);
  else if ((teleDiv.x == 26) && ((param == 0) || (param == 2)))
     teleDiv.move(-376, 72, 5, -40, 0, 2, 0);
}

// Vie du scenario
function scenario()
{
  if (paramScenario == 0)
  {
    if ((teleDiv.x == 26) &&
        ((currentText == futureText) || (futureText == 0)))
      paramScenario = 2;
    else
      paramScenario = 1;
  }

  if (paramScenario == 1)
  {
    if (scenarioState & TELECOMMANDE_SCENARIO)
    {
      scenarioState &= ~TELECOMMANDE_SCENARIO;
      if (telecommandeDiv.x != 450)
         telecommandeLaunch(paramScenario);
      else
         scenario();
    }
    else if (scenarioState & TELE_SCENARIO)
    {
      scenarioState &= ~TELE_SCENARIO;
      if (teleDiv.x != 26)
         teleLaunch(paramScenario);
      else
         scenario();
    }
    else if (scenarioState & TEXTE_SCENARIO)
    {
      scenarioState &= ~TEXTE_SCENARIO;
      teleTitleView(1);
      if (currentText != futureText)
        teleSwap();
      if (currentText == detailsList[3])
        teleNavView(1);
    }
  }
  else if (paramScenario == 2)
  {
    if (scenarioState & TEXTE_SCENARIO)
    {
      if (currentText)
        currentText.hide();
      if (futureText)
        futureText.hide();
      currentText = 0;
      futureText = 0;
      scenarioState &= ~TEXTE_SCENARIO;
      teleNavView(2);
      teleTitleView(0);
    }
    if (scenarioState & TELE_SCENARIO)
    {
      scenarioState &= ~TELE_SCENARIO;
      if (teleDiv.x == 26)
         teleLaunch(paramScenario);
      else
         scenario();
    }
    else if (scenarioState & TELECOMMANDE_SCENARIO)
    {
      scenarioState &= ~TELECOMMANDE_SCENARIO;
      if (telecommandeDiv.x == 450)
         telecommandeLaunch(paramScenario);
      else
         scenario();
    }
  }
}

// Vie de la diapo
function diapoLoaded()
{
  diapoReady++;
  if (diapoReady >= 2)
  {
    if ((IE) && (imagesDiv) && (diapoTransition != "OUI") && (imageDiapo.filters) && (imageDiapo.filters.blendTrans))
    {
      imageDiapo.filters.blendTrans.play();
    }
    if ((currentDiapo > 0) && (currentDiapo < endDiapo) && (diapoRun == 1))
      setTimeout("diapoStart();", 1100);
  }
}

function diapoTimeoutLoaded()
{
  diapoTimeout = 0;
  diapoLoaded();
}

function diapoStart()
{
  currentDiapo++;
  diapoReady = 0;
  if (currentDiapo < imgList.length)
  {
    imagesDiv.show();
    diapoTrans();
    imageDiapo.src = imgList[currentDiapo].name;
    scenarioState = TELECOMMANDE_SCENARIO | TELE_SCENARIO | TEXTE_SCENARIO;
    paramScenario = 2;
    scenario();
  }
  if (diapoFirst == 1)
  {
    diapoFirst = 0;
    diapoLoaded();
  }
  else
    diapoTimeout = setTimeout("diapoTimeoutLoaded();", (diapoDuration - 1) * 1000);
  //return false;
}

function diapoStop()
{
  diapoRun = 0;
  dt = diapoTimeout;
  diapoTimeout = 0;
  if (dt)
  {
    clearTimeout(dt);
    diapoLoaded();
  }
}

function diapoStartStop()
{
  if (diapoRun == 1)
  {
    diapoStop();
  }
  else
  {
    diapoRun = 1;
    diapoFirst = 1;
    diapoStart();
  }
}

function diapoSetBounds(start, end)
{
  diapoRun = 1;
  currentDiapo = start;
  endDiapo = end;
  if (endDiapo > imgList.length)
    endDiapo = imgList.length;
  diapoFirst = 1;
  diapoStart();
  //return false;
}

function diapoImage(num)
{
  currentDiapo = num;
  diapoReady = 1;
  imagesDiv.show();
  diapoTrans();
  imageDiapo.src = imgList[currentDiapo].name;
  scenarioState = TELECOMMANDE_SCENARIO | TELE_SCENARIO | TEXTE_SCENARIO;
  paramScenario = 2;
  scenario();
  //return false;
}


// Vie de la tele
function teleTitleView(param)
{
  if (param)
  {
    if (printTitle & FICHE_TITLE)
      teleFicheDiv.show();
    if (printTitle & ROLE_TITLE)
      teleRoleDiv.show();
    if (printTitle & EPISODES_TITLE)
      teleEpisodesDiv.show();
    if (printTitle & RESUME_TITLE)
      teleResumeDiv.show();
    if (printTitle & BESTOF_TITLE)
      teleBestofDiv.show();
    if (printTitle & CONTACT_TITLE)
      teleContactDiv.show();
    if (printTitle & QUI_TITLE)
      teleQuiDiv.show();
    if (printTitle & PRINCIPE_TITLE)
      telePrincipeDiv.show();
    if (printTitle & MODEDEMPLOI_TITLE)
      teleModedemploiDiv.show();
  }
  else
  {
    if (printTitle & FICHE_TITLE)
      teleFicheDiv.hide();
    if (printTitle & ROLE_TITLE)
      teleRoleDiv.hide();
    if (printTitle & EPISODES_TITLE)
      teleEpisodesDiv.hide();
    if (printTitle & RESUME_TITLE)
      teleResumeDiv.hide();
    if (printTitle & BESTOF_TITLE)
      teleBestofDiv.hide();
    if (printTitle & CONTACT_TITLE)
      teleContactDiv.hide();
    if (printTitle & QUI_TITLE)
      teleQuiDiv.hide();
    if (printTitle & PRINCIPE_TITLE)
      telePrincipeDiv.hide();
    if (printTitle & MODEDEMPLOI_TITLE)
      teleModedemploiDiv.hide();
  }
}

function teleNavView(param)
{
  switch(param)
  {
    case 1:
      teleGaucheDiv.show();
      teleDroiteDiv.show();
      break;

    case 2:
      teleGaucheDiv.hide();
      teleDroiteDiv.hide();
      break;
  }
}

function teleSwap()
{
  futureText.moveTo(80, 527);
  // futureTitle highlight
  futureText.move(80, 107, 5, 0, -20, 1, 1);
  if (currentText)
    currentText.move(80, 527, 5, 0, 20, 2, 1);
  // currentTitle delight
  currentText = futureText;
  futureText = 0;
  currentTitle = futureTitle;
  futureTitle = 0;
  teleTitleView(currentTitle);
}

function teleSwapHoriz(param)
{
  if (param == 1)
  {
    futureText.moveTo(-190, 107);
    futureText.move(80, 107, 5, 20, 0, 1, 3);
    currentText.move(350, 107, 5, 20, 0, 2, 2);
    currentText = futureText;
    futureText = 0;
  }
  else if (param == 2)
  {
    futureText.moveTo(350, 107);
    futureText.move(80, 107, 5, -20, 0, 1, 2);
    currentText.move(-190, 107, 5, -20, 0, 2, 3);
    currentText = futureText;
    futureText = 0;
  }
}

function teleGauche()
{
  if (currentDetails > 3)
  {
    currentDetails--;
    futureText = detailsList[currentDetails];
    if ((contactList.length > currentDetails) &&
        (currentText == contactList[currentDetails+1]))
      futureText = contactList[currentDetails];
    else if ((aideList.length > currentDetails) &&
        (currentText == aideList[currentDetails+1]))
      futureText = aideList[currentDetails];
    teleSwapHoriz(1);
  }
  //return false;
}

function teleDroite()
{
  if ((currentDetails < contactList.length) &&
      (currentText == contactList[currentDetails]))
  {
    if (currentDetails < contactList.length - 1)
    {
      currentDetails++;
      futureText = contactList[currentDetails];
      teleSwapHoriz(2);
    }
  }
  else if ((currentDetails < aideList.length) &&
           (currentText == aideList[currentDetails]))
  {
    if (currentDetails < aideList.length - 1)
    {
      currentDetails++;
      futureText = aideList[currentDetails];
      teleSwapHoriz(2);
    }
  }
  else if (currentDetails < detailsList.length - 1)
  {
    currentDetails++;
    futureText = detailsList[currentDetails];
    teleSwapHoriz(2);
  }
  //return false;
}

function teleFiche()
{
  if (currentTitle != teleFicheDiv)
  {
    futureTitle = teleFicheDiv;
    futureText = detailsList[1];
    teleTitleView(1);
    teleSwap();
    teleNavView(2);
  }
  //return false;
}

function teleResume()
{
  if (currentTitle != teleResumeDiv)
  {
    futureTitle = teleResumeDiv;
    futureText = detailsList[3];
    currentDetails = 3;
    teleTitleView(1);
    teleSwap();
    if (detailsList.length > 4)
      teleNavView(1);
  }
  //return false;
}

function teleRole()
{
  if (currentTitle != teleRoleDiv)
  {
    futureTitle = teleRoleDiv;
    futureText = detailsList[2];
    teleTitleView(1);
    teleSwap();
    teleNavView(2);
  }
  //return false;
}

function teleEpisodes(num)
{
  if (currentTitle != teleEpisodesDiv)
  {
    futureTitle = teleEpisodesDiv;
    futureText = detailsList[num];
    currentDetails = num;
    teleTitleView(1);
    teleSwap();
    if (detailsList.length > 4)
      teleNavView(1);
  }
  //return false;
}

function teleBestof(num)
{
  if (currentTitle != teleBestofDiv)
  {
    futureTitle = teleBestofDiv;
    futureText = detailsList[num];
    currentDetails = num;
    teleTitleView(1);
    teleSwap();
    if (detailsList.length > 4)
      teleNavView(1);
  }
  //return false;
}

function teleContact()
{
  if (currentTitle != teleContactDiv)
  {
    futureTitle = teleContactDiv;
    futureText = contactList[1];
    teleTitleView(1);
    teleSwap();
    teleNavView(2);
  }
  //return false;
}

function teleQui(num)
{
  if (currentTitle != teleQuiDiv)
  {
    futureTitle = teleQuiDiv;
    futureText = contactList[num];
    currentDetails = num;
    teleTitleView(1);
    teleSwap();
    if (contactList.length > 4)
      teleNavView(1);
  }
  //return false;
}

function telePrincipe(num)
{
  if (currentTitle != telePrincipeDiv)
  {
    futureTitle = telePrincipeDiv;
    futureText = aideList[1];
    teleTitleView(1);
    teleSwap();
    teleNavView(2);
  }
  //return false;
}

function teleModedemploi(num)
{
  if ((currentTitle != teleModedemploiDiv) || (num != currentDetails))
  {
    futureTitle = teleModedemploiDiv;
    futureText = aideList[num];
    currentDetails = num;
    teleTitleView(1);
    teleSwap();
    if (aideList.length > 4)
      teleNavView(1);
  }
  //return false;
}
