var IE5=(document.getElementById && document.all)? true : false;
var W3C=(document.getElementById)? true: false;
var currIDb=null, currIDs=null, xoff=0, yoff=0; zctr=0; totz=0;

function trackmouse(evt){
if((currIDb!=null) && (currIDs!=null)){
var x=(IE5)? event.clientX+document.body.scrollLeft : evt.pageX;
var y=(IE5)? event.clientY+document.body.scrollTop : evt.pageY;
currIDb.style.left=x+xoff+'px';
currIDs.style.left=x+xoff+4+'px';
currIDb.style.top=y+yoff+'px';
currIDs.style.top=y+yoff+4+'px';
return false;
}}

function stopdrag(){
currIDb=null;
currIDs=null;
}

function grab_id(evt){
xoff=parseInt(this.IDb.style.left)-((IE5)? event.clientX+document.body.scrollLeft : evt.pageX);
yoff=parseInt(this.IDb.style.top)-((IE5)? event.clientY+document.body.scrollTop : evt.pageY);
currIDb=this.IDb;
currIDs=this.IDs;
}

function incrzindex(){
zctr=zctr+10;
this.subb.style.zIndex=zctr;
this.subs.style.zIndex=zctr-1;
}

function createPopup(id, title, width, height, x , y , isdraggable, boxcolor, barcolor, shadowcolor, text, titlecolor ){
if(W3C){
zctr+=2;
totz=zctr;
var txt='';
txt+='<div id="'+id+'_s" style="position:absolute; left:'+(x+4)+'px; top:'+(y+4)+'px; width:'+width+'px; height:'+height+'px; background-color:'+shadowcolor+'; filter:alpha(opacity=20); opacity:0.2; z-index:1003;"></div>';
txt+='<div id="'+id+'_b" style="border:solid #000000 1px; border-top-width: 0px; position:absolute; left:'+x+'px; top:'+y+'px; width:'+width+'px; height:'+height+'px; background-color:'+boxcolor+'; z-index:1004; overflow:hidden;">';
txt+='<table cellpadding="0" cellspacing="0" border="0" width="100%" id="messagePopup" style="height:18px;"><tr><td width="100%"><div id="'+id+'_h" style=\"color:'+titlecolor+';\">&nbsp;'+title+'</div></td><td><b><a href="#null" style="color: #FFFFFF; text-decoration: none;" onclick=" if(IE5){unhideSelect();} document.getElementById(\''+id+'_s\').style.display=\'none\'; document.getElementById(\''+id+'_b\').style.display=\'none\';return false">Fermer</a>&nbsp;&nbsp;</b></td></tr></table>';
txt+='<div id="'+id+'_ov" style="margin-left:5px; margin-top:3px; overflow:auto; width:'+(width-5)+'px; height:'+(height-24)+'px;">'+text+'</div></div>';
document.write(txt);
this.IDh=document.getElementById(id+'_h');
this.IDh.IDb=document.getElementById(id+'_b');
this.IDh.IDs=document.getElementById(id+'_s');
this.IDh.IDb.subs=this.IDh.IDs;
this.IDh.IDb.subb=this.IDh.IDb;
this.IDh.IDb.IDov=document.getElementById(id+'_ov');
if(IE5){
this.IDh.IDb.IDov.style.width=width-7;
this.IDh.IDb.IDov.style.height=height-25;
this.IDh.IDb.IDov.style.scrollbarBaseColor=barcolor;
hideSelect();
}
this.IDh.IDb.onmousedown=incrzindex;
if(isdraggable){
this.IDh.onmousedown=grab_id;
this.IDh.onmouseup=stopdrag;
}}}

if(W3C)document.onmousemove=trackmouse;

// Hide all select boxes    
function hideSelect()
{
// Only do this for IE
for (formIdx=0; formIdx<document.forms.length; formIdx++)
{
var theForm = document.forms[formIdx];
for(elementIdx=0; elementIdx<theForm.elements.length; elementIdx++)
{
//window.status += theForm[elementIdx].type;
if(theForm[elementIdx].type == "select-one" || theForm[elementIdx].type == "select-multiple")
{theForm[elementIdx].style.visibility="hidden";}
}
}
}

// Unhide all select boxes
function unhideSelect()
{
// Only do this for IE
for (formIdx=0; formIdx<document.forms.length; formIdx++)
{
var theForm = document.forms[formIdx];
for(elementIdx=0; elementIdx<theForm.elements.length; elementIdx++)
{
if(theForm[elementIdx].type == "select-one")
{theForm[elementIdx].style.visibility="visible";}
}
}
}

