// Selection des collection
// Variables collection

// liste des tableaux de fils
ArrayNull = new Array();
Collections = new Array();

// Classe CCollection
function CCollection( TOC_ID, ChildsArray, ParentsArray)
{
	this.TOC_ID=TOC_ID;
	this.ChildsArray=ChildsArray;
	this.ParentsArray=ParentsArray;
}

//
// Méthodes de sélection des CheckBox par collection
// 
function FindCollectionIndex(TOC_ID)
{
	iSize=Collections.length;
	var iIndex=0;

	while( iIndex < iSize)
	{	
		if(Collections[iIndex].TOC_ID==TOC_ID)
		{
			return iIndex;
		}
		iIndex++;
	}
	alert("collection non trouvée" + TOC_ID);
	return -1;
}

function MM_Check_Child_And_Parent( etat, collection)
{
	var FormSelectionCollections=MM_findObj("FormSelectionCollections")
		
	var j=0;
	for (j=0; j < collection.ChildsArray.length;j++)
	{
		FormSelectionCollections[collection.ChildsArray[j]].checked=etat;
		MM_Check_Update(collection.ChildsArray[j],etat);
	}

	if( etat == false)
	{
		FormSelectionCollections[MainCollection].checked=etat;
		for (j=0; j < collection.ParentsArray.length;j++)
		{
			FormSelectionCollections[collection.ParentsArray[j]].checked=etat;
		}
	}
}

function MM_Check_Update(TOC_ID,etat)
{
	var iCol=FindCollectionIndex(TOC_ID);
	if (iCol != -1)
		MM_Check_Child_And_Parent(etat,Collections[iCol]);
}	

function MM_ValideCollection()
{
	var FormSelectionCollections=MM_findObj("FormSelectionCollections")
		
	alert(FormSelectionCollections.name)
	
	FormSelectionCollections.ACTION.value="cC";
	FormSelectionCollections.FILE.value="SelectionCollections.html";
	FormSelectionCollections.submit();
}

// Méthode d'affichage d'un mode de recherche
// La cible est toujour la "FrameClient"
function MM_CritereRecherche(Type_Rech, Section_Conf, Toc_ID, Toc_Titre)
{
	// alert("MM_CritereRecherche")
	var FormSelectionRecherches=MM_findObj("FormSelectionCollections")
		
	var Plus="";
	var Depliage="";
	var Action="M";
	var TypeIndex=""
	var AllerA=""
	var Par_Toc_Id="1"
	var Par_Toc_Id3=""
		
	// Application
	if (Type_Rech=="TI")
	{
		FormSelectionRecherches.FILE.value="FrameAlpha.html"
		if ( Toc_ID == "10" )
		{
			FormSelectionRecherches.FILE.value="FrameLexique.html"
		}
		
		TypeIndex = "TableIndex"
		AllerA= " A AZZZZ"
		Depliage="Neant";
		Action=""
	}
	else if (Type_Rech=="TM")
	{
		FormSelectionRecherches.FILE.value="RechTableMat.html"
		if (Toc_ID == "2" || Toc_ID == "3" || Toc_ID == "10" )
		{
			// Dépliage sur le premier niveau dans CGI,LPF et PF
			Plus="0";
		}
		Depliage="Neant";
	}
	else if (Type_Rech=="REFDOC")
	{
		FormSelectionRecherches.FILE.value="RechRefDoc.html"
		if (Toc_ID == "5" || Toc_ID == "6" || Toc_ID == "11")
		{
			// Présentation 3 listes de la recherche par référence pour les BOI et les PDOC
			Par_Toc_Id="rien"		// pas de série choisie par défaut
			Par_Toc_Id3="neant"		// toutes les références de BOI ou de PDOC par défaut
			
			// Cas par défaut les BOI
			FormSelectionRecherches.FILE.value="RechRefDoc_3L.html"
			if (Toc_ID == "6")
			{
				// A voir
			}
		}
		
		if (Toc_ID == "3" || Toc_ID == "10" )
		{
			// Uniquement une liste pour le LPF les BOI ADM et le PF
			FormSelectionRecherches.FILE.value="RechRefDocUneListe.html"
			Par_Toc_Id="1";	
			
			if (Toc_ID == "10")
			{
				Par_Toc_Id="0";
			}
		}
		Action=""
	}
	else if (Type_Rech=="DATE")
	{
		FormSelectionRecherches.FILE.value="RechDate.html"
	}
	else if (Type_Rech=="FULL_TEXTE")
	{
		FormSelectionRecherches.FILE.value="RechFullTexte.html"
	}
		
	FormSelectionRecherches.target="FrameClient"
	FormSelectionRecherches.TYPE_RECH.value=Type_Rech
	FormSelectionRecherches.SECTION_CONF.value=Section_Conf
	FormSelectionRecherches.TOC_ID_SEL.value=Toc_ID	
	FormSelectionRecherches.TOC_ID_SEL_TITRE.value=Toc_Titre
	FormSelectionRecherches.ACTION.value=Action
		
	// Conditions Initiales
	FormSelectionRecherches.PLUS.value=Plus
	FormSelectionRecherches.DEPLIAGE.value=Depliage
	FormSelectionRecherches.TYPE_INDEX.value=TypeIndex
	FormSelectionRecherches.ALLER_A.value=AllerA
	FormSelectionRecherches.PAR_TOC_ID.value=Par_Toc_Id
	FormSelectionRecherches.PAR_TOC_ID3.value=Par_Toc_Id3
						
	FormSelectionRecherches.submit()
	// Modification Maquette	
	/*
	if (Type_Rech=="TI")
		FormSelectionCollections.FILE.value="FrameAlpha.xhtml"
	else if (Type_Rech=="TM")
		FormSelectionCollections.FILE.value="FrameAnalytique.xhtml"
	else if (Type_Rech=="REFDOC")
		FormSelectionCollections.FILE.value="RechRefDoc1.xhtml"
	else if (Type_Rech=="DATE")
		FormSelectionCollections.FILE.value="RechDate.xhtml"

	FormSelectionCollections.target="FrameClient"
	FormSelectionCollections.TYPE_RECH.value=Type_Rech
	FormSelectionCollections.SECTION_CONF.value=Section_Conf
	FormSelectionCollections.TOC_ID_SEL.value=Toc_ID
	
	f=MM_findFrm("FrameClient",top)
	if(f)
	{
		f.document.location=document.FormCollection.FILE.value											
	}
	*/
}

