// Accordeon menu Gauche
var accordion=function(){
	var tm=sp=10;
	function slider(n){this.nm=n; this.arr=[]}
	slider.prototype.init=function(t,c,k){
		var a,h,s,l,i; a=document.getElementById(t); this.sl=k?k:'';
		h=a.getElementsByTagName('dt'); s=a.getElementsByTagName('dd'); this.l=h.length;
		for(i=0;i<this.l;i++){var d=h[i]; this.arr[i]=d; d.onclick=new Function(this.nm+'.pro(this)'); if(c==i){d.className=this.sl}}
		l=s.length;
		for(i=0;i<l;i++){var d=s[i]; d.mh=d.offsetHeight; if(c!=i){d.style.height=0; d.style.display='none'}}
	}
	slider.prototype.pro=function(d){
		for(var i=0;i<this.l;i++){
			var h=this.arr[i], s=h.nextSibling; s=s.nodeType!=1?s.nextSibling:s; clearInterval(s.tm);
			if(h==d&&s.style.display=='none'){s.style.display=''; su(s,1); h.className=this.sl}
			else if(s.style.display==''){su(s,-1); h.className=''}
		}
	}
	function su(c,f){c.tm=setInterval(function(){sl(c,f)},tm)}
	function sl(c,f){
		var h=c.offsetHeight, m=c.mh, d=f==1?m-h:h; c.style.height=h+(Math.ceil(d/sp)*f)+'px';
		c.style.opacity=h/m; c.style.filter='alpha(opacity='+h*100/m+')';
		if(f==1&&h>=m){clearInterval(c.tm)}else if(f!=1&&h==1){c.style.display='none'; clearInterval(c.tm)}
	}
	return{slider:slider}
}();

///////
function montrercacher (id1,id2,classDepart,classArrivee) {
 divID1 = document.getElementById(id1);
 divID2 = document.getElementById(id2);
	 if (divID1.style.display == "") {
		divID1.style.display = "none";
		divID2.className = classDepart;
	}
	else {
		divID1.style.display = "";
		divID2.className = classArrivee;
	}
}
/////////////////////////////

// popUp IMAGE
function popMe (genre,adresse) {
	var haut = document.body.clientHeight;
	//construction popIN
	if (!i2h("contPopIn")){
		contPop = document.createElement('div');
		contPop.setAttribute ("id", "contPop");
		DivAlpha = document.createElement('div');
		DivAlpha.setAttribute ("id", "alpha");
		DivAlpha.style.height=haut-310+'px';// on affecte la hauteur du document � la div alpha � laquelle on retranche celle du footer
		DivVid = document.createElement('div');
		DivVid.setAttribute ("id", "contPopIn");
		fermer = document.createElement('a');
		//creation bouton fermer
		fermer.setAttribute ("href", "#");
		olacAddEvent(fermer,"click",function () { 
		document.body.removeChild(contPop);	
		});
		fermer.className='c_lk_close';
		fermer.innerHTML='fermer';
		img = document.createElement('img');
		img.src= adresse;
		olacAddEvent(img,"click",function () { 
		document.body.removeChild(contPop);	
		});
		document.body.appendChild(contPop);
		document.getElementById("contPop").appendChild(DivAlpha);
		document.getElementById("contPop").appendChild(DivVid);
		if (adresse.indexOf(".svg") == -1){
			document.getElementById("contPopIn").appendChild(img);
		}else{
			document.getElementById("contPopIn").innerHTML="<object type='image/svg+xml' data="+adresse+" ><param name='src' value="+adresse+"><\/object>";
		}
		document.getElementById("contPopIn").appendChild(fermer);
	}
}

function olacAddEvent(objdom,typeofevent,func){ 
	if (objdom.addEventListener){ objdom.addEventListener(typeofevent,func,false); }
	else { objdom['e'+ typeofevent + func] = func;objdom[typeofevent + func] = function(){objdom['e'+ typeofevent + func](window.event);};objdom.attachEvent('on'+ typeofevent, objdom[typeofevent + func]); }
}
/*
function addOnloadHook(func){
	
}*/

function blocHref(node){
   var nodeA = dojo.query("A:first", node);
   if (0 < nodeA.length) {
               if( !targetPopup( nodeA[0])) {
                       window.location.href = nodeA[0].href;
               }
   }
   return false;
}

function targetPopup( a)
{
       var target=( a.target!="" )?a.target : "_self" ;
       if(target=="_blank") {
               var href=( typeof a.href!="undefined"&&a.href!=document.location&&a.href!=document.location+"#" )?a.href:false;
               if(href) {
                       return window.open(href,target);
               }
       }
       if(target.substr(0,5)=="popup") {
               var href=( typeof a.href!="undefined"&&a.href!=document.location&&a.href!=document.location+"#" )?a.href:false;
               
               width=target.substr(5,3);
               height=target.substr(9,3);
               
               options = null;
               if( width!="" && height!="" )
                       options="width="+width+",height="+height;
                       
               if( href && target && options)
                       return window.open( href,target,options);
       }
       return false;
}
