
    // FONCTIONS GENERALES
    
    function OuvrirFenetre(url) {
        window.open(url);
        return false;
    }
    
    function DoSubmit(inputSubmit) {
        inputSubmit.disabled=true;
        inputSubmit.value= 'Patientez Svp'; 
        inputSubmit.form.submit();
    }
    
    function Rediriger(url) {
        window.location.replace(url);
    }

    function EnvoyerMail() {
	var strMailTo =  'mailto:' + 'info' + '@' + 'digitick' + '.' + 'com';
    	location.href = strMailTo;
    }    
    
// ********************************************************************* //
    
    // FONCTIONS POUR L'ACCUEIL
    
    var numPageEvtAffichee = 0;
    var numPageOrgSalAffichee = 0;
    var numPageOrgAffichee = 0;
    var numPageSalAffichee = 0;
    var numPageFestAffichee = 0;

    // On affiche que les lignes qui sont dans la page demandée
    function AfficherPage(numeroPage, nbPages, nbItemsParPage,nbTotalItems, nomListe ) {	
        var indiceDebut = numeroPage * nbItemsParPage;
        var indiceFin = (numeroPage + 1) * nbItemsParPage;

        
        for (i = indiceDebut; i < indiceFin; i++) {
            if (i % 2 == 1) {
                document.getElementById('tr'+nomListe+i).className = "bg_silver visible";
            }
            else {
                document.getElementById('tr'+nomListe+i).className = "visible";
            }
        }
    }
    
    // On masque les lignes de la page demandée 
    function MasquerPage(numeroPage, nbItemsParPage, nomListe ) {	
        var indiceDebut = numeroPage * nbItemsParPage;
        var indiceFin = (numeroPage + 1) * nbItemsParPage;

        for (i = indiceDebut; i < indiceFin; i++) {
            document.getElementById('tr'+nomListe+i).className = "invisible";
        }
    }
    
    // On affiche tous les numéros de page et on souligne la page en cours
    function majNumerotationToutesPages (numeroPage, nbPages, nomListe) {
        for (i = 0; i < nbPages; i++) {
            document.getElementById('idpage'+nomListe+i).className = "poussetInactif cursor_pointer";
        }
        
        document.getElementById('idpage'+nomListe+numeroPage).className= "poussetActif cursor_pointer";
    }

    // On affiche les numéros de pages de 5 en 5 + les 10 intermédiaires à la page actuelle
    function majNumerotationPagesSimplifiee (numeroPage, nbPages, nomListe) {
        nbPagesIntermediaire = 3;
        
        for (i = 0; i < nbPages; i++) {
            if (i == 0 || i == (nbPages - 1) || (i % 10 == 9) || ((numeroPage - nbPagesIntermediaire) < i &&  (numeroPage + nbPagesIntermediaire) > i)) {
                document.getElementById('idpage'+nomListe+i).className = "poussetInactif cursor_pointer";
            }
            else {
                document.getElementById('idpage'+nomListe+i).className = "invisible";
            }
        }
        document.getElementById('idpage'+nomListe+numeroPage).className= "poussetActif cursor_pointer";
    }

    function AfficherPageEvt(numeroPage, nbPages, nbItemsParPage, nbTotalItems) {
        if (numeroPage < nbPages && numeroPage >= 0) {
            MasquerPage (numPageEvtAffichee, nbItemsParPage, 'evt');
            AfficherPage(numeroPage, nbPages, nbItemsParPage, nbTotalItems, 'evt');
            majNumerotationToutesPages (numeroPage, nbPages, 'evt');
            numPageEvtAffichee = numeroPage;
        }
    }

    function AfficherPageEvtAccueil(numeroPage, nbPages, nbItemsParPage, nbTotalItems) {
        if (numeroPage < nbPages && numeroPage >= 0) {
            MasquerPage (numPageEvtAffichee, nbItemsParPage, 'evt');
            AfficherPage(numeroPage, nbPages, nbItemsParPage, nbTotalItems, 'evt');
            majNumerotationPagesSimplifiee (numeroPage, nbPages, 'evt');
            numPageEvtAffichee = numeroPage;
        }
    }


    function AfficherPageOrgSal(numeroPage, nbPages, nbItemsParPage, nbTotalItems) {
        if (numeroPage < nbPages && numeroPage >= 0) {
            MasquerPage (numPageOrgSalAffichee, nbItemsParPage, 'orgsal');
            AfficherPage(numeroPage, nbPages, nbItemsParPage, nbTotalItems, 'orgsal');
            majNumerotationToutesPages (numeroPage, nbPages, 'orgsal');
            numPageOrgSalAffichee = numeroPage;
        }
    }

    function AfficherPageSal(numeroPage, nbPages, nbItemsParPage, nbTotalItems) {
        if (numeroPage < nbPages && numeroPage >= 0) {
            MasquerPage (numPageSalAffichee, nbItemsParPage, 'sal');
            AfficherPage(numeroPage, nbPages, nbItemsParPage, nbTotalItems, 'sal');
            majNumerotationToutesPages (numeroPage, nbPages, 'sal');
            numPageSalAffichee = numeroPage;
        }
    }

    function AfficherPageOrg(numeroPage, nbPages, nbItemsParPage, nbTotalItems) {
        if (numeroPage < nbPages && numeroPage >= 0) {
            MasquerPage (numPageOrgAffichee, nbItemsParPage, 'org');
            AfficherPage(numeroPage, nbPages, nbItemsParPage, nbTotalItems, 'org');
            majNumerotationToutesPages (numeroPage, nbPages, 'org');
            numPageOrgAffichee = numeroPage;
        }
    }
    
    function AfficherPageFest(numeroPage, nbPages, nbItemsParPage, nbTotalItems) {
        if (numeroPage < nbPages && numeroPage >= 0) {
            MasquerPage (numPageFestAffichee, nbItemsParPage, 'fest');
            AfficherPage(numeroPage, nbPages, nbItemsParPage, nbTotalItems, 'fest');
            majNumerotationToutesPages (numeroPage, nbPages, 'fest');
            numPageFestAffichee = numeroPage;
        }
    }
    
    function AfficherMoisCalendrierAccueil(mois) {	
        document.getElementById('tabcal' + mois).className = "calendarAccueil visible";
    }
    
    function MasquerMoisCalendrierAccueil(mois) {	
        document.getElementById('tabcal' + mois).className = "invisible";
    }
    
    function AfficherMoisCalendrierAccueil2(mois) {	
        document.getElementById('tabcal' + mois).className = "calendar visible";
    }
    
    function MasquerMoisCalendrierAccueil2(mois) {	
        document.getElementById('tabcal' + mois).className = "calendar invisible";
    }



    
// ********************************************************************* //
    
    // FONCTIONS POUR LA RECHERCHE PAR DATE

    var numPageRepAffichee = 0;

    function AfficherPageRep(numeroPage, nbPages, nbItemsParPage, nbTotalItems) {
        if (numeroPage < nbPages && numeroPage >= 0) {
            MasquerPage (numPageRepAffichee, nbItemsParPage, 'rep');
            AfficherPage(numeroPage, nbPages, nbItemsParPage, nbTotalItems, 'rep');
            majNumerotationToutesPages (numeroPage, nbPages, 'rep');
            numPageRepAffichee = numeroPage;
        }
    }



// ********************************************************************* //

    // FONCTION POUR LA FAQ

    function AfficherReponseFaq(id) {	
        document.getElementById('faq' + id).className = "visible";
    }
    
    function MasquerReponseFaq(id) {	
        document.getElementById('faq' + id).className = "invisible";
    }
    
    function ChangerEtatReponseFaq(id) {
        if (document.getElementById('faq' + id).className == 'visible') {
            MasquerReponseFaq(id);
        }
        else {
            AfficherReponseFaq(id);
        }
    }

// ********************************************************************* //

    // FONCTION POUR LA LISTE DES REPRESENTATIONS

    function AfficherMoisCalendrier(mois) {	
        document.getElementById('tabcal' + mois).className = "calendar visible";
    }
    
    function MasquerMoisCalendrier(mois) {	
        document.getElementById('tabcal' + mois).className = "invisible";
    }
    
    var jourAffiche = '';
    
    function AfficherHoraires (jourStr) {
        document.getElementById('divrep'+jourStr).className = "visible";
        jourAffiche = jourStr;
    }

    function MasquerHorairesJourAffiche() {
        if (jourAffiche.length > 0) {
            document.getElementById('divrep'+jourAffiche).className = "invisible";
            jourAffiche = '';
        }
    }    
    
    function AfficherImageChoixDate() {
        document.getElementById('divimgchoixdate').className='visible';
    }
    
    function MasquerImageChoixDate() {
        document.getElementById('divimgchoixdate').className='invisible';
    }
    
    function AfficherImageChoixSeance() {
        document.getElementById('divimgchoixseance').className='visible';
    }

    function MasquerImageChoixSeance() {
        document.getElementById('divimgchoixseance').className='invisible';
    }

    function RemplirDivChoixDate(jour, afficherTxtPlace) {

        contenuDiv = '<p class="center">'+ listeRep[jour][0]['jourcourt'];
        
        for (var i = 0; i < listeRep[jour].length; i++) {
            contenuDiv = contenuDiv + '<br /><br /><a href="index.php4?p=207&amp;idRep=' + listeRep[jour][i]['idrep']
                      + '" class="lien black"><span>' 
                      + listeRep[jour][i]['heure'];

            if (afficherTxtPlace) {
                contenuDiv = contenuDiv + '<br />' + listeRep[jour][i]['txtPlace']; 
            }

            contenuDiv = contenuDiv + '</span></a>';                      
                      
        }
        
        contenuDiv = contenuDiv 
                    + '</p><p><img src="http://www.digitick.com/images/choisissez_seance.gif" alt="Choisissez votre séance" title="Choisissez votre séance" /></p>';

        document.getElementById('divchoixrep').innerHTML = contenuDiv;
    }
    
    function ViderDivChoixDate() {
        document.getElementById('divchoixrep').innerHTML = '';
    }

// ********************************************************************* //

    // FONCTIONS POUR LES ETAPES D'ACHAT

    function AfficherBlock(blockname) {
        document.getElementById('block'+blockname).className = "visible_block";
        document.getElementById('ancrereduire'+blockname).className = "cursor_pointer visible_block";
        document.getElementById('ancredevelopper'+blockname).className = "invisible";
    }
    
    function MasquerBlock(blockname) {
        document.getElementById('block'+blockname).className = "invisible";
        document.getElementById('ancrereduire'+blockname).className = "invisible";
        document.getElementById('ancredevelopper'+blockname).className = "cursor_pointer visible_block";
    }


// ********************************************************************* //

    // FONCTIONS POUR LE CADRE GAUCHE
    
    var numPageNewsAffichee = 0;
    
    function AfficherPageNews(numeroPage, nbPages, nbItemsParPage, nbTotalItems) {
        if (numeroPage < nbPages && numeroPage >= 0) {
            
            // Masquage de la page précédente
            var indiceDebutPageAMasquer = numPageNewsAffichee * nbItemsParPage;
            var indiceFinPageAMasquer = (numPageNewsAffichee + 1) * nbItemsParPage;
            for (i = indiceDebutPageAMasquer; i < indiceFinPageAMasquer; i++) {
                document.getElementById('news'+i).className = "invisible";
            }

            // Affichage de la nouvelle page
            var indiceDebutPageAAfficher = numeroPage * nbItemsParPage;
            var indiceFinPageAAfficher = (numeroPage + 1) * nbItemsParPage;
            for (i = indiceDebutPageAAfficher; i < indiceFinPageAAfficher; i++) {
                document.getElementById('news'+i).className = "visible_block";
            }

            numPageNewsAffichee = numeroPage;
            
            if (numeroPage == 0) {
                document.getElementById('newspageprec').className = "cursor_pointer invisible";
            }
            else {
                document.getElementById('newspageprec').className = "cursor_pointer visible";
            }
            
            if (numeroPage == 3) {
                document.getElementById('newspagesuiv').className = "cursor_pointer invisible";
            }
            else {
                document.getElementById('newspagesuiv').className = "cursor_pointer visible";
            }
            
        }
    }

    function GetDateStringByTimestamp(timestamp) {
        var resultat = '';
        
        if (timestamp > 3600 * 24 * 2) {
            resultat = resultat + Math.floor(timestamp / (3600 * 24)) + ' jours ';
            timestamp = timestamp % 3600;
        }
        else if (timestamp > 3600 * 24) {
            resultat = resultat + Math.floor(timestamp / (3600 * 24)) + ' jour ';
            timestamp = timestamp % 3600;
        }
        
        var nbHeures = Math.floor(timestamp / 3600);
        var nbMinutes = Math.floor((timestamp % 3600) / 60);
        var nbSecondes = Math.floor(timestamp % 60);
        
        if (nbHeures < 10) {
            nbHeures = '0' + nbHeures;
        }

        if (nbMinutes < 10) {
            nbMinutes = '0' + nbMinutes;
        }

        if (nbSecondes < 10) {
            nbSecondes = '0' + nbSecondes;
        }

        return resultat + nbHeures + ' h ' + nbMinutes + ' m ' + nbSecondes + ' s ';
        
    }

    
    function UpdateCompteARebours(idSpan, intervalleSec, tsTpsRestant) {
        if (tsTpsRestant > 0) {
            document.getElementById(idSpan).innerHTML = 'Fin des ventes dans <br>' + GetDateStringByTimestamp(tsTpsRestant);
            window.setTimeout("UpdateCompteARebours('"+idSpan+"',"+intervalleSec+","+ (tsTpsRestant - intervalleSec)+")" , intervalleSec * 1000);
        }
        else {
            document.getElementById(idSpan).innerHTML = "Ventes terminées";
        }    
    }
    
    function GetServerName() {
		var reg = new RegExp("^ssl","");
		var serverName = window.location.host;
		var http = "http";
		// Si on est en SSL (HTTPS)
		if(reg.test(serverName)) {
			http += "s";
		}
		return http+"://"+serverName;
	}
		
	function OuvrirPopupCGV(site,version){
		var h = 300;
		var w = 455;
		var topPosition = (screen.height - h) / 2;
		var leftPosition = (screen.width - w) / 2;
		
		window.open(GetServerName()+"/web/index.php4?p=235", "CGV", "width="+w+", height="+h+", top="+topPosition+", left="+leftPosition+", toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
	}

// ********************************************************************* //

    /* Fonction ajax pour le post newsletter canal de vente */
    function envoiAjaxNewsletterCanalDeVente(nomSite, canalId, inscription, page, nomBoutonValider){

        var heightButton = document.getElementById(nomBoutonValider).height;
        $('#' + nomBoutonValider).attr('height', 0);
        $('#txtinscriptionnewsletter').text("Patientez svp");
        
        var m = $("#mailnewslettercanaldevente");
        var lienDesinscription = "<a class='white bold' href='javascript:void(0);' onclick='envoiAjaxNewsletterCanalDeVente(\"" + nomSite + "\"," + canalId + ",0 ," + page + ",\"" + nomBoutonValider + "\");'>Me désinscrire</a>";
        $.post("index.php4", { p: page, mail: m.val(), site: nomSite, canalDeVenteId: canalId, inscription: inscription },
        function(data){
            var texte;
            switch (data) {
                case "0" : 
                    texte = "Merci de vous être inscrit à notre newsletter !";
                    break;
                case "1" :
                    texte = "E-mail incorrect";
                    break;
                case "2" : 
                    texte = "Vous êtes déjà inscrit ! Vous souhaitez vous désinscrire ? <br />" + lienDesinscription;
                    break; 
                case "3" : 
                    texte = "Vous êtes déjà inscrit ! Vous souhaitez vous désinscrire ? ";
                    break; 
                case "4" : 
                    texte = "Vous n'êtes pas inscrit !";
                    break;
                case "5" : 
                    texte = "Vous êtes déja désinscrit !";
                    break;
                case "6" : 
                    texte = "Vous êtes désormais désinscrit de notre newsletter";
                    break;
            }
            $('#txtinscriptionnewsletter').html(texte);
            $('#' + nomBoutonValider).attr('height', heightButton);

        });

        return false;
        
    }


