function divLinks(divid, firstCat, sec, bExpand, classChild, classChildOver, classChildSelected, ImgChild, ImgChildOver, ImgChildSelected, classImgChild, h, ed)
{
this.adivid = divid;
this.afirstcat = firstCat + "";
this.iCategorie = 0;
this.asec = sec;
this.bExpandMode = false;
this.aclasschild = classChild;
this.aclasschildover = classChildOver;
this.aclasschildselected = classChildSelected;
this.aimgchild = ImgChild;
this.aimgchildover = ImgChildOver;
this.aimgchildselected = ImgChildSelected;
this.aclassimgchild = classImgChild;
if(bExpand != null && bExpand == true) 
{
  this.bExpandMode = true;
}
this.hdiv = h;
this.FirstCategorie = null;              // current categorie
this.LastCategorieCreated = null;
this.categoriewithspeed = null;
this.iTimerSpeed = null;
this.heighttogroup = null;
this.divDisplay = null;
this.divtotalheight = null;                            // height
this.heighttoexpand = null;                            // height
this.iTimer = null;
this.bWorking = false;
this.bs = false;
this.bGroupbeforeDisplay = false;
this.CurrentLinksId = null;              // current links id
this.bhidefirstblock = true;
if(this.hdiv <= 0) 
{
 // document.all  ie4
  this.dr = (navigator.appVersion.indexOf("Mac")!=-1)?true:false;
  this.NotSupported = ((document.all)&&(this.dr))?true:false;
  this.IESupported = ((document.all)&&(navigator.appVersion.indexOf("MSIE 4.")!=-1))?true:false;
 //this.IESupported = true;
  this.dq = new Array();
}
};





// load style img src


divLinks.prototype.LoadStyle =function() 
{
  var i, j;
  var divContainer, divCategorie, achild, objCategorie;
  divContainer = document.getElementById(this.adivid);
  for(i = 0; i < divContainer.childNodes.length; i++) 
  {
    divCategorie = divContainer.childNodes[i];
    if(divCategorie.id.substring(0, 2) != "__")     
    {
       this.CreateCategorie(divCategorie.id, 0);                                                             // CreateCategorie set LastCategorieCreated
       objCategorie = this.LastCategorieCreated;
    }
    else 
    {
       for(j = 0; j < divCategorie.childNodes.length; j++) 
       {
         achild = divCategorie.childNodes[j];

         this.CreateCategorie(achild.id, 1);
         objCategorie.grouped = true;         // has one or more links
         if(this.afirstcat == this.LastCategorieCreated.adivid) 
         {
            this.afirstcat = objCategorie.adivid;
            objCategorie.isdisplay = true;
            this.CurrentLinksId = this.LastCategorieCreated.adivid;
            this.SetStyle(this.LastCategorieCreated.adivid, 5, false);
         }
         else 
         {
           this.SetStyle(this.LastCategorieCreated.adivid, 3, true);
         }
       }
    }
  }

  if(this.hdiv > 0) 
  {
    this.SelectCategorie();
  }
};


divLinks.prototype.SelectCategorie =function() 
{
   var objCategorie = this.FirstCategorie;
   var objDiv;
   while(objCategorie != null) 
   {
     if(objCategorie.orderid == 0) 
     {
       if(objCategorie.grouped == true)       // has one or more links
       {
         objDiv = document.getElementById("__" + objCategorie.adivid);
         objDiv.style.overflow = "auto";
         objDiv.style.height = this.hdiv + "px";
         if(objCategorie.isdisplay == false) 
         {
           objDiv.style.display = "none";
         }
         else 
           if(this.bExpandMode == false) 
           {
             this.categoriewithspeed = objDiv;
           }
       }
     }
     objCategorie = objCategorie.GetNextCategorie();
   }
   document.getElementById(this.adivid).style.visibility = "visible";
};


divLinks.prototype.SetLinksStyleClass =function(controlid, styleclass) 
{
  var objDiv;
  if(controlid != null && styleclass != null) 
  {
    objDiv = document.getElementById(controlid);
    if(objDiv != null) 
    {
       objDiv.className = styleclass;
    }
  }
};

divLinks.prototype.SetStyle =function(controlid, styleid, dm) 
{
  var styleclass, el;
//  alert(controlid + ' ' + styleid + ' ' + dm);
  if(controlid == null || styleid == null || styleid < 0 || styleid > 5 || dm == null) 
  {
    return;
  }
  el = this.GetCategorie(controlid);
  if(el == null) 
  {
    return;
  }
  if(dm == true && (el.isdisplay == true || this.CurrentLinksId == el.adivid)) 
  {
//    return;
  }
  switch(styleid) 
  {
    case 3:styleclass = this.aclasschild;
           break;
    case 4:styleclass = this.aclasschildover;
           break;
    case 5:styleclass = this.aclasschildselected;
           break;
    default:
           return;
   }
   this.SetLinksStyleClass(controlid, styleclass);
};


divLinks.prototype.GetOnClick =function(controlid) 
{
   if(this.bWorking == true) 
   {
    return;
   }
   var el, objCategorie;
   this.bWorking = true;
   el = this.GetCategorie(controlid);
   if(el == null) 
   {
     this.bWorking = false;
     return;
   }
   this.heighttoexpand = 0;
   this.iTimerSpeed = 0;
   this.divDisplay = document.getElementById("__" + controlid);
   if(el.isdisplay == true) 
   {
     this.iTimerSpeed = el.hcategoriediv;
     this.heighttogroup = this.iTimerSpeed;
     this.categoriewithspeed = this.divDisplay;
     this.divDisplay = null;
     el.isdisplay = false;
     this.iTimer = window.setInterval("a" + this.adivid + ".groupwithtimer()", 1);
     return;
   }
   this.divtotalheight = el.hcategoriediv;
   this.bGroupbeforeDisplay = false;
   objCategorie = this.GetCurrentCategorieDisplay();
   if(this.bExpandMode == false) 
   {
     if(objCategorie == null) 
     {
       this.heighttogroup = 0;
     }
     else 
     {
       if(objCategorie.grouped == true) 
       {
         this.heighttogroup = objCategorie.hcategoriediv;
       }
       else        
       {

       }
       objCategorie.isdisplay = false;
     }
     objCategorie = null;
     if(this.categoriewithspeed != null) 
     {
       this.iTimerSpeed = this.heighttogroup;
       this.bGroupbeforeDisplay = true;
     }
   }
   this.afirstcat = controlid;
   el.isdisplay = true;
   this.bhidefirstblock = true;
   this.iTimer = window.setInterval("a" + this.adivid + ".displaywithtimer()", 1);
};



divLinks.prototype.groupwithtimer =function() 
{
  if(this.iTimerSpeed < 1) 
  {
     this.categoriewithspeed.style.display = "none";
     window.clearInterval(this.iTimer);
     this.categoriewithspeed = this.divDisplay;
     this.bWorking = false;
     return;
  }
  this.categoriewithspeed.style.overflow = "hidden";
  this.categoriewithspeed.style.height = this.iTimerSpeed + "px";
  this.iTimerSpeed -= this.asec;
};


divLinks.prototype.displaywithtimer =function() 
{
  if(this.bGroupbeforeDisplay == true)   
  {
    this.groupwithtimer();
  }
  if(this.heighttoexpand >= this.divtotalheight) 
  {
    this.divDisplay.style.height = this.divtotalheight + "px";
    this.divDisplay.style.overflow = "auto";
    this.divDisplay.style.display = "block";
    window.clearInterval(this.iTimer);
    this.bWorking = false;
    this.categoriewithspeed = this.divDisplay;
    return;
  }
  this.divDisplay.style.overflow = "hidden";
  this.divDisplay.style.height = this.heighttoexpand + "px";
  if(this.bhidefirstblock == false) 
  {
    this.divDisplay.style.display = "block";
  }
  else 
  {
    this.bhidefirstblock = false;
  }
  this.heighttoexpand += this.asec;
};


divLinks.prototype.CreateCategorie = function(controlid, orderid) 
{
   var objCategorie = new aCategorie(controlid, orderid);
   if(this.hdiv > 0) 
   {
     objCategorie.hcategoriediv = this.hdiv;
   }
   this.iCategorie++;                              
   if(this.FirstCategorie == null) 
   {
      this.FirstCategorie = objCategorie;
      this.LastCategorieCreated = this.FirstCategorie;
   }
   else    {
     this.LastCategorieCreated.AddNextCategorie(objCategorie);
     this.LastCategorieCreated = this.LastCategorieCreated.GetNextCategorie();
   }
};

function aCategorie(controlid, orderid) 
{
   this.adivid = controlid;
   this.orderid = orderid;
   this.NextCategorie = null;
   this.hcategoriediv = null;
   this.isdisplay = false;
   this.grouped = false;
};

aCategorie.prototype.AddNextCategorie = function(objCategorieToAdd) 
{
   this.NextCategorie = objCategorieToAdd;
};

aCategorie.prototype.GetNextCategorie = function() 
{
   return this.NextCategorie;
};

divLinks.prototype.GetCategorie =function(controlid) 
{
   var objCategorie = this.FirstCategorie;
   while(objCategorie != null && objCategorie.adivid != controlid) 
   {
     objCategorie = objCategorie.GetNextCategorie();
   }
   return objCategorie;
};

divLinks.prototype.GetCurrentCategorieDisplay =function() 
{
   var objCategorie = this.FirstCategorie;
   while(objCategorie != null && objCategorie.isdisplay != true) 
   {
    objCategorie = objCategorie.GetNextCategorie();
   }
   if(objCategorie != null) 
   {
     return objCategorie;
   }
   return null;
};



