function iconButtons(name)
{ this.name = (name!=null)? name : "iconButtons"+(iconButtons.count++)
  this.iconPath   = "";
  this.selected   = "";
  this.lastClicked= "";
  this.lastCimg   = null;
  this.obj = this.name + "Object" 
  eval(this.obj + "=this")
  this.icons  = new Array();
  this.setPath= setIconPath;
  this.Load   = loadIcon;
  this.On     = iconOn;
  this.Off    = iconOff;
  this.Click  = iconClick;
  this.OnM    = iconOnM;
  this.OffM   = iconOffM;
  this.ClickM = iconClickM;
  this.NSlayer= iconNSlayer;
}

function loadIcon(name,Inormal,Ihighlighted,Iselected,Iselectedhighlighted)
{ this.icons[name] = new Object();
  if( Inormal != null )
    { this.icons[name].imgN = new Image();
      this.icons[name].imgN.src = this.iconPath+Inormal;
    }
  if( Ihighlighted != null )
    { this.icons[name].imgH = new Image();
      this.icons[name].imgH.src = this.iconPath+Ihighlighted;
    }
  if( Iselected != null )
    { this.icons[name].imgS= new Image();
      this.icons[name].imgS.src = this.iconPath+Iselected;
    }
  if( Iselectedhighlighted != null )
    { this.icons[name].imgSH= new Image();
      this.icons[name].imgSH.src = this.iconPath+Iselectedhighlighted;
    }
}

function iconNSlayer(menu,level,ic)
{ var strEval,iLoop;
  if( is.ie )
    return "document" ;
  if( is.ns)
  { 
      strEval = 'document.layers["'+menu+'"].layers[0]'
      for(iLoop=0; iLoop<level; iLoop++)
      {
         strEval += '.layers[2]';
      }
      strEval += '.layers['+ic+']';
      return strEval;
    }
}

function iconOn(name,menu,level,ic)
{ var strEval;
  strEval = this.NSlayer(menu,level,ic);
  if( is.ns )
  {
    if(is.ns5)
    {
      strEval='document.images["'+name+'"]';
    }
    else
    {
      strEval=strEval+'.document.images["'+name+'"]';
    }
  }
  else
  {
    strEval=strEval+'.images["'+name+'"]';
  }
 
 if( (eval(strEval) != null) && (this.icons[name] != null) )  
    { if( this.lastClicked != name )
       eval(strEval+'.src = this.icons["'+name+'"].imgH.src'); 
      else
        eval(strEval+'.src=this.icons["'+name+'"].imgSH.src'); 
    }
}

function iconOff(name,menu,level,ic)
{ var strEval;
  strEval = this.NSlayer(menu,level,ic);
  if( is.ns )
  {
    if(is.ns5)
    {
      strEval='document.images["'+name+'"]';
    }
    else
    {
      strEval=strEval+'.document.images["'+name+'"]';
    }
  }
  else
  {
    strEval=strEval+'.images["'+name+'"]';
  }
  if( (eval(strEval) != null) && (this.icons[name] != null))  
    { if( this.lastClicked != name )
        eval(strEval+'.src=this.icons["'+name+'"].imgN.src'); 
      else
        eval(strEval+'.src=this.icons["'+name+'"].imgS.src'); 
    }
}

function iconClick(name,menu,level,ic)
{ var strEval;
  strEval = this.NSlayer(menu,level,ic);
  if( is.ns )
  {
    if(is.ns5)
    {
      strEval='document.images["'+name+'"]';
    }
    else
    {
      strEval=strEval+'.document.images';
    }
  }
  else
    strEval=strEval+'.images["'+name+'"]';
  if( (eval(strEval)!=null) && (this.icons[name] != null) )  
    { 
      eval(strEval+'.src=this.icons["'+name+'"].imgSH.src');	 // KI
      if( this.lastClicked.length > 0 && this.lastClicked!=name)
        eval(this.lastCimg+'.src=this.icons["'+this.lastClicked+'"].imgN.src');
      this.lastClicked = name;
      this.lastCimg = strEval;
    }
}

function iconOnM(name,moc,open,menu,level,ic)
{ var strEval,strAux;
  strEval = this.NSlayer(menu,level,ic);
  if( is.ns )
  {
    if(is.ns5)
    {
      strEval='document.images';
    }
    else
    {
      strEval=strEval+'.document.images';
    }
  }
  else
    strEval=strEval+'.images';
  if( (eval(strEval+'["'+name+'"]') != null) && (this.icons[name] != null) )
    {  
       if( open )  
         eval(strEval+'["'+name+'"].src = this.icons["'+name+'"].imgSH.src');  
       else
         eval(strEval+'["'+name+'"].src = this.icons["'+name+'"].imgH.src');  
       if(moc!=null)
       {
         if( open )  
           strAux=strEval+'["'+name+'oc'+'"].src=moc.icons["OPEN"].imgH.src';
         else
           strAux=strEval+'["'+name+'oc'+'"].src=moc.icons["CLOSE"].imgH.src';
         eval(strAux);
       }
    }
}

function iconOffM(name,moc,open,menu,level,ic)
{ var strEval,strAux;
  strEval = this.NSlayer(menu,level,ic);
  if( is.ns )
  {
    if(is.ns5)
    {
      strEval='document.images';
    }
    else
    {
      strEval=strEval+'.document.images';
    }
  }
  else
    strEval = strEval+'.images';
  if( (eval(strEval+'["'+name+'"]') != null) && (this.icons[name] != null) )  
    {  
       if( open )  
         eval(strEval+'["'+name+'"].src = this.icons["'+name+'"].imgS.src');  
       else
         eval(strEval+'["'+name+'"].src = this.icons["'+name+'"].imgN.src');  
       if(moc!=null)
       {
         if( open )  
           strAux=strEval+'["'+name+'oc'+'"].src=moc.icons["OPEN"].imgN.src';
         else
           strAux=strEval+'["'+name+'oc'+'"].src=moc.icons["CLOSE"].imgN.src';
         eval(strAux);
       }
    }
}

function iconClickM(name,moc,open,menu,level,ic)
{ var strEval,strAux;
  strEval = this.NSlayer(menu,level,ic);
  if( is.ns )
  {
    if(is.ns5)
    {
      strEval='document.images';
    }
    else
    {
      strEval=strEval+'.document.images';
    }
  }
  else
    strEval=strEval+'.images';
  if( (eval(strEval+'["'+name+'"]') != null) && (this.icons[name] != null) )  
    { 
       if( !open )  
         eval(strEval+'["'+name+'"].src = this.icons["'+name+'"].imgSH.src');  
       else
         eval(strEval+'["'+name+'"].src = this.icons["'+name+'"].imgH.src');  

       if(moc!=null)
       {
         if( !open )
           strAux=strEval+'["'+name+'oc'+'"].src=moc.icons["OPEN"].imgH.src';
         else
           strAux=strEval+'["'+name+'oc'+'"].src=moc.icons["CLOSE"].imgH.src';
         eval(strAux);
      }
    }
}

function setIconPath(strPath)
{ this.iconPath= strPath;
}

iconButtons.count = 0
