<!--

var SousMenus=new Array();

SousMenus[0]='federation';
SousMenus[1]='syndicat';
SousMenus[2]='transmission';
SousMenus[3]='charte';
SousMenus[4]='signes';
SousMenus[5]='formation';
SousMenus[6]='partenaires';
function in_array(needle,haystack){
	for(u=0;u<haystack.length;u++){
		if(haystack[u]==needle) return true;
	}
	return false;
}

function ShowMenu(which){
		if(in_array(which,SousMenus)){
			for(i=0;i<SousMenus.length;i++){
				if(SousMenus[i]!=which) MM_showHideLayers('SousMenu_'+SousMenus[i],'','hide');
			}
			document.getElementById('SousMenu_'+which).style.left=document.getElementById('SousMenuCommun').style.left;
			document.getElementById('SousMenu_'+which).style.top=document.getElementById('SousMenuCommun').style.top;
			MM_showHideLayers('SousMenu_'+which,'','show');
		}
}









function deleteOption(object,index) {
    object.options[index] = null;
}

function addOption(object,text,value) {
    var defaultSelected = false;
    var selected = false;
    var optionName = new Option(text, value, defaultSelected, selected)
    object.options[object.length] = optionName;
    object.options[object.length-1].selected = false;
    
}

function sortOptions(what,how) {
    var copyOption = new Array();
    for (var i=0;i<what.options.length;i++)
        copyOption[i] = new Array(what[i].value,what[i].text);
	if(how=='valeur'){
	    copyOption.sort(function(a,b) { return a[0]-b[0]; });
	}
	else{
	    copyOption.sort(function(a,b) { return a[1]-b[1]; });
	}
    for (var i=what.options.length-1;i>-1;i--)
        deleteOption(what,i);

    for (var i=0;i<copyOption.length;i++)
        addOption(what,copyOption[i][1],copyOption[i][0])
}

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 checkDate(myDayStr,myMonthStr,myYearStr) {
 
months=new Array;
months['01']='Jan';
months['02']='Feb';
months['03']='Mar';
months['04']='Apr';
months['05']='May';
months['06']='Jun';
months['07']='Jul';
months['08']='Aug';
months['09']='Sep';
months['10']='Oct';
months['11']='Nov';
months['12']='Dec';
if(months[myMonthStr]) {
//if(myDayStr.charAt('0')==0) myDayStr=myDayStr.substring(1);
var myDateStr = myDayStr + ' ' + months[myMonthStr] + ' ' + myYearStr + ' ' +'12:00:00';

/* Using form values, create a new date object
which looks like "Wed Jan 1 00:00:00 EST 1975". */
var myDate = new Date( myDateStr );
// Convert the date to a string so we can parse it.
var myDate_string = myDate.toGMTString();

/* Split the string at every space and put the values into an array so,
using the previous example, the first element in the array is "Wed", the
second element is "Jan", the third element is "1", etc. */
var myDate_array = myDate_string.split( ' ' );

/* If we entered "Feb 31, 1975" in the form, the "new Date()" function
converts the value to "Mar 3, 1975". Therefore, we compare the month
in the array with the month we entered into the form. If they match,
then the date is valid, otherwise, the date is NOT valid. */
if ( myDate_array[2] != months[myMonthStr] ) {
  return false;
} else {
  return true;
}
}
else return false;
}
 

function echeck(str) { 
		var at="@"
		var dot="."
		var lat=str.indexOf(at)
		var lstr=str.length
		var ldot=str.indexOf(dot)
		if (str.indexOf(at)==-1){
		   return false
		}

		if (str.indexOf(at)==-1 || str.indexOf(at)==0 || str.indexOf(at)==lstr){
		   return false
		}

		if (str.indexOf(dot)==-1 || str.indexOf(dot)==0 || str.indexOf(dot)==lstr){
		    return false
		}

		 if (str.indexOf(at,(lat+1))!=-1){
		    return false
		 }

		 if (str.substring(lat-1,lat)==dot || str.substring(lat+1,lat+2)==dot){
		    return false
		 }

		 if (str.indexOf(dot,(lat+2))==-1){
		    return false
		 }
		
		 if (str.indexOf(" ")!=-1){
		    return false
		 }

 		 return true					
	}

function MM_validateForm() { //v5.0
  var i,p,q,nm,pswd,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]); 
	val2=MM_findObj(args[i+1]);
    if (val) { 
		nm=val.name; 
		if ((val=val.value)!="") {
			if (test.indexOf('isEmail')!=-1) { 
				if (!echeck(val)) errors+='- Le champ '+nm+' doit contenir une adresse e-mail correcte.\n';
      		} 
			else if (test.indexOf('same') != -1 && val2) {
				if (val2.value=="") errors += '- Le champ '+val2.name+' est obligatoire.\n'; 
				else if (val2.value!=val) errors += '- Les champs '+nm+' et '+val2.name+' doivent être identiques.\n'; 
			}
			else if (test.indexOf('dateF') != -1){
				 myarraydate=val.split("/");
				 thisDate=new Date();
				 if(myarraydate.length!=3 || isNaN(myarraydate[0]) || isNaN(myarraydate[1]) || isNaN(myarraydate[2]) || myarraydate[2].length!=4 || !checkDate(myarraydate[0],myarraydate[1],myarraydate[2])) errors += '- Le champ '+nm+' doit contenir une date valide au format JJ/MM/AAAA.\n'; 
			}
			else if (test.indexOf('dateE') != -1){
				 myarraydate=val.split("/");
				 thisDate=new Date();
				 if(myarraydate.length!=3 || isNaN(myarraydate[0]) || isNaN(myarraydate[1]) || isNaN(myarraydate[2]) || myarraydate[0].length!=4 || !checkDate(myarraydate[2],myarraydate[1],myarraydate[0])) errors += '- Le champ '+nm+' doit contenir une date valide au format AAAA/MM/JJ.\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(test.indexOf('mini') != -1 ){
				if(val.length<test.substring(test.indexOf('mini')+4)) errors+='- Le champ '+nm+' doit contenir au moins '+test.substring(test.indexOf('mini')+4)+' caractères.\n';
			}
		}
		else if (val2 && test.charAt(0) == 'R' && test.indexOf('same') != -1) {
			if(val=="" && val2.value=="") errors += '- Les champs '+nm+' et '+val2.name+' sont obligatoires.\n'; 
			else if (val=="") errors += '- Le champ '+nm+' est obligatoire.\n'; 
			if(!(val=="" && val2.value=="")&&test.indexOf('mini') != -1 ){
				if(val2.value.length<test.substring(test.indexOf('mini')+4)) errors+='- Le champ '+val2.name+' doit contenir au moins '+test.substring(test.indexOf('mini')+4)+' caractères.\n';
			}
		}
		else if (val2&&val2.value=="" && test.charAt(0) == 'R') errors += '- L\'un des champs '+nm+' et '+val2.name+' est obligatoire.\n'; 
		else if (!val2 && 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 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=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 Deplacer_Simple(listfrom,listto,type,sens,withmenu) {
                if (listfrom.options.selectedIndex>=0)
                        {
                        for(var i=0; i<listfrom.options.length; i++)
                                {
                                if (listfrom.options[i].value=='')
                                        {
                                        }
                                else
                                        {
                                        if(listfrom.options[i].selected && listfrom.options[i].value != "")
                                                {
										if(type=='select') {
													var no = new Option();
													no.value = listfrom.options[i].value;
													no.text = listfrom.options[i].text;
													if(sens==1){
														no.selected=true;
													}
													listto.options[listto.options.length] = no;
													listfrom.options[i]=null;
												}
												else if(type=='texte') {
													if(withmenu=='') listto.value=listfrom.options[i].value;
													else {
														mymenu=eval(withmenu);
														listto.value=mymenu[listfrom.options[i].value].rID;
													}
												}
                                                }
                                        }
                                }
                        }
                else
                        {
                        alert("Aucune sélection");
                        }
 }
 
 function MM_showHideLayers() { //v6.0
  var i,p,v,obj,args=MM_showHideLayers.arguments;
  for (i=0; i<(args.length-2); i+=3) if ((obj=MM_findObj(args[i]))!=null) { v=args[i+2];
    if (obj.style) { obj=obj.style; v=(v=='show')?'visible':(v=='hide')?'hidden':v; }
    obj.visibility=v; }
}

function DeplacerFromTo(listfrom,listto,sens) {
                if (listfrom.options.selectedIndex>=0)
                        {
                        for(var i=0; i<listfrom.options.length; i++)
                                {
                                if (listfrom.options[i].value=='')
                                        {
                                        }
                                else
                                        {
                                        if(listfrom.options[i].selected && listfrom.options[i].value != "")
                                                {
                                                var no = new Option();
                                                no.value = listfrom.options[i].value;
												no.text = listfrom.options[i].text;
												if(sens==1){
													no.selected=true;
												}
                                                listto.options[listto.options.length] = no;
												listfrom.options[i]=null;
                                                }
                                        }
                                }
                        }
                else
                        {
                        alert("Aucune sélection");
                        }
 }
 
function RealPopupPic(titre,sPicURL) {
 				var cmptitre;
				if(titre!='') {
					cmptitre = "&titre="+titre;
				}
				window.open("/Library/realpopup.php?img="+sPicURL+cmptitre, "", "resizable=1,LEFT=200,TOP=100,HEIGHT=150,WIDTH=200");
			}
	
function PopupPage(URL) {
				window.open(URL,"","resizable=1,LEFT=50,TOP=50,scrollbars=1,HEIGHT=640,WIDTH=645");
			}
		
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_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;
}
