	
function init_dialogue(){
	$('#dialog').dialog({
		autoOpen: false,
		modal: true,
		width: 500, 
		minHeight: 100,
		resizable: false,
		draggable: false
	});
}

function init_deploiement(){
	// Initialise les boutons de deploiement
	$(".deploiement").slideUp();
	$(".bouton_deploiement").unbind("click");
	$(".bouton_deploiement").click(function(){
		id = $(this).attr("id");
		$("#commenter_" + id).slideToggle("fast"); 
		$("#texte_" + id).focus();
	});
	$(".bouton_deploiement").mouseover(function(){
		$(this).css({cursor: "pointer"});
	});
	$(".bouton_deploiement").mouseout(function(){
		$(this).css({cursor: "default"});
	});
}
function fenetre_popup(url, data){
			$("#fenetre").html($("#sablier").html());
			$('#dialog').dialog("open");
			//Contenu du film
			//alert(url + " / " + data);
			$.ajax({
				type: "POST",
				url: url,
				data: data,
				success: function(reponse){
					$("#fenetre").html(reponse);
					// repositionne la boite
					posx = ($("#colonne_corps").width() - $("#dialog").width()) / 2 + $("#colonne_corps").offset().left;
					var hauteur = 0;
					if (document.all){
						hauteur = document.documentElement.scrollTop;
					}else{
						hauteur = window.pageYOffset;
					}
					posy = hauteur + ($(window).height() - $("#dialog").height()) / 2;
					//alert(posy);
					$("#dialog").dialog("option", "position", "[" + posx + ", " + posy + "]");
				}
			});
		}

function fermer_fenetre(){
	$('#dialog').dialog("close");
}

function CalculNbLignes(texte){
	resultat = 0;
	lignes = texte.value.split("\n");
	for(n = 0; n < (lignes.length); n++){
		resultat = Math.floor(resultat + (lignes[n].length / (texte.cols)) + 1); 
	}
	return resultat; 
}
function AdapteZoneDeTexte(texte, e){
	texte.rows = CalculNbLignes(texte);
}
function affiche_commentaire(id){
	$("#commenter_" + id).slideDown("slow");
	document.getElementById("texte_" + id).focus();
}
function masque_commentaire(id){
	document.getElementById("commenter_" + id).style.display = "none";
	document.getElementById("commenter_" + id).style.visibility = "hidden";
}
function position_souris(e){
	if (e.pageX || e.pageY){
		posx = e.pageX;
		posy = e.pageY;
	}else if (e.clientX || e.clientY) {
		posx = e.clientX + document.body.scrollLeft
			+ document.documentElement.scrollLeft;
		posy = e.clientY + document.body.scrollTop
			+ document.documentElement.scrollTop;
	}
	return {"x": posx, "y": posy};
}
function tableau_ajouter(tableau, valeur){
	tableau[tableau.length] = valeur;
}
function tableau_supprimer(tableau, valeur){
	var decalage = 0;
	for(var i in tableau){
		tableau[i - decalage] = tableau[i];
		if(tableau[i] == valeur)
			decalage = decalage + 1;
	}
	tableau.pop();
}
function tableau_supprimer_index(tableau, index){
	var decalage = 0;
	for(var i in tableau){
		tableau[i - decalage] = tableau[i];
		if(i == index)
			decalage = decalage + 1;
	}
	tableau.pop();
}
function tableau_in(tableau, valeur){
	var resultat = false;
	for(var i in tableau)
		if(tableau[i] == valeur)
			resultat = true;
	return resultat;
}

function texteNettoyer(texte){
	texte = supprimerAccents(texte);
	texte = supprimerPonctuations(texte);
	return texte;
}

function supprimerAccents(texte){
	temp = texte.replace(/[àâä]/gi,"a");
	temp = temp.replace(/[éèêë]/gi,"e");
	temp = temp.replace(/[îï]/gi,"i");
	temp = temp.replace(/[ôö]/gi,"o");
	temp = temp.replace(/[ùûü]/gi,"u");
	temp = temp.replace(/[ç]/gi,"c");
	return temp;
}

function supprimerPonctuations(texte){
	temp = texte.replace(/['",.-?!]/gi," ");
	return temp;
}
function jours_semaine($n){
	$jours = new Array("dimanche", "lundi", "mardi", "mercredi", "jeudi", "vendredi", "samedi");
	return $jours[n];
}
