// JavaScript Document
function rappelerContextePartie(partie)
	{
	var sfEls = document.getElementById("menu").getElementsByTagName("li");
	for (var i=0; i<sfEls.length; i++) {
		if (sfEls[i].className == partie)
			{
			sfEls[i].className+="Actif";
			}
		}
	}

function afficherCalque(calque)
	{
	var calqueEl = document.getElementById(calque);
	if (calqueEl.style.display == 'none')
		{
		calqueEl.style.display = 'block';
		}
	else
		{
		calqueEl.style.display = 'none';
		}
	}

function activerFiche(calque) {
	var sfEls = document.getElementById("colCentre").getElementsByTagName("div");
	for (var i=0; i<sfEls.length; i++) {
		if (sfEls[i].className == 'ficheDetaillee')
			{
			sfEls[i].style.display = 'none';
			}
		if (sfEls[i].id == calque)
			{
			sfEls[i].style.display = 'block';
			}
		}
	}

function activerOnglet(calque) {
	// gestion des onglets : affichage uniquement de l'onglet demand�
	var sfEls = document.getElementById("contenu").getElementsByTagName("div");
	for (var i=0; i<sfEls.length; i++) {
		if (sfEls[i].className == 'articleOnglet')
			{
			sfEls[i].style.display = 'none';
			}
		if (sfEls[i].id == calque)
			{
			sfEls[i].style.display = 'block';
			}
		}
	// gestion du menu des onglets : affichage uniquement de l'onglet demand�
	var sfEls = document.getElementById("menuOnglets").getElementsByTagName("a");
	for (var i=0; i<sfEls.length; i++) {
		if (sfEls[i].className == 'actif')
			{
			sfEls[i].className = '';
			}
		}
	}

function afficheRetourUtilisateur(message) {
	var p = document.getElementById("retourUtilisateur");
	p.innerHTML = message;
	p.className = 'visible';
	return true;
}

function ouvrirMonCompte(repertoire) {
	var monCompte = window.open('/fr/monCompte/index.php?repertoire='+repertoire,'monCompte','status=yes,scrollbars=yes,resizable=yes,width=600,height=600');
	monCompte.focus();
	}

function ouvrirParametrage(repertoire) {
	var parametrage = window.open('/fr/monCompte/parametrage.php?repertoire='+repertoire,'monCompte','status=yes,scrollbars=yes,resizable=yes,width=600,height=600');
	parametrage.focus();
	}

/*function ouvrirChangerIdentifiant(repertoire) {
	var parametrage = window.open('/fr/monCompte/changer-identifiant.php?repertoire='+repertoire,'monCompte','status=yes,scrollbars=yes,resizable=yes,width=600,height=600');
	parametrage.focus();
	}*/

/*
function ouvrirExport(ID_profil,ID_formatProfil,urlParamProfil,codeSaison,target) {
	//alert(urlParamProfil);
	var exportation = window.open('/popup/export.php?actionForm=exporter&ID_profil='+ID_profil+'&ID_formatProfil='+ID_formatProfil+'&urlParamProfil='+urlParamProfil+'&codeSaison='+codeSaison,'Export','status=yes,scrollbars=yes,resizable=yes,width=600,height=600');
	exportation.focus();
}

function ouvrirExport2(ID_profil) {
	//alert(urlParamProfil);
	var exportation = window.open('/popup/export2.php?ID_profil='+ID_profil,'Export','status=yes,scrollbars=yes,resizable=yes,width=600,height=600');
	exportation.focus();
}
*/
function ouvrirExportTemporaire(ID_profil, forcer) {
	//alert('ouvrirExport3');
	var exportation = window.open('/popup/export3.php?ID_profil='+ID_profil+'&forcer='+forcer,'Export','status=yes,scrollbars=yes,resizable=yes,width=600,height=600');
	exportation.focus();
}
function ouvrirExportSQL(ID_profil, forcer) {
	var exportation = window.open('/popup/exportSQL.php?ID_profil='+ID_profil+'&forcer='+forcer,'Export','status=yes,scrollbars=yes,resizable=yes,width=600,height=600');
	exportation.focus();
}
function ouvrirExportCleUSB(ID_profil, forcer) {
	var exportation = window.open('/popup/exportCleUSB.php?ID_profil='+ID_profil+'&forcer='+forcer,'Export','status=yes,scrollbars=yes,resizable=yes,width=600,height=600');
	exportation.focus();
}
function ouvrirExportKML(ID_profil, forcer) {
	var exportation = window.open('/popup/exportKML.php?ID_profil='+ID_profil+'&forcer='+forcer,'Export','status=yes,scrollbars=yes,resizable=yes,width=600,height=600');
	exportation.focus();
}
function ouvrirExportCartoWeb(ID_profil, forcer) {
	var exportation = window.open('/popup/exportCartoWeb.php?ID_profil='+ID_profil+'&forcer='+forcer,'Export','status=yes,scrollbars=yes,resizable=yes,width=600,height=600');
	exportation.focus();
}
function ouvrirTelechargement(cheminFichier) {
	//alert(navigator.platform);
	if(navigator.platform=='Win32'){
		var telechargement = window.open('/popup/telechargementIE.php?fichier='+cheminFichier,'Telechargement','status=yes,scrollbars=yes,resizable=yes,width=500,height=250');
	}else{
		var telechargement = window.open('/popup/telechargement.php?fichier='+cheminFichier,'Telechargement','status=yes,scrollbars=yes,resizable=yes,width=600,height=600');
	}
	telechargement.focus();
}
function ouvrirPreview(idTFO, codeSaison) {
//	var preview = window.open('/popup/vue-redacteur.php?identifiantTfo='+idTFO+'&codeSaison='+codeSaison,'Previsualisation','status=yes,scrollbars=yes,resizable=yes,width=650,height=500');
	var preview = window.open('/diffusio/diffusio-vueDetail_fr.php?tfoid='+idTFO+'&codeSaison='+codeSaison,'Previsualisation','status=yes,scrollbars=yes,resizable=yes,width=650,height=500');
	preview.focus();
}

/*function ouvrirExport2(ID_profil,repertoire,ID_formatProfil) {
	var exportation = window.open('/popup/export.php?actionForm=exporter&ID_profil='+ID_profil+'&repertoire='+repertoire+'&ID_formatProfil='+ID_formatProfil,'Export','status=yes,scrollbars=yes,resizable=yes,width=600,height=600');
	exportation.focus();
	}*/

function redimensionneConteneur(idFrame)
	{
	var windowFrame=window.document.body.scrollHeight;
	var windowFrame = windowFrame+20;
	window.parent.document.getElementById(idFrame).style.height=windowFrame+'px';
	}

function agrandirIframe(idFrame,hauteur)
	{
	window.parent.document.getElementById(idFrame).style.height=hauteur+'px';
	}



// actualiser de l'iframe thesaurus de mes param�tres
function actualiserThesaurus(nomFichier)
	{
	var iFrame = document.getElementById('thesaurus');
	iFrame.src = "/fr/monCompte/thesaurus.php?nomFichier="+nomFichier;
	}

// actualiser de l'iframe granule de la fiche OI
function actualiserGranule(nomGranule,fichierOI)//,ID_OI
	{
	var iFrame = document.getElementById('granule');//+ID_OI
	iFrame.src = nomGranule+'?fichierOI='+fichierOI;
	}

// actualiser de l'iframe pour la creation d'une nouvelle fiche OI
function activerCreation(repertoire)
	{
	var iFrame = document.getElementById('creationOI');
	iFrame.src = "/xml/"+repertoire+"/xforms/OI-DublinCore.xhtml?fichierOI=OI-modele.xml";
	}

// active l'onglet du moteur et d�sactive l'onglet des r�sultats
function activerMoteur()
	{
	document.getElementById('chercher').style.display='block';
	document.getElementById('resultats').style.display='none';
	// gestion du menu des onglets : affichage uniquement de l'onglet demand�
	var sfEls = document.getElementById("colGauche").getElementsByTagName("a");
	for (var i=0; i<sfEls.length; i++) {
		if (sfEls[i].className == 'actif')
			{
			sfEls[i].className = '';
			}
		else
			{
			sfEls[i].className = 'actif';
			}
		}
	}
function activerResultat()
	{
	document.getElementById('chercher').style.display='none';
	document.getElementById('resultats').style.display='block';
	// gestion du menu des onglets : affichage uniquement de l'onglet demand�
	var sfEls = document.getElementById("colGauche").getElementsByTagName("a");
	for (var i=0; i<sfEls.length; i++) {
		if (sfEls[i].className == 'actif')
			{
			sfEls[i].className = '';
			}
		else
			{
			sfEls[i].className = 'actif';
			}
		}
	}

function actualiserCommunes(ID_departement)
	{
	var iFrame = document.getElementById('communes');
	iFrame.src = "/fr/monCompte/communes.php?ID_departement="+ID_departement;
	}

function checkAll(on,serieCheckBox)
	{
	for (i=0;i<document.forms[0].elements.length;i++)
		{
		if (document.forms[0].elements[i].type=="checkbox" && document.forms[0].elements[i].name.indexOf(serieCheckBox)==0)
			{
			document.forms[0].elements[i].checked=on;
			}
		}
	}

function afficherOI(fichierOI,titre)
	{
	// Mise � jour des �l�ments de l'onglet OI
	window.parent.document.getElementById('lienOI').innerHTML= titre.substring(0,13)+'...'; // onglet
	window.parent.document.getElementById('lienOI').style.display = 'block';
	window.parent.document.getElementById('lienOI').setAttribute("title",titre);
	window.parent.activerOnglet('ficheDetail1');
	window.parent.document.getElementById('lienOI').className = 'actif';
	window.parent.document.getElementById('legendOI').innerHTML=titre; // titre du fieldset
	window.parent.document.getElementById('detailOI').fichierOI.value = fichierOI; // champ cach� du formulaire de choix de la granule
	var repertoire = window.parent.document.getElementById('detailOI').repertoire.value;
	window.parent.document.getElementById('detailOI').listeGranule.selectedIndex="";
	window.parent.actualiserGranule('/xml/'+repertoire+'/xforms/OI-DublinCore.xhtml',fichierOI);
	}

