/*Instanciation pour l'ajax
*/
var xhr = null;
//fonction de création d'objet XMLHttRequest
function get_Xhr() {
    if (window.XMLHttpRequest)
    { xhr = new XMLHttpRequest(); }
    else if (window.ActiveXOject) {
        try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); }
        catch (e) {
            try { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
            catch (el) { xhr = null; }
        }
    }
    else { alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest\nVeuillez le mettre à jour"); }
    return xhr;
}
/*Titre : Appel aux pages d'affichage
*/
function Appel(Ind) {

    //mneHaut(Ind);
    Contenue(Ind, 0);
    //mneGauche(Ind) ;
}
/*Titre : Appel aux pages d'affichage Version 2 */
function Appel2(Ind, Page, Diapo, div) {

    //mneHaut(Ind);
    Contenue2(Ind, Page, Diapo, div);
    //mneGauche(Ind) ;
}
/*Titre : Affichage du Menu Haut
*/
function mneHaut(Ind) {
    if (Ind == 2) {
        new Ajax.Updater("mneHaut", "contenue/mneHaut1.htm", { method: 'get' });
    }
    else {
        new Ajax.Updater("mneHaut", "contenue/mneHaut.htm", { method: 'get' });
    }

}
/*Titre : Affichage du Contenu
*/
function Contenue(Haut, Gauche) {
    new Ajax.Updater("contenue", "contenue/contenu_" + Haut + "_" + Gauche + ".htm", { method: 'get' });
    var pageTracker = _gat._getTracker("UA-120822-3");
    pageTracker._initData();
    pageTracker._trackPageview("/Catalogue_" + Haut + "_" + Gauche + ".htm");
    mneGauche(Haut);
}
/*Titre : Affichage du Contenu version 2
*/
function Contenue2(Haut, Gauche, Diapo, div) {
    mneGauche(Haut);
    if (Diapo != 0) {
        ContenueDiap(Diapo, Gauche, div);
    }
    else {
        new Ajax.Updater("contenue", "contenue/contenu_" + Haut + "_" + Gauche + ".htm", { method: 'get' });
        var pageTracker = _gat._getTracker("UA-120822-3");
        pageTracker._initData();
        pageTracker._trackPageview("/Catalogue_" + Haut + "_" + Gauche + ".htm");
    }
}
/*Titre : Affichage du Menu gauche*/
function mneGauche(Haut) {
    new Ajax.Updater("mneGauche", "contenue/mneGauche_" + Haut + ".htm", { method: 'get' });
}
/* Fontion pour le Diaporama */
var Fichier = new Array;
var Texte = new Array;
var FichierA = new Array;
var Comm = new Array;
var indexPhoto = 0;
var photoMini = 1;
var photoMaxi = 1;
var photo = photoMini - 1;
var photoDuree = 5000;
var diapoTemps;
var photoHeight = '400px';
var photoWidth = '600px';
function ContenueDiap(Ind, Conten, Titre) {
    if (Ind == 2) {
        strFichier = "contenue/diaporama_html_vignet.cont";
        photoHeight = '225px';
        photoWidth = '300px';
        new Ajax.Updater(Titre, strFichier, { method: 'get' });
        LectContenueDiap(Conten);
    }
    if (Ind == 1) {
        strFichier = "contenue/diaporama_html.cont";
        photoHeight = '400px';
        photoWidth = '600px';
        new Ajax.Updater(Titre, strFichier, { method: 'get' });
        LectContenueDiap(Conten);
    }
    GoogleAnalytics("/" + Ind + "/" + Conten + "/ajaxDiap.htm");
}
function LectContenueDiap(Conten) {
    GoogleAnalytics("/2/" + Conten + "/ajaxDiap.htm");
    var indexPhoto = 1;
    var photoMini = 1;
    var photoMaxi = 1;
    var photo = photoMini - 1;
    window.clearTimeout(diapoTemps);
    switch (Conten) {
        default:
            strFichierD = "diaporama/tableexemple.cont";
            break;
    }
    new Ajax.Request(strFichierD, { method: 'get',
        onSuccess: function(transport, json) { EvalContenue(transport.responseText); },
        onFailure: function() {
            alert("Une erreur est survenue lors de l'appel AJAX.\nRecharger la page devrait résoudre le problème. -- " + strFichierD)
        }
    });
}
function EvalContenue(strCont) {
    //alert ('Js');
    eval(strCont);
}
function Diaporama() {
    window.clearTimeout(diapoTemps);
    //alert('TEST');
    photo = photo + 1;
    if (photo > photoMaxi) {
        photo = photoMini;
    }
    var PAGE = photo / photoMaxi;
    document.getElementById('divPage').innerHTML = photo + "/" + photoMaxi;
    document.getElementById('divCOMMENT').innerHTML = Comm[photo];
    if (FichierA[photo] == "") {
        document.getElementById('divIMAGE').innerHTML = "<img src='" + Fichier[photo] + "' height='" + photoHeight + "' Border='0' >";
    }
    else {
        document.getElementById('divIMAGE').innerHTML = "<a href='" + FichierA[photo] + "' Target='Photo'><img src='" + Fichier[photo] + "' height='" + photoHeight + "' Border='0' ></a>";
    }
    //alert('Test Av');     
    //document.getElementById('divImageTexte').innerHTML = Texte[photo];
    diapoTemps = window.setTimeout("Diaporama()", photoDuree);
    // alert('Test Fin');
}
function DiaporamaP() {
    photo = photo - 1;
    if (photo < photoMini) {
        photo = photoMaxi;
    }
    var PAGE = photo / photoMaxi;
    document.getElementById('divPage').innerHTML = photo + "/" + photoMaxi;
    document.getElementById('divCOMMENT').innerHTML = Comm[photo];
    if (FichierA[photo] == "") {
        document.getElementById('divIMAGE').innerHTML = "<img src='" + Fichier[photo] + "' height='" + photoHeight + "' Border='0' >";
    }
    else {
        document.getElementById('divIMAGE').innerHTML = "<a href='" + FichierA[photo] + "' Target='Photo'><img src='" + Fichier[photo] + "' height='" + photoHeight + "' Border='0' ></a>";
    }
    document.getElementById('divImageTexte').innerHTML = Texte[photo];
}
function DiaporamaS() {
    photo = photo + 1;
    if (photo > photoMaxi) {
        photo = photoMini;
    }
    var PAGE = photo / photoMaxi;
    document.getElementById('divPage').innerHTML = photo + "/" + photoMaxi;
    document.getElementById('divCOMMENT').innerHTML = Comm[photo];
    if (FichierA[photo] == "") {
        document.getElementById('divIMAGE').innerHTML = "<img src='" + Fichier[photo] + "' height='" + photoHeight + "' Border='0' >";
    }
    else {
        document.getElementById('divIMAGE').innerHTML = "<a href='" + FichierA[photo] + "' Target='Photo'><img src='" + Fichier[photo] + "' height='" + photoHeight + "' Border='0' ></a>";
    }
    document.getElementById('divImageTexte').innerHTML = Texte[photo];
}
function DiaporamaA() {
    window.clearTimeout(diapoTemps);
}
/* Fin de la Fonction diaporama */
/* Titre: Google analytics */
function GoogleAnalytics(NomFichier) {
    try {
        var pageTracker = _gat._getTracker("UA-120822-3");
        pageTracker._initData();
        pageTracker._trackPageview(NomFichier);
    } catch (e) {
        throw e;
    }
}
