﻿//ouvre 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)
}


//ouvre 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)
}	


//ouvre une photo dans une fenetre fille à la taille de la photo
function fenetrephoto2 (repimages, lo, ha, nomimage,id)
{	
	browser=window.open("visualisation.asp?image="+repimages+"&id="+id, nomimage,"resizable=no,scrollbars=auto,toolbar=no,status=no,menubar=no,location=0,directories=no,width="+lo+",height="+ha)
}


// Mise a jour des listes via XMLHttpRequest
function listeAJAX (valeur, script, mform, mselect,mValeurDefault,mvaleur) 
{
	var xhr_object1 = null;   
    if(window.XMLHttpRequest) xhr_object1 = new XMLHttpRequest();   // Firefox     
	else if(window.ActiveXObject) xhr_object1 = new ActiveXObject("Microsoft.XMLHTTP");   // Internet Explorer  
	else return;   // XMLHttpRequest non supporte par le navigateur   

	xhr_object1.open("POST", script, true);   
    
	xhr_object1.onreadystatechange = function() { if(xhr_object1.readyState == 4) eval(xhr_object1.responseText); }   
		
	xhr_object1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");   
	var data = "var="+escape(valeur)+"&form=" + mform + "&select=" + mselect +"&valeurDefault="+mValeurDefault+"&valeur=" +mvaleur;   
	xhr_object1.send(data);   
}
function RempliDonneeAJAX (valeur, script, mform, mtable) 
{
	var xhr_object2 = null;   
    if(window.XMLHttpRequest) xhr_object2 = new XMLHttpRequest();   // Firefox     
	else if(window.ActiveXObject) xhr_object2 = new ActiveXObject("Microsoft.XMLHTTP");   // Internet Explorer  
	else return;   // XMLHttpRequest non supporte par le navigateur   

	xhr_object2.open("POST", script, true);   
    
	xhr_object2.onreadystatechange = function() { if(xhr_object2.readyState == 4) eval(xhr_object2.responseText); }   
		
	xhr_object2.setRequestHeader("Content-type", "application/x-www-form-urlencoded");   
	var data = "var="+escape(valeur)+"&form=" + mform + "&table=" + mtable;   
	xhr_object2.send(data);   
}
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-elements
function changeF(id, val)
	{
	var testId = document.getElementById(id)
	if (testId)	{document.getElementById(id).style.display = val}
	}


//Affichage ou non des sous-elements
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;

    var _info = navigator.userAgent;
    var _ie = (_info.indexOf("MSIE") > 0 && _info.indexOf("Win") > 0 && _info.indexOf("Windows 3.1") < 0);

    if(_ie)  {_nav="IE"}
    else {_nav="Mozilla"}
		
	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=500"
			break;
		case 4:
			size=",width=650,height=500"
			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 passe en parametre


//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 passe 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 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 = ''");

	var oiframe =document.getElementById('ProprietesImage_' + nomchamp)
	oiframe.innerHTML = "";	
	
	
	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)
			}
	}	
	
	

	
	//***************************************************************
	// 			lien ff vers fichier propose en telechargement		*
	//***************************************************************
	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 != "")
		{		
			// creation 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 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;
	}	
	
	
	
function VisualiserMedia (idcomportement, wi, he)
{
	if (idcomportement!="")
	{
		size=",width="+wi+",height="+he;
		monURL = "visualisationMedia.asp?idcomportement=" + idcomportement;
		browser=window.open(monURL,'zoom',"resizable=no,scrollbars=no,toolbar=no,status=no,menubar=no,location=0,directories=no"+size);
	}
}
		
	

function BM(param)
{
	var top=(screen.height-600)/2;
	var left=(screen.width-600)/2;
	window.open('../SX_banque_de_media2/SX_BM_sommaire_categorie.asp?' + param, '', 'resizable=no, location=no, top='+top+', left='+left+', width=600, height=600, status=no, scrollbars=yes, menubar=no');
}

	
function SupprimerObjetBM ()
{
	var args = SupprimerObjetBM.arguments;
	var nomchamp = args[0];
	for (i=0;i<args.length;i++)
	{	
		var obj = eval ("document.formulaire." + args[i]);
		if (obj) obj.value = '';
	}		
	var oiframe =document.getElementById('ProprietesImage_' + nomchamp)
	oiframe.innerHTML = "";	
	var photogauche = nomchamp + "I";
	
	eval("document.formulaire."+photogauche+".src='design/blank.gif'"); 		
	eval ("window.document.getElementById('boutonBM"+ nomchamp +"').style.display = 'none';");
	
	//var valeur = eval ("document.formulaire." + nomchamp + ".value");
	//if (valeur!="")
	//	browser=window.open("../SX_banque_de_media2/SX_BM_supprimer_comportement.asp?idc=" + valeur , "supprcomportement", "resizable=non,scrollbars=no,toolbar=no,status=no,menubar=no,location=0,directories=no,width=250,height=100");
}	

function switchImage(imgName, imgSrc) 
{ 
  if (document.images)
  {
    if (imgSrc != "none")
    {
      document.images[imgName].src = imgSrc;
    }
  }
}	

function changeRA()
{
	change('rechercheavancee');
	var testId = document.getElementById('rechercheavancee');
	if (testId)	
	{
		if (testId.style.display == 'block') switchImage('imgrechercheavancee', 'design/rechercheavancee2.gif');
		else switchImage('imgrechercheavancee', 'design/rechercheavancee.gif');
	}
} 

//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 ExecAJAX () 
{
	//premier parametre = nom du script serveur
	
	var args = ExecAJAX.arguments;
	var erreur = 0;
	var script = args[0];
	
	var xhr_object1 = null;   
    if(window.XMLHttpRequest) xhr_object1 = new XMLHttpRequest();   // Firefox     
	else if(window.ActiveXObject) xhr_object1 = new ActiveXObject("Microsoft.XMLHTTP");   // Internet Explorer  
	else return;   // XMLHttpRequest non supporte par le navigateur   

	xhr_object1.open("POST", script, true);   
    
	xhr_object1.onreadystatechange = function() { if(xhr_object1.readyState == 4) eval(xhr_object1.responseText); }   
		
	xhr_object1.setRequestHeader("Content-type", "application/x-www-form-urlencoded");   

	var data = "";
	
	for (i=1;i<args.length;i++)
	{
		if (i>1) data = data + "&";
		data = data + "param" + i + "=" + escape(args[i]);		
		
	}
	
	//data = "param1=valider&param2=6&param3=test%2024"
	
	xhr_object1.send(data);  
	
}


