//<!--


function MM_findObj(n, d) { //v4.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);
  if(!x && document.getElementById) x=document.getElementById(n); return x;
}

function MM_validateForm() { //v4.0
  var i,p,q,nm,test,num,min,max,errors='',args=MM_validateForm.arguments;
  for (i=0; i<(args.length-2); i+=3) { test=args[i+2]; val=MM_findObj(args[i]);
    if (val) { nm=val.name; if ((val=val.value)!="") {
      if (test.indexOf('isEmail')!=-1) { p=val.indexOf('@');
        if (p<1 || p==(val.length-1)) errors+='- Le champ '+nm+' doit contenir une adresse e-mail correcte.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- Le champ '+nm+' doit contenir un nombre.\n';
        if (test.indexOf('inRange') != -1) { p=test.indexOf(':');
          min=test.substring(8,p); max=test.substring(p+1);
          if (val<min || max<val) errors+='- Le champ '+nm+' doit être un nombre entre '+min+' et '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- Le champ '+nm+' est obligatoire.\n'; }
  } if (errors) alert('Les erreurs suivantes sont apparues :\n\n'+errors);
  document.MM_returnValue = (errors == '');
}

function MM_validateFormR1() { //v5.0
  var i,p,q,nm,pswd,test,num,min,max,errors='',args=MM_validateFormR1.arguments;
  for (i=0; i<(args.length-2); i+=3) { 
  	test=args[i+2]; 
	val=MM_findObj(args[i]); 
	val2=MM_findObj(args[i+1]);
    if (val) { 
		nm=val.name; 
		if (val2 && val) {
			if ((val2.value=="" && val.value=="") && (test.charAt(0) == 'R')) errors += '- L\'un des champs '+nm+' et '+val2.name+' est obligatoire.\n'; 
		}
		else if ((val=val.value)!="") {
			if (test.indexOf('isEmail')!=-1) { 
				p=val.indexOf('@');
				if (p<1 || p==(val.length-1)) errors+='- Le champ '+nm+' doit contenir une adresse e-mail correcte.\n';
      		} 
			else if (test!='R') {
        		if (isNaN(val)) errors+='- Le champ '+nm+' doit contenir un nombre.\n';
        		if (test.indexOf('inRange') != -1) { 
					p=test.indexOf(':');
          			min=test.substring(8,p);
					max=test.substring(p+1);
          			if (val<min || max<val) errors+='- Le champ '+nm+' doit être un nombre entre '+min+' et '+max+'.\n';
    			}
			}
			/*if (pswd != "" && val==pswd) {
				errors+='Le champ '+nm+' est invalide.\n'
			} */
		}
		else if (test.charAt(0) == 'R') errors += '- Le champ '+nm+' est obligatoire.\n'; 
	}
  } 
  if (errors) alert('Les erreurs suivantes sont apparues :\n\n'+errors);
  document.MM_returnValue = (errors == '');
}


function MM_reloadPage(init) {  //reloads the window if Nav4 resized
  if (init==true) with (navigator) {if ((appName=="Netscape")&&(parseInt(appVersion)==4)) {
    document.MM_pgW=innerWidth; document.MM_pgH=innerHeight; onresize=MM_reloadPage; }}
  else if (innerWidth!=document.MM_pgW || innerHeight!=document.MM_pgH) location.reload();
}
MM_reloadPage(true);

function MM_goToURL() { //v3.0
  var i, args=MM_goToURL.arguments; document.MM_returnValue = false;
  for (i=0; i<(args.length-1); i+=2) eval(args[i]+".location='"+args[i+1]+"'");
}

function CreerMenu(profondeur,titre1,titre2,titre3,titre4,target) {
        this.nb=0;this.prof=profondeur;
        this.titre1=titre1; this.titre2=titre2; this.titre3=titre3; this.titre4=titre4; this.target=target
        this.Add=AddObjet;
        this.Aff1=AffMenu1;
        this.Aff2=AffMenu2;
        this.Aff3=AffMenu3;
}
function AddObjet(deep,txt,page,rID) {
        var rub = new Object;
        rub.deep=deep;
        rub.txt=txt;
        rub.page=page;
		rub.rID=rID
        this[this.nb]=rub;
        this.nb++;
}

// Affiche le premier select
function AffMenu1() {
        var Z="<OPTION selected>"+this.titre1+"</OPTION>";
        for (var i=0;i<this.nb;i++) {
                if (this[i].deep==1) {
                        Z+="<OPTION value='"+i+"'>"+this[i].txt+"</OPTION>"
                }
        }
        document.write(Z);
}

// Affiche le second select
function AffMenu2() {
        var Z="<OPTION>"+eval("menu.titre2")+"</OPTION><OPTION></OPTION><OPTION></OPTION><OPTION></OPTION><OPTION></OPTION><OPTION></OPTION>";
        document.write(Z);
}

// Affiche le troisième select
function AffMenu3() {
        var Z="<OPTION>"+eval("menu.titre3")+"</OPTION><OPTION></OPTION><OPTION></OPTION><OPTION></OPTION><OPTION></OPTION><OPTION></OPTION>";
        document.write(Z);
}

function add() {
        var c=new Option("ADD","",true,true);
        document.forms[0].elements["list"].options[0]=c;
}
function Clic(no) {
        var valeur=document.forms["mf"].elements["list"+no].options[ document.forms["mf"].elements["list"+no].selectedIndex].value;
		if ((valeur!="")&&(valeur!=null)&&(no<menu.prof)) {
                var deep=menu[valeur].deep;
                var no2=1;
                for (var noX=(no+1);noX<=menu.prof;noX++) {
                        document.forms["mf"].elements["list"+eval(noX)].options.length=0;
                        var titre=eval("menu.titre"+noX);
                        var c=new Option(titre);
                        document.forms["mf"].elements["list"+(noX)].options[0]=c;
                        document.forms["mf"].elements["list"+(noX)].selectedIndex=0;
                }
                valeur++;
                for (var i=valeur;i<menu.nb;i++) {
                        //alert(i);
                        if (menu[i].deep==deep+1) {
                                //alert("no="+no+" texte="+menu[i].txt);
                                var c=new Option(menu[i].txt,i);
                                document.forms["mf"].elements["list"+(no+1)].options[no2]=c;
                                no2++;
                        } else { if (menu[i].deep==deep){i=menu.nb;}}
                }
                document.forms["mf"].elements["list"+(no+1)].options.length=no2+1;
                document.forms["mf"].elements["list"+(no+1)].selectedIndex=0;
                Clic(no+1)
                valeur--;
        }
        if ((valeur!="")&&(valeur!=null)) {
                var page=menu[valeur].page;
                if ((page!="")&&(page!=null)) {
                        if (menu.target=="self") {window.location=page}
                        else if (menu.target=="_blank") {window.open(page,"","menubar,scrollbars,toolbar,status,location")}
                        else {parent.frames[menu.target].location.href=page;}
                }
        }
}
// Fonctions destinées à afficher l'arborescence du menu
function space(i) {var Z="";for (var j=0;j<i;j++){Z+="&nbsp;&nbsp;&nbsp;&nbsp;";}return Z}
function Arbo(m) {
        var Z="<BR>";
        for (var i=0;i<m.nb;i++) {
                Z+=space(m[i].deep)+m[i].txt+"&nbsp;&nbsp; <A href='"+m[i].page+"'>"+m[i].page+"</A><BR>"
        }
        document.write(Z);
}

// Fonction qui affiche tous éléments sélectionnés
function Affichetout(l)
        {
        var listecomplete="";
        if (l.options.length!=0)
                {
                for(var i=0; i<l.options.length; i++)
                                {
                                if(l.options[i].value != "")
                                        {
										tmpr1=l.options[i].value;
										if (tmpr1.substring(0,3) !="org") {
											listecomplete=listecomplete+tmpr1;
										}
										else {
											listecomplete=listecomplete+tmpr1.substring(3,tmpr1.length)
										}
                                        if(i!=l.options.length-1)         listecomplete=listecomplete+",";
                                        }
                                }
                document.mf.listef.value=listecomplete;
                }
        else
                {
                alert("Vous devez sélectionner au moins un poste");
                }
        }

// Fonction qui permet le transfert ou le retrait d'une liste à l'autre
function Deplacer(l1,l2,l3,lresult,sens,stock)
        {
        if (sens==1)
                {
                if (l3.options.selectedIndex>=0)
                        {
                        var metier=l1.options[l1.options.selectedIndex].text;
                        var competence=l2.options[l2.options.selectedIndex].text;
                        for(var i=0; i<l3.options.length; i++)
                                {
                                if (l3.options[i].value==0)
                                        {
                                        }
                                else
                                        {
                                        if(l3.options[i].selected && l3.options[i].value != "")
                                                {
                                                var no = new Option();
                                                no.value = l3.options[i].value;
                                                stock.value=stock.value+menu[l3.options[i].value].rID;
                                                stock.value=stock.value+",";
                                                no.text = metier+" / "+competence+" / "+l3.options[i].text;
                                                lresult.options[lresult.options.length] = no;
                                                }
                                        }
                                }
                        }
                else
                        {
                        alert("Aucune catégorie sélectionnée.");
                        }
                }
        else
                {
                if (lresult.options.selectedIndex>=0)
                        {
                        for(var i=0; i<lresult.options.length; i++)
                                {
                                if(lresult.options[i].selected && lresult.options[i].value != "")
                                        {
										var r1val=lresult.options[i].value;

										if (r1val.substring(0,3) !='org') {
                                        stock.value=stock.value+menu[lresult.options[i].value].rID;
										}
										else {
										stock.value=stock.value+r1val.substring(3,r1val.length);
										}
                                        stock.value=stock.value+",";
                                        lresult.options[i]=null;
                                        }
                                }
                        }
                else
                        {
                        alert("Aucune catégorie sélectionnée.");
                        }
                }
        }


function popup(page) 
{
	window.open(page,'popup','width=270,height=200,toolbar=false,scrollbars=false');	
}
function kill() {
	window.open("/navigation/Javascript/kill.html",'popup','width=270,height=200,toolbar=false,scrollbars=false');
}

//-->