// Tool Barre

//
//	Mtéhode : Il un div par combinaison possible des etats de navigation
//			  Il s'agit d'afficher le bon div : la concaténation des identifiants de CState 'visible'
//			  correspond à l'identifiant du div à afficher	
//
//			  	
//

// Classe Javascript de gestion des objets de navigation dans la tool barre
// 6 objets de navigation avec pour identifiants : "navAcc", "navSel", "navRech", "navResCol", "navResOuv", "navDoc"
// 
function CState(width,show,name)
{
	if (!show) show='show'
	this.width=width					// Largeur de l'objet en pixel
	this.href=""						// Url pointée par l'objet
	this.show=show						// Etat de l'objet visible/non visible
	this.name=name						// Nom de lobjet (par défaut = indice dans le tableau
}

// Instanciation des objets : l'identifiant du 'div' dans la page HTML correspond à l'indice du tableau
CStates = new Array()
CStates['navAcc'] = new CState(0,'hide','navAcc')
CStates['navSel'] = new CState(0,'hide','navSel')
CStates['navRech'] = new CState(0,'hide','navRech')
CStates['navResCol'] =new CState(0,'hide','navResCol')
CStates['navResOuv'] =new CState(0,'hide','navResOuv')
CStates['navDoc'] = new CState(0,'hide','navDoc')

///////////////////////////////////////////////////////////////////////////////
//
// Positionne physiquement l'ensemble des objets de navigation dans la page HTML
//
//
/*
function MM_DrawState()
{
	var left=40		// Position initiale en x dans la page html
	var top=62			// Position initiale en y dans la page html
	var show
	for (divId in CStates)
	{
		show='hide'
		if (CStates[divId].show=='show')
		{
			MM_MoveDiv(divId,left,top,CStates[divId].width)
			left=left+CStates[divId].width
			show='show'
		}
		MM_showHideLayers(divId,'',show)
	}
	
}
*/

// Méthode : déterminationde la chaine strID
//	strStatIDs est la cooncaténation des états valides
//	strStatIDs est le Div équivalent dans ToolBarre.htlm
//  on affiche alors strStatIDs
var strCurrentStatIDs
function MM_DrawState()
{
	var left=40		// Position initiale en x dans la page html
	var top=62			// Position initiale en y dans la page html
	var show
	var strStatIDs = ""
	for (divId in CStates)
	{
		if (CStates[divId].show=='show')
		{
			strStatIDs += CStates[divId].name
		}
	}

	// alert("strStatIDs = " + strStatIDs)
	
	if (strCurrentStatIDs && strCurrentStatIDs != "") 
	{
		MM_showHideLayers(strCurrentStatIDs,'','hide')
	}
	if (strStatIDs != "" )	MM_showHideLayers(strStatIDs,'','show')
	strCurrentStatIDs = strStatIDs
	
	if (strStatIDs == 'navAcc')
	{
		MM_ShowNavGlobale1(false)
	}
	else
	{
		MM_ShowNavGlobale1(true)
	}
}

// Méthode appelée par les pages "cible"
// Indique à la tool barre l'URL visée par un objet ID (state)
// Met à jour l'état des objets de navigation dans la tool barre au fure et à mesure de la progession dans le site
function MM_SetState(state, href, secondName)
{
	// alert("HREF = " + href)
	
	if (secondName == "navTableIndex" || secondName == "navTableMat" || secondName == "navRefDoc")
	{
		hrefNew = MM_DeleteEntree(href,"DEPLIAGE")
		hrefNew = MM_DeleteEntree(hrefNew,"MOINS")
		hrefNew = MM_DeleteEntree(hrefNew,"PLUS")
		hrefNew = MM_DeleteEntree(hrefNew,"TYPE_INDEX")
		hrefNew = MM_DeleteEntree(hrefNew,"ALLER_A")
		hrefNew = MM_DeleteEntree(hrefNew,"PAR_TOC_ID")
		hrefNew = MM_DeleteEntree(hrefNew,"PAR_TOC_ID3")
		hrefNew = MM_DeleteEntree(hrefNew,"POSITION_LIST")
		hrefNew = MM_DeleteEntree(hrefNew,"POSITION_LIST2")
		hrefNew = MM_DeleteEntree(hrefNew,"POSITION_LIST3")
		
		if (hrefNew != href)
		{
			// alert(hrefNew);
		}
		href = hrefNew
	}
	
	var iLen=CStates.lenth
	var bSetNextHide=false
	for (divId in CStates)
	{
		if (bSetNextHide==true) CStates[divId].show='hide'
		if (divId==state)
		{
			CStates[divId].show='show'
			CStates[divId].href=href
			CStates[divId].name=divId
			if (secondName)
			{
				CStates[divId].name=secondName
			}
			bSetNextHide=true
		}
	}
	MM_DrawState()
}

// Remplace 
//		aaaaaaaaaaaaaaa&ENTRE=bbbb&aaaaaaaaaa
// par 
//		aaaaaaaaaaaaaaa&aaaaaaaaaa
// ou
//		aaaaaaaaaaaaaaa&ENTRE=bbbb
// par 
//      aaaaaaaaaaaaaaa
	
function MM_DeleteEntree(URL,entree)
{
	search="&" + entree + "="
	ideb= URL.indexOf(search)
	// alert(search)
	if (ideb != -1)
	{
		ifin= URL.indexOf("&",ideb+1)
		if (ifin == -1) ifin = URL.length 
		
		toReplace = URL.substring(ideb,ifin)
		// alert(toReplace)
			
		return URL.replace(toReplace,"")
	}
	return URL;
}

// Appelle de l'URL par un objet de navigation
function MM_Link(state)
{
	// alert("HREF " + CStates[state].href)
	
	if (CStates[state].href)
	{
		// alert(CStates[state].href)
		f=MM_findFrm("FrameClient",top)	
		if (!f) return
		if (f.window.location.href != CStates[state].href)
		{
			f.window.location=CStates[state].href
		}
	}
}

//////////////////
// Gestion des connexions utilisateur
//
function MM_Connexion()
{
	// Affichage de la boite de connextion
	var FormToolBarre=MM_findObj("FormToolBarre")
	if (!FormToolBarre) return;
	
	var strUrl = FormToolBarre.action + "?"
	strUrl += "CONTEXT=" + FormToolBarre.CONTEXT.value;
	strUrl += "&ACTION=u";
	strUrl += "&FILE_IDENT_HTML=Ident_popup.html";
	strUrl += "&FILE=Ident_ok.html";
	strUrl += "&Cache-Control=no-cache";
	
	open(strUrl,"Connexion","status=no,location=no,directorie=no,resizable=yes,scrollbars=no,menubar=no,toolbar=no,width=310,height=260")
}

// Affichage de la recherche avancée
function MM_AfficherRechercheAvancee()
{
	var FormRechAvancee=MM_findObj("FormToolBarre")
		
	if(FormRechAvancee)
	{
		FormRechAvancee.ACTION.value="CFM"
		FormRechAvancee.TYPE_RECH.value="MULTILISTE"
		FormRechAvancee.SECTION_CONF.value="MULTILISTE1"
		
		FormRechAvancee.target="FrameClient"
		FormRechAvancee.FILE.value="SelectionCollections.html"

		// Cas d'une base icomplete
		if (strSelectAnnee == strAnneePrincipale)
		{
			if (MM_bBaseComplete() == false)
			{
				if ( MM_HaveCGI() == false && MM_HavePF() == false)
				{
					FormRechAvancee.FILE.value="SelectionCollections2.html"
				}
				else
				if ( MM_HaveCGI() == false)
				{
					FormRechAvancee.FILE.value="SelectionCollections3.html"
				}
			}
		}
		else
		{
			if (MM_HavePDOC() == false)
			{
				FormRechAvancee.FILE.value="SelectionCollectionsSansPDoc.html"
			}
		}

		FormRechAvancee.TOC_ID_SEL.value=""
	
		// Application
		FormRechAvancee.submit()
	}
}

// Affichage de la page d'acceuil
function MM_AfficherAcceuil()
{
	var FormToolBarre=MM_findObj("FormToolBarre")
	if(FormToolBarre)
	{
		FormToolBarre.target="FrameClient"
		FormToolBarre.FILE.value="Acceuil.html"
		FormToolBarre.TYPE_RECH.value=""
		FormToolBarre.SECTION_CONF.value=""
		FormToolBarre.ACTION.value=""
	
		// Application
		FormToolBarre.submit()
	}
}

function MM_ShowNavGlobale1(show)
{
	if (show)
	{
		MM_showHideLayers('navGlobale1','','show')
		MM_showHideLayers('navGlobale2','','hide')
	}
	else
	{
		MM_showHideLayers('navGlobale1','','hide')
		MM_showHideLayers('navGlobale2','','show')
	}
}

// Affichage des brochures pratiques
function MM_AfficherBrochuresIR()
{
	var window_brochuresIR = window.open("","SiteBrochuresIR")
	if (window_brochuresIR && window_brochuresIR.location == "about:blank")
	{
		var strURL="brochures_ir" + strSelectAnnee;
		window_brochuresIR.location = strURL;
	}
	if (window_brochuresIR)
	{
		window_brochuresIR.focus()
	}
}

function MM_AfficherBrochuresIDL()
{
	var window_brochuresIR = window.open("","SiteBrochuresIDL")
	if (window_brochuresIR && window_brochuresIR.location == "about:blank")
	{
		var strURL="brochures_idl" + strSelectAnnee;
		window_brochuresIR.location = strURL;
	}
	if (window_brochuresIR)
	{
		window_brochuresIR.focus()
	}
}

// Affichage du précis de ficalité expérimental
function MM_AfficherPFExperimental()
{
	var window_PFExperimental = window.open("","SitePFExperimental")
	if (window_PFExperimental && window_PFExperimental.location == "about:blank")
	{
		// var strURL="http://aida.pf-exp.jouve-hdi.com/aida";
		var strURL="http://pfexp.appli.dgi/pfexp";
		window_PFExperimental.location = strURL;
	}
	if (window_PFExperimental)
	{
		window_PFExperimental.focus()
	}
}

// Affichage du lien créer un lien
function MM_CreerUnLien()
{
	var FormToolBarre=MM_findObj("FormToolBarre")
	if(FormToolBarre)
	{
		FormToolBarre.target="FrameClient"
		FormToolBarre.FILE.value="CreerUnLien.html"
	
		// Application
		FormToolBarre.submit()
	}
}



