
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;

 //document.getElementById('position').value=document.body.clientWidth-(currIDs.offsetLeft+450);
 //alert(document.body.clientWidth-(currIDs.offsetLeft+450))

 if((document.body.clientWidth-(currIDs.offsetLeft+450))>5)
 {

     currIDb.style.left=x+xoff;
     currIDs.style.left=x+xoff+5;
 }
 else
{
//alert(document.body.clientWidth)
if((x+xoff)>(document.body.clientWidth-475))
  {
    currIDs.style.left=document.body.clientWidth-455;
    currIDb.style.left=document.body.clientWidth-459;
  }
  else
  {
      currIDb.style.left=x+xoff;
      currIDs.style.left=x+xoff+5;
 }

 }
 currIDb.style.top=y+yoff;
 currIDs.style.top=y+yoff+5;

 return false;
}
}

function stopdrag(){

currIDb=null;
currIDs=null;
NS6bugfix();
}

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 NS6bugfix(){
if(!IE5){
self.resizeBy(0,1);
self.resizeBy(0,-1);
}}

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

function createPopup(id, title, width, height, x , y , isdraggable, boxcolor, barcolor, shadowcolor, text , textcolor, textptsize, textfamily, titlecolor ){
if(W3C){
zctr+=2;
totz=zctr;
var txt='';

txt+='<div id="'+id+'_s" style="position:absolute; left:'+(x+5)+'px; top:'+(y+5)+'px; width:'+(width)+'px; height:'+(height)+'px; background-color:'+shadowcolor+';filter:alpha(opacity=30);  visibility:visible"> </div>';
txt+='<div id="'+id+'_b" style="border:solid '+barcolor+' 1px; position:absolute;filter:alpha(opacity=100);background-color:'+boxcolor+'; left:'+x+'px; top:'+y+'px; width:'+width+'px; overflow:hidden; height:'+height+'px; visibility:visible">';
txt+='<div id="'+id+'_e" style="width:'+width+'px; height:16px; background-color:'+barcolor+';filter:alpha(opacity=100); padding:0px; border:1px"><table cellpadding="0" cellspacing="0" border="0" width="'+(IE5? width-4 : width)+'"><tr> ';
txt+='<td width="'+(width-20)+'"  ><div id="'+id+'_h" style="cursor:pointer;width:'+(width-20)+'px; height:14px; font: bold 12px Arial; color:'+titlecolor+'">&nbsp; '+title+'</div></td><td align="right"><a onmousedown="document.getElementById(\''+id+'_s\').style.display=\'none\'; document.getElementById(\''+id+'_b\').style.display=\'none\';return false"><img src="../img/closeb.gif" border="0" height="15" width="15" id="img_popup"></a></td></tr></table></div>';
txt+='<div id="'+id+'_ov" width:'+width+'px; height:'+(height)+'px; style="cursor:default;margin:2px; color:'+textcolor+';filter:alpha(opacity=100); font:'+textptsize+'pt '+textfamily+';">'+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-6;
this.IDh.IDb.IDov.style.height=height-22;
this.IDh.IDb.IDov.style.scrollbarBaseColor=boxcolor;
this.IDh.IDb.IDov.style.overflow="auto";
}else{
this.IDh.IDs.style.MozOpacity=.5;
}
this.IDh.IDb.onmousedown=incrzindex;
if(isdraggable){
this.IDh.onmousedown=grab_id;
this.IDh.onmouseup=stopdrag;
}}}

if(W3C)document.onmousemove=trackmouse;
if(!IE5 && W3C)window.onload=NS6bugfix;

/*
function modif_opac(id,pourcent)
{

 if(pourcent>100)
 {
    pourcent=1;
    clearTimeout(mm);
  for(i=0;i<50;i+=3)
   document.getElementById(id+'_s').filters["alpha"].opacity=i
    return 0
 }
 else pourcent +=2;
  document.getElementById(id+'_s').filters["alpha"].opacity=pourcent/50000
 document.getElementById(id+'_b').filters["alpha"].opacity=pourcent
 document.getElementById(id+'_e').filters["alpha"].opacity=pourcent
 document.getElementById(id+'_ov').filters["alpha"].opacity=pourcent
 mm=setTimeout("modif_opac(\'"+id+"\',"+pourcent+")",10)
}
*/

