+}
+
+var positionTypeX = {gauche: 0, gaucheRecouvrement: 1, centre: 2, droiteRecouvrement: 3, droite: 4}
+var positionTypeY = {haut: 0, hautRecouvrement: 1, centre: 2, basRecouvrement: 3, bas: 4}
+
+/**
+ * Afficher une boite flottante (élément) par rapport à une cible.
+ * La boite est affichée de manière à ne pas dépasser de la fenêtre.
+ * @boite l'élément à afficher
+ * @cible l'élément sur lequel est affiché la boite
+ * @positionX de type positionTypeX
+ * @positionY de type positionTypeY
+ */
+Util.prototype.afficherBoite = function(boite, cible, positionX, positionY)
+{
+ var positionCible = cible.offset()
+ var positionBoite =
+ {
+ left : positionX == positionTypeX.gauche ? positionCible.left - boite.width() :
+ (positionX == positionTypeX.gaucheRecouvrement ? positionCible.left - boite.width() + cible.width() :
+ (positionX == positionTypeX.droitelsRecouvrement ? positionCible.left :
+ (positionX == positionTypeX.droite ? positionCible.left + cible.width() :
+ positionCible.left + cible.width() / 2 - boite.width() / 2 ))), // centre
+ top : positionY == positionTypeY.haut ? positionCible.top - boite.height() :
+ (positionY == positionTypeY.hautRecouvrement ? positionCible.top - boite.height() + cible.height() :
+ (positionY == positionTypeY.basRecouvrement ? positionCible.top :
+ (positionY == positionTypeY.bas ? positionCible.top + cible.height() :
+ positionCible.top + cible.height() / 2 - boite.height() / 2 ))) // centre
+ }
+
+ // calcul les décalages en x et en y pour éviter que la boite ne sorte de la fenêtre, tient compte de la position des barres de défilement
+ var marge = 10
+ positionBoite.left = positionBoite.left < marge + window.pageXOffset ? marge + window.pageXOffset :
+ (boite.width() - $(window).width() + (positionBoite.left - window.pageXOffset) + marge > 0 ? $(window).width() - boite.width() - marge + window.pageXOffset : positionBoite.left)
+ positionBoite.top = positionBoite.top < marge + window.pageYOffset ? marge + window.pageYOffset :
+ (boite.height() - $(window).height() + (positionBoite.top - window.pageYOffset) + marge > 0 ? $(window).height() - boite.height() - marge + window.pageYOffset : positionBoite.top)
+
+ boite.css("top", positionBoite.top).css("left", positionBoite.left).show()
+}
+
+var positionBulleType = {haut : 0, droite : 1, bas : 2, gauche : 3}
+
+/**
+ * Affiche un info bulle lorsque le curseur survole l'élément donné.
+ * @param message le message à afficher
+ * @param element l'élément DOM sur lesquel afficher la bulle
+ * @param la position de la bulle, voir positionBulleType. Par défaut à 0 (haut)
+ */
+Util.prototype.infoBulle = function(message, element, position)
+{
+ var thisUtil = this
+ if (position == undefined)
+ position = positionBulleType.haut
+
+ var cacherBulle = function()
+ {
+ $("#flecheBulle").hide()
+ $("#messageBulle").hide()
+ }
+
+ element.hover(
+ function()
+ {
+ if (!thisUtil.bulleActive)
+ return
+
+ var m = $("#messageBulle")
+ var f = $("#flecheBulle")
+ f.removeClass().addClass(position == positionBulleType.haut ? "flecheBulleHaut" :
+ (position == positionBulleType.droite ? "flecheBulleDroite" :
+ (position == positionBulleType.bas ? "flecheBulleBas" : "flecheBulleGauche" )))
+
+ // remplie le paragraphe de la bulle avec le message
+ $("p", m).html(message)
+
+ // réinitialise la position, évite le cas ou la boite est collé à droite et remplie avec un texte la faisant dépassé
+ // dans ce cas la hauteur n'est pas calculé correctement
+ m.css("top", 0).css("left", 0)
+
+ var positionFleche = {
+ left : position == positionBulleType.haut || position == positionBulleType.bas ?
+ element.offset().left + element.outerWidth() / 2 - f.width() / 2 :
+ (position == positionBulleType.gauche ? element.offset().left - f.width() : element.offset().left + element.outerWidth()),
+ top : position == positionBulleType.gauche || position == positionBulleType.droite ?
+ element.offset().top + element.outerHeight() / 2 - f.height() / 2 :
+ (position == positionBulleType.haut ? element.offset().top - f.height() : element.offset().top + element.outerHeight())
+ }
+ var positionMessage = {
+ left : position == positionBulleType.haut || position == positionBulleType.bas ?
+ element.offset().left + element.width() / 2 - m.width() / 2 :
+ (position == positionBulleType.gauche ? element.offset().left - f.width() - m.width() : element.offset().left + f.width() + element.outerWidth()),
+ top : position == positionBulleType.gauche || position == positionBulleType.droite ?
+ element.offset().top + element.outerHeight() / 2 - m.height() / 2 :
+ (position == positionBulleType.haut ? element.offset().top - f.height() - m.height() : element.offset().top + f.height() + element.outerHeight())
+ }
+ var depassementDroit = (positionMessage.left + m.width()) - $("body").width()
+ if (depassementDroit > 0)
+ positionMessage.left -= depassementDroit
+ else
+ {
+ if (positionMessage.left < 0)
+ positionMessage.left = 0
+ }
+
+ m.css("top", positionMessage.top).css("left", positionMessage.left).show()
+ f.css("top", positionFleche.top).css("left", positionFleche.left).show()
+ },
+ cacherBulle
+ ).click(cacherBulle)
+}