/**
* Tommy Brière
* Productions Vic Pelletier tous droits réservées
* Afficher des belles boites de dialogues
*
* Nécessite:
* jquery
**/
$j.fn.message= function(msg, frame){
if(!frame)
frame="body";
var c='<div class="form-tooltip" >'+'<div class="form-tooltip-top"></div>'+'<div class="form-tooltip-wrapper">'+'<p>'+msg+'</p>'+'</div>'+'<div class="form-tooltip-bottom"></div>'+"<a href=\"#\" class=\"form-tooltip-close\" onclick=\"$j(this).parent().closeMessage(); return false;\"></a>"+'   <div class="form-tooltip-fleche"></div>'+'</div>';
$j(frame).prepend(c);
var t= $j(frame+"> .form-tooltip:first" );
var o= $j(this).offset();
var fp= $j(frame).offset();
t.css("position","absolute" );
var x= o.left- t.width()- 7- fp.left;
var y= o.top+($j(this).height() / 2)- 16- fp.top;
t.css("left", x+"px" );
t.css("top", y+"px" );
return this;}
$j.fn.closeMessage= function(){
this.fadeOut('fast', function(){
$j(this).remove();} );
return this;}
$j.clearMessages= function(){
$j(".form-tooltip").closeMessage();}
$j.fn.tooltip= function(msg, frame){
var c= $j(this);
var etat= 0;
var tool= null;

function addToDom(){
var coords= c.offset();
var t= $j('<div class="WQ_tooltip">'+'<div class="top-tooltip" ></div>'+'<div class="wrapper-tooltip">'+'<p>'+msg+'</p>'+'</div>'+'<div class="bottom-tooltip"></div>'+'<div class="fleche" ></div>'+'</div>'
);


$j(document.body).prepend(t);
t= $j(".WQ_tooltip");
var o= c.offset();
var fp= $j(frame).offset();
t.css("position","absolute" );
var x= o.left- t.width()- 7- fp.left;
var y= o.top+(c.height() / 2)- 16- fp.top;
t.css("left", x+"px" );
t.css("top", y+"px" );
tool= t;

return true;}

function isOver(){
var r= false;
c.each(function(i){
if(this.over){
r= true;}});
return r;}

function update(){
var over= isOver();
if(over){
if(etat== 0){
if(addToDom()){
etat= 1;
update();}}} else{
if(etat== 1){
tool.remove();
tool= null;
etat= 0;
update();}}}
c.mouseover(function(){
this.over= true;
update();});
c.mouseout(function(){
this.over= false;
update();});}
function PopUpHtml(html, x, y, width, height){
var tool= null;

function addToDom(){
var t= $j("<div>"+ html+"</div>" );
t[0].className="ajaxpopup";
$j(document.body).prepend(t);
var div= document.body.firstChild;
tool= $j(div);
tool.css("top", y);
tool.css("left", x);
if(width){
tool.css("width", width);}
if(height){
tool.css("height", height);}
etat= 2;}
this.close= function(){
tool.hide("normal", function(){
tool.remove();
tool= null;});}
addToDom();}
function ToolTip(msg, cibles){
$j(cibles).tooltip(msg);}