 
var test = 1;
var test2 = 1;
var myTimer;
		
window.addEvent('domready', function() {
		
	//Si on clique, on arrête le timer	
	 $('accordion').addEvent('click', function() { 
		 $clear(myTimer); 
		 test++;
	 });
			
	 var myAccordion = new Accordion($('accordion'), 'h3.toggler', 'div.element', {
		 opacity: true,show:0,
		 onActive: function(toggler, element){
                         //Premier passage, on lance le timer
			 if(test2<2) { 
				 myTimer = this.display.delay(3000, this, (this.previous + 1) % this.togglers.length);
				 test2++;
                          }
 
		 },
		 onComplete: function(){
                         //chaque fois qu'on a déplié, on vérifie si on a cliqué ou pas
                         //étonnament on ne passe pas ici lors du premier passage
			
			 if(test>1) {
				 $clear(myTimer); 
			 }else{ 
				 myTimer = this.display.delay(3000, this, (this.previous + 1) % this.togglers.length);
			 }
		 }
	});
});

window.addEvent('domready', function() {
	
	//create our Accordion instance
	var myAccordion1 = new Accordion($('accordionabc'), 'h3.togglerabc', 'div.elementabc', {
		opacity: true,show:0,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#a1c700');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#d70615');
		}
	});

});


window.addEvent('domready', function() {
	
	//create our Accordion instance
	var myAccordion2 = new Accordion($('accordionquizz'), 'h3.togglerquizz', 'div.elementquizz', {
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#528CE0');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#528CE0');
		}



	});

var nb = 1;

//add click event to the "add section" link
	$('add_section').addEvent('click', function(event) {
		event.stop();

		
		nb = nb+1;
		
		// create toggler
		var toggler = new Element('h3', {
			'class': 'togglerquizz',
			'html': '<span style="color:#528CE0;font-size:16px;">Question '+nb+' : <br /><input type="text" name="'+nb+'" /><br /><a>Réponse :</a> <input class="input" type="radio" name="choix'+nb+'" value="Vrai">Vrai <input class="input" type="radio" name="choix'+nb+'" value="Faux">Faux</span>'
		});
		
		// create content
		var content = new Element('div', {
			'class': 'elementquizz',
			'html': '<textarea cols="60" rows="10" name="texte'+nb+'" /></textarea>'
		});
		
		// position for the new section
		var position = 0;
		
		// add the section to our myAccordion using the addSection method
		myAccordion2.addSection(toggler, content, position);
		document.formulairequizz.nb.value = nb;
	
	});


});




window.addEvent('domready', function() {
	
	//create our Accordion instance
	var myAccordion3 = new Accordion($('accordionquizz1'), 'h3.togglerquizz1', 'div.elementquizz1', {
		opacity: false,
		onActive: function(toggler, element){
			toggler.setStyle('color', '#ff0000');
		},
		onBackground: function(toggler, element){
			toggler.setStyle('color', '#528CE0');
		}



	});

var nb1 = document.formulairequizz1.nb1.value;;

//add click event to the "add section" link
	$('add_section').addEvent('click', function(event) {
		event.stop();

		
		nb1++;
		
		// create toggler
		var toggler = new Element('h3', {
			'class': 'togglerquizz1',
			'html': '<span style="color:#528CE0;font-size:16px;">Question '+nb1+' : <br /><input type="text" name="'+nb1+'" /><br /><a>Réponse :</a> <input class="input" type="radio" name="choix'+nb1+'" value="Vrai">Vrai <input class="input" type="radio" name="choix'+nb1+'" value="Faux">Faux</span>'
		});
		
		// create content
		var content = new Element('div', {
			'class': 'elementquizz1',
			'html': '<textarea cols="60" rows="10" name="texte'+nb1+'" />'
		});
		
		// position for the new section
		var position = 0;
		
		// add the section to our myAccordion using the addSection method
		myAccordion3.addSection(toggler, content, position);

		document.formulairequizz1.nb1.value = nb1;
	
	});


});


