// diaporama
function diaporama(largeur_image, duree, duree_retour, auto){
	var diaporama = $('diaporama');
	if(diaporama){
		var nbImages = $('diaporama-images').getElements('li').length;
		if(nbImages>1){
			$(diaporama).removeClass('bloc-diaporama');
			$(diaporama).addClass('bloc-diaporama-js');
			var ulImages = $(diaporama).getElement('ul');
			$(ulImages).removeClass('list-image-diaporama');
			$(ulImages).addClass('list-image-diaporama-js');
			
			var totIncrement		= 0;
			var increment			= largeur_image;
			var maxRightIncrement	= increment*(-(nbImages-1));
			
			var fx 				= "";
			var fx_initial		= new Fx.Tween($('diaporama-images'), {duration: duree, transition: 'back:in:out'});
			if(auto == true){
				var fx_retour	= new Fx.Tween($('diaporama-images'), {duration: duree_retour, transition: 'back:in:out'});
				var deplacement = function(){
					if (totIncrement == 0){
						fx = fx_initial;
					} else if(totIncrement == maxRightIncrement){
						fx = fx_retour;
						totIncrement = increment;
					}
					totIncrement -= increment;
					fx.pause();
					fx.start('margin-left', totIncrement);
					
				}
				var monDep = deplacement.periodical(5000);
			}else{
				var divControle  = new Element('div', {
					'id': 'diaporama-control',
					'class': 'btn-control-diapo',
					'html': '<img id="prec" src="/img/milleetune/fleche-diaporama-gche[0].gif" alt="image précedente"> <img id="suiv" src="/img/milleetune/fleche-diaporama-dte[0].gif" alt="image suivante">'
				});
				divControle.inject(diaporama, 'after');
				var fx = new Fx.Tween($('diaporama-images'), {duration: duree, transition: 'back:in:out'});
				if(totIncrement == 0) {
				$('prec').src='/img/milleetune/fleche-diaporama-gche[2].gif';
				}
				if(totIncrement == maxRightIncrement) {
				$('suiv').src='/img/milleetune/fleche-diaporama-dte[2].gif';
				}
				$('prec').addEvent('mouseover', function() {
				if(totIncrement < 0) {
				this.src='/img/milleetune/fleche-diaporama-gche[1].gif';
				}else{
				this.src='/img/milleetune/fleche-diaporama-gche[2].gif';
				}
				});
				$('prec').addEvent('mouseout', function() {
				if(totIncrement < 0) {
				this.src='/img/milleetune/fleche-diaporama-gche[0].gif';
				}else{
				this.src='/img/milleetune/fleche-diaporama-gche[2].gif';
				}
				});
				$('prec').addEvent('click', function() {
				if(totIncrement < 0) {
				totIncrement += increment;
				fx.pause();
				fx.start('margin-left', totIncrement);
				$('suiv').src='/img/milleetune/fleche-diaporama-dte[0].gif';
				}
				});
				$('suiv').addEvent('mouseover', function() {
				if(totIncrement > maxRightIncrement) {
				this.src='/img/milleetune/fleche-diaporama-dte[1].gif';
				}else{
				this.src='/img/milleetune/fleche-diaporama-dte[2].gif';
				}
				});
				$('suiv').addEvent('mouseout', function() {
				if(totIncrement > maxRightIncrement) {
				this.src='/img/milleetune/fleche-diaporama-dte[0].gif';
				}else{
				this.src='/img/milleetune/fleche-diaporama-dte[2].gif';
				}
				});
				$('suiv').addEvent('click', function() {
				if(totIncrement > maxRightIncrement) {
				totIncrement -= increment;
				fx.pause();
				fx.start('margin-left', totIncrement);
				$('prec').src='/img/milleetune/fleche-diaporama-gche[0].gif';
				}
				});		
		}	
		}
	 }
}

function ajout_com_blog(){
	nom 	= document.getElementById('nom').value;
	titre 	= document.getElementById('titre').value;
	crypto 	= document.getElementById('crypto').value;
	if (nom == "" || titre == "" || crypto == ""){
		alert("Votre nom, le titre et le cryptogramme doivent être remplis");
		return false;
	} else {
		return true;
	}
}

function ajout_com_question(){
	nom 	= document.getElementById('nom').value;
	prenom 	= document.getElementById('prenom').value;
	ville 	= document.getElementById('ville').value;
	crypto 	= document.getElementById('crypto').value;
	if (nom == "" || prenom == "" || ville == "" || crypto == ""){
		alert("Votre nom, prenom, ville et le cryptogramme doivent être remplis");
		return false;
	} else {
		return true;
	}
}

function popupcentree(page,largeur,hauteur,options) {
	var top=(screen.height-hauteur)/2;
	var left=(screen.width-largeur)/2;
	window.open(page,"","top="+top+",left="+left+",width="+largeur+",height="+hauteur+","+options);
}

function affichage_ecoute(type, compteur){
	element = document.getElementById(type+"_"+compteur);
	// Enleve tous les autres lecteurs
	elements_a_cacher = document.getElementsByTagName('object');
	for(i=0;i<elements_a_cacher.length;i++){
		if ((elements_a_cacher[i].id.substring(0, 4) == "mp3_" || elements_a_cacher[i].id.substring(0, 4) == "flv_") && elements_a_cacher[i].id != type+"_"+compteur){
			elements_a_cacher[i].style.visibility 	= 'hidden';
			elements_a_cacher[i].style.position		= 'absolute';
			elements_a_cacher[i].SetVariable("player:jsStop", "");
		}
	}
	if (element.style.visibility == 'hidden'){
		element.style.visibility 	= 'visible';
		element.style.position		= '';
	} else {
		element.style.visibility 	= 'hidden';
		element.style.position		= 'absolute';
		element.SetVariable("player:jsStop", "");
		
	}
}
