function Afficher(elemId) {
	var elem = document.getElementById(elemId);
	if (elem) {
		elem.style.display = "block";
	}
}

function Masquer(elemId) {
	var elem = document.getElementById(elemId);
	if (elem) {
		elem.style.display = "none";
	}
}

function Switcher(elemId) {
	var elem = document.getElementById(elemId);
	if (elem) {
		if (elem.style.display != "none") {
			elem.style.display = "none";
		}
		else {
			elem.style.display = "block";
		}
	}
}

function SwitchDisplayByButton(elemId, buttonId, textOn, textOff) {
	var elem = document.getElementById(elemId);
	var bouton = document.getElementById(buttonId);
	if (elem && buttonId) {
		if (elem.style.display == "none") {
			elem.style.display = "block";
			bouton.innerHTML = textOn;
		}
		else {
			elem.style.display = "none";
			bouton.innerHTML = textOff;
		}
	}
}

function OuvrirFenetre(url) {
    window.open(url);
    return false;
}

function DoSubmit(inputSubmit) {
    inputSubmit.disabled=true;
    inputSubmit.value= 'Patientez Svp';
    inputSubmit.form.submit();
}

function DoSubmitTxt(inputSubmit,texte) {
    inputSubmit.disabled=true;
    inputSubmit.value= texte;
    inputSubmit.form.submit();
}

function Rediriger(url) {
    window.location.replace(url);
}

function EnvoyerMail() {
	var strMailTo =  'mailto:' + 'info' + '@' + 'digitick' + '.' + 'com';
    	location.href = strMailTo;
}    
    
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){
	var h = 300;
	var w = 500;
	var topPosition = (screen.height - h) / 2;
	var leftPosition = (screen.width - w) / 2;
	
    window.open(GetServerName()+"/web/ext/billetterie2/index.php4?p=34&site="+site, "CGV", "width="+w+", height="+h+", top="+topPosition+", left="+leftPosition+", toolbar=no, menubar=no, scrollbars=no, resizable=no, location=no, directories=no, status=no");
}

function DescendreFenetreRep() {

    for (i = 0; i < nbIterations; i++) {
        if (idDernierRepAffiche < totalNbLignes - 1) { 
        	// Masquage du premier
            document.getElementById('rep'+idPremierRepAffiche).className = "invisible";
            idPremierRepAffiche++;

            // Affichage du suivant
            idDernierRepAffiche++;
            document.getElementById('rep'+idDernierRepAffiche).className = "visible" + (i%2 == 0 ? " ligneUn" : " ligneDeux") ;
        }
    
        if (idDernierRepAffiche == totalNbLignes - 1) {
            document.getElementById('accueilevtssuivants').className = "invisible";
        }
        
        if (idPremierRepAffiche > 0) {
            document.getElementById('accueilevtsprecedents').className = "visible";
        }
    }
}

function MonterFenetreRep() {

    for (i = 0; i < nbIterations; i++) {

        if (idPremierRepAffiche > 0) {        
            // Masquage du dernier
            document.getElementById('rep'+idDernierRepAffiche).className = "invisible";
            idDernierRepAffiche--;
    
            // Affichage du précédent
            idPremierRepAffiche--;
            document.getElementById('rep'+idPremierRepAffiche).className = "visible" + (i%2 == 0 ? " ligneDeux" : " ligneUn") ;

            if (idPremierRepAffiche == 0) {
                document.getElementById('accueilevtsprecedents').className = "invisible";
            }
            
            if (idDernierRepAffiche < totalNbLignes - 1) {
                document.getElementById('accueilevtssuivants').className = "visible";
            }
        }
    }
}

// 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) {

    contenuDiv = '<p class="txtCenter">'+ listeRep[jour][0]['jourcourt'];

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

    contenuDiv = contenuDiv
                + '</p>';

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

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