function position(e) {
x = (navigator.appName.substring(0,3) == "Net") ? e.pageX : event.x+document.body.scrollLeft;
y = (navigator.appName.substring(0,3) == "Net") ? e.pageY : event.y+document.body.scrollTop;
}

if (navigator.appName.substring(0,3) == "Net") document.captureEvents(Event.MOUSEMOVE);
document.onmousemove = position;

var array_mes = new Array();
var movement;
var intX;
var intY;
var moved=0;
var focus = new Array();

function Message(x, y, width, height, contenu,backgroundc,backgroundc2,fontc,affich,movable,closable) {
this.contenu = contenu;
this.affiche = Message_aff;
this.minimize = Message_minimize;
this.moveTo = Message_moveTo;
this.minimized = false;
this.movable = movable;
this.closable = closable;

if(height < 100)
{height = 100;}
if(width < 100)
{width = 100;}
this.height = height;

exist = false;

for(a=0;a<array_mes.length;a++)
{if(array_mes[a].contenu == contenu)
{exist = a+1;}}

if(exist==false)
{
this.id = array_mes.length;
array_mes[array_mes.length] = this;
focus[focus.length] = this.id;
}else{
array_mes[exist-1].affiche(false);
this.id = exist-1;
array_mes[exist-1] = this;
giveFocus(exist-1);
document.body.removeChild(document.getElementById("message"+this.id));
document.body.removeChild(document.getElementById("message"+this.id+".bord1"));
document.body.removeChild(document.getElementById("message"+this.id+".bord2"));
document.body.removeChild(document.getElementById("message"+this.id+".bord3"));
document.body.removeChild(document.getElementById("message"+this.id+".ombre"));
}

if(navigator.appName == "Netscape") navopacity = "-moz-opacity:0.30";
else navopacity = "filter:alpha(opacity=30)";

document.body.innerHTML += ('<DIV id="message'+this.id+'.ombre" style="position:absolute;top:'+(x+3)+'px;left:'+(y+4)+'px;visibility:hidden;color:'+fontc+';border-color:transparent;">'
+'<TABLE border="0" cellspacing="0" cellpadding="0"><TR><TD style="height:17px;width:'+(width)+'px;">'
+'<b class="rtop"><b style="background-color:black;'+navopacity+';" class="r1" style="background-color:black;'+navopacity+';"></b><b style="background-color:black;'+navopacity+';" class="r2"></b><b style="background-color:black;'+navopacity+';" class="r3"></b><b style="background-color:black;'+navopacity+';" class="r4"></b><b style="background-color:black;'+navopacity+';" class="r5"></b><b style="background-color:black;'+navopacity+';" class="r6"></b><b style="background-color:black;'+navopacity+';" class="r7"></b><b style="background-color:black;'+navopacity+';" class="r8"></b><b style="background-color:black;'+navopacity+';" class="r9"></b><b style="background-color:black;'+navopacity+';" class="r10"></b><b style="background-color:black;'+navopacity+';" class="r11"></b><b style="background-color:black;'+navopacity+';" class="r12"></b><b style="background-color:black;'+navopacity+';" class="r13"></b><b style="background-color:black;'+navopacity+';" class="r14"></b><b style="background-color:black;'+navopacity+';" class="r15"></b><b style="background-color:black;'+navopacity+';" class="r16"></b><b style="background-color:black;'+navopacity+';" class="r17"></b><b style="background-color:black;'+navopacity+';" class="r18"></b></b>'
+'</TD></TR><TR><TD id="message'+this.id+'.ombre.center" style="background-color:black;'+navopacity+';width:'+(width)+'px;height:'+(height-34)+'px;">'
+'</TD></TR><TR><TD style="width:'+(width)+'px;height:17px;">'
+'<b class="rbottom"><b style="background-color:black;'+navopacity+';" class="r18"></b><b style="background-color:black;'+navopacity+';" class="r17"></b><b style="background-color:black;'+navopacity+';" class="r16"></b><b style="background-color:black;'+navopacity+';" class="r15"></b><b style="background-color:black;'+navopacity+';" class="r14"></b><b style="background-color:black;'+navopacity+';" class="r13"></b><b style="background-color:black;'+navopacity+';" class="r12"></b><b style="background-color:black;'+navopacity+';" class="r11"></b><b style="background-color:black;'+navopacity+';" class="r10"></b><b style="background-color:black;'+navopacity+';" class="r9"></b><b style="background-color:black;'+navopacity+';" class="r8"></b><b style="background-color:black;'+navopacity+';" class="r7"></b><b style="background-color:black;'+navopacity+';" class="r6"></b><b style="background-color:black;'+navopacity+';" class="r5"></b><b style="background-color:black;'+navopacity+';" class="r4"></b><b style="background-color:black;'+navopacity+';" class="r3"></b><b style="background-color:black;'+navopacity+';" class="r2"></b><b style="background-color:black;'+navopacity+';" class="r1"></b></b>'
+'</TD></TR></TABLE>'
+'</DIV>');

document.body.innerHTML += ('<DIV id="message'+this.id+'.bord3" style="position:absolute;top:'+(x-2)+'px;left:'+(y-2)+'px;visibility:hidden;color:'+fontc+';border-color:transparent;">'
+'<TABLE border="0" cellspacing="0" cellpadding="0"><TR><TD style="height:17px;width:'+(width)+'px;">'
+'<b class="rtop"><b style="background-color:'+backgroundc+';" class="r1" style="background-color:'+backgroundc+';"></b><b style="background-color:'+backgroundc+';" class="r2"></b><b style="background-color:'+backgroundc+';" class="r3"></b><b style="background-color:'+backgroundc+';" class="r4"></b><b style="background-color:'+backgroundc+';" class="r5"></b><b style="background-color:'+backgroundc+';" class="r6"></b><b style="background-color:'+backgroundc+';" class="r7"></b><b style="background-color:'+backgroundc+';" class="r8"></b><b style="background-color:'+backgroundc+';" class="r9"></b><b style="background-color:'+backgroundc+';" class="r10"></b><b style="background-color:'+backgroundc+';" class="r11"></b><b style="background-color:'+backgroundc+';" class="r12"></b><b style="background-color:'+backgroundc+';" class="r13"></b><b style="background-color:'+backgroundc+';" class="r14"></b><b style="background-color:'+backgroundc+';" class="r15"></b><b style="background-color:'+backgroundc+';" class="r16"></b><b style="background-color:'+backgroundc+';" class="r17"></b><b style="background-color:'+backgroundc+';" class="r18"></b></b>'
+'</TD></TR><TR><TD id="message'+this.id+'.bord3.center" style="background-color:'+backgroundc+';width:'+(width)+'px;height:'+(height-34)+'px;">'
+'</TD></TR><TR><TD style="width:'+(width)+'px;height:17px;">'
+'<b class="rbottom"><b style="background-color:'+backgroundc+';" class="r18"></b><b style="background-color:'+backgroundc+';" class="r17"></b><b style="background-color:'+backgroundc+';" class="r16"></b><b style="background-color:'+backgroundc+';" class="r15"></b><b style="background-color:'+backgroundc+';" class="r14"></b><b style="background-color:'+backgroundc+';" class="r13"></b><b style="background-color:'+backgroundc+';" class="r12"></b><b style="background-color:'+backgroundc+';" class="r11"></b><b style="background-color:'+backgroundc+';" class="r10"></b><b style="background-color:'+backgroundc+';" class="r9"></b><b style="background-color:'+backgroundc+';" class="r8"></b><b style="background-color:'+backgroundc+';" class="r7"></b><b style="background-color:'+backgroundc+';" class="r6"></b><b style="background-color:'+backgroundc+';" class="r5"></b><b style="background-color:'+backgroundc+';" class="r4"></b><b style="background-color:'+backgroundc+';" class="r3"></b><b style="background-color:'+backgroundc+';" class="r2"></b><b style="background-color:'+backgroundc+';" class="r1"></b></b>'
+'</TD></TR></TABLE>'
+'</DIV>');

document.body.innerHTML += ('<DIV id="message'+this.id+'.bord2" style="position:absolute;top:'+(x-1)+'px;left:'+(y-1)+'px;visibility:hidden;color:'+fontc+';border-color:transparent;">'
+'<TABLE border="0" cellspacing="0" cellpadding="0"><TR><TD style="height:17px;width:'+(width-2)+'px;">'
+'<b class="rtop"><b class="r1" style="background-color:'+backgroundc2+';"></b><b style="background-color:'+backgroundc2+';" class="r2"></b><b style="background-color:'+backgroundc2+';" class="r3"></b><b style="background-color:'+backgroundc2+';" class="r4"></b><b style="background-color:'+backgroundc2+';" class="r5"></b><b style="background-color:'+backgroundc2+';" class="r6"></b><b style="background-color:'+backgroundc2+';" class="r7"></b><b style="background-color:'+backgroundc2+';" class="r8"></b><b style="background-color:'+backgroundc2+';" class="r9"></b><b style="background-color:'+backgroundc2+';" class="r10"></b><b style="background-color:'+backgroundc2+';" class="r11"></b><b style="background-color:'+backgroundc2+';" class="r12"></b><b style="background-color:'+backgroundc2+';" class="r13"></b><b style="background-color:'+backgroundc2+';" class="r14"></b><b style="background-color:'+backgroundc2+';" class="r15"></b><b style="background-color:'+backgroundc2+';" class="r16"></b><b style="background-color:'+backgroundc2+';" class="r17"></b><b style="background-color:'+backgroundc2+';" class="r18"></b></b>'
+'</TD></TR><TR><TD id="message'+this.id+'.bord2.center" style="background-color:'+backgroundc2+';width:'+(width-2)+'px;height:'+(height-36)+'px;">'
+'</TD></TR><TR><TD style="width:'+(width-2)+'px;height:17px;">'
+'<b class="rbottom"><b style="background-color:'+backgroundc2+';" class="r18"></b><b style="background-color:'+backgroundc2+';" class="r17"></b><b style="background-color:'+backgroundc2+';" class="r16"></b><b style="background-color:'+backgroundc2+';" class="r15"></b><b style="background-color:'+backgroundc2+';" class="r14"></b><b style="background-color:'+backgroundc2+';" class="r13"></b><b style="background-color:'+backgroundc2+';" class="r12"></b><b style="background-color:'+backgroundc2+';" class="r11"></b><b style="background-color:'+backgroundc2+';" class="r10"></b><b style="background-color:'+backgroundc2+';" class="r9"></b><b style="background-color:'+backgroundc2+';" class="r8"></b><b style="background-color:'+backgroundc2+';" class="r7"></b><b style="background-color:'+backgroundc2+';" class="r6"></b><b style="background-color:'+backgroundc2+';" class="r5"></b><b style="background-color:'+backgroundc2+';" class="r4"></b><b style="background-color:'+backgroundc2+';" class="r3"></b><b style="background-color:'+backgroundc2+';" class="r2"></b><b style="background-color:'+backgroundc2+';" class="r1"></b></b>'
+'</TD></TR></TABLE>'
+'</DIV>');

document.body.innerHTML += ('<DIV id="message'+this.id+'.bord1" style="height:'+(height-4)+'px;width:'+(width-4)+'px;position:absolute;display:inline;top:'+x+'px;left:'+y+'px;visibility:hidden;color:'+fontc+';border-color:transparent;background-color:transparent;">'
+'<TABLE border="0" cellspacing="0" cellpadding="0"><TR><TD style="height:17px;width:'+(width-4)+'px;">'
+'<b class="rtop"><b style="background-color:'+backgroundc+';" class="r1"></b><b style="background-color:'+backgroundc+';" class="r2"></b><b style="background-color:'+backgroundc+';" class="r3"></b><b style="background-color:'+backgroundc+';" class="r4"></b><b style="background-color:'+backgroundc+';" class="r5"></b><b style="background-color:'+backgroundc+';" class="r6"></b><b style="background-color:'+backgroundc+';" class="r7"></b><b style="background-color:'+backgroundc+';" class="r8"></b><b style="background-color:'+backgroundc+';" class="r9"></b><b style="background-color:'+backgroundc+';" class="r10"></b><b style="background-color:'+backgroundc+';" class="r11"></b><b style="background-color:'+backgroundc+';" class="r12"></b><b style="background-color:'+backgroundc+';" class="r13"></b><b style="background-color:'+backgroundc+';" class="r14"></b><b style="background-color:'+backgroundc+';" class="r15"></b><b style="background-color:'+backgroundc+';" class="r16"></b><b style="background-color:'+backgroundc+';" class="r17"></b><b style="background-color:'+backgroundc+';" class="r18"></b></b>'
+'</TD></TR><TR><TD id="message'+this.id+'.bord1.center" style="background-color:'+backgroundc+';width:'+(width-4)+'px;height:'+(height-38)+'px;">'
+'</TD></TR><TR><TD style="width:'+(width-4)+'px;height:17px;">'
+'<b class="rbottom"><b style="background-color:'+backgroundc+';" class="r18"></b><b style="background-color:'+backgroundc+';" class="r17"></b><b style="background-color:'+backgroundc+';" class="r16"></b><b style="background-color:'+backgroundc+';" class="r15"></b><b style="background-color:'+backgroundc+';" class="r14"></b><b style="background-color:'+backgroundc+';" class="r13"></b><b style="background-color:'+backgroundc+';" class="r12"></b><b style="background-color:'+backgroundc+';" class="r11"></b><b style="background-color:'+backgroundc+';" class="r10"></b><b style="background-color:'+backgroundc+';" class="r9"></b><b style="background-color:'+backgroundc+';" class="r8"></b><b style="background-color:'+backgroundc+';" class="r7"></b><b style="background-color:'+backgroundc+';" class="r6"></b><b style="background-color:'+backgroundc+';" class="r5"></b><b style="background-color:'+backgroundc+';" class="r4"></b><b style="background-color:'+backgroundc+';" class="r3"></b><b style="background-color:'+backgroundc+';" class="r2"></b><b style="background-color:'+backgroundc+';" class="r1"></b></b>'
+'</TD></TR></TABLE>'
+'</DIV>');

document.body.innerHTML += ('<DIV id="message'+this.id+'" onCilck="giveFocus('+this.id+');" style="height:'+(height-4)+'px;width:'+(width-4)+'px;position:absolute;display:inline;top:'+x+'px;left:'+y+'px;visibility:hidden;color:'+fontc+';border-color:transparent;background-color:transparent;">'
+'<TABLE border="0" cellspacing="0" cellpadding="0"><TR><TD style="height:17px;width:'+(width-4)+'px;" onmousedown="JavaScript:StartMove('+this.id+');" onmouseup="JavaScript:StopMove('+this.id+');">'
+'<div style="float: right; width: 35px; height: 15px; background-color:'+backgroundc+'; margin:0;"><img onclick="array_mes['+this.id+'].minimize();" style="cursor:pointer;" id="message'+this.id+'.resize" src="img/min.gif"> <img onclick="JavaScript:array_mes['+this.id+'].affiche(false);" style="cursor:pointer;" src="img/close.gif" /></div>'
+'<b class="rtop"><b class="r1" style="background-color:'+backgroundc+';"></b><b style="background-color:'+backgroundc+';" class="r2"></b><b style="background-color:'+backgroundc+';" class="r3"></b><b style="background-color:'+backgroundc+';" class="r4"></b><b style="background-color:'+backgroundc+';" class="r5"></b><b style="background-color:'+backgroundc+';" class="r6"></b><b style="background-color:'+backgroundc+';" class="r7"></b><b style="background-color:'+backgroundc+';" class="r8"></b><b style="background-color:'+backgroundc+';" class="r9"></b><b style="background-color:'+backgroundc+';" class="r10"></b><b style="background-color:'+backgroundc+';" class="r11"></b><b style="background-color:'+backgroundc+';" class="r12"></b><b style="background-color:'+backgroundc+';" class="r13"></b><b style="background-color:'+backgroundc+';" class="r14"></b><b style="background-color:'+backgroundc+';" class="r15"></b><b style="background-color:'+backgroundc+';" class="r16"></b><b style="background-color:'+backgroundc+';" class="r17"></b><b style="background-color:'+backgroundc+';" class="r18"></b></b>'
+'</TD></TR><TR><TD style="background-color:'+backgroundc+';">'
+'<DIV id="message'+this.id+'.center" style="color:'+fontc+';width:'+(width-4)+'px;height:'+(height-38)+'px;overflow:auto;">'
+ contenu
+'</DIV>'
+'</TD></TR><TR><TD style="width:'+(width-4)+'px;height:17px;" onmousedown="JavaScript:StartMove('+this.id+');" onmouseup="JavaScript:StopMove('+this.id+');">'
+'<b class="rbottom"><b style="background-color:'+backgroundc+';" class="r18"></b><b style="background-color:'+backgroundc+';" class="r17"></b><b style="background-color:'+backgroundc+';" class="r16"></b><b style="background-color:'+backgroundc+';" class="r15"></b><b style="background-color:'+backgroundc+';" class="r14"></b><b style="background-color:'+backgroundc+';" class="r13"></b><b style="background-color:'+backgroundc+';" class="r12"></b><b style="background-color:'+backgroundc+';" class="r11"></b><b style="background-color:'+backgroundc+';" class="r10"></b><b style="background-color:'+backgroundc+';" class="r9"></b><b style="background-color:'+backgroundc+';" class="r8"></b><b style="background-color:'+backgroundc+';" class="r7"></b><b style="background-color:'+backgroundc+';" class="r6"></b><b style="background-color:'+backgroundc+';" class="r5"></b><b style="background-color:'+backgroundc+';" class="r4"></b><b style="background-color:'+backgroundc+';" class="r3"></b><b style="background-color:'+backgroundc+';" class="r2"></b><b style="background-color:'+backgroundc+';" class="r1"></b></b>'
+'</TD></TR></TABLE>'
+'</DIV>');

nb=this.id*6;
if(exist==false)
{
document.getElementById("message"+this.id).style.zIndex = (nb + 5);
document.getElementById("message"+this.id+".bord1").style.zIndex = (nb + 4);
document.getElementById("message"+this.id+".bord2").style.zIndex = (nb + 3);
document.getElementById("message"+this.id+".bord3").style.zIndex = (nb + 2);
document.getElementById("message"+this.id+".ombre").style.zIndex = (nb + 1);
}else{
giveFocus(exist-1);
}
this.affiche(affich);


}

function Message_aff(bool) {
if(bool || this.closable)
{
document.getElementById("message"+this.id).style.visibility= (bool)?'visible':'hidden';
document.getElementById("message"+this.id+".bord1").style.visibility= (bool)?'visible':'hidden';
document.getElementById("message"+this.id+".bord2").style.visibility= (bool)?'visible':'hidden';
document.getElementById("message"+this.id+".bord3").style.visibility= (bool)?'visible':'hidden';
document.getElementById("message"+this.id+".ombre").style.visibility= (bool)?'visible':'hidden';
}
}

function Message_moveTo(ax,ay){
document.getElementById("message"+this.id).style.left=ax+"px";
document.getElementById("message"+this.id).style.top=ay+"px";

document.getElementById("message"+this.id+".bord1").style.left=ax+"px";
document.getElementById("message"+this.id+".bord1").style.top=ay+"px";

document.getElementById("message"+this.id+".bord2").style.left=(ax-1)+"px";
document.getElementById("message"+this.id+".bord2").style.top=(ay-1)+"px";

document.getElementById("message"+this.id+".bord3").style.left=(ax-2)+"px";
document.getElementById("message"+this.id+".bord3").style.top=(ay-2)+"px";

document.getElementById("message"+this.id+".ombre").style.left=(ax+4)+"px";
document.getElementById("message"+this.id+".ombre").style.top=(ay+3)+"px";
}

function Message_minimize(){
if(this.closable){
if(this.minimized)
{
document.getElementById("message"+this.id+".resize").src = "img/min.gif";

document.getElementById("message"+this.id+".center").style.height = (this.height-38)+"px";
document.getElementById("message"+this.id+".bord1.center").style.height = (this.height-38)+"px";
document.getElementById("message"+this.id+".bord2.center").style.height = (this.height-36)+"px";
document.getElementById("message"+this.id+".bord3.center").style.height = (this.height-34)+"px";
document.getElementById("message"+this.id+".ombre.center").style.height = (this.height-34)+"px";

document.getElementById("message"+this.id+".center").innerHTML = this.contenu;

document.getElementById("message"+this.id).style.height=(this.height-4)+"px";
document.getElementById("message"+this.id+".bord1").style.height=(this.height-4)+"px";
document.getElementById("message"+this.id+".bord2").style.height=(this.height-2)+"px";
document.getElementById("message"+this.id+".bord3").style.height=this.height+"px";
document.getElementById("message"+this.id+".ombre").style.height=this.height+"px";
}
else
{
document.getElementById("message"+this.id+".resize").src = "img/max.gif";

document.getElementById("message"+this.id+".center").innerHTML = "";

document.getElementById("message"+this.id+".center").style.height = "0px";
document.getElementById("message"+this.id+".bord1.center").style.height = "0px";
document.getElementById("message"+this.id+".bord2.center").style.height = "0px";
document.getElementById("message"+this.id+".bord3.center").style.height = "0px";
document.getElementById("message"+this.id+".ombre.center").style.height = "0px";

document.getElementById("message"+this.id).style.height=34+"px";
document.getElementById("message"+this.id+".bord1").style.height=34+"px";
document.getElementById("message"+this.id+".bord2").style.height=36+"px";
document.getElementById("message"+this.id+".bord3").style.height=38+"px";
document.getElementById("message"+this.id+".ombre").style.height=38+"px";
}


this.minimized = !this.minimized;
}
}

function giveFocus(id){

nvFocus = new Array();

idFocussed = -1;
a=0
for(a=0;a<focus.length;a++)
if(id == focus[a])idFocussed=a;


for(z=focus.length-1;z>idFocussed;z--)
{

n = document.getElementById("message"+focus[idFocussed]).style.zIndex;
b1 = document.getElementById("message"+focus[idFocussed]+".bord1").style.zIndex;
b2 = document.getElementById("message"+focus[idFocussed]+".bord2").style.zIndex;
b3 = document.getElementById("message"+focus[idFocussed]+".bord3").style.zIndex;
om = document.getElementById("message"+focus[idFocussed]+".ombre").style.zIndex;

document.getElementById("message"+focus[idFocussed]).style.zIndex = document.getElementById("message"+focus[z]).style.zIndex;
document.getElementById("message"+focus[idFocussed]+".bord1").style.zIndex = document.getElementById("message"+focus[z]+".bord1").style.zIndex;
document.getElementById("message"+focus[idFocussed]+".bord2").style.zIndex = document.getElementById("message"+focus[z]+".bord2").style.zIndex;
document.getElementById("message"+focus[idFocussed]+".bord3").style.zIndex = document.getElementById("message"+focus[z]+".bord3").style.zIndex;
document.getElementById("message"+focus[idFocussed]+".ombre").style.zIndex = document.getElementById("message"+focus[z]+".ombre").style.zIndex;

document.getElementById("message"+focus[z]).style.zIndex = n;
document.getElementById("message"+focus[z]+".bord1").style.zIndex = b1;
document.getElementById("message"+focus[z]+".bord2").style.zIndex = b2;
document.getElementById("message"+focus[z]+".bord3").style.zIndex = b3;
document.getElementById("message"+focus[z]+".ombre").style.zIndex = om;

i = focus[idFocussed];
focus[idFocussed] = focus[z];
focus[z] = i;
}

}

function StartMove(id){
if(moved==0 && array_mes[id].movable)
{
stl = document.getElementById("message"+id).style;
left = stl.left;

giveFocus(id);

stl.cursor = "move";

topa = stl.top;
X = left.substr(0, left.length-2)*1;
Y = topa.substr(0, topa.length-2)*1;

moved=1;
intX = x-X;
intY = y-Y;
movement = setInterval('Move('+id+');',10);
}
}

function StopMove(id){
clearInterval(movement);
moved=0;
document.getElementById("message"+id).style.cursor = "auto";
}

function Move(id){
array_mes[id].moveTo(x-intX,y-intY);
}
