var testtext = "vide";


function display(theliste){
	
	//alert('func display');
	
	
	var temp = new Array();
	temp = theliste.split(';')
	var texte = "";

	var substr = new Array();
	var qteVerif = temp[0].split("|");	
	
	for(x = 0;x<temp.length;x++){
		substr = temp[x].split('|');
	
		if(x == 0 ){
		
			if( substr[3] == "0" || substr[3] == "1"){
				texte = texte + "<h5 title=\"" + substr[0] + "\" id=\"niv" + substr[3] + "\">" + substr[0] + "</h5><br />"
			}
			
			if( substr[3] == "2" ){
				texte = texte + "<h5 title=\"" + substr[0] + "\" id=\"niv" + substr[3] + "\">" + substr[0] + "</h5><br />"
			}			
			
			document.getElementById('crouton').innerHTML = "";
			if(substr[3] == "0"){
				var string1 = "";
				if( qteVerif[0] != "NULL-NULL-"){
					string1 = substr[0];
					string1 = " / " + string1
				}
				document.getElementById('crouton').innerHTML  = "// common items " + string1;
			}else if(substr[3] == "1"){
				var string2 = "";
				if( qteVerif[0] != "NULL-NULL-"){
					string2 = substr[0];
					string2 = " / " + string2
				}
				//document.getElementById('crouton').innerHTML  = "// common items " + "/ " + document.getElementById('niv0').title + string2;			
				//document.getElementById('crouton').innerHTML  = "// common items " + "/ " + document.getElementById('niv0').title + string2;			
			}
			else if(substr[3] == "2"){
				var string3 = "";
				if( qteVerif[0] != "NULL-NULL-"){
					string3 = substr[0];
					string3 = " / " + string3
				}
				//document.getElementById('crouton').innerHTML  = "// common items " + "/ " + document.getElementById('niv0').title + " / " + document.getElementById('niv1').title + string3;			
				//document.getElementById('crouton').innerHTML  = "// common items " + "/ " + document.getElementById('niv2').title + " / " + document.getElementById('niv2').title + string3;			
			}			
		}

		if(substr[3] == "0"){
			texte = texte + "<a id='num1"+ x +"'  class=\"inactif\" onclick=javascript:mod(\'1_num1"+x+"\');  href=javascript:ListCat(\'1_" + substr[1] +"\');>" +  substr[2] + "</a>";			
		}else if(substr[3] == "1"){
			texte = texte + "<a id='num2"+ x +"'  class=\"inactif\" onclick=\"javascript:mod(\'2_num2"+x+"\'); test(\'sub" + substr[1] + "\');\"  href=javascript:ListCat(\'2_" + substr[1] +"\');>" +  substr[2] + "</a>";				
			 // texte = texte + "<a id='num2"+ x +"'  class=\"inactif\" onclick=\"javascript:mod(\'2_num2"+x+ "\');  \"  href=javascript:ListCat(\'2_" + substr[1] +"\'); test(\'sub" + substr[1] + "\');>" +  substr[2] + "</a><div id=\"sub" + substr[1] + "\"></div>";							
			  
		}else if(substr[3] == "2"){
			//texte = texte + "<a id='num3"+ x +"'  class=\"inactif\" onclick=javascript:mod(\'3_num3"+x+"\');  href=javascript:VoirProduit(\'2_" + substr[1] +"\');>" +  substr[2] + "</a>";				
			texte = texte + "<a href=main.cfm?p=112&amp;l=" + substr[5] + "&amp;CATID=" +  substr[1] + " style=\"margin: 0 0 0 15px;\" >" +  substr[2]  + "</a>";		
			
			//testtext = testtext + "<a href=main.cfm?p=112&amp;l=<cfoutput>#url.l#</cfoutput>&amp;CATID=" +  substr[1] + " style=\"margin: 0 0 0 15px;\" >" +  substr[2]  + "</a>";		
		}
	}
	
	

	//alert(temp);
	
	if( qteVerif[0] != "NULL-NULL-"){// Pas vide
		
		var verif = temp[0].split("|");
		
		if(verif[3] == "0"){			
			document.getElementById('nivParentID1Ajax').innerHTML = texte;
			document.getElementById('nivParentID2Ajax').innerHTML = "";
			document.getElementById('nivParentID3Ajax').innerHTML = "";
			
		}else if(verif[3] == "1"){
			document.getElementById('nivParentID2Ajax').innerHTML = texte;
			document.getElementById('nivParentID3Ajax').innerHTML = "";
			
		}else if(verif[3] == "2"){
			document.getElementById('nivParentID3Ajax').innerHTML = texte;
			//document.getElementById('sub9').innerHTML = texte;
			
			//var thesub = 
			
			//document.getElementById('sub9').innerHTML = texte;
			//document.getElementById('sub555').innerHTML = texte;
		
		}
	}else{// vide
		var verifNiveau = temp[0].split("|");
		if(verifNiveau[3] == "0"){
			document.getElementById('nivParentID1Ajax').innerHTML = " ";
			document.getElementById('nivParentID2Ajax').innerHTML = " ";
			document.getElementById('nivParentID3Ajax').innerHTML = " ";
		}else if(verifNiveau[3] == "1"){
			document.getElementById('nivParentID2Ajax').innerHTML = " ";
		}else if(verifNiveau[3] == "2"){
			document.getElementById('nivParentID3Ajax').innerHTML = " ";
		}
	}
	
	
	//document.getElementById('nivParentID3Ajax').innerHTML = testtext;
	//testtext = "";
	
}





function mod(Niv_ID){

	//alert('func mod');

	var temp = Niv_ID.split("_");
	var niveau = temp[0];
	var theID = temp[1];
	
	if(niveau == "1"){
		var leDiv = document.getElementById("nivParentID1Ajax");
	}else if(niveau == "2"){
		var leDiv = document.getElementById("nivParentID2Ajax");
	}else if(niveau == "3"){
		var leDiv = document.getElementById("nivParentID3Ajax");
	}
	
	var items = leDiv.getElementsByTagName("a");
	for(var x=0; x < items.length; x++){
		items[x].setAttribute("class","actif");
		items[x].className = "inactif";
	}

	if (document.getElementById(theID).className == "inactif") {
		document.getElementById(theID).className = "actif"
	}
	else{
		document.getElementById(theID).className = "inactif"
	}
}



function test(theId){

		//alert('func test');

		var leDiv = document.getElementById("nivParentID2Ajax");
		var itemsOfDiv = leDiv.getElementsByTagName("div");
		
		var temp = "";
		for(var x=0; x < itemsOfDiv.length; x++){
			temp = temp +  itemsOfDiv[x].getAttribute("id");
			//itemsOfDiv[x].setAttribute("class","actif");
			//itemsOfDiv[x].className = "inactif";
			itemsOfDiv[x].innerHTML = "";
			//itemsOfDiv[x].style.display = "none";
		}	
		
		//alert(temp);

		//document.getElementById(theId).innerHTML = testtext;
		//testtext = "";
		//document.getElementById(theId).style.display = "block";

		
	//alert(theId);

}
