/*  $Header$ : $Name: ST_migration_20040513 $  */
function Nav() {
  window.NavSetup.apply(this,new Array());
  var sib = 'layers';
  var prt = 'parentLayer';
  var clr = 'bgColor';
  this.active = function() {
    var p,i,c;
    p = (request && request.getParameter) ? request.getParameter('navH') : false;
    if(p) p = p.replace(/[^0-9]/gi,'');
    if(p) for(i=0; i<this.titles.length; i++) { if(this.titles[i][0].match(/[^\/ttl_]\/ttl_(\d*)/)[1] == p) return i; }
    for(i=0,c=0; i<this.dir.length; i++) { if(this.dir[i]) { if(this.dir[i]!='no' && window.location.pathname.indexOf(this.dir[i]) == 0) { return c; } c++; } }
    return -1;
  }
  this.write = function() {
    var s,i,j;
    s = '<div id="navItems">';
    for(i=0; i<this.titles.length; i++) {
      if(this.offset[i] > 0 || i==0) s += '<div class="navT"></div>';
      s += '<div id="navT'+i+'" class="navT"><div class="navTBg"><img src="'+this.titles[i][0]+'.gif" width="140" height="11" border="0" alt="" /></div>';
      if(this.titles[i][1]) s += '<div class="navTLnk"><a href="'+this.titles[i][1]+'"><img src="/hvc/image/common/spacer.gif" width="140" height="'+(12+(this.padding[i]*2))+'" border="0" alt="" /></a></div>';
      s += '</div>';
      if(i == this.titles.length-1) s += '<div class="navT"></div>'; 
    }
    for(i=0; i<this.menus.length; i++) {
      if(this.menus[i].length > 0) {
        s += '<div class="navM"><div class="navMDie"></div><div class="navMSpcr"></div>';
        for(j=0; j<this.menus[i].length; j++) {
          s += '<div class="navI"><div class="navIBg"><nobr>'+this.menus[i][j][0]+'</nobr></div><div class="navILnk"><a href="'+this.menus[i][j][1]+'"><img src="/hvc/image/common/spacer.gif" width="140" height="16" border="0" alt="" /></a></div></div>';
        }
        s += '<div class="navMSpcr"></div><div class="navMDie"></div><div class="navMCurv"><img src="/hvc/image/navigation/curve_'+(this.menus[i].length-1)+'.gif" width="15" border="0" alt="" /></div></div>';
      }
    }
    s += '</div>';
    with(document) { open('text/html'); write(s); close(); }
  }
  this.setup = function() {
    var p,c,s,i,j,t,d,o,l,act,ttl,mnu,itm,ofs;
    p = document[sib]['navItems'];
    p.top = this.top-this.offset[0]-29;
    p.left = this.left;
    p.onmouseout = this.msOutTtl;
    p.active = null;
    act = this.active();
    o = [];
    for(i=0,t=0,ttl=0,mnu=0; i<p[sib].length; i++) {
      c = p[sib][i];
      l = c[sib].length;
      if(l<4) {
        c.clip.width = 140;
        c.top = t;
        if(l==0) {
          t += c.clip.height = (ttl==0 || ttl==this.titles.length) ? 29 : this.offset[ttl];
        } else {
          o[ttl] = c;
          if(ttl==act) {
            c.active = true;
            c[sib][0][clr] = this.highlight;
          }
          c[sib][0].top = this.padding[ttl];
          t += c.clip.height = 12+(this.padding[ttl]*2);
          ttl++;
        }
        c.onmouseover = this.msOverTtl;
      } else {
        while(this.menus[mnu].length == 0) mnu++;
        c.navP = o[mnu];
        o[mnu].navC = c;
        c.active = null;
        for(j=0,d=0,itm=0; j<l; j++) {
          s = c[sib][j];
          if(j!=l-1) s.top = d;
          s.onmouseover = (j==0 || j==l-2) ? this.msOutItm : this.msOverItm;
          d += (j==0 || j==l-2) ? 20 : (j==1 || j==l-3) ? 9 : (j==l-1) ? 0 : 18;
          if(j>1 && j<l-3) itm++; 
        }
        ofs = c.navP.top-29+(this.padding[mnu]/2);
        c.top = (mnu > this.menus.length/2) ? ofs-(18*(itm-1)) : ofs;
        c.clip.height = d;
        mnu++;
      }
    }
    p.clip.height = t;
    p.visibility = 'visible';
  }
  this.close = function(o) {
    var a,c;
    a = o.active;
    if(a) {
      if(a.navC) {
        c = a.navC;
        if(c.active) {
          c.active[sib][0][clr] = null;
          c.active = null;
        }
        c.visibility = 'hidden';
        o.clip.width = 140;
      }
      if(!a.active) a[sib][0][clr] = null;
      o.active = null;
      o.aId = null;
    }
  }
  this.msOutTtl = function(e,el) {
    document.nav.close(e.target);
  }
  this.msOutItm = function(e) {
    document.nav.close(e.target[prt].navP[prt]);
  }
  this.msOverTtl = function(e) {
    var o,p,a,c;
    o = e.target;
    p = o[prt];
    a = p.active;
    if(a) {
      if(a.navC) {
        c = a.navC;
        if(c.active) {
          c.active[sib][0][clr] = null;
          c.active = null;
        }
        if(a.id != o.id) {
          c.visibility = 'hidden';
          if(!a.active) a[sib][0][clr] = null;
        }
      } else if(!a.active) {
        a[sib][0][clr] = null;
      }
    }  
    if(o[sib].length > 0) {
      o[sib][0][clr] = document.nav.highlight;
      if(o.navC) {
        o.navC.visibility = 'visible'
        p.clip.width = 295;
      }
      p.active = o;
      p.aId = o.id;
    } else {
      p.clip.width = 140;
      p.active = null;
      p.aId = null;
    }
  }
  this.msOverItm = function(e) {
    var o,p;
    o = e.target;
    p = o[prt];
    if(p.active) p.active[sib][0][clr] = null;
    if(o[sib].length > 0) {
      o[sib][0][clr] = '#ffffff';
      p.active = o;
    } else {
      p.active = null;
    }
  }
  this.write();
  this.setup();
}