/* AUTEUR: Dje */
/* DATE DE CREATION: 13/11/2000 */



function MM_swapImgRestore() { 
  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_preloadImages() { 
  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];}}
}

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_swapImage() { 
  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_controlShockwave(objStr,x,cmdName,frameNum) {
 		var obj=MM_findObj(objStr);
  		if (obj) eval('obj.'+cmdName+'('+((cmdName=='GotoFrame')?frameNum:'')+')');
}
	

function OpenDetailsClient(ind)
{
	win2=window.open("administration31.asp?ind="+ind+"","Client","toolbar=no,location=no,directories=no,status=no,scrollbar=no,resizable=no,copyhistory=no, width=360, height=380")
	return false; 
}

function ReplaceURL(url)
{
	
	top.frames['principal'].document.location = url;
}
//Permet de basculer une option d'une liste dans une autre liste
/*
	objet1 : liste source
	objet2 : liste destination
	objet3 : champs caché de sélection

*/
function AddOptions(objet1,objet2,objet3)
	{
	var i=0;
	if (objet1.selectedIndex==-1 | objet1.selectedIndex==0)
		{
		alert("Veuillez sélectionner une information dans la liste !");
		return false;
		}
	else
		{
		for(i=0;i < objet2.options.length; i++)
		{
			if(objet1.value.substr(0, objet1.value.indexOf("#")) == objet2.options[i].value) 
			{return false;}
		}
		objet3.value  = objet3.value + objet1.value.substr(0, objet1.value.indexOf("#"));
		objet3.value  = objet3.value + "#";
		var o=new Option(objet1.value.substr(objet1.value.indexOf("#")+1, (objet1.value.length-objet1.value.indexOf("#"))),objet1.value.substr(0, objet1.value.indexOf("#")));
		objet2.options[objet2.options.length]=o;
		
		}
		
		return false;
	}	

function OpenWindow(file,names,heights,widths,objet)
{
	objetInsert = objet;
	win2=window.open(file,names,"toolbar=no,location=no,directories=no,status=no,scrollbar=no,resizable=no,copyhistory=no, width="+heights+", height="+widths+"");
	return win2; 
}
function OpenWindow1(file,names,heights,widths,objet)
{
	objetInsert = objet;
	win2=window.open(file,names,"toolbar=no,location=no,directories=no,status=no,scrollbars=1,resizable=no,copyhistory=no, width="+heights+", height="+widths+"");
	return win2; 
}

/*
	Permet de trier une liste
*/
function ChangeTri(file,value,value1)
{
	window.location.replace(file+"?get_tri="+value+"&get_theme="+value1);
}
/*
	Permet de changer un theme
*/
function ChangeTheme(file,value,value1)
{
	window.location.replace(file+"?get_theme="+value+"&get_tri="+value1);
}
/*
	fonction pour ordonné vers le haut
	l : objet représentant la liste
*/
function tjs_haut(l) {
	var indice=l.selectedIndex
	if (indice<0) {
		alert("Aucune ligne n'est sélectionnée");
	}
	if (indice>0) {	// Il reste une ligne au-dessus
		tjs_swap(l,indice,indice-1);
	}
}
/*
	fonction pour ordonné vers le bas
	l : objet représentant la liste
*/
function tjs_bas(l) {
	var indice=l.selectedIndex
	if (indice<0) {
		alert("Aucune ligne n'est sélectionnée");
	}
	if (indice<l.options.length-1) {	// Il reste une ligne en-dessous
		tjs_swap(l,indice,indice+1);
	}
}

function tjs_swap(l,i,j) {
	var valeur=l.options[i].value;
	var texte=l.options[i].text;
	l.options[i].value=l.options[j].value;
	l.options[i].text=l.options[j].text;
	l.options[j].value=valeur;
	l.options[j].text =texte;
	l.selectedIndex=j
	tjs_ordre(l.form);
}

function tjs_ordre(f) {
	var l=f.liste;
	var ordre="";
	for(var i=0;i<l.options.length;i++) {
		if (i>0) {ordre+="-";}
		ordre+=l.options[i].value;		
	}
	f.ordre.value=ordre;
}
/*Gestion de l'affichage des calques*/

function swap_couche(couche,historique){
	triangle = MM_findObj('triangle' + couche);
	triangleHisto = MM_findObj('triangle' + histo);
	//alert(couche);
	// arrete le script si il ne trouve pas le calque passé en param grace à "couche"
	if (!(layer = MM_findObj('Layer' + couche))) return;
	// --
	if (historique != false && histo != couche && (layerHisto = MM_findObj('Layer' + histo))){
		if (triangleHisto) triangleHisto.src = 'Images/menu_gauche/ccbvc_'+histo+'_off.gif';
			layerHisto.style.display = 'none';
			vis[histo] = 'hide';
	}
	//alert(vis[couche]);
	if (vis[couche] == 'hide'){
		if (triangle) triangle.src = 'Images/menu_gauche/ccbvc_'+couche+'_on.gif';
		layer.style.display = 'block';
		vis[couche] = 'show';
	} else {
		if (triangle) triangle.src = 'Images/menu_gauche/ccbvc_'+couche+'_off.gif';
		layer.style.display = 'none';
		vis[couche] = 'hide';
	}
	histo = couche;
}

/*Fonction de date*/

function fait_Array(n) {
  this.length = n;
  return this;
}

aMois = new fait_Array(12);
aMois[1] = "janvier";
aMois[2] = "février";
aMois[3] = "mars";
aMois[4] = "avril";
aMois[5] = "mai";
aMois[6] = "juin";
aMois[7] = "juillet";
aMois[8] = "août";
aMois[9] = "septembre";
aMois[10] = "octobre";
aMois[11] = "novembre";
aMois[12] = "décembre";

aJours = new fait_Array(7);
aJours[1] = "Dimanche";
aJours[2] = "Lundi";
aJours[3] = "Mardi";
aJours[4] = "Mercredi";
aJours[5] = "Jeudi";
aJours[6] = "Vendredi";
aJours[7] = "Samedi";

function date_long(nDate) {
  var nEr = nDate.getDate();
  if (nEr == 1) nEr += "er";
  var nJour = aJours[nDate.getDay() + 1];
  var nMois = aMois[nDate.getMonth() + 1];
  var nAnnee = nDate.getYear();
  if (nAnnee < 100) nAnnee += 2000;
  if (nAnnee > 100&&nAnnee < 2000) nAnnee += 1900;
  return nJour + " " + nEr + " " + nMois + " " + nAnnee;
}

//Gestion calques
compteur=1;
function drop(ind) {
	clearTimeout(compteur);
	themes(ind);

	
}
function dropoff(ind) {
	if (ind == "1"){nothemes();}
	if (ind == "2"){noorgs();}
	if (ind == "3"){notrav();}
}
function themes(ind){  
	if(document.getElementById){
		if (ind == "1")
		{var elt=document.getElementById("menucomm");
		elt.style.display = "block";}
		if (ind == "2")
		{var elt=document.getElementById("menuorg");
		elt.style.display = "block";}
		if (ind == "3")
		{var elt=document.getElementById("menutra");
		elt.style.display = "block";}
	}
}

function nothemes(){  
	if(document.getElementById){
		var elt=document.getElementById("menucomm");
		elt.style.display = "none";
	}
}
function noorgs(){  
	if(document.getElementById){
		var elt=document.getElementById("menuorg");
		elt.style.display = "none";
	}
}
function notrav(){  
	if(document.getElementById){
		var elt=document.getElementById("menutra");
		elt.style.display = "none";
	}
}

nereidFadeObjects = new Object();
nereidFadeTimers = new Object();

/* object - image to be faded (actual object, not name);
 * destop - destination transparency level (ie 80, for mostly solid)
 * rate   - time in milliseconds between trasparency changes (best under 100)
 * delta  - amount of change each time (ie 5, for 5% change in transparency)
 */

function nereidFade(object, destOp, rate, delta){
if (!document.all)
return
    if (object != "[object]"){  //do this so I can take a string too
        setTimeout("nereidFade("+object+","+destOp+","+rate+","+delta+")",0);
        return;
    }
    clearTimeout(nereidFadeTimers[object.sourceIndex]);
    
    diff = destOp-object.filters.alpha.opacity;
    direction = 1;
    if (object.filters.alpha.opacity > destOp){
        direction = -1;
    }
    delta=Math.min(direction*diff,delta);
    object.filters.alpha.opacity+=direction*delta;

    if (object.filters.alpha.opacity != destOp){
        nereidFadeObjects[object.sourceIndex]=object;
        nereidFadeTimers[object.sourceIndex]=setTimeout("nereidFade(nereidFadeObjects["+object.sourceIndex+"],"+destOp+","+rate+","+delta+")",rate);
    }
}

