
		/*-----------------------------------------------------------------------------
		 
			Javascript pour le composant "js/partials/accordion"
			
			
		-----------------------------------------------------------------------------*/
				
		
		
		$(document).ready(function() {
		
			/* Chargement du plugin accordion */
			$('#accordion').accordion({
				header: '.title',
				autoheight: false
			});
			jQuery.easing.def = "easeOutCubic";
			
			/* gestion du click sur les têtes de chapitre */
			$('#accordion .title').click(function() {
				var el = $(this).next().find('ul li:first-child a');
				$.historyLoad(el.attr('rel'));
			});
		
			/* gestion du click sur les liens dans les volets */
			$('#accordion .ui-accordion-subcontainer-title').click(function() {
				$.historyLoad($(this).attr('rel'));
				return false;
			});
			
			/* initialisation de l'historique ajax */
			$.historyInit(pageload);
		});
		
		/* gestion de l'historique */
		function pageload(hash) 
		{
			var base = '/adsl/pages';
			if(hash) {
				var e = findItemWithRel(hash);
				switchContent(e.pathname.substring(base.length));
			}
			else {
				switchContent(document.location.pathname.substring(base.length));
			}
		}
		
		/* trouve un lien de l'accordeon avec son attribut title */
		function findItemWithRel(rel)
		{
			var e = null;
			if(rel)
			{
				$('#accordion li a.title').each(function() {
					if(this.rel == rel) {
						e = this;
					}
					else {
						/* on recherche dans les liens dans les volets */
						$(this).parent().find('.ui-accordion-subcontainer-title').each(function() {
							if (this.rel == rel) {
								e = this;
							}
						});
					}
				});
			}
			return e;
		}
		
		/* modifie le contenu de la page */
		function switchContent(href)
		{
			$('#ajax-container').load('/adsl/tmplx/' + href.trimSlashes() + ' #content-box');
			hightlightAccordion('/adsl/pages/' + href.trimSlashes());
		}
		
		/* highlight le bon lien dans l'accordeon */
		function hightlightAccordion(href)
		{
			/* activation d'un volet par rapport à l'url */
			var i = 0;
			$('#accordion li a.title').each(function() {
				if('/' + this.pathname.trimSlashes() == href) {
					/* l'url est celui d'une head */
					$('#accordion').accordion('activate', i);
					$(this).parent().find('.ui-accordion-subcontainer-title').removeClass('selected');
					$(this).parent().find('.ui-accordion-subcontainer-title:first').addClass('selected');
				}
				else {
					/* on recherche dans les liens dans les volets */
					$(this).parent().find('.ui-accordion-subcontainer-title').each(function() {
						if ('/' + this.pathname.trimSlashes() == href) {
							$('#accordion').accordion('activate', i);
							$(this).addClass('selected');
						}
						else {
							$(this).removeClass('selected');
						}
					});
				}
				i++;
			});
		}
	
		
	