//=============================================================== 
//  Variable globale
//===============================================================

var effectOn = false;


/******************************************************
  Initialisation
*******************************************************/
function initialisation () {
	
	if ( $('mainContent').getElementsByClassName ('blocDeroulant') != ''  ) {
		hideBlocDeroulant();
		insEventBlocDeroulant ();
	}	
	
}


/******************************************************
  Bloc Déroulant : on cache tous les blocs sauf
  le premier
*******************************************************/
function hideBlocDeroulant () {
	var allbloc = $('mainContent').getElementsByClassName ('blocContent');
	var taballbloc = $A (allbloc);
	taballbloc.each (function (el) {
		el.hide();		
	});
	taballbloc[0].show();
}



/******************************************************
  Bloc Déroulant : Insertion des événements onclick 
*******************************************************/
function insEventBlocDeroulant () {
	var allElm = $('mainContent').getElementsByClassName ('titre');
	var tabAllElm = $A (allElm);
	var indice = 0;
	tabAllElm.each (function (el) {
		indice++
		el.onclick = new Function ("deplBloc('"+indice+"'); return false;");
		el.setStyle ({
			cursor: 'pointer'
		});
	});	
}


/******************************************************
  Bloc Déroulant : Gestion de l'ouverture ou de la
  fermeture du bloc
*******************************************************/
function deplBloc (i) {
	var num = i - 1;
	var bloc = $('mainContent').getElementsByClassName ('blocContent')[num];


	if ( ! $(bloc).visible() && !effectOn ) {
		new Effect.BlindDown (bloc, {
					duration: 1.0, 
					beforeStart: function () { effectOn = true; } ,
					afterFinish: function () { effectOn = false; } 
				});
	}
	else if ( $(bloc).visible() && !effectOn ) {
		new Effect.BlindUp (bloc, {
					duration: 1.0, 
					beforeStart: function () { effectOn = true; } ,
					afterFinish: function () { effectOn = false; } 
				});	
	}
	
}


/******************************************************
  Swap Image
*******************************************************/
function MM_findObj(n, d) { //v4.01
  var p,i,x;  if(!d) d=document; if((p=n.indexOf("?"))>0&&parent.frames.length) {
    d=parent.frames[n.substring(p+1)].document; n=n.substring(0,p);}
  if(!(x=d[n])&&d.all) x=d.all[n]; for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
  for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
  if(!x && d.getElementById) x=d.getElementById(n); return x;
}


function MM_changeProp(objName,x,theProp,theValue) { //v6.0
 var obj = MM_findObj(objName);
  if (obj && (theProp.indexOf("style.")==-1 || obj.style)){
    if (theValue == true || theValue == false)
      eval("obj."+theProp+"="+theValue);
    else eval("obj."+theProp+"='"+theValue+"'");
  }
}