/*
Copyright (c) 2006 ATXOOM.  Tous Droits Réservés.

1 - PROPRIETE INTELLECTUELLE
Ce Logiciel est la propriété de ATXOOM ou de ses fournisseurs.
Ce Logiciel est protégé par la loi relative au droit d'auteur et
par les conventions internationales. En conséquence, vous devez
considérer ce Logiciel comme n'importe quel autre matériel protégé
par un droit d'auteur (par exemple, un livre ou un enregistrement
sonore). Cependant, l'autorisation vous est accordée d'effectuer
une copie du Logiciel à seule fin de constituer une sauvegarde ou
une archive. Vous n'êtes pas autorisé à reproduire la documentation
fournie avec le Logiciel, sauf pour un usage personnel autorisé.

Toute personne ne respectant pas ces dispositions se rendra
coupable du délit de contrefaçon et sera passible des sanctions
pénales prévues par la loi.

2 - ACCORD DE LICENSE
Le droit d'utilisation qui vous est concédé permet l'installation et
l'utilisation du Logiciel sur un et seul ordinateur.

3 - CESSION
Le droit d'utilisation qui vous est concédé est incessible et non
transférable.


Copyright (c) 2006 ATXOOM.  All Rights Reserved.

1 - COPYRIGHT
The Software is owned by ATXOOM or its suppliers and is protected
by copyright laws and international treaty provisions. Therefore,
you must treat the Software like any other copyrighted material
(e.g., a book or musical recording) except that you may make one
copy of the Software solely for back up or archival purposes.
You may not copy the user documentation provided with the Software, except
for your own authorized use. 

2 - GRANT OF LICENSE
This Software License Agreement ("License") permits you to install
and use one copy solely of the Software on one computer solely.

3 - NOT FOR RESALE SOFTWARE
The software is labeled “Not For Resale” or “NFR”, then, notwithstanding
other sections of this license, your use of the software is limited to
use for demonstration, test, or evaluation purposes and you may
not resell, or otherwise transfer for value, the software.
*/

window.onscroll = atx_MoveMenu;

//=======================================================================
//    Main slice dimension
//=======================================================================

function Redim() {

  var intHeight = Math.max(document.getElementById('slice_07').clientHeight, document.getElementById('slice_08').clientHeight);

  document.getElementById('slice_07').style.height = intHeight + 'px';
  document.getElementById('slice_08').style.height = intHeight + 'px';

  document.getElementById('slice_07_div').style.height = intHeight + 'px';
  document.getElementById('slice_08_div').style.height = intHeight + 'px';
  document.getElementById('slice_09_div').style.height = intHeight + 'px';

  document.getElementById('slice_07_img').style.height = intHeight + 'px';
  document.getElementById('slice_08_img').style.height = intHeight + 'px';
  document.getElementById('slice_09_img').style.height = intHeight + 'px';

  var intTop = parseInt(document.getElementById('slice_07').style.top) + intHeight;

  document.getElementById('slice_10_div').style.top = intTop + 'px';
  document.getElementById('slice_11_div').style.top = intTop + 'px';
  document.getElementById('slice_12_div').style.top = intTop + 'px';

  document.getElementById('slice_11').style.top = intTop + 'px';

  intTop += 130;

  document.getElementById('slice_13_div').style.top = intTop + 'px';
  document.getElementById('slice_13').style.top = intTop + 'px';

}

/* ================================================= */
//
// Positionnement du menu
//
/* ================================================= */

function atx_MoveMenu() {
    try {
    var Itop = (document.all) ? document.documentElement.scrollTop : window.pageYOffset;
    document.getElementById('TBDownLevelDiv').style.top = Math.max(0, Itop) + "px";
    } catch (e) {alert(e.message)}
}

//=======================================================================

function NavAdd(strURL,strName,strOver) {

  var strMyURL=window.location.href;
  
  if (typeof(NavFolder) == 'undefined') {
  	var NavFolder = '00';
  }

  strMyURL=strMyURL.substr(strMyURL.lastIndexOf("/")+1);
  if (strMyURL == strURL) {
    document.write("<p class=\"centersmbo\">" +
                   "<img name=\"img" + "0" + "\" border=\"0\" src=\"../images/bouton_web_on.gif\" alt=\"\" width=\"110\" height=\"68\">" +
                   "<br>" + strName + "<" + "/a><" + "/p>");
  }
  else {
    document.write("<p class=\"centersmbo\">" +
                   "<a href=\"../" + NavFolder + "/" + strURL + "\" target=\"_self\" " +
                   "onmouseover=\"NavOn('img" + intNav + "',ShowHead,'" + strOver + "');\" " +
                   "onmouseout=\"NavOff('img" + intNav + "',ShowBlank);\">" +
                   "<img name=\"img" + intNav + "\" border=\"0\" src=\"../images/bouton_web_off.gif\" alt=\"\" width=\"110\" height=\"68\">" +
                   "<br>" + strName + "<" + "/a><" + "/p>");
    ++intNav;
  }

}

//=======================================================================

function NavOn(ImageName,HeadFlag,ImageLabel)
{
   var LocalPage = ImageName.substr(0,ImageName.length-1)+"0";

   if(ImageLabel != null) overlib(ImageLabel,RIGHT);
   window.status = ImageLabel;
   if(document.images) {
      if(document.images[eval("'" + LocalPage + "'")] != null) {
        document.images[eval("'" + LocalPage + "'")].src = '../images/' + 'bouton_web' + '_off.gif';
      }
      document.images[eval("'" + ImageName + "'")].src = '../images/' + 'bouton_web' + '_on.gif';
      if(HeadFlag) {
        document.images['head'].src = '..images/' + ImageName + '_head.jpg';
      }
   }
   return (true);
}

//=======================================================================

function NavOff(ImageName,HeadFlag)
{
   var LocalPage = ImageName.substr(0,ImageName.length-1)+"0";

   nd();
   window.status = ' ';
   if(document.images) {
      if(document.images[eval("'" + LocalPage + "'")] != null)
        document.images[eval("'" + LocalPage + "'")].src = '../images/' + 'bouton_web' + '_on.gif';
      if(LocalPage != ImageName) {
        document.images[eval("'" + ImageName + "'")].src = '../images/' + 'bouton_web' + '_off.gif';
      }
      if(HeadFlag) {
        document.images['head'].src = '..images/' + LocalPage + '_head.jpg';
      }
   }
   return (true);
}

//=======================================================================
//    Language detection
//=======================================================================

function WhichLanguage(undNull)
{
  var strLanguage = "fr";
  if (navigator.userLanguage != undNull) {
    strLanguage=navigator.userLanguage;
  }
  else {
    if (navigator.systemLanguage != undNull) {
      strLanguage=navigator.systemLanguage;
    }  
    else {
      if (navigator.language != undNull) strLanguage=navigator.language;
    }
  }
  if ((strLanguage != 'fr') && (strLanguage != 'en')) strLanguage = 'fr';
  return (strLanguage);
}

//=======================================================================
//    Webpage speaks
//=======================================================================

var agentLoad;
var agentName;

function page_loaded(speakWhat,log_Debug,str_LanguageID)
{
//=======================================================================
// The variables are initialized here.
// 
// If no agent have been specified with the agentName property in
// the <body style="margin:0;"> tag, then Peedy is specified.
//
// agentLoad can be specified by the page, or it assumes it is working
// with a Microsoft Agent and will specify the appropriate URL to
// load the agent from Microsoft's web site.
//
//=======================================================================

	NavBarLoad();

  var speakText = '';
  var startText = window.document.body.innerText;

  if (log_Debug==null)
    log_Debug = false;
  if (str_LanguageID==null)
    str_LanguageID='fr';
  if (agentName==null)
    agentName = "Peedy";
  if (agentLoad==null)
//2006-01-02    agentLoad = "http://agent.microsoft.com/agent2/chars/peedy/peedy.acf";
    agentLoad = "peedy.acs";

  if (speakWhat==null)
    speakWhat = "page";
  speakWhat = speakWhat.toUpperCase();

  if (speakWhat != "PAGE") {
    var a = window.document.all.item(speakWhat);
    startText = "";
    if (a!=null) {
      if (a.length!=null) {
        for (i=0; i<a.length; i++) {
          startText = startText + (a(i).innerText) + String.fromCharCode(13);
        }
      } 
      else startText = a.innerText + String.fromCharCode(13);
    } 
  }
  if (log_Debug) alert(startText);

//=======================================================================
// Initialize the agent control.
//=======================================================================

  AgentControl.Connected = true;
  AgentControl.Characters.Load(agentName, agentLoad);
 
  if (AgentControl.Characters.Character(agentName).visible==false) {
    Agent = AgentControl.Characters.Character(agentName);
  	Agent.Commands.Add('ACO', 'Options avancées');
    Agent.LanguageID = 0x0409;
    if (str_LanguageID=='fr') {
      Agent.LanguageID = 0x040C;
    }
    else {
      if (str_LanguageID=='it') {
        Agent.LanguageID = 0x0410;
      }
    }

//=======================================================================
// Retrieve agent animations and states and show the agent.
//=======================================================================

    Agent.Get("state", "Showing, Speaking");
    Agent.Get("animation", "Greet, GreetReturn");
    Agent.moveto(80,300);
    Agent.Show();

//    Agent.Play("Announce");

    if (startText != '') {
      if (log_Debug) alert('-->'+startText+'<--');
      Agent.Get("animation", "Read, ReadContinue, ReadReturn");
      Agent.Get("state", "Hiding");

      Agent.Play("Greet");

//=======================================================================
// Wait for Agent to be ready and Check for TTS engine.
//=======================================================================

      TTSengineFound = false;
      window.status = 'Waiting for Agent TTS engine to initialize...';
      for (i=0; i < 250; i++) {
        if (Agent.TTSModeID.length == 0) {
          j = 0;
          while (j < 10000) {
            j = j + 1;
          }
        }
        else {
          TTSengineFound = true;
          break;
        }
      }
      window.status = '';
      if (log_Debug) alert(i+', '+j);
    
      if (!TTSengineFound) {
          MyConfirm = "No Text To Speak engine seems to be installed on your computer. "+
                      "Do you want to install a TTS engine so that Peedy the parrot speaks?";
          MyURL = "http://www.microsoft.com/msagent/downloads.htm#tts";
          if (str_LanguageID=='fr') {
            Agent.LanguageID = 0x040C;
            MyConfirm = "Il semble que votre ordinateur ne dispose pas d\'un moteur linguistique français "+
                        "(Text To Speak engine). Voulez-vous installer un moteur linguistique pour faire parler Peedy le perroquet ?";
            MyURL = "http://www.microsoft.com/msagent/downloads.htm#tts";
          }
          else {
            if (str_LanguageID=='it') {
            Agent.LanguageID = 0x0410;
            MyConfirm = "Ci sembra che non sia installato un Text To Speak engine. Vuoi installare "+
                        "a TTS engine in modo che Peedy possia parlare?";
            MyURL = "http://www.microsoft.com/msagent/downloads.htm#tts";
          }
        }
        MyResponse = window.confirm(MyConfirm);
        if (MyResponse) {
          MyWindow = window.open(MyURL,"TTSengine",
                     "toolbar=0,location=0,directories=0,status=0,menubar=0,scrollbars=1,resizable=1,"+
                     "width=750,height=550,top=25,left=25");
        }
      }

//=======================================================================
// Since the innerText property returns all of the text from the web
// page, it is necessary to look for the carriage returns and speak at
// the paragraph breaks.  Otherwise agent runs the paragraphs together.
//
// Don't ever speak if the line is empty ('').
//=======================================================================

      Agent.Play("Read");
      startText = startText + String.fromCharCode(13,10);

      for (i=0; i<startText.length;  i++) {
        if (startText.charCodeAt(i) != 13) speakText = speakText + startText.charAt(i);
        else {
          if (speakText!='') {
            Agent.Speak(speakText);
            speakText = '';
          }
        }
      }

      if (speakText!='') {
        Agent.Speak(speakText);
      }

      Agent.Play("ReadReturn");
//  Agent.Hide();
    }
    else {
      Agent.Play("Announce");
    }
  }
}

//------------------------------------------------------------------------
// (C) Netscape Communications 1999.  Permission granted to reuse and distribute. 
function Is () 
{
    var agt=navigator.userAgent.toLowerCase(); 
    this.major = parseInt(navigator.appVersion); 
    this.minor = parseFloat(navigator.appVersion); 
    this.nav  = ((agt.indexOf('mozilla')!=-1) && (agt.indexOf('spoofer')==-1) 
                && (agt.indexOf('compatible') == -1) && (agt.indexOf('opera')==-1) 
                && (agt.indexOf('webtv')==-1)); 
    this.nav2 = (this.nav && (this.major == 2)); 
    this.nav3 = (this.nav && (this.major == 3)); 
    this.nav4 = (this.nav && (this.major == 4)); 
    this.nav4up = (this.nav && (this.major >= 4)); 
    this.navonly      = (this.nav && ((agt.indexOf(";nav") != -1) || 
                          (agt.indexOf("; nav") != -1)) ); 
    this.nav5 = (this.nav && (this.major == 5)); 
    this.nav5up = (this.nav && (this.major >= 5)); 
    this.ie   = (agt.indexOf("msie") != -1); 
    this.ie3  = (this.ie && (this.major < 4)); 
    this.ie4  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")==-1) ); 
    this.ie4up  = (this.ie  && (this.major >= 4)); 
    this.ie5  = (this.ie && (this.major == 4) && (agt.indexOf("msie 5.0")!=-1) ); 
    this.ie5up  = (this.ie  && !this.ie3 && !this.ie4); 
    this.aol   = (agt.indexOf("aol") != -1); 
    this.aol3  = (this.aol && this.ie3); 
    this.aol4  = (this.aol && this.ie4); 
    this.opera = (agt.indexOf("opera") != -1); 
    this.webtv = (agt.indexOf("webtv") != -1); 
    if (this.nav2 || this.ie3) this.js = 1.0 
    else if (this.nav3 || this.opera) this.js = 1.1 
    else if ((this.nav4 && (this.minor <= 4.05)) || this.ie4) this.js = 1.2 
    else if ((this.nav4 && (this.minor > 4.05)) || this.ie5) this.js = 1.3 
    else if (this.nav5) this.js = 1.4 
    else if (this.nav && (this.major > 5)) this.js = 1.4 
    else if (this.ie && (this.major > 5)) this.js = 1.3 
    else this.js = 0.0; 
    this.win   = ( (agt.indexOf("win")!=-1) || (agt.indexOf("16bit")!=-1) ); 
    this.win95 = ((agt.indexOf("win95")!=-1) || (agt.indexOf("windows 95")!=-1)); 
    this.win16 = ((agt.indexOf("win16")!=-1) || 
                  (agt.indexOf("16bit")!=-1) || (agt.indexOf("windows 3.1")!=-1) || 
                  (agt.indexOf("windows 16-bit")!=-1) ); 
    this.win31 = ((agt.indexOf("windows 3.1")!=-1) || (agt.indexOf("win16")!=-1) || 
                  (agt.indexOf("windows 16-bit")!=-1)); 
    this.win98 = ((agt.indexOf("win98")!=-1) || (agt.indexOf("windows 98")!=-1)); 
    this.winnt = ((agt.indexOf("winnt")!=-1) || (agt.indexOf("windows nt")!=-1)); 
    this.win32 = ( this.win95 || this.winnt || this.win98 || 
                   ((this.major >= 4) && (navigator.platform == "Win32")) || 
                   (agt.indexOf("win32")!=-1) || (agt.indexOf("32bit")!=-1) ); 
    this.os2   = ((agt.indexOf("os/2")!=-1) || 
                  (navigator.appVersion.indexOf("OS/2")!=-1) || 
                  (agt.indexOf("ibm-webexplorer")!=-1)); 
    this.mac    = (agt.indexOf("mac")!=-1); 
    this.mac68k = (this.mac && ((agt.indexOf("68k")!=-1) || 
                               (agt.indexOf("68000")!=-1))); 
    this.macppc = (this.mac && ((agt.indexOf("ppc")!=-1) || 
                               (agt.indexOf("powerpc")!=-1))); 
    this.sun   = (agt.indexOf("sunos")!=-1); 
    this.sun4  = (agt.indexOf("sunos 4")!=-1); 
    this.sun5  = (agt.indexOf("sunos 5")!=-1); 
    this.suni86= (this.sun && (agt.indexOf("i86")!=-1)); 
    this.irix  = (agt.indexOf("irix") !=-1);    // SGI 
    this.irix5 = (agt.indexOf("irix 5") !=-1); 
    this.irix6 = ((agt.indexOf("irix 6") !=-1) || (agt.indexOf("irix6") !=-1)); 
    this.hpux  = (agt.indexOf("hp-ux")!=-1); 
    this.hpux9 = (this.hpux && (agt.indexOf("09.")!=-1)); 
    this.hpux10= (this.hpux && (agt.indexOf("10.")!=-1)); 
    this.aix   = (agt.indexOf("aix") !=-1);      // IBM 
    this.aix1  = (agt.indexOf("aix 1") !=-1); 
    this.aix2  = (agt.indexOf("aix 2") !=-1); 
    this.aix3  = (agt.indexOf("aix 3") !=-1); 
    this.aix4  = (agt.indexOf("aix 4") !=-1); 
    this.linux = (agt.indexOf("inux")!=-1); 
    this.sco   = (agt.indexOf("sco")!=-1) || (agt.indexOf("unix_sv")!=-1); 
    this.unixware = (agt.indexOf("unix_system_v")!=-1); 
    this.mpras    = (agt.indexOf("ncr")!=-1); 
    this.reliant  = (agt.indexOf("reliantunix")!=-1); 
    this.dec   = ((agt.indexOf("dec")!=-1) || (agt.indexOf("osf1")!=-1) || 
         (agt.indexOf("dec_alpha")!=-1) || (agt.indexOf("alphaserver")!=-1) || 
         (agt.indexOf("ultrix")!=-1) || (agt.indexOf("alphastation")!=-1)); 
    this.sinix = (agt.indexOf("sinix")!=-1); 
    this.freebsd = (agt.indexOf("freebsd")!=-1); 
    this.bsd = (agt.indexOf("bsd")!=-1); 
    this.unix  = ((agt.indexOf("x11")!=-1) || this.sun || this.irix || this.hpux || 
                 this.sco ||this.unixware || this.mpras || this.reliant || 
                 this.dec || this.sinix || this.aix || this.linux || this.bsd || 
                 this.freebsd); 
    this.vms   = ((agt.indexOf("vax")!=-1) || (agt.indexOf("openvms")!=-1)); 
}

var is; 
var isIE3Mac = false; 
if ((navigator.appVersion.indexOf("Mac")!=-1) && (navigator.userAgent.indexOf("MSIE")!=-1) &&
(parseInt(navigator.appVersion)==3)) 
       isIE3Mac = true; 
else   is = new Is();  

