/***** SCRIPT.JS ***********************************************************

 Version : 02/12/2004
 Auteur : 
 Sébastien Poubelle
 Jérôme Demyttenaere
 Philippe Prédhomme
 Rémi Wipliez

******************************************************************************/

/***** Liste des fonctions ****************************************************

 isRef - Retourne la référence du navigateur.
 getRef - retourne l'odjet d'un indice du script courant.
 loadOne - Recharge la page.
 loaded -
 IsNumeric - Vérifie si une chaine de caractère est au format numérique.
 popup -
 MM_preloadImages -
 agrandir -
 ejs_img_fx -
 roll -
 addFavorite -
 calque_open -
 calque_close -
 calendar -

 + fonction BETA en fin de fichier

******************************************************************************/


/************************** isRef 1.0 2005-02-15
 *
 * Auteur : Sébastien Poubelle
 *
 * Retourne la référence du navigateur : 'DOM', 'IE4' ou 'NS4'.
 *
 */


function isRef() {
	if(document.getElementById) return "DOM";
	if(document.all) return "IE4";
	if(document.layers) return "NS4";
	}


/************************** getRef 1.3 2005-02-15
 *
 * Auteur : Sébastien Poubelle
 *
 * Retourne l'odjet d'indice 'id' du script courant.
 *
 */


function getRef(id) {
	if(isRef() == "DOM") return document.getElementById(id);
	if(isRef() == "IE4") return document.all[id];
	if(isRef() == "NS4") return document.layers[id];
	}


/************************** getCssValue ? 2006-12-08
 *
 * Auteur : HackTrack http://www.commentcamarche.net/forum/profil-HackTrack
 * Adaptation : Sébastien Poubelle
 *
 * Retourne les valeurs css d'un élément html.
 *
 */


// function getCssValue(tagRef,element)
// {
// 	var tag = getRef(tagRef);
// 	var value= tag.style[element];
// 	if(value==null || value=='' || value=='undefined')
// 	{
// 		var aClass = tag.className;
// 		var cssRules = 'rules';
// 		for(var sSheet=0; sSheet < document.styleSheets.length; sSheet++)
// 		{
// 			for (var rule=0; rule < document.styleSheets[sSheet][cssRules].length; rule++)
// 			{
// 				var currentClass = document.styleSheets[sSheet][cssRules][rule].selectorText.substring(1);
// 				if (currentClass == aClass) return document.styleSheets[sSheet][cssRules][rule].style[element];
// 			}
// 		}
// 	}
// 	return  value;
// }

/************************** loadOne 1.0 2005-02-15
 *
 * Auteur : Jérôme Demyttenaere
 *
 * Recharge la page
 *
 */


function loadOne() {
        window.location.reload();
        }


/************************** loaded 3.0 2006-03-17
 *
 * Auteur : Jérôme Demyttenaere, Sébastien Poubelle
 *
 */


function loaded(color) {
	getRef('nowLoading').innerHTML = "<font color='"+ color +"'>TRAITEMENT EN COURS</font>";
	}


/************************** IsNumeric 3.0
 *
 * Auteur : Jérôme Demyttenaere
 *
 * Vérifie si une chaine de caractère est au format numérique.
 *
 */


function IsNumeric(strString) {
	var strValidChars = "0123456789.- ";
	var strChar;
	var blnResult = true;
	if (strString.length == 0) return false;
	for (i = 0; i < strString.length && blnResult == true; i++) {
		strChar = strString.charAt(i);
		if (strValidChars.indexOf(strChar) == -1) blnResult = false;
		}
	return blnResult;
	}


/************************** popup 3.1 2005-05-03
 *
 * Auteur : Sébastien Poubelle
 *
 * void popup( String pop_url , Int pop_width , Int pop_height [ , String pop_bar ] )
 *
 * pop_url : url de la page pop-up.
 * pop_width : largeur de la fenêtre en pixel.
 * pop_height : hauteur de la fenêtre en pixel.
 * pop_bar : affichage de la scrollbar, option : 'yes' / 'no'.
 *
 */


function popup(pop_url,pop_width,pop_height) {
	var pop_bar = "yes", pop_arg = popup.arguments;
	if(pop_arg.length == 4) pop_bar = pop_arg[3];
	pop_name = pop_url.substring(0,3);
	pop_left = (window.screen.availWidth / 2) - (pop_width / 2);
	pop_top = (window.screen.availHeight / 2) - (pop_height / 2);
	window.open(pop_url,pop_name,"left=" + pop_left + ",top=" + pop_top + ",width=" + pop_width + ",height=" + pop_height + ",scrollbars="+ pop_bar +",noresize");
	}


/************************** MM_preloadImages 3.0
 *
 * Auteur : Macromédia
 *
 *
 */


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];
			}
		}
	}


/************************** agrandir 3.0 2005-02-15
 *
 * Auteur : Sébastien Poubelle
 *
 *
 */


function agrandir(img_src,link_color,bg_color) {
	var pop_width = 640;
	var pop_height = 480;
	var pop_img = new Image();
	pop_img.src = img_src;
	pop_win = window.open("","","width="+ pop_width +",height="+ pop_height +",scrollbars=yes");
	pop_win.document.open();
	pop_win.document.write("<head><title>Arbre d'un jour</title></head>");
	pop_win.document.write("<body leftmargin='0' topmargin='0' marginwidth='0' marginheight='0'");
	pop_win.document.write(" link='"+link_color+"' alink='"+link_color+"' vlink='"+link_color+"' bgcolor='"+bg_color+"'>");
	pop_win.document.write("<table width='100%' border='0' style='height:100%;'>");
	pop_win.document.write("<tr><td align='center' valign='middle'><img src='"+pop_img.src+"' style='border-color:#62013A;border-style:solid;border-width:1px;'></td></tr>");
	pop_win.document.write("<tr><td align='center' valign='middle'><font size='1' face='Verdana,Arial,Helvetica,sans-serif'>");
	pop_win.document.write("<a href='javascript:window.close();'>Fermer la fen&ecirc;tre</a>");
	pop_win.document.write("</font></td></tr>");
	pop_win.document.write("</table>");
	pop_win.document.write("</body>");
	pop_win.document.close();
	pop_left = (window.screen.availWidth / 2) - (pop_width / 2);
	pop_top = (window.screen.availHeight / 2) - (pop_height / 2);
	pop_win.moveTo(pop_left,pop_top);
	}

/*function menu
window.innerWidth
window.innerHeight
*/
/************************** ejs_img_fx 1.0 2005-02-15
 *
 * Auteur : ???
 *
 *
 */


function ejs_img_fx(img) {
	if(img && img.filters && img.filters[0]) {
		img.filters[0].apply();
		img.filters[0].play();
		}
	}


/************************** roll 1.0 2005-02-15
 *
 * Auteur : Sébastien Poubelle
 *
 * i : indice en cours. Lors de l'initialisation il est égale à 0.
 * speed : Vitesse du roll over en ms
 * ejs_img_fx : booléen indiquant si il existe un style du genre style="filter:progid:DXImageTransform.Microsoft.Fade(Duration=1)" sur l'image.
 * roll : objet image dans laquelle le roll over est effectif
 *
 * Préalablement il faut initialiser 'roll_array[roll]', tableau des sources images de l'animation. 'roll_array' étant déjà définit.
 *
 * exemple :
 *
 *	<IMG id="monImage" src="" width="410" height="600" border="0">
 *	
 *	<SCRIPT>
 *	
 *	roll_array['monImage'] = new Array();
 *	roll_array['monImage'][0] = "monImage1.jpg";
 *	roll_array['monImage'][1] = "monImage2.jpg";
 *	roll_array['monImage'][2] = "monImage3.jpg";
 *	roll_array['monImage'][3] = "monImage4.jpg";
 *	roll_array['monImage'][4] = "monImage5.jpg";
 *	
 *	roll(0,3000,false,roll);
 *	
 *	</SCRIPT>
 *
 *
 */


var roll_array = new Array();


function roll(i,speed,img_fx,roll) {
	if(img_fx) ejs_img_fx(getRef(roll));
	getRef(roll).src = roll_array[roll][i];
	i++;
	if(i >= roll_array[roll].length) i = 0;
	setTimeout("roll("+ i +","+ speed +","+ img_fx +",'"+ roll +"')",speed);
	}


/************************** addFavorite 1.0 2005-06-14
 *
 * Auteur : Sébastien Poubelle
 *
 * Ajoute la page aux favories
 *
 */


function addFavorite() {
	NomNavigateur = navigator.appName;
	VersionNavigateur = parseInt(navigator.appVersion);
	if(NomNavigateur == "Microsoft Internet Explorer" && VersionNavigateur >= 4) {
		window.external.AddFavorite(location.href, document.title);
		}
	else alert("Votre navigateur ne permet pas l'ajout automatique dans vos favories.");
	}


/************************** calque_open 1.0 2006-03-17
 *
 * Auteur : Sébastien Poubelle
 *
 */


function calque_open(id) {
	if(getRef(id).style.visibility == 'hidden') {
		getRef(id).style.visibility = 'visible';
//		setTimeout("calque_close('"+id+"')",9000);
		}
	else getRef(id).style.visibility = 'hidden';
	}


/************************** calque_close 1.0 2006-03-17
 *
 * Auteur : Sébastien Poubelle
 *
 */


function calque_close(id) {
	getRef(id).style.visibility = 'hidden';
	}



/************************** calendar 1.0 2006-03-17
 *
 * Auteur : Sébastien Poubelle
 *
 */


function calendar(id, buttoncolor, bgcolor, color, langue, objet_input, m_plus) {
	var str = "";
	var flg = 0;
	M_fr = new Array("Janvier","Fevier","Mars","Avril","Mai","Juin","Juillet","Aout","Septembre","Octobre","Novembre","Decembre");
	D_fr = new Array("Dim","Lun","Mar","Mer","Jeu","Ven","Sam");
	M_uk = new Array("January","February","March","April","May","June","July","August","September","October","November","December");
	D_uk = new Array("Sun","Mon","Tue","Wed","Thu","Fri","Sat");

	M = M_uk;
	D = D_uk;
	if(langue == "fr") {
		M = M_fr;
		D = D_fr;
		}

	if(m_plus < 0) m_plus = 0;
	if(m_plus > 12) m_plus = 12;

	pdy = new Date();        // today
	pmo = pdy.getMonth();    // present month
	pyr = pdy.getYear();     // present year
	if(pyr < 1000) pyr += 1900;

	yr = pyr;                // present year
	mo = pmo + m_plus;                // present month
	if(mo > 11) {
		mo = mo - 12;
		yr++;
		}

	bgn = new Date(M_uk[mo] + " 1," + yr); // assign to date

	dy = bgn.getDay();
	yr = eval(yr);
	d = "312831303130313130313031";
	if (yr / 4 == Math.floor(yr / 4)){
		d = d.substring(0,2) + "29" + d.substring(4,d.length);
		}
	pos = (mo*2);
	ld = eval(d.substring(pos,pos+2));

	str += ""
	+ "<TABLE BGCOLOR=\""+ bgcolor +"\" BORDER=0 cellpadding=\"1\" cellspacing=\"2\"' style=\"border-right:1px solid "+ color +";border-top:1px solid "+ color +";border-left:1px solid "+ color +";border-bottom:1px solid "+ color +";\">"
	+ "<TR><TD ALIGN=CENTER BGCOLOR=\""+ buttoncolor +"\" style=\"cursor:pointer;font-size:12px;font-family:Verdana,sans-serif;color:"+ color +";\" onclick=\"calendar('"+ id +"','"+ buttoncolor +"','"+ bgcolor +"','"+ color +"','"+ langue +"','"+ objet_input +"',"+ (m_plus-1) +");\"><B>&#171;</B></TD><TD ALIGN=CENTER COLSPAN=5 style=\"font-size:10px;font-family:Verdana,sans-serif;color:"+ color +";\"><B>"+ M[mo] +" "+ yr +"</B></TD><TD ALIGN=CENTER BGCOLOR=\""+ buttoncolor +"\" style=\"cursor:pointer;font-size:12px;font-family:Verdana,sans-serif;color:"+ color +";\" onclick=\"calendar('"+ id +"','"+ buttoncolor +"','"+ bgcolor +"','"+ color +"','"+ langue +"','"+ objet_input +"',"+ (m_plus+1) +");\"><B>&#187;</B></TD></TR>"
	+ "<TR>";
	for (var i=0;i<7;i++){
		str += "<TD WIDTH=\"15%\" style=\"font-size:10px;font-family:Verdana,sans-serif;color:"+ color +";\" ALIGN=CENTER>"+ D[i] +"</TD>";
		}
	str += "</TR><TR>";
	ctr = 0;
	for(var i = 0; i < 7; i++) {
		if (i < dy){
			str += "<TD></TD>";
			}
		else{
			ctr++;
			jour = ""+ ctr; 
			if(jour.length < 2) jour = "0"+ jour;
			mois = ""+ (mo+1); 
			if(mois.length < 2) mois = "0"+ mois;
			str += "<TD BGCOLOR=\""+ buttoncolor +"\" ALIGN=CENTER style=\"cursor:pointer;font-size:10px;font-family:Verdana,sans-serif;color:"+ color +";\" onclick=\""+ objet_input +".value = '"+ jour +"/"+ mois +"/"+ yr +"';calque_close('"+ id +"');\">"+ ctr +"</TD>";
			}
		}
	str += "</TR><TR>";
	while (ctr < ld){
		for (var i = 0; i < 7; i++){
			ctr++;
			if (ctr > ld){
				str += "<TD></TD>";
				}
			else{
				jour = ""+ ctr; 
				if(jour.length < 2) jour = "0"+ jour;
				mois = ""+ (mo+1); 
				if(mois.length < 2) mois = "0"+ mois;
				str += "<TD BGCOLOR=\""+ buttoncolor +"\" ALIGN=CENTER style=\"cursor:pointer;font-size:10px;font-family:Verdana,sans-serif;color:"+ color +";\" onclick=\""+ objet_input +".value = '"+ jour +"/"+ mois +"/"+ yr +"';calque_close('"+ id +"');\">"+ ctr +"</TD>";
				}
			}
		str += "</TR><TR>";
		}
	str += "</TR></TABLE>";
	getRef(id).innerHTML = str;
	}


/************************** Under-Warz
 *
 * Auteur : Under-Warz http://www.siteduzero.com/membres-294-1821.html
 *
 * Librairie de fonction divers pour le formatage de texte.
 * http://www.siteduzero.com/tuto-3-1982-1-creation-d-un-bbcode-et-apercu-en-direct.html
 * Je les ai légèrement modifié pour les adapter à ma bibliothèque de fonction.
 *
 */

var ptag = String.fromCharCode(5,6,7);

// function deblaie(reg,t)
// {
// 	textarea=new String(t);
// 	return textarea.replace(reg,'$1\n');
// }

function remblaie(t)
{
	textarea=new String(t);
	textarea=textarea.replace(/\r/g,'');
	return textarea.replace(/\n/g,'');
}

function remplace_tag(reg,rep,t)
{
	textarea=new String(t);
	return textarea.replace(reg,rep);
}

function nl2br(t)
{
	textarea=new String(t);
	textarea=textarea.replace(/\r/g,'');
	return textarea.replace(/\n/g,'<BR/>');
}

function space2nbsp(t)
{
	textarea=new String(t);
	return textarea.replace(/ /g,'&nbsp;');
}

function nl2khol(t)
{
	textarea = new String(t);
	textarea=textarea.replace(/\r/g,'');
	return textarea.replace(/\n/g,ptag);
}

function unkhol(t)
{
	textarea=new String(t);
	return textarea.replace(new RegExp(ptag,'g'),'\n');
}


/************************** wyzArea 1.0 2006-10-19
 *
 * Auteur : Sébastien Poubelle
 *
 * Cette librairie permet d'utiliser dans un formulaire un petit éditeur html.
 *
 * L'objet créé wyzArea est constitué d'un champ de saisi et d'une zone pour
 * prévisualiser le rendu du code. Le champ de saisie représente le code html
 * préformaté avec des '\n' à la place des '<BR/>' et des ' ' à la place des
 * '&nbsp;'. La valeur retournée lors de la soumission du formulaire est un
 * code HTML sans retour à la ligne.
 *
 * Arguments :
 * name : Le nom que vous voulez donner à l'objet du formulaire.
 * width : La taille que vous voulez donner à l'objet du formulaire.
 * style : Style css pour formater la prévisualisation du code HTML.
 * init : Le code html sans retour à la ligne pour l'initialisation.
 *
 */

var wyz_array = new Array();

function wyzCode (name, bbdebut, bbfin)
{
	var input = getRef(name);
	input.focus();
	/* IE */
	if(typeof document.selection != 'undefined')
	{
		var range = document.selection.createRange();
//		alert(document.getSelection());
		var insText = range.text;
//		alert(insText);
		range.text = bbdebut + insText + bbfin;
		range = document.selection.createRange();
		if (insText.length == 0)
		{
			range.move('character', -bbfin.length);
		}
		else
		{
			range.moveStart('character', bbdebut.length + insText.length + bbfin.length);
		}
		range.select();
	}
	/* Firefox */
	else if(typeof input.selectionStart != 'undefined')
	{
		var start = input.selectionStart;
		var end = input.selectionEnd;
		var insText = input.value.substring(start, end);
		input.value = input.value.substr(0, start) + bbdebut + insText + bbfin + input.value.substr(end);
		var pos;
		if (insText.length == 0)
		{
			pos = start + bbdebut.length;
		}
		else
		{
			pos = start + bbdebut.length + insText.length + bbfin.length;
		}
		input.selectionStart = pos;
		input.selectionEnd = pos;
	}
	/* Netscape */
	else
	{
		var pos;
		var re = new RegExp('^[0-9]{0,3}$');
		while(!re.test(pos))
		{
			pos = prompt("insertion (0.." + input.value.length + "):", "0");
		}
		if(pos > input.value.length)
		{
			pos = input.value.length;
		}
		var insText = prompt("Veuillez taper le texte");
		input.value = input.value.substr(0, pos) + bbdebut + insText + bbfin + input.value.substr(pos);
	}
}

function wyzHtml(str)
{
	str = nl2khol(str);
	str = remblaie(str);
	str = unkhol(str);
	str = nl2br(str);
//	str = space2nbsp(str);
	return str;
}

function  wyzPrevisualisation(name)
{
	var wyzhtml = wyzHtml(getRef("wyz_textarea_"+ name).value);
	getRef("wyz_preview_"+ name).innerHTML = wyzhtml;
	getRef("wyz_"+ name).value = wyzhtml;
	wyz_array[name]['timer'] = setTimeout("wyzPrevisualisation('"+ name +"')",100);
}

function wyzArea (name, width, style, init)
{
	wyz_array[name] = new Array();
	wyz_array[name]['name'] = name;
	wyz_array[name]['width'] = width;
	wyz_array[name]['style'] = style;
	wyz_array[name]['timer'] = 0;
	if(typeof document.selection != 'undefined') init = init.replace(/<BR\/>/g,"\r\n");
	else init = init.replace(/<BR\/>/g,"\n");
//	var init = init.replace(/&nbsp;/g,' ');
	var wyzarea = "<INPUT id=\"wyz_"+ wyz_array[name]['name'] +"\" type=\"hidden\" name=\""+ wyz_array[name]['name'] +"\" value=\"\" style=\"width:640px;\" />";
	wyzarea += "<TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"1\" style=\"background-color:#FFFFFF;border:1px solid #000000;\">";
	wyzarea += "<TR><TD align=\"right\"><TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"1\"><TR>";
	wyzarea += "<TD align=\"center\" style=\"font-size:10px;width:15px;height:15px;border:1px solid #000000;\"><A href=\"javascript:wyzCode('wyz_textarea_"+ wyz_array[name]['name'] +"','<B>','</B>');\" style=\"color:#000000;text-decoration:none;\"><B>B</B></A></TD>";
	wyzarea += "<TD align=\"center\" style=\"font-size:10px;width:15px;height:15px;border:1px solid #000000;\"><A href=\"javascript:wyzCode('wyz_textarea_"+ wyz_array[name]['name'] +"','<I>','</I>');\" style=\"color:#000000;text-decoration:none;\"><I>I</I></A></TD>";
	wyzarea += "<TD align=\"center\" style=\"font-size:10px;width:15px;height:15px;border:1px solid #000000;\"><A href=\"javascript:wyzCode('wyz_textarea_"+ wyz_array[name]['name'] +"','<U>','</U>');\" style=\"color:#000000;text-decoration:none;\"><U>U</U></A></TD>";
//	wyzarea += "<TD align=\"center\" style=\"font-size:10px;width:15px;height:15px;border:1px solid #000000;cursor:pointer;color:#000000;text-decoration:none;\" onClick=\"javascript:wyzCode('wyz_textarea_"+ wyz_array[name]['name'] +"','<B>','</B>');\"><B>B</B></TD>";
//	wyzarea += "<TD align=\"center\" style=\"font-size:10px;width:15px;height:15px;border:1px solid #000000;cursor:pointer;color:#000000;text-decoration:none;\" onClick=\"javascript:wyzCode('wyz_textarea_"+ wyz_array[name]['name'] +"','<I>','</I>');\"><I>I</I></TD>";
//	wyzarea += "<TD align=\"center\" style=\"font-size:10px;width:15px;height:15px;border:1px solid #000000;cursor:pointer;color:#000000;text-decoration:none;\" onClick=\"javascript:wyzCode('wyz_textarea_"+ wyz_array[name]['name'] +"','<U>','</U>');\"><U>U</U></TD>";
	wyzarea += "</TR></TABLE></TD></TR>";
	wyzarea += "<TR><TD><TABLE width=\"100%\" border=\"0\" cellpadding=\"0\" cellspacing=\"0\"><TR>";
	wyzarea += "<TD><TEXTAREA id=\"wyz_textarea_"+ wyz_array[name]['name'] +"\" style=\"width:100%;font-size:11px;height:80px;border:1px solid #000000;\">"+ init +"</TEXTAREA></TD>";
	wyzarea += "</TR></TABLE></TD></TR>";
	wyzarea += "<TR><TD><DIV style=\"padding:3px;border:1px dashed #000000;\" align=\"left\">";
	wyzarea += "<DIV style=\"color:#AAAAAA;font-size:10px;border-bottom:1px dashed #AAAAAA;\" align=\"left\">prévisualisation</DIV>";
	wyzarea += "<DIV id=\"wyz_preview_"+ wyz_array[name]['name'] +"\" style=\""+ wyz_array[name]['style'] +"height:60px;overflow:auto;width:"+ wyz_array[name]['width'] +"px;\" align=\"left\"></DIV>";
	wyzarea += "</DIV></TD></TR></TABLE>";
	document.write(wyzarea);
	wyzPrevisualisation(name);
}


/************************** popList 1.0 2007-04-11
 *
 */

var pop_list = new Array();

function popList(arg_form, arg_input, arg_url, arg_value, arg_lib, arg_style, arg_script)
{
	arg_name = arg_form+"_"+arg_input;
	pop_list[arg_name] = new Array();
	pop_list[arg_name]["name"] = arg_name;
	pop_list[arg_name]["input"] = arg_input;
	pop_list[arg_name]["value"] = arg_value;
	pop_list[arg_name]["form"] = arg_form;
	pop_list[arg_name]["url"] = arg_url;
	pop_list[arg_name]["style"] = arg_style;
	pop_list[arg_name]["script"] = arg_script;
	document.write("<INPUT name=\"poplist_"+arg_name+"\" type=\"button\" value=\""+arg_lib+"\" onClick=\"popList_open('"+arg_name+"');\" style=\""+arg_style+"\" /><INPUT name=\""+arg_input+"\" type=\"hidden\" value=\""+arg_value+"\" />");
}

function popList_open(arg_name)
{
	pop_width = 480;
	pop_height = 480;
	pop_left = (window.screen.availWidth / 2) - (pop_width / 2);
	pop_top = (window.screen.availHeight / 2) - (pop_height / 2);
	pop_url = pop_list[arg_name]["url"];
	if(pop_url.indexOf("?") == -1) pop_url += "?";
	else pop_url += "&";
	pop_url += "name="+pop_list[arg_name]["name"]+"&value="+pop_list[arg_name]["value"];
	window.open(pop_url,"poplist"+pop_list[arg_name]["name"],"left="+pop_left+",top="+pop_top+",width="+pop_width+",height="+pop_height+",scrollbars=yes,noresize");
}

function popList_set(arg_name,arg_value,arg_lib)
{
	pop_list[arg_name]["value"] = arg_value;
//	alert("document."+pop_list[arg_name]["form"]+"."+pop_list[arg_name]["input"]+".value=\""+arg_value+"\"");
	setTimeout("document."+pop_list[arg_name]["form"]+"."+pop_list[arg_name]["input"]+".value=\""+arg_value+"\"",10);
	setTimeout("document."+pop_list[arg_name]["form"]+".poplist_"+pop_list[arg_name]["name"]+".value=\""+arg_lib+"\"",10);
//	alert(document.form_prospect.contact_id.value);
	if(pop_list[arg_name]["script"] != "") setTimeout(pop_list[arg_name]["script"],10);
}

/************************** getXhr 1.0 2007-03-13
 *
 * Retourne un objet XMLHttpRequest en déterminant le navigateur utilisé.
 *
 */

function getXhr()
{
	var xhr = null; 
	if(window.XMLHttpRequest) xhr = new XMLHttpRequest(); // Firefox et autres
	else if(window.ActiveXObject) // Internet Explorer
	{
		try { xhr = new ActiveXObject("Msxml2.XMLHTTP"); }
		catch (e) { xhr = new ActiveXObject("Microsoft.XMLHTTP"); }
	}
	else // XMLHttpRequest non supporté par le navigateur 
	{
		alert("Votre navigateur ne supporte pas les objets XMLHTTPRequest...");
		xhr = false;
	}
	return xhr
}

/************************** valider 1.0 2007-03-17
 *
 * Valide le formulaire arg_form
 *
 */

function form_traiter(arg_form)
{
	getRef('traitement_en_cours').innerHTML = "<FONT class=\"alert\">TRAITEMENT EN COURS</FONT>";
	arg_form.submit();
}

/************************** qteInput 1.0 2007-04-25
 *
 */

var qteInput_array = new Array();

function qteInput (arg_form, arg_input, arg_value, arg_min, arg_max, arg_img_plus, arg_img_moins, arg_style, arg_script)
{
	var qteInput = arg_form +"_"+ arg_input;
	qteInput_array[qteInput] = new Array();
	qteInput_array[qteInput]["min"] = arg_min;
	qteInput_array[qteInput]["max"] = arg_max;
	qteInput_array[qteInput]["script"] = arg_script;
	document.write("<INPUT id=\""+ qteInput +"\" name=\""+ arg_input +"\" type=\"hidden\" value=\""+ arg_value +"\" />");
	document.write("<TABLE border=\"0\" cellpadding=\"1\" cellspacing=\"0\" style=\""+ arg_style +"\">");
	document.write("<TR><TD class=\"input\"><DIV id=\""+ qteInput +"_str\">"+ arg_value +"</DIV></TD>");
	document.write("<TD><TABLE border=\"0\" cellpadding=\"0\" cellspacing=\"1\">");
	document.write("<TR><TD><A href=\"javascript:qteInput_plus('"+ qteInput +"');\"><IMG alt=\"&#043;\" src=\""+ arg_img_plus +"\" border=\"0\" /></A></TD></TR>");
	document.write("<TR><TD><A href=\"javascript:qteInput_moins('"+ qteInput +"');\"><IMG alt=\"&#045;\" src=\""+ arg_img_moins +"\" border=\"0\" /></A></TD></TR>");
	document.write("</TABLE></TD></TR>");
	document.write("</TABLE>");
}

function qteInput_plus (qteInput)
{
	var val = getRef(qteInput).value;
	if(qteInput_array[qteInput]["max"] == null || val < qteInput_array[qteInput]["max"])
	{
		val++;
		getRef(qteInput).value = val;
		getRef(qteInput+"_str").innerHTML = val;
		if(qteInput_array[qteInput]["script"] != "") setTimeout(qteInput_array[qteInput]["script"],10);
	}
}

function qteInput_moins (qteInput)
{
	var val = getRef(qteInput).value;
	if(qteInput_array[qteInput]["min"] == null || val > qteInput_array[qteInput]["min"])
	{
		val--;
		getRef(qteInput).value = val;
		getRef(qteInput+"_str").innerHTML = val;
		if(qteInput_array[qteInput]["script"] != "") setTimeout(qteInput_array[qteInput]["script"],10);
	}
}

/************************** getXhrById 1.0 2007-05-30
 *
 * Retourne le résultat du script arg_script dans l'id arg_id.
 *
 */

function getXhrById (arg_script, arg_id)
{
	var xhr = getXhr()
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			getRef(arg_id).innerHTML = xhr.responseText;
		}
	}
	xhr.open("GET",arg_script,true);
	xhr.send(null);
}


/************************** getXhrByScript 1.0 2007-05-30
 *
 * Exécute le résultat retourné par le script arg_script.
 *
 */

function getXhrByScript (arg_script)
{
	var xhr = getXhr()
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			eval(xhr.responseText);
		}
	}
	xhr.open("GET",arg_script,true);
	xhr.send(null);
}


/************************** getXhrFormById 1.0 2007-05-29
 *
 * Traite un formulaire arg_form par un objet XMLHttpRequest en utilisant
 * le script arg_script. Le résultat est retourné dans l'id arg_id.
 *
 */

function getXhrFormById (arg_form, arg_script, arg_id)
{
	var xhr = getXhr()
	var xhr_data = "";
	for(var i = 0; i < arg_form.elements.length; i++)
	{
		if(i != 0) xhr_data += "&";
		xhr_data += arg_form.elements[i].name +"="+ arg_form.elements[i].value;
	}
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			getRef(arg_id).innerHTML = xhr.responseText;
		}
	}
	xhr.open("POST",arg_script,true);
	xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xhr.send(xhr_data);
}

/************************** getXhrFormByScript 1.0 2007-05-30
 *
 * Traite un formulaire arg_form par un objet XMLHttpRequest en utilisant
 * le script arg_script. Le résultat retourné est exécuté en tand que
 * script JS.
 *
 */

function getXhrFormByScript (arg_form, arg_script)
{
	var xhr = getXhr()
	var xhr_speed = 10;
	var xhr_data = "";
	for(var i = 0; i < arg_form.elements.length; i++)
	{
		if(i != 0) xhr_data += "&";
		xhr_data += arg_form.elements[i].name +"="+ arg_form.elements[i].value;
	}
	xhr.onreadystatechange = function()
	{
		if(xhr.readyState == 4 && xhr.status == 200)
		{
			eval(xhr.responseText);
		}
	}
	xhr.open("POST",arg_script,true);
	xhr.setRequestHeader("Content-type","application/x-www-form-urlencoded");
	xhr.send(xhr_data);
}

/************************** dateString 1.0 2007-05-16
 *
 * Retourne une chaine de caractère de forme 'AAAA-MM-JJ'
 * à partir de l'objet arg_date.
 *
 * exemple d'utilisation : alert(dateString(new Date()));
 *
 */

function dateString (arg_date)
{
	var annee = arg_date.getFullYear();
	annee = ""+ annee;
	var mois = arg_date.getMonth()+1;
	mois = ""+ mois;
	if(mois.length < 2) mois = "0"+ mois;
	var jour = arg_date.getDate();
	jour = ""+ jour;
	if(jour.length < 2) jour = "0"+ jour;
	return(annee +"-"+ mois +"-"+ jour);
}

/************************** mailto 1.1 2007-06-22
 *
 * Auteur : Sébastien Poubelle
 *
 */


function mailto(user,domaine,style) {
	var at = "@"
	document.write("<a href=\"mailto:"+ user + at + domaine +"\" style=\""+ style +"\">");
	document.write(user + at + domaine +"</a>");
	}

/************************** mailing_valid 1.0 2008-02-05
 *
 * Auteur : Sébastien Poubelle
 *
 */


function mailing_valid ()
{
	var mailing = document.mailing.mailing;
	if(mailing.value == "" || mailing.value.indexOf("@") == "-1" || mailing.value.indexOf(".") == "-1" || mailing.value.indexOf(" ") != "-1")
	{
		alert("Votre adresse E-mail est incorrecte.");
		mailing.focus();
		mailing.select();
		return;
	}
	document.mailing.submit();
//	document.location.href = "newsletter.html?mailing="+mailing.value;
}

/************************** recherche_valid 1.0 2008-02-05
 *
 * Auteur : Sébastien Poubelle
 *
 */


function recherche_valid ()
{
	var recherche = getRef("recherche");
	if(recherche.value == "" || recherche.value == "Rechercher...")
	{
		recherche.focus();
		recherche.select();
		return;
	}
	document.location.href = "recherche.html?recherche="+recherche.value;
}

/************************** recherche_valid 1.0 2008-02-05
 *
 * Auteur : Sébastien Poubelle
 *
 */

var catalogueIsOpen = false;

function catalogue_open ()
{
	if(!catalogueIsOpen)
	{
		getRef("contenu").innerHTML = "<DIV align=\"center\" style=\"width:100%;height:320px;\"><BR /><BR /><BR /><IMG alt=\"\" src=\"images/nowloading.gif\" border=\"0\" align=\"center\" /></DIV>";
		getXhrById("xhr_catalogue.php","contenu");
		catalogueIsOpen = true;
	}
}

function catalogue_close ()
{
	getRef("contenu").innerHTML = getRef("contenu_tmp").innerHTML;
	catalogueIsOpen = false;
}
/*
function openwindow(url,name,width,height,ptop,pleft)
{
	window.open(url,name,'toolbar=0,menubar=0,scrollbars=yes,resizable=0,width=' + width + ',height=' + height + ',top=' + ptop + ',left=' + pleft);
}

function openwindow_email(url,name,width,height)
{
	window.open(url,name,'toolbar=0,menubar=0,scrollbars=no,resizable=0,width=' + width + ',height=' + height + ',top=100,left=100');
}

function MM_openBrWindow(theURL,winName,features) { //v2.0
  window.open(theURL,winName,features);
}

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;
}

function MM_preloadImages() { //v3.0
  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() { //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_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+='- la zone de saisie doit comporter une adresse email.\n';
      } else if (test!='R') {
        if (isNaN(val)) errors+='- '+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+='- '+nm+' doit contenir un nombre entre '+min+' et '+max+'.\n';
    } } } else if (test.charAt(0) == 'R') errors += '- email attendu.\n'; }
  } if (errors) alert('Les erreurs suivantes sont apparues :\n'+errors);
  document.MM_returnValue = (errors == '');
}

function valid_newsletter()
{
	var email = document.form.email.value;
	if(email.indexOf("@") != "-1" && email.indexOf(".") != "-1" && email != "")
	{
		openwindow_email("newsletter_valid.php?email=" + email,"email",220,130);
		//document.form.submit(); 
	} 
	else
	{ 
		alert('Veuillez saisir une adresse e-mail correcte, s\'il vous plait.');
		document.form.email.focus();
	} 
}
function popup(url,name,width,height)
{
        pleft = (window.screen.availWidth - width) / 2;
        ptop = (window.screen.availHeight - height) / 2;
        openwindow(url, name, width, height, ptop, pleft);
}

function mailto(user,domaine,style) {
	var at = "@"
	document.write("<a href=\"mailto:"+ user + at + domaine +"\" style=\""+ style +"\">");
	document.write(user + at + domaine +"</a>");
	}
*/
