
	var PASSWORD_LG_MINI = 4;
	var PASSWORD_LG_MAX = 8;
	
	function writeRBformate(nombre,id)
	{
		var szDiv = "nombreRB" + id;
		 
		document.write('<div class="fondRB" id="' + szDiv + '">');

		document.write('</div>');

		var so = new SWFObject("imagestyle/nombre_RB.swf", "mymovieRB" , "100%", "100%", "7", "");

		so.addParam("wmode","transparent");
		so.addVariable("nombreRB",""+nombre);

		so.write(szDiv);
	}



	function changeBtnRounded(id,back,coul)
	{
		var elt = document.getElementById(id);

		if (elt)
		{
			elt.style.backgroundColor = back;
			elt.style.color = coul;
		}
	}



	function remetBtnRounded(id,back,coul)
	{
		var elt = document.getElementById(id);

		if (elt)
		{
			elt.style.backgroundColor = '';
			elt.style.color = '';
		}
	}


	function afficheLogoCours(fichier)
	{
		//alert(fichier);
		if (fichier != "")
		{
			// si modif taille voir aussi div correspondant
			var so = new SWFObject(fichier, "mymovie", "100%", "100%", "7", "");

			so.addParam("wmode","transparent");

			so.write("div_description_logo");
		}
	}
	
	function agrandirSWF(id)
	{
		var url= "php/visuSWF.php" + "?id=" + id;
		
	
		//alert(url);
		
		var win = window.open(url , "sujet", "width=650px,height=490px,location=no,status=no,menubar=no,toolbar=no,scrollbars=yes,resizable=yes");
	
		win.focus();
	}


	function ouvrirFenetre(url,nom)
	{
		var win = window.open(url , nom, "location=no,status=yes,menubar=no,toolbar=no,scrollbars=yes,resizable=yes");
		
	
		win.focus();
		
		return win
	}		


	function changeBtnRoundedPDF(id)
	{
		changeBtnRounded(id,"#333333","#FFFFFF");
	}

	function remetBtnRoundedPDF(id)
	{
		remetBtnRounded(id,"#B8B8B8","#000000");
	}


	function btnBackgroundImageInit(id)
	{
		var elt = document.getElementById(id);

		if (elt)
			elt.style.backgroundImage = '';

	}

	function btnBackgroundImage(id,img)
	{
		var elt = document.getElementById(id);

		if (elt)
		{
			elt.style.backgroundImage = img;
		}

	}

	function coderPageUrl(url)
	{
		return 'index.php?page=' + escape(url);
	}
	
	function getValueInputformulaire(form,champ)
	{
		return document.forms[form].elements[champ].value
	}


	function setValueInputformulaire(form,champ,val)
	{
		document.forms[form].elements[champ].value = val;
	}


	function checkEmail(emailAddr) 
	{
		// Cette fonction vérifie la bon format d'une adresse e-mail.
		// Comme :  user@domain.com ou user.perso@domain.com

		var i;
		// Recherche de @
		i = emailAddr.indexOf("@");
		if (i == -1) {
			return false;
		}

		// Séparation du nom de l'utilisateur et du nom de domaine.
		var username = emailAddr.substring(0, i);
		var domain = emailAddr.substring(i + 1, emailAddr.length)

		// Recherche des espaces au début du nom de l'utilisateur.
		i = 0;
		while ((username.substring(i, i + 1) == " ") && (i < username.length)) {
			i++;
		}
		// Les enlève s'il en trouve.
		if (i > 0) {
			username = username.substring(i, username.length);
		}

		// Recherche d'espaces à la fin du nom de domaine.
		i = domain.length - 1;
		while ((domain.substring(i, i + 1) == " ") && (i >= 0)) {
			i--;
		}
		// Les enlève s'il en trouve.
		if (i < (domain.length - 1)) {
			domain = domain.substring(0, i + 1);
		}

		// Vérifie que le nom de l'utilisateur et du domaine ne soit pas vide.
		if ((username == "") || (domain == "")) {
			return false;
		}

		// Vérifie s'il n'y a pas de caractères interdits dans le nom de l'utilisateur.
		var ch;
		for (i = 0; i < username.length; i++) {
			ch = (username.substring(i, i + 1)).toLowerCase();
			if (!(((ch >= "a") && (ch <= "z")) || 
				((ch >= "0") && (ch <= "9")) ||
				(ch == "_") || (ch == "-") || (ch == "."))) {
					return false;
			}
		}

		// Vérifie s'il n'y a pas de caractères interdits dans le nom de domaine
		for (i = 0; i < domain.length; i++) {
			ch = (domain.substring(i, i + 1)).toLowerCase();
			if (!(((ch >= "a") && (ch <= "z")) || 
				((ch >= "0") && (ch <= "9")) ||
				(ch == "_") || (ch == "-") || (ch == "."))) {
					return false;
			}
		}

		// Ajouter ci-dessous de nouveaux noms de domaine.
		var aSuffix = new Array("com","net","int","aero","biz","museum","name","info","coop","pro","eu","edu","org","gov","mil","bj","dz","de","ad","be","ca","bf","bi","cm","cf","cg","cd","ci","dj","fr","ga","gp","gf","lu","mg","ml","ma","mq","mr","mc","nc","pf","re","pm","sn","ch","td","tf","tn");
			var bFoundSuffix = false;
			i = 0;
			while (i < aSuffix.length) {
				if (("." + aSuffix[i]) == domain.substring(domain.length - aSuffix[i].length - 1, domain.length)) {
					return true;
				}
				i++;
			}
			// Si le nom de domaine est inconnu  : return false
		return false;
	
	}

	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 controlerChampTxt(id)
	{
		var ret = true;
		
		var elt = document.getElementById(id);
		
		if (elt)
		{
			ret = false;
			if (trim(elt.value,' ') != "")
				ret = true;
		}
		
		return ret;
		
	}

	
	function errorChampTxt(id, err) 
	{
		var eltError = document.getElementById(id);

		if (err) 
		{
			if (eltError)
				eltError.style.borderColor="red";
		}
		else
		{
			if (eltError)
				eltError.style.borderColor="";
		}
	}


	function focusTxt(id)
	{
		elt = document.getElementById(id);
		if (elt)
			elt.focus();
	}

	function errorMsg(id)
	{
		alert ("Veuillez corriger le(s) champ(s) incorrect(s) encadré(s) en rouge, Merci.");

		elt = document.getElementById(id);
		if (elt)
			elt.focus();

	}

	/** 
	 * Javascript trim, ltrim, rtrim 
	 * Fonctions de suppression des espaces surnuméraires (ou autres caractères) 
	 * en début et en fin de chaine. 
	 * trim va faire appel à deux autres méthodes rtrim et ltrim qui éventuellement 
	 * restent accessibles individuellement. 
	 * 
	 * Source :  * http://www.webtoolkit.info/ 
	 * 
	 * @param   {String}  str       Chaine de caractères à traiter.         OBLIGATOIRE 
	 * @param   {String}  chars     Chaine à supprimer (par défaut, espace) FACULTATIF 
	 * @return  {String} 
	 */ 
	function trim (str, chars) 
	{ 
		return ltrim(rtrim(str, chars), chars); 
	} 

	function ltrim (str, chars) 
	{ 
		var car = (chars != undefined) ? chars : "\\s"; 
		return str.replace(new RegExp("^[" + chars + "]*", "g"), ""); 
	} 

	function rtrim (str, chars) 
	{ 
		var car = (chars != undefined) ? chars : "\\s"; 
		return str.replace(new RegExp("[" + chars + "]*$", "g"), ""); 
	} 


	function ImprimerPage(script,params,lg,ht)
	{
		var sOption="toolbar=yes,location=no,directories=yes,menubar=yes,";
			 sOption+="scrollbars=yes,left=100,top=25";
			 
		var fichier = 'print';
			 
		if (lg == -1)			 
			sOption = sOption + ",width=750";
		else			
			sOption = sOption + ",width=" + lg;
			
		if (ht == -1)			 
			sOption = sOption + ",height=600";
		else			
			sOption = sOption + ",height=" + ht;

		
		if (script != '')
			fichier = script;
			
		
		var winprint=window.open("php/" + fichier + ".php" + params,"Print",sOption);

		winprint.focus();
	}


/*
** Returns the caret (cursor) position of the specified text field.
** Return value range is 0-oField.length.
*/
function doGetCaretPosition (oField)
{

	// Initialize
	var iCaretPos = 0;

	// IE Support
	if (document.selection)
	{ 

		// Set focus on the element
		oField.focus ();

		// To get cursor position, get empty selection range
		var oSel = document.selection.createRange ();

		// Move selection start to 0 position
		oSel.moveStart ('character', -oField.value.length);

		// The caret position is selection length
		iCaretPos = oSel.text.length;
	}

	// Firefox support
	else if (oField.selectionStart || oField.selectionStart == '0')
	iCaretPos = oField.selectionStart;

	// Return results
	return (iCaretPos);
}


/*
** Sets the caret (cursor) position of the specified text field.
** Valid positions are 0-oField.length.
*/
function doSetCaretPosition (oField, iCaretPos)
{

	// IE Support
	if (document.selection)
	{ 
		// Set focus on the element
		oField.focus ();

		// Create empty selection range
		var oSel = document.selection.createRange ();

		// Move selection start and end to 0 position
		oSel.moveStart ('character', -oField.value.length);

		// Move selection start and end to desired position
		oSel.moveStart ('character', iCaretPos);
		oSel.moveEnd ('character', 0);
		oSel.select ();
	}

	// Firefox support
	else if (oField.selectionStart || oField.selectionStart == '0') {
	oField.selectionStart = iCaretPos;
	oField.selectionEnd = iCaretPos;
	oField.focus ();
	}
}

function lienMail(nom, domaine, sujet)
{
	var subject = "subject=" + sujet ;
		
	document.write('<a href=\"mailto:' + nom + '@' + domaine + ' ?' + subject + '\">') ;
	document.write(nom + '@' + domaine + '</a>') ;
}

function confirmation(url,mess)
{
	resultat = confirm("Etes-vous s\373r de vouloir " + mess);

	//alert(location.pathname);
	//alert(url);

	if(resultat == true)
	{
		location.href = location.pathname + url;
	}

}
