function editer(type,id){
	switch(type){
		case "question":
			var url = "am_question_edit.php?action=editer&id="+id;
			fenetre_nouvelle_centree(url,500,300);
		break;
		case "reponse":
			var url = "am_question_edit.php?action=editer_reponse&id="+id;
			fenetre_nouvelle_centree(url,500,250);
		break;
		case "mot_cle":
			var url = "am_mot_cle_edit.php?action=editer_mot_cle&id="+id;
			fenetre_nouvelle_centree(url,500,100);
		break;
	}

	return false;
}

function valider(type,id,id2){
	var id2 = (id2 !== null) ? id2 : 0;
	if(confirm("Etes vous sur de vouloir valider cette "+type+" ?")){
		switch(type){
			case "question":
				var url = "am_question_edit.php?action=valider&id="+id;
				dom_array_supp("liste","l_"+id);
			break;
			case "reponse":
				var url = "am_question_edit.php?action=valider_reponse&id="+id;
				dom_array_supp("liste_reponse_"+id2,"lr_"+id);
			break;
			case "mot_cle":
				var url = "am_mot_cle_edit.php?action=valider_mot_cle&id="+id;
				dom_array_supp("liste","l_"+id);
			break;
		}
		var obj = $("page_traitement");
		dom_set_attribut(obj,"src",url);

	}
	return false;
}

function refuser(type,id,id2){
	var id2 = (id2 !== null) ? id2 : 0;
	if(confirm("Etes vous sur de vouloir refuser cette "+type+" ?")){
		switch(type){
			case "question":
				var url = "am_question_edit.php?action=refuser&id="+id;
				dom_array_supp("liste","l_"+id);
			break;
			case "reponse":
				var url = "am_question_edit.php?action=refuser_reponse&id="+id;
				dom_array_supp("liste_reponse_"+id2,"lr_"+id);
			break;
			case "mot_cle":
				var url = "am_mot_cle_edit.php?action=refuser_mot_cle&id="+id;
				dom_array_supp("liste","l_"+id);
			break;
		}
		var obj = $("page_traitement");
		dom_set_attribut(obj,"src",url);

	}
	return false;
}

//D'autres scripts sur http://www.toutjavascript.com
//Si vous utilisez ce script, merci de m'avertir !
var var_max = 220;  		// 50 caract&egrave;res maximum

function compter(f) {
	var txt=$F(f);
	var nb=txt.length;
	if (nb>var_max) {
		alert("Pas plus de "+var_max+" caracteres dans ce champ");
		$(f).value = txt.substring(0,var_max);
		nb=var_max;
	}
	if($('nbcar')){
		dom_set_attribut($('nbcar'),'value',nb);
	}
}

function set_var_max(value){
	var_max = value;
}


function decompter(f,new_max,champ_nb) {
	var new_max = (new_max != null) ? new_max : var_max;
	var champ_nb = (champ_nb != null) ? champ_nb : "nbcar";
	if(var_max != new_max){
		set_var_max(new_max);
	}
	var txt=$F(f);
	var nb=txt.length;
	var nb_aff = var_max-nb;
	var retour = true;
	if (nb>var_max) {
		alert("Pas plus de "+var_max+" caracteres dans ce champ");
		 txt = txt.substring(0,var_max-1);
		 $(f).value = txt;
		txt=$F(f);
		nb=txt.length;
		nb_aff=var_max-nb;
		retour = false;
	}

	if($(champ_nb)){
		dom_set_attribut($(champ_nb),'value',nb_aff);
	}
	return retour;
}


function timer() {
	compter("descriptif");
	setTimeout("timer()",100);
}

function submit_form(type){
	var type = (type != null) ? type:1;
	switch(type){
		case 1:
			document.form1.submit();
		break;
		case 2:
			document.form2.submit();
		break;
		case 3:
			document.form3.submit();
		break;
	}
	return false;
}

function submit_reponse(type){
	if(document.form1.descriptif.value == ""){
		alert("Veuillez saisir un contenu à votre réponse.");
		return false;
	}else{
		document.form1.submit();
	}
}

function submit_question(type){
	if(document.form1.objet.value == ""){
		alert("Veuillez saisir un titre à votre question.");
		return false;
	}else{
		if(document.form1.descriptif.value == ""){
			alert("Veuillez saisir un contenu à votre question.");
			return false;
		}else{
			return true;
		}
	}
}

function new_search(obj){
	if(obj.value = "Rechercher"){
		obj.value = "";
	}
}

function expand(id)
{
		document.getElementById('exp'+id).style.display = 'none';
		document.getElementById('col'+id).style.display = 'inline';
		document.getElementById('display'+id).style.display = 'inline';
		return false;

}

function collapse(id)
{
		document.getElementById('exp'+id).style.display = 'inline';
		document.getElementById('col'+id).style.display = 'none';
		document.getElementById('display'+id).style.display = 'none';
		return false;

}