// nécessite une prédéfinition des variables listChar et nbLevel

var aListToSwitchID = new Array();
var aListToSwitchType = new Array();
var toTreatMin=0;
var toTreatMax=0;
var oDragSource;
var oDragDest;

function switchNode(oPic,typeSwitch) {
  changePic=false;
  sPictPath="../rfi/p/";
  picTypeVal=picType(oPic);
  iRange=iRange=picTypeVal.charAt(picTypeVal.length-5);
  if (typeSwitch=="q") {
    changePic=true;
	if (picTypeVal.charAt(picTypeVal.length-6)=="m") {typeSwitch="c"}
	if (picTypeVal.charAt(picTypeVal.length-6)=="p") {typeSwitch="o"}
    }
  if (typeSwitch=="c") {displayType="none"; nextPict="p" + iRange + ".gif"; stop=false;}
  if (typeSwitch=="o") {displayType="block"; nextPict="m" + iRange + ".gif";stop=false;}
  if (picTypeVal.charAt(picTypeVal.length-6)=="t") {stop=true;}
  if (!stop) {
    if (changePic) {oPic.src=sPictPath + nextPict;}
    nodeID=oPic.id;
    var tmp = new Array();
    tmp = nodeID.split('0');
    nodeRoot=tmp[0];
    nodeLevel=nodeRoot.length;
    for (cpt1= 0; cpt1<listChar.length;cpt1++) {
      tmpNode=nodeRoot + listChar.charAt(cpt1);
      for (cpt2= nodeLevel;cpt2<nbLevel-1;cpt2++) {
        tmpNode+="0";
        }    
      if (typeSwitch=="o") {
 		eval ("if (!isNull(document.getElementById('d" + tmpNode + "'))) {tmpPictTypeVal=picType(document.getElementById('" + tmpNode + "'));if (picTypeVal.charAt(picTypeVal.length-6)=='m'){aListToSwitchID[toTreatMax]='" + tmpNode + "';aListToSwitchType[toTreatMax]='o';toTreatMax ++};document.getElementById('d" + tmpNode + "').style.display = '" + displayType + "';}else{cpt1<listChar.length;}");
        }
      if (typeSwitch=="c") {
 		eval ("if (!isNull(document.getElementById('d" + tmpNode + "'))) {tmpPictTypeVal=picType(document.getElementById('" + tmpNode + "'));if (picTypeVal.charAt(picTypeVal.length-6)=='m'){aListToSwitchID[toTreatMax]='" + tmpNode + "';aListToSwitchType[toTreatMax]='c';toTreatMax ++};document.getElementById('d" + tmpNode + "').style.display = '" + displayType + "';}else{cpt1<listChar.length;}");
        }
      }
    }
  }

function recursiveSwitchNode() {
  for (cpt=toTreatMin;cpt<toTreatMax;cpt++) {
    eval("switchNode(document.getElementById('" + aListToSwitchID[cpt] + "'),'" + aListToSwitchType[cpt] + "')");
    toTreatMin=cpt+1;
    }
  }
  
function swN(oPic) {	
  switchNode(oPic,'q');
  recursiveSwitchNode();
  adjustContextVAlign();
  }
  
function picType(oPic) {

  var tmp1 = new Array();
  tmp1=oPic.src.split('/');
  picTypeValue=tmp1[tmp1.length-1];
  return picTypeValue;
  }
 
function openIf(sPic) {
	oPic=document.getElementById(sPic);
	picTypeVal=picType(oPic);
	if('p'==picTypeVal.charAt(picTypeVal.length-6)){
		swN(oPic);
	}
}
 
function isNull(val) {
  return(val==null);
  }

function arboOpenThread (arboId) {
  while (arboId.charAt(1)!=0) {
  	for (intFCT_cpt1=9; intFCT_cpt1>-1;intFCT_cpt1 --) {
  		if (arboId.charAt(intFCT_cpt1)!=0) {
  			strFCT_tempArboId = arboId.substr(0,intFCT_cpt1);
  			for (intFCT_cpt2=0; intFCT_cpt2<(10-intFCT_cpt1);intFCT_cpt2 ++) strFCT_tempArboId += "0";
  			swN(document.getElementById(strFCT_tempArboId));
  			arboId = strFCT_tempArboId;
  			break;
      	}
      }
    }
  }
  
  function arboOpenLevel(sType,nLevel) {
 	var cate=document.getElementById(sType);
	var arboNodes = cate.childNodes;
	for (var i=0,j=0;i<arboNodes.length;i++) {
	  if (arboNodes[i].nodeType == 1){
	  	if ('0' == arboNodes[i].attributes['id'].value.charAt(nLevel)){
			swN(arboNodes[i].firstChild);		
		}
	  }
	}
  }
     
