/* Script de menu accordeon en jquery avec ajout d'une class Active 
    Source : http://www.haleystar.com/blog/jquery-accordion-menu-active-states
 */
 function menu_verti() {
/*
* collapsor (1.1) // 2009.02.27 // <http://plugins.jquery.com/project/collapsor>
* 
* REQUIRES jQuery 1.2.3+ <http://jquery.com/>
* 
* Copyright (c) 2008 TrafficBroker <http://www.trafficbroker.co.uk>
* Licensed under GPL and MIT licenses
* 
* collapsor opens and closes sublevel elements, like a collapsable menu
*
* We need to select the clickable elements that trigger the opening action of the sublevels: $('#menu ul li a').collapsor();
* The sublevel element must be in the same level than the triggers
*
* Sample Configuration:
* $('ul a').collapsor();
* 
* Config Options:
* openClass: Class added to the element when is open // Default: 'open'
* sublevelElement: Element that must open or close // Default: 'ul'
* closeOthers: Close other elements when opening // Default: false
* speed: Speed for the opening animation // Default: 500
* easing: Easing for the opening animation. Other than 'swing' or 'linear' must be provided by plugin // Default: 'swing'
* 
* We can override the defaults with:
* $.fn.collapsor.defaults.speed = 1000;
* 
* @param  settings  An object with configuration options
* @author    Jesus Carrera <jesus.carrera@trafficbroker.co.uk>
*/
(function($) {
$.fn.collapsor = function(settings) {
	// override default settings
	settings = $.extend({}, $.fn.collapsor.defaults, settings);
	var triggers = this;
	// for each element
	return this.each(function() {
	  if ($(this).find('+ ' + settings.sublevelElement).length ) {
      $(this).addClass(settings.activeClass);
    }
		// occult the collapsing elements
		$(this).find('+ ' + settings.sublevelElement).hide();
		//show the opened
		if($(this).hasClass(settings.openClass)){
			$(this).find('+ ' + settings.sublevelElement).show();
		}
		// event handling
	  $(this).click(function() {
			// if the new active have sublevels
			if ($(this).next().is(settings.sublevelElement)){
				// blur and add the open class to the clicked
				$(this).blur().toggleClass(settings.openClass);
				// close others
				if (settings.closeOthers == true) {				  
				  $(this).parent().parent().children().find('.'+settings.openClass).not(this).removeClass(settings.openClass).next().animate({height:'toggle', opacity:'toggle'}, settings.speed, settings.easing);
				}
				// toggle the clicked
				$(this).next().animate({height:'toggle', opacity:'toggle'}, settings.speed, settings.easing);
				return false;
			}
	   });
	});
};
// default settings
$.fn.collapsor.defaults = {
	openClass:'open',
	activeClass: 'afficherSousMenu',
	sublevelElement: 'ul',
	closeOthers: true,
	speed: 500,
	easing: 'swing'
};
})(jQuery);

$("a", "ul#navigation").collapsor();  
}
	$(document).ready(function (){
	//témoignage accordéon
	if($(".DetailTemoigne").length!=0)
		{
		$(".DetailTemoigne:not(.activeqa), .DetailTemoigne:not(.detail)").children(".VoirDetailTemoigne").hide();
		$(".DetailTemoigne:not(.detail) .titreTemoigne").click(function(){
			if($(this).parent(".DetailTemoigne").hasClass("activeqa")) {
				$(this).next(".VoirDetailTemoigne").slideUp("slow",function() {
					$(this).parent(".DetailTemoigne").removeClass("activeqa");
				});
			} else {
				  $(this).next(".VoirDetailTemoigne").slideDown("slow",function() {
					  $(this).parent(".DetailTemoigne").addClass("activeqa");
				  });
			}
			  return false;
		});
		}
	//annimation centre page
	if($('ul#annimatedAccueil').length!=0)
		{
		$('ul#annimatedAccueil').animatedinnerfade({ 
				speed: 2000, 
				timeout:  5000, 
				type: 'sequence', 
				containerheight: '281px', 
				containerwidth: '526px', 
				animationSpeed: 15000, 
				animationtype: 'fade',
			controlBox: 'none'
			});
		}
	//annimation logo
	if($('ul#annimationLogo').length!=0)
		{
		$('ul#annimationLogo').innerfade({ 
			animationtype: 'slide',
			speed: 'slow',
			timeout: 4000,
			type: 'sequence' 
			});
		}
	
	if($("a.grande_image").length!=0)
		{
		$("a.grande_image").colorbox();
		}
		
	if($("#slideshow").length!=0)
		{
		$("#slideshow").innerfade({
			speed: 2000,
			timeout: 3000,
			type: 'sequence',
			containerwidth: '595px',
			containerheight: '375px'
			});
		}
	if($("ul#navigation").length!=0)
		{
		menu_verti("a","ul#navigation");
		}
	});
	
function SubmitNewsletter(idEcole)
	{
	var emailVal = $("#emailNewsletter_"+idEcole).val(); 
	var ecoleVal = $("#idEcole_"+idEcole).val(); 
	
	$.post("modules/formulaire/newsletter/inscripNewsletter.php",{email:emailVal,ecole:ecoleVal,provenance:"ajax"},function success(data)
		{
		$("#messageErreur").html(data);
		if($("#messageErreur").length>0)
			{
			//afficher color box
			$.fn.colorbox({width:"40%",height:"30%",inline:true, open:true, href:"#messageErreur"});
			}
		});
	return false;
	}
	
