<!--

var BIB = "/consultation2/";

function gereCases(c) {
	switch (c) {
		case 1 :
			if ((document.saisie.typedoc1.checked) && (document.saisie.typedoc.checked))
					document.saisie.typedoc.click();
			break;
		case 2 :
			if ((document.saisie.typedoc2.checked) && (document.saisie.typedoc.checked))
					document.saisie.typedoc.click();
			break;
		default :
			if (document.saisie.typedoc.checked) {
				if (document.saisie.typedoc1.checked)
					document.saisie.typedoc1.click();
				if (document.saisie.typedoc2.checked)
					document.saisie.typedoc2.click();
			}
			break;
	}
}


function verifDate(zone) {
	//alert(d);
	v = zone.value;
	var re = /\d\d\d\d/;
	if ((v) && (!v.match(re))) {
		alert("vous devez entrer une date sur 4 chiffres");
		//zone.focus();
		zone.value = "";
	}
}

// FONCTIONS SERVANT A LA MEMORISATION ET AU RAPPEL DES CRITERES DE RECHERCHE
// POUR LA FONCTIONNALITE "DERNIERE RECHERCHE"
function derniereRecherche(chaine) {
	if (chaine.length == 0) {
		alert("Aucune recherche mémorisée pour l'instant.");
	}
	else {
		document.recherche.chargeinfos.value = "OUI";
		var tabval = chaine.split("|");

		if (tabval[0] == "EXP")
		{
			parent.gauche.document.location = BIB + "BibExperte.html";
		}
		else
		{
			with (parent.gauche.Bib.document) {
				if (tabval[0] == "MONO") {
					location = BIB + "BibSimple.html";
				}
				else {
					if (tabval[0] == "NOUV") {
						location = BIB + "BibNouveautes.html";
					}
					else {
						if (tabval[0] == "BASE") {
							location = BIB + "BaseDonnee.html";
						}
					}
				}
			}
			parent.gauche.bas.document.location = BIB + "bagauche.htm";
		}
	}
}

function nouvelleRecherche(chaine) {
	if (chaine.length == 0) {
		alert("Aucune recherche mémorisée pour l'instant");
	}
	else {
		//alert(chaine);
		var tabval = chaine.split("|");

		with (parent.Bib.document) {
			if (tabval[0] == "MONO") {
				location = BIB + "BibSimple.html";
			}
			else {
				if (tabval[0] == "EXP") {
					location = BIB + "BibExperte.html";
				}
				else {
					if (tabval[0] == "NOUV") {
						location = BIB + "BibNouveautes.html";
					}
					else {
						if (tabval[0] == "BASE") {
							location = BIB + "BaseDonnee.html";
						}
					}
				}
			}
		}
		parent.gauche.bas.document.location = BIB + "bagauche.htm";
	}
}

function criteresRecherche() {
	var chaine = parent.parent.menu.document.recherche.crits.value;
	var tab = chaine.split("|");

	for (var i=1; i < tab.length; i++) {
		var tab2 = tab[i].split("=");
		if (tab2[0].search("LISTE") >=0 ) { // champ de type liste de sélection
			var nomchamp = tab2[0].substr(5);
			//alert(tab2[0]+","+tab2[1]);
			var ch = eval("document.saisie." + nomchamp);
			ch.selectedIndex = tab2[1];
		}
		else {
			if (tab2[0].search("RADIO") >=0 ) { // champ de type bouton radio
				var nomchamp = tab2[0].substr(5);
				//alert(tab2[0]+","+tab2[1]);
				var ch = eval("document.saisie." + nomchamp);
				var r = tab2[1]; 
				ch[r].click(); 
			}
			else {
				if (tab2[0].search("CASE") >=0 ) { // champ de type case à cocher
					var nomchamp = tab2[0].substr(4);
					//alert(tab2[0]+","+tab2[1]);
					var ch = eval("document.saisie." + nomchamp);
					//var r = tab2[1];
					if (!ch.checked) ch.click();
				}
				else { // champ de type zone de texte
					var ch = eval("document.saisie." + tab2[0]);
					//alert(tab2[0]+","+tab2[1]);
					//document.selectForm.critere.value = tab2[1];
					ch.value = tab2[1];
				}
			}
		}
	}
}

function bonTypeChamp(typ) {
	if (typ.search("hidden") >= 0) return -1;
	if (typ.search("submit") >= 0) return -1;
	if (typ.search("reset") >= 0) return -1;

	return 0;
}

function memoriseRecherche(type) {
	var chaine = type;
	with (document.saisie) {
		
		var nbchamps = elements.length;
		for (var i=0; i < nbchamps ; i++) {
			if (bonTypeChamp(elements[i].type) >= 0) {
				//alert(elements[i].name + " est du type " + elements[i].type);
				if (elements[i].type.search("select") >= 0) { // liste de sélection
					chaine += "|LISTE" + elements[i].name + "=" + elements[i].selectedIndex;
				}
				else {
					if (elements[i].type.search("radio") >= 0) { // boutons radio
						var rang = 0;
						var elt = eval(elements[i].name);
						for (var j in elt) {
							if (elt[j].checked=="1") {
								rang = j;
							}
						}
						chaine += "|RADIO" + elements[i].name + "=" + rang;
					}
					else {
						if (elements[i].type.search("checkbox") >= 0) { // case à cocher
							if (elements[i].checked) {
								chaine += "|CASE" + elements[i].name + "=OUI";	
							}
						}
						else { // zone de texte
							chaine += "|" + elements[i].name + "=" + elements[i].value;
						}
					}
				}
			}
		}
	}
	parent.parent.menu.document.recherche.crits.value = chaine;
	//alert(parent.parent.menu.document.recherche.crits.value);
}

function init_formulaire() {
	if (parent.parent.menu.document.recherche.chargeinfos.value == "OUI") {
		criteresRecherche();
		parent.parent.menu.document.recherche.chargeinfos.value = "NON";
	}
	var stLoc = new String(top.droite.location);
	if (!stLoc.match(/videDroite\.html/))
	{
		top.droite.location = BIB + "videDroite.html";
	}
}

function ouvreAidePhotographies() {
	var Wmax = screen.width;
	var Hmax = screen.height;

	var iW = 500;
	var iH = 500;
	

	var optFen = "dependant=yes,scrollbars=yes,resizable=no,height="+iH+",width="+iW;
	var aide = open("aide/Photographies.html", "aidePhotographies", optFen);
}

function ouvreAideGravures() {
	var Wmax = screen.width;
	var Hmax = screen.height;

	var iW = 500;
	var iH = 500;
	

	var optFen = "dependant=yes,scrollbars=yes,resizable=no,height="+iH+",width="+iW;
	var aide = open("aide/Gravures.html", "aideGravures", optFen);
}

function ouvreAideAlbMaciet() {
	var Wmax = screen.width;
	var Hmax = screen.height;

	var iW = 500;
	var iH = 500;
	

	var optFen = "dependant=yes,scrollbars=yes,resizable=no,height="+iH+",width="+iW;
	var aide = open("aide/AlbMaciet.html", "aideAlbMaciet", optFen);
}

function ouvreAideCatVente() {
	var Wmax = screen.width;
	var Hmax = screen.height;

	var iW = 500;
	var iH = 500;
	

	var optFen = "dependant=yes,scrollbars=yes,resizable=no,height="+iH+",width="+iW;
	var aide = open("aide/catVente.html", "aideCatVente", optFen);
}

function ouvreAideMaciet() {
	var Wmax = screen.width;
	var Hmax = screen.height;

	var iW = 500;
	var iH = 500;
	

	var optFen = "dependant=yes,scrollbars=yes,resizable=no,height="+iH+",width="+iW;
	var aide = open("aide/maciet.html", "aideMaciet", optFen);
}

// FONCTIONS SERVANT A LA MISE EN VALEUR
// DES OPERATEURS DOCUMENTAIRES A L'INTERIEUR DES CHAMPS DE SAISIE
function init_evt() {
	NS4 = (window.document.layers) ? true : false;
	IE4 = (window.document.all) ? true : false;
	NS4MAC = NS4 && (navigator.appVersion.indexOf("Macintosh") > -1);

	active = false;
	style = 1;

	if (NS4) window.document.captureEvents(Event.KEYUP);
	window.document.onkeyup = checkKey;
}

function focusse() {
	active = true;
}

function blure() {
	active = false;
}

function checkKey(evt) {
	if (!active) return;
	//var msg = String.fromCharCode(evt.which);
	//alert(msg);

    //var form = document.saisie;
    var field = evt.target;
	//var field = form.mots;
	var mot = field.value;
	//alert(mot);
	
	var re = / ou /i;
    if (mot.match(re)) {
		mot = mot.replace(re, " [OU] ");
		field.value = mot;
		field.focus();
	}
}


// FONCTIONS SERVANT A GERER LA SELECTION DE PLUSIEURS NOTICES
// ET A LES VISUALISER
function selectNotice(num,etat) {
	chaine = document.selection.notices.value;
	if (etat){
		chaine += num+"/";
	}
	else {
		chaine = enleveNotice(num, chaine);
	}
	document.selection.notices.value = chaine;
}

function enleveNotice (n,c) {
	var re = /\d/;
	var aux = c;
	var trouve = 0;
	var pos = -1;

	while (!trouve) {
		pos = aux.indexOf(n, pos+1);
		var carAp = aux.charAt(pos+n.length); //caractère de la liste situé juste après la chaine cherchée
		//alert ("après "+carAp);
		if (carAp.match(re)) { //notice incluse dans une autre
			//alert("ce n'était pas la bonne notice");
			continue;
		}
		else { //bonne notice
			aux = c.substring(0, pos)+ c.substring(pos+n.length+1, c.length);
			c = aux;
			trouve = 1;
		}
	}

	return c;
}

function voirNotices (liste) {
	if (liste) {
		if (parent.Bib.document.selection.liens.value)
			parent.parent.droite.document.location = "/cgi-bin/visu_base.pl?" + liste;
		else
			parent.parent.droite.document.location = "/cgi-bin/visu.pl?" + liste;
	}
	else {
		alert("Aucune notice n'est sélectionnée !");
	}
}

function voirNotices_base (liste) {
	if (liste) {
		//alert(liste);
		parent.parent.droite.document.location = "/cgi-bin/visu_base.pl?" + liste;
	}
	else {
		alert("Aucune notice n'est sélectionnée !");
	}
}

function deselectionneTout () {
	parent.Bib.document.cases.reset();
	parent.Bib.document.selection.notices.value = '';
}

function selectionneTout () {
	with (parent.Bib.document.cases) {
		var nbchamps = elements.length;
		//alert(nbchamps);
		for (var i=0; i < nbchamps ; i++) {
			var ch = eval(elements[i]);
			if (!ch.checked) ch.click();
		}
	}
}

function MM_findObj(n, d) { //v3.0
	var p,i,x;
	if (!d) d=document;
	if ((p=n.indexOf("?"))>0 && parent.frames.length) {
	  d=parent.frames[n.substring(p+1)].document;
	  n=n.substring(0,p);
	}
	if(!(x=d[n])&&d.all) x=d.all[n];
	for (i=0;!x&&i<d.forms.length;i++) x=d.forms[i][n];
	for(i=0;!x&&d.layers&&i<d.layers.length;i++) x=MM_findObj(n,d.layers[i].document);
	
	return x;
}

function MM_swapImgRestore() { //v3.0
  var i,x,a=document.MM_sr; for(i=0;a&&i<a.length&&(x=a[i])&&x.oSrc;i++) x.src=x.oSrc;
}

function MM_swapImage() { //v3.0
  var i,j=0,x,a=MM_swapImage.arguments; document.MM_sr=new Array; for(i=0;i<(a.length-2);i+=3)
   if ((x=MM_findObj(a[i]))!=null){document.MM_sr[j++]=x; if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];}
}

function MM_preloadImages() { //v3.0
  var d=document; if(d.images){ if(!d.MM_p) d.MM_p=new Array();
    var i,j=d.MM_p.length,a=MM_preloadImages.arguments; for(i=0; i<a.length; i++)
    if (a[i].indexOf("#")!=0){ d.MM_p[j]=new Image; d.MM_p[j++].src=a[i];}}
}

//-->
