// ******************************************************************************************************************************************************
// ***	CODE JAVASCRIPT version 3
// ******************************************************************************************************************************************************
// ***
// *** number_format(nb)					met les '.' pour les milliers
// *** setHTML(div,html)
// ***
// ***	getCheckedValue(radioObj)					<Radio> javascript
// ***	setCheckedValue(radioObj, newValue) 		<Radio> javascript
// ***
// ***	ajax_send(url,data,reponse)					Envoi une requete AJAX
// ***
// *** 	videoFlash(fichier,x,y)							Affiche un Lecteur Flash "video"
// ***	onlyFlash(fichier,x,y,bgcolor,id)				Renvoie le code d'un Lecteur Flash
// ***	objetFlash(fichier,x,y,bgcolor,id)				Affiche un Lecteur Flash
// ***
// ***	cacheid(id)								Fixe le style 'display' de l'ID correspondant à 'none'
// ***	afficheid(id)								Fixe le style 'display' de l'ID correspondant à 'block'
// ***	swapid(id)								Inverse le style 'display' de l'ID correspondant
// ***
// ******************************************************************************************************************************************************

var cadrehg = new Image(); cadrehg.src='images/cadrehg.gif';
var cadrehm = new Image(); cadrehm.src='images/cadrehm.gif';
var cadrehd = new Image(); cadrehd.src='images/cadrehd.gif';
var cadremg = new Image(); cadremg.src='images/cadremg.gif';
var cadremd = new Image(); cadremd.src='images/cadremd.gif';
var cadrebg = new Image(); cadrebg.src='images/cadrebg.gif';
var cadrebm = new Image(); cadrebm.src='images/cadrebm.gif';
var cadrebd = new Image(); cadrebd.src='images/cadrebd.gif';

function number_format(nb) {
	txt = ''+Math.round(nb); neo=''; a=0;
	for (i=txt.length;i>0;i--) {
		j=i-1; neo=txt.substring(j,j+1)+neo; a++;
		if ((a>2)&&(j>0)) {neo='.'+neo;a=0;}
		}
	return neo;
	}

function setHTML(div,html) {
	if (document.getElementById(div)) {
		document.getElementById(div).innerHTML=html;
		}// else {alert(div+'?');}
	}

function setOpacity(div,pourcent) {
	if (document.getElementById(div)) {
		document.getElementById(div).style.filter='alpha(opacity='+pourcent+')';
		if (pourcent>=100) {
			document.getElementById(div).style.mozOpacity='1.0';
			document.getElementById(div).style.opacity='1.0';
			} else {
			if (pourcent<10) {pourcent='0'+pourcent;}
			document.getElementById(div).style.mozOpacity='0.'+pourcent;
			document.getElementById(div).style.opacity='0.'+pourcent;
			}
		}// else {alert(div+'?');}
	}

function imgHTML(url,largeur,hauteur) {
	return '<img src="'+url+'" width="'+largeur+'" height="'+hauteur+'" border="0" />';
	}

function getCheckedValue(radioObj) {
	if (!radioObj) {return "";}
	var radioLength = radioObj.length;
	if (radioLength == undefined) {
		if (radioObj.checked) {
			return radioObj.value;
			} else {
			return "";
			}
		}
	for (var i = 0; i < radioLength; i++) {
		if (radioObj[i].checked) {
			return radioObj[i].value;
			}
		}
	return "";
	}
function setCheckedValue(radioObj, newValue) {
	if (!radioObj) {return;}
	var radioLength = radioObj.length;
	if (radioLength == undefined) {
		radioObj.checked = (radioObj.value == newValue.toString());
		return;
		}
	for (var i = 0; i < radioLength; i++) {
		radioObj[i].checked = false;
		if (radioObj[i].value == newValue.toString()) {
			radioObj[i].checked = true;
			}
		}
	}

function ajax_send(url,data,reponse) {
	//	url = POST ACTION	data = POST Vars de la forme 'a=1&b=2&c=3'	reponse = fonction pour la reponse (a mettre sans parenthèses) ; exemple : en mettant "test" la fonction test(return_vars) sera lancé !
	var xmlhr_object = null; if (window.XMLHttpRequest) {xmlhr_object = new XMLHttpRequest();} else if (window.ActiveXObject) {xmlhr_object = new ActiveXObject("Microsoft.XMLHTTP");}
		xmlhr_object.onreadystatechange = function() { if (xmlhr_object.readyState == 4) {
			retour = reponse+"('"+xmlhr_object.responseText+"');";
			eval(retour);
			} }
		xmlhr_object.open("POST", url, true);
		xmlhr_object.setRequestHeader("Content-type", "application/x-www-form-urlencoded");
		xmlhr_object.send(data);
	}

function videoFlash(fichier,x,y) {
	document.write('<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+x+'" height="'+y+'"><param name="movie" value="'+fichier+'"></param><param name="allowfullscreen" value="true"></param><embed src="'+fichier+'" type="application/x-shockwave-flash" width="'+x+'" height="'+y+'" allowfullscreen="true"></embed></object>');
	}
function onlyFlash(fichier,x,y,bgcolor,id) {
	flashvars = fichier.split("?");
	HTML = '<object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" codebase="http://fpdownload.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=8,0,0,0" width="'+x+'" height="'+y+'" id="'+id+'" align="middle">';
	HTML+= '<param name="movie" value="'+fichier+'" />';
	HTML+= '<param name="quality" value="high" />';
	HTML+= '<param name="bgcolor" value="'+bgcolor+'" />';
	HTML+= '<param name="scale" value="exactfit" />';
	HTML+= '<param name="wmode" value="transparent" />';
	HTML+= '<param name="menu" value="false" />';
	HTML+= '<param name="flashvars" value="'+flashvars[1]+'" />';
	HTML+= '<param name="allowfullscreen" value="true" />';
	HTML+= '<embed src="'+fichier+'" allowfullscreen="true" flashvars="'+flashvars[1]+'" menu="false" wmode="transparent" scale="exactfit" quality="high" bgcolor="'+bgcolor+'" width="'+x+'" height="'+y+'" name="'+id+'" align="middle" allowScriptAccess="sameDomain" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" />';
	HTML+= '</object>';
	return HTML;
	}
function objetFlash(fichier,x,y,bgcolor,id) {
	HTML = onlyFlash(fichier,x,y,bgcolor,id);
	document.write(HTML);
	}

function cacheid(id) {if (document.getElementById(id)) {document.getElementById(id).style.display='none';}
	// else {alert(id+'?');}
	}
function afficheid(id) {if (document.getElementById(id)) {document.getElementById(id).style.display='block';}
	// else {alert(id+'?');}
	}
function swapid(id) {
	if (document.getElementById(id)) {
		if (document.getElementById(id).style.display=='block') {
			document.getElementById(id).style.display='none';
			} else {
			document.getElementById(id).style.display='block';
			}
		}// else {alert(id+'?');}
	}
