
function changeTousDisplay ()
	{	
	var args = changeTousDisplay.arguments;
	for (i=2;i<args.length;i++)
		{
		if (args[0]=="inverse") {changeDisplay (args[i])}
		else {changeDisplayVal (args[i], args[0])}
		}
	}

function changeDisplayVal (idpave, val)
	{
	changeF(idpave, val);
	valeurDisplay = eval("document.forms[0].Display_"+idpave);	
	valeurDisplay.value = val
	imgpave = eval("document.forms[0].apave_"+idpave);	
	if (valeurDisplay.value == "none"){imgpave.src = "design/apave2.gif"}
	else {imgpave.src = "design/apave.gif"}
	}


function changeDisplay (idpave)
	{
	change(idpave);
	valeurDisplay = eval("document.forms[0].Display_"+idpave);
	valeurDisplay.value = document.getElementById(idpave).style.display;		
	imgpave = document.getElementById("apave_"+idpave)
	if (valeurDisplay.value == "none") {imgpave.src = "design/apave2.gif"}
	else {imgpave.src = "design/apave.gif"}
	}

//Affichage ou non des sous-éléments
function changeF(id, val)
	{
	var testId = document.getElementById(id)
	if (testId)	{document.getElementById(id).style.display = val}
	}


//Affichage ou non des sous-éléments
function change(id)
	{
	var testId = document.getElementById(id)
	if (testId)	
		{
		if (testId.style.display == 'block') {testId.style.display = 'none';}
		else {testId.style.display = 'block';}
		}
	}

function Remplace(expr,a,b) 
	{
	var i=0
	while (i!=-1) 
		{
		i=expr.indexOf(a,i)
		if (i>=0) 
			{
			expr=expr.substring(0,i)+b+expr.substring(i+a.length)
			i+=b.length
			}
		}
	return expr
	}

function replaceA (originalString,searchText,replaceText) 
	{ 
	var strLength = originalString.length
	var txtLength = searchText.length
	if ((strLength == 0) || (txtLength == 0)) {return originalString} 
	var i = originalString.indexOf(searchText)
	if ((!i) && (searchText != originalString.substring(0,txtLength))) {return originalString} 
	if (i == -1) {return originalString} 
	var newstr = originalString.substring(0,i) + replaceText;
	if (i+txtLength < strLength) {newstr += replaceA(originalString.substring(i+txtLength,strLength),searchText,replaceText)} 
	return newstr
	} 

//ouvre le champ memo en ff
function OuvreMemo(nomchamp, css, t)
	{
	src = "htmledit/default.Asp?t="+t+"&nomchamp=" + nomchamp + "&css=" + css
	size=",width=660,height=500"
	browser=window.open(src,'memo',"resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no,location=0,directories=no"+size)
	}

//------------------------------------------------------------------------------ Syb XHTMLEdit
//ouvre le champ memo en ff
function OuvreXMemo(nomchamp, css, t)
	{
	var _info = navigator.userAgent;
	
	if (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0) {_nav="IE"}
	if (_info.indexOf("Gecko") > 0 && _info.indexOf("Safari") < 0) {_nav="NS"}
	if (_info.indexOf("Mac") > 0) {_nav="MAC"}
	
	src = "XHTMLEdit/editor_" + _nav + ".asp?t="+t+"&nomchamp=" + nomchamp + "&css=" + css + "&uploadBaseDirectory=upload" + "&uploadSubDirectory=pagesEdito"
	switch (t)
		{
		case 1:
			size=",width=400,height=250"
			break;
		case 2:
			size=",width=400,height=250"
			break;
		case 3:
			size=",width=750,height=600"
			break;
		}
	browser=window.open(src,'memo',"resizable=yes,scrollbars=no,toolbar=no,status=no,menubar=no,location=no,directories=no"+size)
	}

//retourne l'index dans un selectbox d'une valeur passé en parametre
function indexselectbox (obj,valeur)
	{
	var windexchecked = -1;
	
	for(i=0;i<obj.length;i++)
		{
		if (obj.options[i].value == valeur)
			{
			windexchecked = i;
			break;
			}
		}
	return windexchecked;
	}

//function altselect (texte) {if (texte != 'Tous') return overlib(texte,FGCOLOR,'#ECECF0',BGCOLOR,'#AAAAAA',WIDTH,200,OFFSETX,10,OFFSETY,10)}

function AltImgAgrandir (obj)
	{
	var mystr = obj.src.toString();
	if (mystr.indexOf("Agrandir.gif")==-1) {return overlib('Cacher la zone',FGCOLOR,'#ECECF0',BGCOLOR,'#AAAAAA',WIDTH,100, OFFSETY, 20)}
	else {return overlib('Agrandir la zone',FGCOLOR,'#ECECF0',BGCOLOR,'#AAAAAA',WIDTH,100, OFFSETY, 20)}
	}

function changeImgAgrandir (obj)
	{
	nd();
	AltImgAgrandir (obj);
	var mystr = obj.src.toString();
	if (mystr.indexOf("Agrandir.gif")==-1) {obj.src = "design/Agrandir.gif"}
	else {obj.src = "design/Diminuer.gif"}
	}

//selectionne une element passé en parametre dans une selectbox
function selectionneselectbox (obj,valeur)
	{
	var i = indexselectbox (obj,valeur)
	obj[i].selected = true;
	}

//retourne l'index dans un selectbox d'une valeur passé en parametre
function indexselectbox (obj,valeur)
	{
	var windexchecked = -1;
	for(i=0;i<obj.length;i++)
		{
		if (obj.options[i].value == valeur)
			{
			windexchecked = i;
			break;
			}
		}
	return windexchecked
	}

function indexchecked(obj)
	{
	var windexchecked = -1
	if (typeof(obj.length) == 'undefined')
		{if (obj.checked) {windexchecked = 0}}
	else
		{
		for(i=0;i<obj.length;i++)
			{
			if (obj[i].checked == true)
				{
				windexchecked = i;
				break;
				}
			}
		}	
	return windexchecked
	}

function valuechecked(obj)
	{
	var wvaluechecked = ""
	if (typeof(obj.length) == "undefined") {if (obj.checked) {wvaluechecked = obj.value}}
	else
		{
		for(i=0;i<obj.length;i++)
			{
			if (obj[i].checked == true)
				{
				wvaluechecked = obj[i].value;		
				break;
				}
			}
		}
	return wvaluechecked
	}
	
function SupprimeFichier (nomchamp, tp, calcul, champbalise)
	{
	var champpoids = "poids" + nomchamp;
	var champwidth = "largeur" + nomchamp;
	var champheight = "hauteur" + nomchamp;	

	eval ("document.formulaire." + nomchamp + ".value = ''");
	eval ("ProprietesImage_" + nomchamp + ".document.open()");
	eval ("ProprietesImage_" + nomchamp + ".document.write('')");
	eval ("ProprietesImage_" + nomchamp + ".document.close()");
	
	if (tp=="img")
		{
		var photogauche = nomchamp + "I";
		eval("document.formulaire."+photogauche+".src='design/blank.gif'"); 
		if (calcul=="1")
			{
			eval ("document.formulaire." + champpoids + ".value=''");	
			eval ("document.formulaire." + champwidth + ".value=''");	
			eval ("document.formulaire." + champheight + ".value=''");				
			}
		eval ("document.getElementById('TDModImage_" + nomchamp + "').style.display = 'none'");						
		}
	if (calcul=="1" && tp !="img") {eval ("document.formulaire." + champpoids + ".value=''")}

	if (champbalise!="") {eval ("document.formulaire." + champbalise + ".value=''")}
		
	eval ("document.getElementById('TDProprietesImage_" + nomchamp + "').style.display = 'none'");		
	eval ("document.getElementById('TDSupprimeImage_" + nomchamp + "').style.display = 'none'");		
	eval ("document.getElementById('TDVoirImage_" + nomchamp + "').style.display = 'none'");				
	}




	//***************************************************************	
	//        Fenetre fille de modification d'image				   	*
	//***************************************************************	
	function ModPhoto(id, nomc)
	{
			valeur = eval("document.forms[0]." + nomc + ".value")
			if (valeur != '')
			{
				//URLI = "ASPjpeg/progress.asp?calcul="+calcul+"&tp=img&nomchamp="+nomc+"&repertoire="+rep+"&valeur=" + valeur
				URLI = "ASPjpeg2/default.asp?" + JavaScriptURLEncode(id) + "&image=" + JavaScriptURLEncode(valeur);
				new_browser3(URLI,'ajout',440,450)
			}
	}	
	//***************************************************************			


	//*******************************************************************	
	//   fonction permettant d'ouvrir une fenetre fille retaillable    	*
	//*******************************************************************	
	function new_browser(src,name,w,h)
	{
		size=",width="+w+",height="+h
		browser=window.open(src,name,"resizable=yes,scrollbars=yes,toolbar=no,status=no,menubar=no,location=0,directories=no"+size)
	}
	
	//********************************************************************	
	//   fonction permettant d'ouvrir une fenetre fille de taille fixe   *
	//********************************************************************		
	function new_browser3(src,name,w,h)
	{
		size=",width="+w+",height="+h
		browser=window.open(src,name,"resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no,location=0,directories=no"+size)
	}	
	
	
	
	//***************************************************************
	// 			lien ff vers fichier proposé en téléchargement		*
	//***************************************************************
	function fenetrefichier (monimage,repimages)
	{					
		monURL = JavaScriptURLEncode(repimages+"/") + eval ("document.formulaire."+monimage+".value")		
		recupphoto = eval("window.document.formulaire." + monimage + ".value")
		if (recupphoto != "")
		{		
			browser=window.open(monURL,'fichier',"resizable=yes,scrollbars=yes,toolbar=no,status=no,menubar=no,location=0,directories=no,width=640,height=480")
		}
	}
			
	//***************************************************************
	// 		visualisation d'une photo en ff							*
	//***************************************************************
	function fenetrephoto (monimage,repimages, wi, he)
	{					
		if (monimage!='')
		{
			chemimage = repimages +	"/" + monimage;
			size=",width="+wi+",height="+he;
			monURL = "visualisation.asp?image=" + JavaScriptURLEncode(chemimage);
			browser=window.open(monURL,'zoom',"resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no,location=0,directories=no"+size)
		}
	}		
	
	
	//***************************************************************
	// 		visualisation d'une photo en ff							*
	//***************************************************************
	function fenetrephoto2 (monimage,repimages)
	{					
		chemimage = repimages +	"/" + eval ("document.formulaireff."+monimage+".value")		
		recupphoto = eval("document.formulaireff." + monimage + ".value")
		if (recupphoto != "")
		{		
			// création de l'Objet image
			var Objimage;		
			Objimage = new Image()				
			// initialisation
			Objimage.src = chemimage
			// recup des infos
			wi = Objimage.width 
			he = Objimage.height		
			if (wi == 20)
			{
				wi = 320
				he = 200
			}			
			delete Objimage	
			
			size=",width="+wi+",height="+he	
			monURL = "visualisation.asp?image=" + JavaScriptURLEncode(chemimage)
			browser=window.open(monURL,'zoom',"resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no,location=0,directories=no"+size)
		}
	}	
	
	function fenetrephoto3 (repimages, lo, ha, nomimage,titre,id)
	{	
		var ha = new Number(ha);
		ha2=ha+50
		browser=window.open("visualisation3.asp?titre="+titre+"&image="+repimages+"&nomimage="+id,nomimage,"resizable=no,scrollbars=auto,toolbar=no,status=no,menubar=no,location=0,directories=no,width="+lo+",height="+ha2)
	}
	
	//Encode les caracteres spéciaux en JS pour passé une URL correctement
	//necessairre car encode coté ASP puis passé texte a fonction JS --> encodage detruit...
	function JavaScriptURLEncode (URL)
	{
		var wURL = URL;
		wURL = replaceA (wURL,".","%2E"); 	
		wURL = replaceA (wURL,"/","%2F");
		return wURL;
	}
	
	
	
	//***************************************************************
	//   	permet de changer a couleur d'une cellule d'un tableau  *
	//***************************************************************	
	var docObj = (document.all) ? "document.all." : "document.";	
	
	function chgColor(rowNum,Color) 
	{
	   	thisRow = eval(docObj + rowNum)
	    thisRow.bgColor = Color;
	}	
	
	
	
	