var isNav, isIE;



var quel_nav = navigator.userAgent.toLowerCase();
var nav_opera = (quel_nav.indexOf("opera") != -1);
var Msie = (quel_nav.indexOf("msie") != -1)&&document.all&&!nav_opera;


caractere_apostrophe = "'";

if(parseInt(navigator.appVersion) >=4)
{
    if(navigator.appName == 'Netscape')
    {
        isNav = true;
		isIE = false;
    }
    else{
        isNav = false;
		isIE = true;
    }
}



function add_Event_Listener (elem,quel_ev,quel_fonc) {
	try {
		elem.addEventListener(quel_ev,quel_fonc,false);
	} catch(e) {
		try {
			elem.detachEvent('on'+quel_ev,quel_fonc);
			elem.attachEvent('on'+quel_ev,quel_fonc);
		} catch(e) {
			elem['on'+quel_ev]=quel_fonc;
		}
	} 
}

function remove_Event_Listener (elem,quel_ev,quel_fonc) {
	try {
		elem.removeEventListener(quel_ev,quel_fonc,false);
	} catch(e) {
		try {
			elem.detachEvent('on'+quel_ev,quel_fonc);
		} catch(e) {
			elem['on'+quel_ev]=null;
		}
	}
}

var GestionTouches = function(e) {
	if (!e) e = window.event; // ie
	if (!e.target) e.target = e.srcElement; // ie
	if (e.target.form) return true;
	url = '';
	switch (e.keyCode) {
		case 39: case 13: url = quel_add[0]; break; // D
		case 37: url = quel_add[1]; break; // G
		//case 40: url = quel_add[2]; break; // B
		//case 38: url = quel_add[3]; break; // H
	}
	if (url) { 
		remove_Event_Listener(document,nav_opera?'keypress':'keydown',GestionTouches);
		window.location.href=url;
		if (e.preventDefault) e.preventDefault(); // no scroll
    	else e.returnValue = false;
		return false;
	}
}

function addToFavorites(anchor)
{
	if (window.external)
	{
		window.external.AddFavorite(anchor.getAttribute('href'), anchor.getAttribute('title'));
	}
}


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


function TrouveValeurRadio(argNomGroupeRadio) 
{
 	radio =  document.getElementsByName(argNomGroupeRadio);
	
	for (var i=0; i<radio.length;i++) 
	{
		if (radio[i].checked) 
		{
			return(radio[i].value);
		}
	}
      
}

function RadioButton_SetCheckedValue(radioObj, newValue) 
{

        if(!radioObj) return;
		//if(radioObj == 'question_9_reponse') alert('t1');
        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 RadioButton_SetEnable(radioObj, argValue, argEnable) 
{
	if(!radioObj) return;
	
	//if(radioObj == 'question_9_reponse') alert('t1');
	var radioLength = radioObj.length;

	if(radioLength == undefined) 
	{
	   return;
	}

	for(var i = 0; i < radioLength; i++) 
	{
		
		if(radioObj[i].value == argValue) 
		{
			
			radioObj[i].checked = false;
			radioObj[i].disabled = !argEnable;
		}
	   
	}
}


  function StringRemplace(argSource, argChercher, argRemplacerPar)
  {
  	var chaine= argSource;
  	
  	//alert('chercher:'+argChercher);
  	
	var reg=new RegExp(argChercher, "i");
	
	var resultat = chaine.replace(reg, argRemplacerPar);
	//id = nomimage[0].replace('-idcache', '');
	//alert('res:'+resultat);

	return resultat;
  	
  }
   
function ouvre_popup(page, nom_popup) 
{
	window.open(page,nom_popup,"menubar=no, status=no, scrollbars=no, menubar=no, width=200, height=100");
}
   
function CheckBoxSelectDeselect(argName, argBool)
{
	// Select if true
	document.getElementById(argName).checked = argBool;
	// Deselect if false
}

function activer_object(obj, argBool)
{
	document.getElementById(obj).disabled = argBool;
	
}

function afficher(obj, disp){

	
	
	if(disp == true)
	{
		//alert('t0');
		if(isNav)
		{
			//alert('t0_0');
			document.getElementById(obj).style.display = "";
		}
		else
		{
			//alert('t0_1');
			document.getElementById(obj).style.visibility = "visible";
		}
	}
	else
	{
		//alert('t1');
		if(isNav){
			//alert('t1_0');
			document.getElementById(obj).style.display = "none";
		}
		else{
			//alert('t1_1');	
			document.getElementById(obj).style.visibility = "hidden";
		}
	}
}

function afficherTr(obj, disp){
	if(disp == true)
	{
		//alert('t0');
		if(isNav)
		{
			//alert('t0_0');
			document.getElementById(obj).style.visibility = "visible";
			document.getElementById(obj).style.display = "table-row";
		}
		else
		{
			//alert('t0_1');
			document.getElementById(obj).style.display = "";
		}
	}
	else
	{
		//alert('t1');
		if(isNav){
			//alert('t1_0');
			document.getElementById(obj).style.visibility = "collapse";
		}
		else{
			//alert('t1_1');
			document.getElementById(obj).style.display = "none";
		}
	}
}

function TrouveDernierCaractereTape(e)
{
	if(isIE == true)
	{
		caractere = e.keyCode;
	}
	else
	{
		caractere = e.keyCode;
	}
	
	return caractere;	
}


function DoLaissePasserCaractere(event, nom_du_champ, boolChiffre, boolLettre, boolAutre, boolPointOuVirgule, boolSigneMoins, argSeparateur)
{
	res = true;
	
	if(isIE == true)
	{
		caractere = event.keyCode;
	}
	else
	{
		caractere = event.charCode;
	}
	
	if(caractere == 0) return true;
	
	// ***** CHIFFRES
	// Char 48 : '0'
	// Char 57 : '9'
	if (caractere >= 48 && caractere <= 57)
	{
		if(boolChiffre == false)
			res = false;
		else
			res = true;
	}
	
	// ***** LETTRES
	if (
				(caractere >= 65 && caractere <= 90)
			||	(caractere >= 97 && caractere <= 122)
			||	(caractere >= 192 && caractere <= 255)
		)
	{
		if(boolLettre == false)
			res = false;
		else
			res = true;
	}

	// ***** CARACTERE "-"
	if(caractere == 45)
	{
		if(boolSigneMoins == true)
		{
			res = true;
		}
		else
		{
			res = false;
		}
	}
	
	// ***** AUTRES
	if (
				(caractere >= 32 && caractere <= 44)
			||	(caractere >= 46 && caractere <= 47)
			||	(caractere >= 58 && caractere <= 64)
			||	(caractere >= 91 && caractere <= 96)
			||	(caractere >= 123 && caractere <= 191)			
		)
	{
		if(boolAutre == false)
			res = false;
		else
			res = true;
	}

	// ***** SEPARATEUR POINT OU VIRGULE
	if(argSeparateur == ',') separateur = 44;
	if(argSeparateur == '.') separateur = 46;
	
	if(boolPointOuVirgule == true && caractere == separateur)
	{
		// Si l'utilisateur tape , ou . on regarde si il n'y a pas déjà ce
		// caractère dans la chaine.
		// Cela veut dire que l'on autorise seulement un point ou une virgule dans ces champs la.
		
		valeur = document.getElementById(nom_du_champ).value;	
		
		// On regarde si ce caractère existe deja dans le champ valeur.
		pos = valeur.indexOf(argSeparateur, 0);
		
		if(pos == -1)
		{
			res = true;
		}

	}	
	
/*
	if(res == true)
		alert('true');
	else
		alert('false');
*/

	event.returnValue = res;
	return res;	

}

function ShowYN(divName) 
{
	if (document.getElementById(divName).style.display == 'none') 
	{
		document.getElementById(divName).style.display = 'block';
	}
	
}

function HideYN(divName) 
{
	if (document.getElementById(divName).style.display != 'none') 
	{
		document.getElementById(divName).style.display = 'none';
	}
}

function Toggle(divName)
{
	
	if (document.getElementById(divName).style.display == 'none') 
	{
		ShowYN(divName);
	} else 
	{
		HideYN(divName);
	}
	
}



function DisplayOrHideControl(divName)
{
	
	if (document.getElementById(divName).style.display == 'none') 
	{
		ShowYN(divName);
	} else 
	{
		HideYN(divName);
	}
	
}


function jsUpload(upload_field, argUploadDiv, argUploadContent, argFiltre, argPrefixMessage)
{
	// this is just an example of checking file extensions
    // if you do not need extension checking, remove 
    // everything down to line
    // upload_field.form.submit();

    var re_text = argFiltre;
    //  /\.jpg|\.gif|\.jpeg/i
    var filename = upload_field.value;

    /* Checking file type */
    if (filename.search(re_text) == -1)
    {
        //alert('File does not have image(jpg, gif, jpeg) extension');
        alert(argPrefixMessage);
        upload_field.form.reset();
        return false;
    }

    upload_field.form.submit();
    
    document.getElementById(argUploadDiv).innerHTML = Base64.decode(argUploadContent);
    
    //alert(document.getElementById(argUploadDiv).innerHtml);
    upload_field.disabled = true;
    return true;
}


/* ***** IMAGES ***** */

/**
* Swap out an image src property via the DOM
*
* @param id the element id of the image (not name)
* @param src the src property of the image
*/

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_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_findObj(n, d) 
{ //v4.01
  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 && d.getElementById) x=d.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)
  {
	  	//alert(i);
		if ((x=MM_findObj(a[i]))!=null)
		{
			//alert(x);
			document.MM_sr[j++]=x; 
			if(!x.oSrc) x.oSrc=x.src; x.src=a[i+2];
		}
  }
}

/* ***** PLUS / MOINS ***** */

function addEvent(argDivConteneur, argNomDivCompteur, argDivContenu, argPrefixNom, argValeurDefault)
{
	var ni = document.getElementById(argDivConteneur);
	var numi = document.getElementById(argNomDivCompteur);
	var num = (document.getElementById(argNomDivCompteur).value -1)+ 2;
	numi.value = num;
	
	var divIdName = argPrefixNom+'_'+num;
	
	//alert(argValeurDefault);
	//alert(argValeurDefault[0]);
	//alert(argValeurDefault[1]);
	//alert(argValeurDefault[2]);
	//alert(argValeurDefault[3]);
	
	var newdiv = document.createElement('div');
	newdiv.setAttribute("id",divIdName);
	
	var contenuDiv = document.getElementById(argDivContenu);
	var strContenuDiv = contenuDiv.innerHTML;
	
	//alert(strContenuDiv);
	
	var reg=new RegExp("(meta_div_number)", "g");
	strContenuDiv = strContenuDiv.replace(reg, num);
	
	var reg2=new RegExp("(meta_div_name)", "g");
	strContenuDiv = strContenuDiv.replace(reg2, argPrefixNom);

	//alert(strContenuDiv);
	
	for(var i = 0 ; i < 10 ; i++)
	{
		//alert('val'+i+':'+argValeurDefault[i]);
		
		if(argValeurDefault[i] != 'undefined' && argValeurDefault[i] != null)
		{
			var reg3=new RegExp("(meta_div_valeur_"+(i+1)+")", "g");
			
			if(isIE == true)	
				strContenuDiv = strContenuDiv.replace(reg3, "\""+argValeurDefault[i]+"\"");
			else
				strContenuDiv = strContenuDiv.replace(reg3, ""+argValeurDefault[i]+"");
		}
		else
		{
			var reg3=new RegExp("(meta_div_valeur_"+(i+1)+")", "g");
			strContenuDiv = strContenuDiv.replace(reg3, '');
		}
		
		//alert(strContenuDiv);
		
	}		
	
	//alert(strContenuDiv);
	newdiv.innerHTML = strContenuDiv;
	//alert(newdiv.innerHTML);
	
	
	ni.appendChild(newdiv);
}

function removeEvent(argDivConteneur, argPrefixNom, divNum)
{
	//alert('argDivConteneur='+argDivConteneur+'\nargPrefixNom='+argPrefixNom+'\ndivNum='+divNum);
	var d = document.getElementById(argDivConteneur);
	var olddiv = document.getElementById(argPrefixNom+'_'+divNum);
	d.removeChild(olddiv);
}




/* ***** BASE 64 ***** */

/**
*
*  Base64 encode / decode
*  http://www.webtoolkit.info/
*
**/

var Base64 = {

	// private property
	_keyStr : "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",

	// public method for encoding
	encode : function (input) {
		var output = "";
		var chr1, chr2, chr3, enc1, enc2, enc3, enc4;
		var i = 0;

		input = Base64._utf8_encode(input);

		while (i < input.length) {

			chr1 = input.charCodeAt(i++);
			chr2 = input.charCodeAt(i++);
			chr3 = input.charCodeAt(i++);

			enc1 = chr1 >> 2;
			enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
			enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
			enc4 = chr3 & 63;

			if (isNaN(chr2)) {
				enc3 = enc4 = 64;
			} else if (isNaN(chr3)) {
				enc4 = 64;
			}

			output = output +
			this._keyStr.charAt(enc1) + this._keyStr.charAt(enc2) +
			this._keyStr.charAt(enc3) + this._keyStr.charAt(enc4);

		}

		return output;
	},

	// public method for decoding
	decode : function (input) {
		var output = "";
		var chr1, chr2, chr3;
		var enc1, enc2, enc3, enc4;
		var i = 0;

		input = input.replace(/[^A-Za-z0-9\+\/\=]/g, "");

		while (i < input.length) {

			enc1 = this._keyStr.indexOf(input.charAt(i++));
			enc2 = this._keyStr.indexOf(input.charAt(i++));
			enc3 = this._keyStr.indexOf(input.charAt(i++));
			enc4 = this._keyStr.indexOf(input.charAt(i++));

			chr1 = (enc1 << 2) | (enc2 >> 4);
			chr2 = ((enc2 & 15) << 4) | (enc3 >> 2);
			chr3 = ((enc3 & 3) << 6) | enc4;

			output = output + String.fromCharCode(chr1);

			if (enc3 != 64) {
				output = output + String.fromCharCode(chr2);
			}
			if (enc4 != 64) {
				output = output + String.fromCharCode(chr3);
			}

		}

		output = Base64._utf8_decode(output);

		return output;

	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}



/* ***** URL ***** */

/**
*
*  URL encode / decode
*  http://www.webtoolkit.info/
*
**/

var Url = {

	// public method for url encoding
	encode : function (string) {
		return escape(this._utf8_encode(string));
	},

	// public method for url decoding
	decode : function (string) {
		return this._utf8_decode(unescape(string));
	},

	// private method for UTF-8 encoding
	_utf8_encode : function (string) {
		string = string.replace(/\r\n/g,"\n");
		var utftext = "";

		for (var n = 0; n < string.length; n++) {

			var c = string.charCodeAt(n);

			if (c < 128) {
				utftext += String.fromCharCode(c);
			}
			else if((c > 127) && (c < 2048)) {
				utftext += String.fromCharCode((c >> 6) | 192);
				utftext += String.fromCharCode((c & 63) | 128);
			}
			else {
				utftext += String.fromCharCode((c >> 12) | 224);
				utftext += String.fromCharCode(((c >> 6) & 63) | 128);
				utftext += String.fromCharCode((c & 63) | 128);
			}

		}

		return utftext;
	},

	// private method for UTF-8 decoding
	_utf8_decode : function (utftext) {
		var string = "";
		var i = 0;
		var c = c1 = c2 = 0;

		while ( i < utftext.length ) {

			c = utftext.charCodeAt(i);

			if (c < 128) {
				string += String.fromCharCode(c);
				i++;
			}
			else if((c > 191) && (c < 224)) {
				c2 = utftext.charCodeAt(i+1);
				string += String.fromCharCode(((c & 31) << 6) | (c2 & 63));
				i += 2;
			}
			else {
				c2 = utftext.charCodeAt(i+1);
				c3 = utftext.charCodeAt(i+2);
				string += String.fromCharCode(((c & 15) << 12) | ((c2 & 63) << 6) | (c3 & 63));
				i += 3;
			}

		}

		return string;
	}

}

	function sendToClipboard(s)
   {
      if( window.clipboardData && clipboardData.setData )
      {
         clipboardData.setData('Text', s);
      }
      else
      {
       	//alert('Internet Explorer required');
      }
   }













var tabQuestionnaireListeQuestion = new Array();
						
function questionnaire_display_div(type,id_question,id_reponse) {
	
	var balisesDivs = document.getElementsByTagName("div");
	var name_div = "div_questionnaire_"+id_question+"_"+id_reponse;
	var name_div2 = "div_questionnaire_"+id_question;
	
	for (var i=0; i < balisesDivs.length; i++) {
	
		if (balisesDivs[i].id.substr(0,name_div.length) == name_div) {
			
			if (document.getElementById(balisesDivs[i].id).style.display == "inline") {
				document.getElementById(balisesDivs[i].id).style.display = "none";
			} else {
				document.getElementById(balisesDivs[i].id).style.display = "inline";
			}
		
		} else if (balisesDivs[i].id.substr(0,name_div2.length) == name_div2) {
			
			if (type == "select" || type == "radio") {
				document.getElementById(balisesDivs[i].id).style.display = "none";
			}
			
		}
		
	}
	
	questionnaire_deselectionne_question(id_question,type,id_reponse);
	
	//alert("QuestionnaireListeQuestion : "+document.getElementById("questionnaire_liste_question").value);
	
}

function questionnaire_mise_a_jour_liste_question(id_question,id_reponse,action) {
	
	var QuestionnaireListeQuestion = document.getElementById("questionnaire_liste_question").value;
	
	if (QuestionnaireListeQuestion != "") {
		var tabQuestionnaireListeQuestion = QuestionnaireListeQuestion.split("|");
		var nbQuestion = tabQuestionnaireListeQuestion.length;
	} else {
		var nbQuestion = 0;
		var tabQuestionnaireListeQuestion = new Array();
	}
	
	//SUPPRESSION
	if (nbQuestion > 0) {
		
		for (var i=0; i<nbQuestion; i++) {
			
			if (tabQuestionnaireListeQuestion[i]) {
			
				var d = tabQuestionnaireListeQuestion[i].split("_");
				
				var q_id_question = d[1];
				var q_id_reponse = d[2];
				
				if (id_question == q_id_question && id_reponse == q_id_reponse) {
					tabQuestionnaireListeQuestion.splice(i,1);
				}
				
			}
			
		}
		
	}

	//AJOUT
	if (action == "ajout") {
		tabQuestionnaireListeQuestion.push("question_"+id_question+"_"+id_reponse);
	}
	
	QuestionnaireListeQuestion = tabQuestionnaireListeQuestion.join("|");
	
	document.getElementById("questionnaire_liste_question").value = QuestionnaireListeQuestion;
	
	

}

function questionnaire_deselectionne_question(id_question,type,id_reponse_selectionnee) {
	
	//Type de question
	type = document.getElementById("type_question_"+id_question).value;
	
	//Pas de reponse pour ce type de question donc on initialise directement
	if (type == "text") {
		document.getElementById("question_"+id_question+"_reponse").value = "";
	} else if (type == "area") {
		document.getElementById("question_"+id_question+"_reponse").value = "";
	} else if (type == "vote_etoile") {
		questionnaire_selection_vote_etoile(id_question,0);
	}
	
	//Recuperation de la lise des reponses
	if (document.getElementById("liste_reponses_"+id_question)) {
		var liste_reponses = document.getElementById("liste_reponses_"+id_question).value;
	}
	
	//Si la question où se passe laction (id_reponse_selectionnee present) est un checkbox, la liste des repose est limité à celle selectionnée pour pas initialiser les autres
	if (type == "checkbox" && id_reponse_selectionnee) {
		var liste_reponses = id_reponse_selectionnee;
	}
	
	if (liste_reponses) {
	
		var tab_liste_reponse = liste_reponses.split(",");
		var nb_reponses = tab_liste_reponse.length;
		
		for (var i=0; i<nb_reponses; i++) {
			
			var effacer_sous_question = true;
			
			if (tab_liste_reponse[i]) {
				
				var id_reponse = tab_liste_reponse[i];
				
				if (id_reponse_selectionnee) { //Question action
				
				
					if (type == "checkbox") {
						if (id_reponse_selectionnee == id_reponse) {
							if (document.getElementById("question_"+id_question+"_reponse_"+id_reponse).checked == true) {
								questionnaire_mise_a_jour_liste_question(id_question,id_reponse,"ajout");
								effacer_sous_question = false;
							} else {
								questionnaire_mise_a_jour_liste_question(id_question,id_reponse,"effacer");
							}
						}
					} else {
						if (id_reponse_selectionnee == id_reponse) {
							questionnaire_mise_a_jour_liste_question(id_question,id_reponse,"ajout");
							effacer_sous_question = false;
						} else {
							questionnaire_mise_a_jour_liste_question(id_question,id_reponse,"effacer");
						}
					}
				
				
				} else { //Sous question
				
					//alert("div_questionnaire_"+id_question+"_"+id_reponse);
					if (document.getElementById("div_questionnaire_"+id_question+"_"+id_reponse)) {
						document.getElementById("div_questionnaire_"+id_question+"_"+id_reponse).style.display = "none";
					}
					
					if (type == "checkbox") {
						document.getElementById("question_"+id_question+"_reponse_"+id_reponse).checked = false;
					} else if (type == "radio") {
						//document.getElementById("question_"+id_question+"_reponse").value = "-1";
						RadioButton_SetCheckedValue(document.getElementsByName("question_"+id_question+"_reponse"), "");
					} else if (type == "select") {
						document.getElementById("question_"+id_question+"_reponse").selectedIndex = 0;
					}
					
					//EFFACER
					questionnaire_mise_a_jour_liste_question(id_question,id_reponse,"effacer");
					
				}
				
				if (effacer_sous_question) {
				
					var liste_sous_questions = document.getElementById("liste_sous_questions_"+id_question+"_"+id_reponse).value;
					
					if (liste_sous_questions) {
						
						var tab_liste_sous_questions = liste_sous_questions.split(",");
						var nb_reponses2 = tab_liste_sous_questions.length;
							
						for (var x=0; x<nb_reponses2; x++) {
							
							if (tab_liste_sous_questions[x]) {
									
								var id_sous_question = tab_liste_sous_questions[x];
									
								questionnaire_deselectionne_question(id_sous_question,"","");
								
							}
							
						}											
						
					}
					
				}
				
			}
			
		}
		
	}

}

function questionnaire_selection_vote_etoile(id_question,note) {
	var largeur = note*20;
	document.getElementById("questionnaire_vote_etoile_"+id_question).style.width = largeur+"%";
	document.getElementById("question_"+id_question+"_reponse").value = note;
}

notificationTitrePageRealTitle = '';

function notificationTitrePage(argNotificationMessagemsg,argNbApparitionNotification) {

	if (!notificationTitrePageRealTitle) {
		notificationTitrePageRealTitle = document.title;
	}

	if (document.title != notificationTitrePageRealTitle || argNbApparitionNotification <= 0) {
		document.title = notificationTitrePageRealTitle;
		if (argNbApparitionNotification == 0) {
			var notificationTitrePageContinu = false;
		} else {
			var notificationTitrePageContinu = true;
		}
	} else {
		var notificationTitrePageContinu = true;
		document.title = argNotificationMessagemsg;
		argNbApparitionNotification--;
	}
	
	if (argNbApparitionNotification >= 0 && notificationTitrePageContinu) {
		setTimeout("notificationTitrePage('"+argNotificationMessagemsg+"','"+argNbApparitionNotification+"')",1000);
	} else {
		notificationTitrePageRealTitle = '';
	}

}

function fbs_click() {
	u=location.href;
	t=document.title;
	window.open('http://www.facebook.com/sharer.php?u='+encodeURIComponent(u)+'&t='+encodeURIComponent(t),'sharer','toolbar=0,status=0,width=626,height=436');
	return false;
}

function simulateur_credit_calcul_mensualite_pow(x,y) {
	return Math.pow(x,y)
}

function simulateur_credit_calcul_mensualite() {
	
	var taux = document.getElementById("_simulateur_credit_calcul_mensualite_taux").value;
	var duree = document.getElementById("_simulateur_credit_calcul_mensualite_duree").value;
	var montant = document.getElementById("_simulateur_credit_calcul_mensualite_montant").value;
	
	//Calcul
	var calcul = true;
	
	if (taux < 0) calcul = false;
	if (duree <= 0) calcul = false;
	if (montant <= 0) calcul = false;
	
	taux = taux/100;

	if (calcul) {
	
		var mensualite = montant * ( (taux/12) /(1-simulateur_credit_calcul_mensualite_pow((1+ (taux/12) ),-duree)));
		
		mensualite = mensualite.toFixed(2);
		
		if (!isNaN(mensualite)) {
			document.getElementById("div_simulateur_credit_calcul_mensualite").innerHTML = mensualite+" &euro;";
		} else {
			document.getElementById("div_simulateur_credit_calcul_mensualite").innerHTML = "";
		}
		
	} else {
		
		document.getElementById("div_simulateur_credit_calcul_mensualite").innerHTML = "";
		
	}
	
}

function simulateur_credit_calcul_taux_endetement() {
	
	var charge = document.getElementById("_simulateur_credit_calcul_taux_endetement_charge").value;
	var credit = document.getElementById("_simulateur_credit_calcul_taux_endetement_credit").value;
	var revenus = document.getElementById("_simulateur_credit_calcul_taux_endetement_revenus").value;
	
	//Calcul
	var calcul = true;
	
	if (charge < 0) calcul = false;
	if (credit < 0) calcul = false;
	if (revenus < 0) calcul = false;
	
	if (calcul) {
	
		var taux_endetement = (Number(charge) + Number(credit)) / Number(revenus) * 100;
		//alert(charge+' - '+credit+' - '+revenus+' -> '+taux_endetement);
		taux_endetement = Math.round(taux_endetement);
		
		if (!isNaN(taux_endetement)) {
			document.getElementById("div_simulateur_credit_calcul_taux_endetement").innerHTML = taux_endetement+" %";
		} else {
			document.getElementById("div_simulateur_credit_calcul_taux_endetement").innerHTML = "";
		}
		
	} else {
		
		document.getElementById("div_simulateur_credit_calcul_taux_endetement").innerHTML = "";
		
	}
	
}
