// Montre et cache de layer <div>

/*function ShowOld(Id,OldID){
	var current = document.getElementById(Id);
	var oldOne = document.getElementById(OldID);
	
	if(oldOne != "begin"){
		oldOne.style.display="none";
	}
	current.style.display="block";
}*/

function Show(Id,OldID){
	var current = document.getElementById(Id);
	var oldOne = document.getElementById(OldID);
	
	if(oldOne != "begin"){
		oldOne.style.display="none";
	    number2 = OldID.substring(1,3);
        sousTitre2 = 'th'+number2;
	    inactive = document.getElementById(sousTitre2);
	    inactive.className = 'linkTheme';

	}
	current.style.display="block";
	number = Id.substring(1,3);
    sousTitre = 'th'+number;
	active = document.getElementById(sousTitre);
	active.className = 'linkThemeActive';
}

/*function Show(Id){
	var current = document.getElementById(Id)
	
	if (current.style.display=="none") {
		current.style.display="block"; //show element
	}
	else {
		current.style.display="none"; //hide element
	}
}*/

function showText(monTexte){
		document.write(monTexte);
}

function Show2(Id){
	var current = document.getElementById(Id);
	if (current.style.display=="none") {
		current.style.display="block"; //show element
	}
	else {
		current.style.display="none"; //hide element
	}
}

function ShowFilm(film){
	var film = document.getElementById(film);
	if (film.style.display=="none") {
		film.style.display="block"; //show element
	}
	else {
		film.style.display="none"; //hide element
	}
}

function ShowHide(Id,otherId){
	var current = document.getElementById(Id)
	
	if (current.style.display=="none") {
		current.style.display="block"; //show element
	}
	else {
		current.style.display="none"; //hide element
	}
	
	var other = document.getElementById(otherId)
	
	if (other.style.display=="none") {
		other.style.display="block"; //show element
	}
	else {
		other.style.display="none"; //hide element
	}
}
/* Function rechercheId() permet de retrouver la bonne rubrique dans une page grâce à l'id du div (pour sitemap)*/
function rechercheId() {
			if (window.location.search!='') {
				var id = window.location.search;
				id = id.substring(4,7);
		   		return(id);
			}
			else{
			 	return('T1');
			}
		}
		
function next() {
	var current = lastOpened;
	var number = current.substring(1, 3);
	chiffre = parseInt(number);
	if (chiffre!= numThemes()) {
		chiffre++;
		theme = 'T'+chiffre;
		Show(theme,lastOpened);
		lastOpened = theme;
	}
	else {
		Show('T1', lastOpened);
		lastOpened = 'T1';
	}
}
function previous() {
	var current = lastOpened;
	var number = current.substring(1, 3);
	chiffre = parseInt(number);
	if (chiffre!= 1) {
		chiffre--;
		theme = 'T'+chiffre;
		Show(theme,lastOpened);
		lastOpened = theme;
	}
	else {
		var last = 'T'+numThemes();
		Show(last, lastOpened);
		lastOpened = last;
	}
}
/* retourne le nombre de theme sur une page */

function numThemes() {
	var liste = document.getElementsByTagName('div');
	var listLength = 0;
	for (i=0; i<liste.length; i++) {
		if (liste[i].id.substring(0, 1)=='T') {
			listLength++
		}
	}
	return(listLength);
}

function menuActive() {
	adresse = window.location.pathname;
	morceaux = adresse.split('/');
	nbreMots = morceaux.length;
	repertoire = morceaux[nbreMots-2].toString();
		switch(repertoire) {

				case 'about': 
					active = document.getElementById('M1');
					active.className = 'linkMenuActive';
					break;
				case 'group': 
					active = document.getElementById('M2');
					active.className = 'linkMenuActive';
					break;
				case 'services': 
					active = document.getElementById('M3');
					active.className = 'linkMenuActive';
					break;
				case 'media': 
					active = document.getElementById('M4');
					active.className = 'linkMenuActive';
					break;
				case 'events': 
					active = document.getElementById('M5');
					active.className = 'linkMenuActive';
					break;
				case 'jobs': 
					active = document.getElementById('M6');
					active.className = 'linkMenuActive';
					break;
				case 'links': 
					active = document.getElementById('M9');
					active.className = 'linkMenuActive';
					break;
				case 'sitemap': 
					active = document.getElementById('M7');
					active.className = 'linkMenuActive';
					break;
				case 'contact': 
					active = document.getElementById('M8');
					active.className = 'linkMenuActive';
					break;
		}
}

function start() {
	 menuActive();
/*	 if (lastOpened != 'undefined') {
		Show(rechercheId(), lastOpened); 
		lastOpened=rechercheId(); 
	 }
*/
/*	 promoAleatoire(true,'apofin');*/	
/* menuActive(); Show(rechercheId(), lastOpened); lastOpened=rechercheId(); promoAleatoire(true,'apofin');*/
}

function mktime() {
    // http://kevin.vanzonneveld.net
    // +   original by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: baris ozdil
    // +      input by: gabriel paderni 
    // +   improved by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   improved by: FGFEmperor
    // +      input by: Yannoo
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +      input by: jakes
    // +   bugfixed by: Kevin van Zonneveld (http://kevin.vanzonneveld.net)
    // +   bugfixed by: Marc Palau
    // *     example 1: mktime(14, 10, 2, 2, 1, 2008);
    // *     returns 1: 1201871402
    // *     example 2: mktime(0, 0, 0, 0, 1, 2008);
    // *     returns 2: 1196463600
    // *     example 3: make = mktime();
    // *     example 3: td = new Date();
    // *     example 3: real = Math.floor(td.getTime()/1000);
    // *     example 3: diff = (real - make);
    // *     results 3: diff < 5
    // *     example 4: mktime(0, 0, 0, 13, 1, 1997)
    // *     returns 4: 883609200
    // *     example 5: mktime(0, 0, 0, 1, 1, 1998)
    // *     returns 5: 883609200
    // *     example 6: mktime(0, 0, 0, 1, 1, 98)
    // *     returns 6: 883609200
    
    var no, ma = 0, mb = 0, i = 0, d = new Date(), argv = arguments, argc = argv.length;
 
    if (argc > 0){
        d.setHours(0,0,0); d.setDate(1); d.setMonth(1); d.setYear(1972);
    }
 
    var dateManip = {
        0: function(tt){ return d.setHours(tt); },
        1: function(tt){ return d.setMinutes(tt); },
        2: function(tt){ var set = d.setSeconds(tt); mb = d.getDate() - 1; return set; },
        3: function(tt){ var set = d.setMonth(parseInt(tt)-1); ma = d.getFullYear() - 1972; return set; },
        4: function(tt){ return d.setDate(tt+mb); },
        5: function(tt){ return d.setYear(tt+ma); }
    };
    
    for( i = 0; i < argc; i++ ){
        no = parseInt(argv[i]*1);
        if (isNaN(no)) {
            return false;
        } else {
            // arg is number, let's manipulate date object
            if(!dateManip[i](no)){
                // failed
                return false;
            }
        }
    }
 
    return Math.floor(d.getTime()/1000);
}

/* Affiche les prestations dans la page du meme nom */
function displayServices(listServices){
	var nbElement = listServices.length;
	var myData = "";
	var fileName = location.href.substring((location.href.lastIndexOf("/")+1), location.href.lastIndexOf("."));
	
	for(i=0;i<nbElement;i++){
		//Détermine la prestation active
		var styleActif = fileName == listServices[i][0] ? "linkThemeActive" : "linkTheme";
		
		//Génération du code
		myData = myData + "<div style=\"float:left; width:220px;\">\n";
		myData = myData + "<div style=\"float:left; margin-right:20px;\"><img src=\"../../../icons/common/bullet_theme.gif\" alt=\"\" width=\"21\" height=\"20\" align=\"absmiddle\" /></div>\n";
		myData = myData + "<div style=\"float:left;\"><a href=\"" + listServices[i][0] + ".htm\" class=\"" + styleActif + "\">" + listServices[i][1] + "</a></div>\n";
		myData = myData + "<div class=\"clear\"></div>\n";
		myData = myData + "</div>\n";
	}
	myData = myData + "<div class=\"clear\"></div>\n";
	
	document.getElementById("servicesBox").innerHTML = myData;
}

/* Gere l'affichage de boutons next - previous (page prestations) */
function displayNextPrevious(listServices,target,lang){
	var nbElement = listServices.length;
	var myData = "";
	var fileName = location.href.substring((location.href.lastIndexOf("/")+1), location.href.lastIndexOf("."));
	var posService = "";
	var nextService = 0;
	var previousService = 0;
	var textPrevious = "";
	var textNext = "";
	
	
	//Détermine le texte en fonction de la langue
	switch(lang){
		//allemand
		case 1 :
			textPrevious = "Vorheriger Artikel";
			textNext = "N&auml;chster Artikel";
			break;
			
		//français
		case 2 :
			textPrevious = "sujet pr&eacute;c&eacute;dent";
			textNext = "sujet suivant";
			break;
		
		//italien
		case 3 :
			textPrevious = "tema precedente";
			textNext = "tema seguente";
			break;
	}
	
	//Détermine les prestations suivante et précédente
	for(i=0;i<nbElement;i++){
		//Détermine la prestation active
		for(j=0;j<nbElement;j++){
			if(listServices[j][0] == fileName){
				posService = j;
				break;
			}
		}
		//Gestion des cas particuliers
		if(posService == 0) {previousService = nbElement-1; nextService = posService+1;}
		else if(posService == (nbElement-1)){previousService = posService-1; nextService = 0;}
		else {previousService = posService-1; nextService = posService+1;}
	}
	
	//Génération du code
	myData = myData + "<a href=\"" + listServices[previousService][0] + ".htm\" class=\"linkTop\">\n";
	myData = myData + "<img src=\"../../../icons/common/bullet_previous.gif\" alt=\"" + textPrevious + " : " + listServices[previousService][1] + "\" width=\"17\" height=\"17\" align=\"absmiddle\" border=\"0\" /></a>&nbsp;\n";
	myData = myData + "<a href=\"" + listServices[previousService][0] + ".htm\" class=\"linkTop\">" + textPrevious + "</a>&nbsp;&nbsp;\n";
	myData = myData + "<span class=\"linkTop\">|</span>&nbsp;\n";
	myData = myData + "<a href=\"" + listServices[nextService][0] + ".htm\" class=\"linkTop\">" + textNext + "</a>&nbsp;\n";
	myData = myData + "<a href=\"" + listServices[nextService][0] + ".htm\" class=\"linkTop\">\n";
	myData = myData + "<img src=\"../../../icons/common/bullet_next.gif\" alt=\"" + textNext + " : " + listServices[nextService][1] + "\" width=\"17\" height=\"17\" align=\"absmiddle\" border=\"0\" /></a>\n";
	
	document.getElementById(target).innerHTML = myData;
}




