var Opened = {div:null,toggler:null};
var Loader = new Element("img");
Loader.src="/Skins/Aupalya/Img/loader.gif";
Loader.setStyles({position:"relative",top:"2px"});
var tabLoca = window.location.href.split(/#/);
var scroll = new Fx.Scroll(window, {
	wait: false,
	duration: 1000,
	transition: Fx.Transitions.Quad.easeInOut
});

function fillAccordion(resultat)
{
	var monDiv = new Element("div");
	monDiv.innerHTML = resultat;
	monDiv.setStyles({opacity:0});
	this.getParent().adopt(monDiv);
	var myEffects = new Fx.Style(monDiv,'opacity',{duration:500});
	myEffects.start(0,1);
	scroll.toElement(this);
	myEffects.addEvent("onComplete",function()
	{
		Loader.remove();
		Lightbox.scan();
	}.bind(this));
	Opened.div = monDiv;
	Opened.toggler = this;
}

window.addEvent("domready",function()
{
	$ES(".toggler").each(function(item)
	{
		if (item.getElement("a")==undefined) return ;
		item.addEvent("focus",function(){this.blur()});
		item.addEvent("click",function(e)
		{
			if (e!=null) e = new Event(e).stop();
			if (Opened.div != null)
			{
					Opened.div.remove();
					Opened.div = null;
			}
			if (this != Opened.toggler)
			{
				//scroll.toElement(this);
				try {Loader.injectTop(this.getElement(".ListeActualitesTexteNoNews"));}
				catch(e) {Loader.injectTop(this.getElement(".ListeActualitesTexte"));}
				
				new Ajax(this.getElement(".lienToggler").href+".htm?Mode=Ajax", {method: 'get',onComplete: fillAccordion.bind(this)}).request();
			}else
			{
				Opened.toggler = null;
			}
		});
		if (item.getElement("a").name==tabLoca[1])
		{
			item.fireEvent('click',null);
		}
	});
	//var location = window.location.href.match(/^[^#]*/)[1];
});







