// [CD]menu construction
// Version 2.0.0a

var cdm_ShowHands=true;

var mainMenu=null;
var cdm_CPgId=null;
var cdm_Max_Exp_Lev=1;
var cdm_Max_Gif_Height=16;

function cdm_MenusInit () {
  if (typeof(ThisPage)!="undefined") cdm_CPgId=ThisPage;
  cdm_GetCurrents(root_node);
  if (cdm_BrowserInit()) {
    mainMenu=cdm_BuildMenu(root_node,0,0,cdmi_Root);
    mainMenu.visible=true;
    return cdm_CreateBaseDiv(mainMenu);
  }
  return cdm_StaticMenu();
}

function cdm_MenusFastRun() {
  mainMenu.afterBDload();
}

function cdm_MenusRun() {
 mainMenu.create_onload();
}

function cdm_MenusResize() {
 if (typeof(mainMenu)!="undefined" && mainMenu!=null) mainMenu.handleResize();
}

//create menu from site chart
function cdm_BuildMenu(n,l,cl,td,rm,il) {
  var res=null;
  if (n==null || n.children()<=0) return res;
  res = (rm==null) ? new cdMenu(l,null) : rm;
  if (td==null) td=0;
  if (cl==null) cl=0;
  if (il==null) il=0;
  var i=0;
  var c;
  while ( (c=n.child(i++))!=null ) {
    var tp=td;
    var ctd=0;

    if ((td&cdmi_Inlined) && (i>=n.children())) {
      if ( ((c.type&cn_Current)&&(c.children()<=0))||!(c.type&(cn_ToCurrent|cn_Current)) )
        tp|=cdmi_LastInlined;
      if ((td|il)&cdmi_LastInlined) tp|=cdmi_LastInlined2;
      il|=cdmi_LastInlined;
    }

    if (c.type&cn_External) tp|=cdmi_External;
    if (c.type&cn_Script)   tp|=cdmi_Script;
    if (c.type&(cn_Trim|cn_Current)) tp|=cdmi_Trim;
    if (c.type&(cn_Current|cn_ToCurrent)) {
      if (c.type&cn_Current) tp|=cdmi_Current;
      if (c.children()>0)    tp|=cdmi_Expanded|cdmi_HasSubs;

      ctd|=cdmi_Inlined;
      res.add_item( new cdmItem(tp,c.name,c.href,c.descr,null,cl), null );
      ctd|=cdmi_Inlined;
      cdm_BuildMenu(c,l,cl+1,ctd,res,il);
    } else {
      var sm=(tp&cdmi_Trim) ? null : cdm_BuildMenu(c,l+1,cl+1,ctd);
      if (sm!=null) tp|=cdmi_HasSubs;
      res.add_item( new cdmItem(tp,c.name,c.href,c.descr,null,cl), sm);
    }
  }
  return res;
}

function cdm_GetCurrents(n) {
  var f=false;
  for (var i=0; i<n.children(); i++) {
    var e=n.refs[i];
    if (e.pgid==cdm_CPgId) { e.type|=cn_Current; f=true; }
    if (cdm_GetCurrents(e)) f=true;  // all levels !
  }
  if (f) n.type|=cn_ToCurrent;
  return f;
}

function cdm_StaticMenu() {
// ???
  return "";
}
// [CD]menu main script classes. variables etc.)
// Version 2.0.0a

var cdmById = new Array();

var cdmi_Trim=1;
var cdmi_Current=2;
var cdmi_Inlined=4;
var cdmi_Expanded=8;
var cdmi_HasSubs=16;
var cdmi_Root=32;
var cdmi_LastInlined=64;
var cdmi_LastInlined2=128;

var cdmi_External=1024; // V3.0
var cdmi_Script  =4096; // V3.0

// Main class

function cdMenu(lev,par) {
  this.id    = cdmById.length;
  this.items = new Array();
  this.menus = new Array();

  this.inum  = 0;
  this.pofs  = 0;
  this.parent= par;
  this.level = lev;

  this.h  = 0;
  this.w  = 0;
  this.oy = 0;
  this.ox = 0;
  this.py = 0;
  this.px = 0;

  this.mh = 0;

  this.b_lr=null;
  this.v_ls=new Array();
  this.s_ls=new Array();

  this.selOfs=null;
  this.expOfs=null;
  this.visible=false;


  this.add_item = cdM_add_item;

  this.create_onload = cdM_create_onload;
  this.afterBDload = cdM_afterBDload;
  this.getMenuLayers = cdM_getMenuLayers;
  this.handleResize=cdM_handleResize;

  this.moveSel=cdM_moveSel;
  this.show=cdM_show;
  this.hide=cdM_hide;
  this.hideSubs=cdM_hideSubs;

  this.runSETimer=cdM_runSETimer;
  this.runSDTimer=cdM_runSDTimer;

  this.eFocus=cdM_eFocus;
  this.eBlur=cdM_eBlur;
  this.eClick=cdM_eClick;

  cdm_AddVMethods(this);
  cdmById[this.id]=this;
  return this;
}

function cdmItem(tp,nm,rf,hlp,po,ol) {
  this.type =tp;
  this.name =nm;
  this.href =rf;
  this.descr=hlp;
  this.pofs =po;
  this.pid  =null;
  this.level=null;
  this.oLevel=(ol==null)?0:ol;
  this.h=0;
  this.w=0;
  this.ox=0;
  this.oy=0;
//  this.generateHtml = cdMI_generateHtml;
  this.eval_size = cdmi_eval_size;
  return this;
}


function cdM_add_item(it,sm) {
  this.items[this.inum]=it;
  this.menus[this.inum]=sm;
  var h=this.h;
  if (it!=null) {
    it.pid=this.id;
    it.pofs=this.inum;
    it.level=this.level;
    it.eval_size();
    it.oy=this.h;
    it.ox=0;
    this.h+=it.h;
    if (this.w<it.w) this.w=it.w;
  }
  if (sm!=null) {
    sm.parent=this;
    sm.level=this.level+1;
    sm.pofs=this.inum;
    sm.oy=h;
    sm.ox=this.w;
    h+=sm.mh;
    if (this.mh<h) this.mh=h;
  }
  if (this.mh<this.h) this.mh=this.h;
  this.inum++;
}
// [CD]menu logical circuitry :)
// Version 2.0.0a

// Timeouts (cool feature :)
var cdmTimeOut=null;
var cdmTO_Type=null;
 var cdmTOT_Shutdown=1;
 var cdmTOT_SubExpand=2;
var cdmTO_Level=0;
var cdmTO_Menu=null;
var cdmTO_Item=null;

var cdmTO_SD_time=400;
var cdmTO_SE_time=200;

function cdM_runSETimer(i) {
  if (cdmTimeOut!=null) clearTimeout(cdmTimeOut);
  cdmTO_Menu=this; cdmTO_Item=i; cdmTO_Level=this.level;
  cdmTO_Type=cdmTOT_SubExpand;
  cdmTimeOut=setTimeout("cdm_eSubExpand()",cdmTO_SE_time);
}

function cdM_runSDTimer(to) {
  if (cdmTimeOut!=null) clearTimeout(cdmTimeOut);
  cdmTO_Menu=this; cdmTO_Level=this.level;
  cdmTO_Type=cdmTOT_Shutdown;
  cdmTimeOut=setTimeout("cdm_eShutdown()",(to!=null)?to:cdmTO_SD_time);
}

function cdm_KillTimer() {
  var f = (cdmTimeOut!=null);
  if (f) { clearTimeout(cdmTimeOut); cdmTimeOut=null;}
  return f;
}


// Show/hide and stuff

function cdM_moveSel(i) {
  if (i!=this.selPos) {
    if (this.selPos!=null) this.showSel(this.selPos,0);
    if ((this.selPos=i)!=null) this.showSel(i,1);
  }
}

function cdM_show() {
  if (!this.visible)
    this.showMenu(this.visible=true);
}

function cdM_hide() {
  if (this.visible) {
    if (this.expOfs!=null) this.menus[this.expOfs].hide();
    this.expOfs=null;
    this.showMenu(this.visible=false);
    this.moveSel(null);
  }
}

function cdM_hideSubs() {
  if (this.visible && this.expOfs!=null)
    { this.menus[this.expOfs].hide(); this.expOfs=null; }
}


// Event handlers of cdMenu

function cdM_eFocus(i) {
  cdm_KillTimer();
  if (this.expOfs!=null) {
    var em=this.menus[this.expOfs];
    if (this.expOfs!=i) { em.hide(); this.expOfs=null; }
    else { em.moveSel(null); em.hideSubs(); }
  }

  this.moveSel(i);
  // Help message
  if (this.items[i].descr!=null) window.status=this.items[i].descr;

  if (this.menus[i]) this.runSETimer(i);
  return true;
}

function cdM_eBlur(i) {
  this.runSDTimer();
  window.status=""; // Help message
  return true;
}

function cdM_eClick(i) {
  cdm_KillTimer();
  this.moveSel(null);
  this.hideSubs();
  var it=this.items[i];
  if (it.href!=null) {
    mainMenu.runSDTimer(1000);

    if (it.type & cdmi_External)
      window.open(it.href).focus();
    else if (it.type & cdmi_Script)
      eval(it.href);
    else {
      window.status="Going to "+it.href+"...";
      location.href=it.href;
    }
  } else window.status=it.name+" clicked";
  return true;
}


// Global handlers

function cdm_eShutdown() {
  if (cdmTimeOut==null || cdmTO_Type!=cdmTOT_Shutdown) return;
  cdmTimeOut=null;
  mainMenu.hideSubs();
  mainMenu.moveSel(null);
  window.status="";
}

function cdm_eSubExpand() {
  if (cdmTimeOut==null || cdmTO_Type!=cdmTOT_SubExpand) return;
  cdmTimeOut=null;
  if (cdmTO_Menu.visible && cdmTO_Menu.level<cdm_Max_Exp_Lev )
    cdmTO_Menu.menus[cdmTO_Menu.expOfs=cdmTO_Item].show();
}
// [CD]menu visualization (browser- and design-dependent code)
// Version 2.0.0a

var cdm_IE4=false; // IE 4+
var cdm_NN4=false; // NN 4.x
var cdm_DOM=false; // DOM: NN6+, IE 5.?+
var cdm_Op =false; // Opera (in "opera" mode :)
var cdm_DB =false; // Not supported

var cdm_N6b=false; // NN6 bug 96220

var cdm_X=0;
var cdm_Y=0;
var cdm_B=null;

var cdm_mLoaded=false;

function cdm_BrowserInit() {
       if ( document.layers ) cdm_NN4=true;
  else if ( document.getElementById && document.createElement 
//  			&&  navigator.userAgent.indexOf("Opera")<0  
			) {
    cdm_DOM=true;
    if (navigator.userAgent.indexOf("Gecko")>0) cdm_N6b=true; // :(
  }
  else if ( document.all ) cdm_IE4=true;
  else {
    if ( navigator.appName.indexOf("pera")>0 ) cdm_IE4=cdm_Op=true;
    else cdm_DB=true;
  }

  if (cdm_NN4) cdm_x4_sdiv=cdm_NN4_sdiv;
  else if (cdm_IE4) cdm_x4_sdiv=cdm_IE4_sdiv;
  return !cdm_DB;
}

function cdm_AddVMethods(m) {
  if (cdm_DOM) {
    m.showSel=cdM_DOM_showSel;
    m.showMenu=cdM_DOM_showMenu;
  } else if (cdm_NN4) {
    m.showSel=cdM_NN4_showSel;
    m.showMenu=cdM_NN4_showMenu;
    m.vh_ls=new Array();
  } else if (cdm_IE4) {
    m.showSel=cdM_IE4_showSel;
    m.showMenu=cdM_IE4_showMenu;
    m.vh_ls=new Array();
  }
}

function cdm_CreateBaseDiv(m) {
  var out;
  var egif = (cdm_Max_Gif_Height > 0) ? cdm_Egif( m.w, Math.min( cdm_Max_Gif_Height, m.mh-m.h+1) ) : "";
  if (cdm_DOM) out="<div id='CDMbase' style='position:relative;'>"+cdm_xx_menuBg(mainMenu)+"</div>"+egif;
  else if (cdm_NN4) out="<div id='CDMbase' class='cdmbasic'>"+cdm_x4_smenu(m)+egif+"</div>";
  else if (cdm_IE4) out="<div id='CDMbase' style='position:relative;'>"+cdm_x4_smenu(m)+egif+"</div>";
  return out;
}

function cdm_Egif(w,h) {
  return "<img src='images/spacer.gif' border=0 width="+w+" height="+h+" alt=''>";
}

var cdm_CornerGif="<img src='extranet/images/corner.gif' border=0 width=16 height=16 alt=''>";
var cdm_ArrowGif="<img src='extranet/images/arrow.gif' border=0 width=8 height=8 alt=''>";

// sizes and positions

function cdmi_eval_size() {
  if (this.level>0) {
    this.h=17;
    this.w=150;
  } else {
    this.w=150;
    if (this.oLevel<2) {
      if (this.type&cdmi_Inlined) this.h= (this.type&cdmi_LastInlined) ? 21:17;
      else if (this.type&cdmi_Expanded) this.h=19;
      else this.h=21;
    } else {
      this.h=(this.type&cdmi_LastInlined) ? ((this.type&cdmi_LastInlined2)?22:20):18;
    }
  }
}

// create menu HTML

function cdM_afterBDload() {
  if (cdm_B!=null) return;
  if (cdm_DOM) {
    cdm_B=document.getElementById("CDMbase");
    if (cdm_B!=null) {
      cdm_DOM_menu(this,cdm_B, -1 );
      if (cdm_N6b) cdm_GEAP(cdm_B);
      cdm_DOM_menu(this,cdm_B, 0, cdm_GEAP_x,cdm_GEAP_y );
      cdm_mLoaded=true;
    }
  } else if (cdm_NN4) {
    cdm_B=document.layers.CDMbase;
    if (cdm_B) cdm_B.onLoad=cdm_NN4_fastRun;
    else setTimeout("mainMenu.afterBDload()", 100);
  }
}

function cdm_NN4_fastRun() {
  if (cdm_B!=null && mainMenu.b_lr==null) {
    mainMenu.b_lr=cdm_B;
    cdm_B.visibility="show";
    mainMenu.getMenuLayers();
    cdm_mLoaded=true;
  }
  return true;
}

function cdM_getMenuLayers(pblr) {
  var i;
  var s="CDM"+this.id+"i";
  if (cdm_NN4) {
    if (this.b_lr==null) this.b_lr=pblr.document.layers["CDMB"+this.id];
    for (i=this.inum-1; i>=0; i--) {
      this.v_ls[i]=this.b_lr.document.layers[s+i+"v"];
      this.vh_ls[i]=this.b_lr.document.layers[s+i+"h"];
      var t=this.b_lr.document.layers[s+i];
      if (t) { t.captureEvents(Event.MOUSEUP); t.onmouseup=NN4_click; this.s_ls[i]=t; }
      if (this.menus[i]) this.menus[i].getMenuLayers(this.b_lr);
    }
  } else if (cdm_IE4) {
    if (this.b_lr==null) this.b_lr=cdm_Op ? document.getElementById("CDMB"+this.id):document.all["CDMB"+this.id];
    for (i=this.inum-1; i>=0; i--) {
      this.s_ls[i]=cdm_Op ? document.getElementById(s+i):document.all[s+i];
      this.v_ls[i]=cdm_Op ? document.getElementById(s+i+"v"):document.all[s+i+"v"];
      this.vh_ls[i]=cdm_Op ? document.getElementById(s+i+"h"):document.all[s+i+"h"];
      if (this.s_ls[i]) this.s_ls[i].style.visibility="visible"; // for Opera :)
      if (this.v_ls[i]) this.v_ls[i].style.visibility="visible";
      if (this.menus[i]) this.menus[i].getMenuLayers();
    }
  }
}

function cdM_create_onload() {
  if (cdm_DOM) {
    this.afterBDload();
  } else if (cdm_NN4) {
    cdm_B=document.layers.CDMbase;
    cdm_NN4_fastRun();
  } else if (cdm_IE4) {
    mainMenu.b_lr=cdm_B= (cdm_Op ? document.getElementById("CDMbase"):document.all["CDMbase"]);
    mainMenu.getMenuLayers();
  }
  cdm_mLoaded=true;
}


function cdM_handleResize() {
  if (!mainMenu) return;
//  ToDo...
}


// DOM layers...

function cdm_DOM_div(id,cl,w,h,t,l,v,o,z,bg,ih) {
  var e=document.createElement("div");
  e.id=id;
  if (cl) e.className=cl;
  with (e.style) {
    position="absolute";
    overflow=o?"visible":"hidden";
    visibility=v?(v<0?"inherit":"visible"):"hidden";
    width=w+"px"; height=h+"px";
    top=t+"px"; left=l+"px";
    if (bg!=null) backgroundColor=bg;
    zIndex=z;
  }
  if (ih!=null) e.innerHTML=ih;
  return e;
}

function cdm_DOM_textdiv(id,cl,w,h,o,bg,ih) {
  var e=document.createElement("div");
  if (id) e.id=id;
  if (cl) e.className=cl;
  with (e.style) {
    if (w) width=w+"px"; if (h) height=h+"px";
    if (o==0) overflow="hidden";
    if (bg!=null) backgroundColor=bg;
  }
  if (ih) e.innerHTML=ih;
  return e;
}

function cdm_DOM_menu(m,pe,l, x,y) {
  if (m==null) return;
  m.b_lr=pe;
  for (var k=0; k<m.inum; k++) {
    var i,e;
    if (l!=0) {
      i=m.items[k];
      var s="CDM"+i.pid+"i"+i.pofs+"v";

    if (m.level>0) {
      e=cdm_DOM_textdiv(s,"cdmpitem",i.w,i.h,0,null,i.name);
    } else {
      if ( i.type&cdmi_Inlined ) {
        if (i.oLevel<2) {
          var h=(i.type&cdmi_LastInlined) ? (i.h-4) : i.h;
          e=cdm_DOM_div(s,(i.type&cdmi_Current?"cdmitemic":"cdmitemi"),i.w-32,h,i.oy,i.ox+32,-1,0,4*i.level+1,"#CCCCCC",i.name);
        } else {
          var h=(i.type&cdmi_LastInlined) ? ((i.type&cdmi_LastInlined2)? i.h-6: i.h-4) : i.h-2;
          e=cdm_DOM_div(s,(i.type&cdmi_Current?"cdmitemiic":"cdmitemii"),i.w-51,h,i.oy+2,i.ox+51,-1,0,4*i.level+1,"#E7F3FF",i.name);
        }
      } else if ( i.type&cdmi_Expanded) {
        e=cdm_DOM_div(s,"cdmitem",i.w,i.h-4,i.oy+2,i.ox,-1,0,4*i.level+1,"#F1AD0E",i.name);
      } else {
        var inn=i.name;
        if (i.type&cdmi_HasSubs) inn+="<span style='position:absolute;top:"+((i.h-14)/2)+"px;right:4px'>"+cdm_ArrowGif+"</span>";
        e=cdm_DOM_div(s,"cdmitem",i.w,i.h-6,i.oy+2,i.ox,-1,0,4*i.level+1,((i.type&cdmi_Current)?"#F1AD0E":"#FFFFFF"),inn);
      }
    }

      pe.appendChild( m.v_ls[k]=e );

      if (!(i.type&cdmi_Trim)) {
       e = cdm_DOM_div("CDM"+i.pid+"i"+i.pofs,0,i.w,i.h,i.oy,i.ox,-1,0,4*i.level+3,null,cdm_Egif(i.w,i.h));
       e.cdmPId=i.pid; e.cdmPOfs=i.pofs;
       e.onclick=DOM_click; e.onmouseout=DOM_mout; e.onmouseover=DOM_mover;
       if (cdm_ShowHands) e.style.cursor= document.all ? "hand" : "pointer"; // ???
       pe.appendChild(m.s_ls[k]=e);
      }
    }
    if (l>=0 && m.menus[k]!=null) {
      i = m.menus[k];
      if (cdm_N6b) { i.py=i.oy+y; i.px=i.ox+x+8; }
      else { i.py=i.oy; i.px=i.ox+8; }

      e=cdm_DOM_div("CDMB"+i.id,0,i.w,i.h,i.py,i.px,0,1,4*i.level,"#E7F3FF",cdm_xx_menuBg(i));
      with (e.style) { border="solid"; borderWidth="1px"; borderColor="#4473B4"; }

      cdm_DOM_menu(i,e,l+1, i.px,i.py);
      (cdm_N6b ? document.body : pe).appendChild(e);
    }
  }
}


// IE4+ layers...

function cdm_IE4_sdiv(id,w,h,t,l,v,o,z,bg,ih,etc) {
  var s="<div id='"+id+"' style=\"position:absolute;top:"+t+";left:"+l+";width:"+w+";height:"+h
       +";visibility:"+(v?(v<0?"inherit":"visible"):"hidden")+"; z-index:"+z
       + (bg!=null?";background-color:"+bg:"");
//  if (!o) s+=" clip='0,0,"+w+","+h+"'";
  s+="\" ";
  if (etc!=null) s+=etc;
  s+=" >";
  if (ih!=null) s+=ih;
  s+="</div>";
  return s;
}


// NN4+ layers...

function cdm_NN4_sdiv(id,w,h,t,l,v,o,z,bg,ih,etc) {
  var s="<layer id="+id+" top="+t+" left="+l+" width="+w+" height="+h
       +" visibility="+(v?(v<0?"inherit":"show"):"hide")+" z-index="+z
       + (bg!=null?" bgcolor="+bg:"");
  if (!o) s+=" clip='0,0,"+w+","+h+"'";
  s+=(etc==null)?" >":etc+" >";
  if (ih!=null) s+=ih;
  s+="</layer>";
  return s;
}


// Common x4 code...

var cdm_x4_sdiv=null;

function cdm_x4_smenu(m) {
  if (m==null) return "";
  var s="";
  for (var k=0; k<m.inum; k++) {
    var i,e;
    if (m.menus[k]!=null) {
      i = m.menus[k];
      s+=cdm_x4_sdiv("CDMB"+i.id,i.w,i.h,i.oy,i.ox+8,0,1,4*i.level,null, cdm_x4_smenu(i)+cdm_xx_menuBg(i) );
    }
    i=m.items[k];
    if (m.level>0) {
      s+=cdm_x4_sdiv("CDM"+i.pid+"i"+i.pofs+"v",i.w-2,i.h-2,i.oy+1,i.ox+1,-1,0,4*i.level+1,"#E7F3FF","<div class='cdmpitem'>"+i.name+"</div>");
      s+=cdm_x4_sdiv("CDM"+i.pid+"i"+i.pofs+"h",i.w-2,i.h-2,i.oy+1,i.ox+1,0,0,4*i.level+2,"#E7F3FF","<div class='cdmpitemh'>"+i.name+"</div>");
    } else {
      if ( i.type&cdmi_Inlined ) {
        var h;
        if (i.oLevel<2) {
          h=(i.type&cdmi_LastInlined) ? (i.h-4) : i.h;
          s+=cdm_x4_sdiv("CDM"+i.pid+"i"+i.pofs+"v",i.w-32,h,i.oy,i.ox+32,-1,0,4*i.level+1,"#CCCCCC","<div class='"+(i.type&cdmi_Current?"cdmitemic":"cdmitemi")+"'>"+i.name+"</div>");
          s+=cdm_x4_sdiv("CDM"+i.pid+"i"+i.pofs+"h",i.w-32,h,i.oy,i.ox+32, 0,0,4*i.level+2,"#CCCCCC","<div class='cdmitemih'>"+i.name+"</div>");
        } else {
          h=(i.type&cdmi_LastInlined) ? ((i.type&cdmi_LastInlined2)? i.h-6: i.h-4) : i.h-2;
          s+=cdm_x4_sdiv("CDM"+i.pid+"i"+i.pofs+"v",i.w-51,h,i.oy+2,i.ox+51,-1,0,4*i.level+1,"#E7F3FF","<div class='"+(i.type&cdmi_Current?"cdmitemiic":"cdmitemii")+"'>"+i.name+"</div>");
          s+=cdm_x4_sdiv("CDM"+i.pid+"i"+i.pofs+"h",i.w-51,h,i.oy+2,i.ox+51, 0,0,4*i.level+2,"#E7F3FF","<div class='cdmitemiih'>"+i.name+"</div>");
        }
      } else if ( i.type&cdmi_Expanded) {
        s+=cdm_x4_sdiv("CDM"+i.pid+"i"+i.pofs+"v",i.w,i.h-4,i.oy+2,i.ox,-1,0,4*i.level+1,"#F1AD0E","<div class='cdmitem'>"+i.name+"</div>");
        s+=cdm_x4_sdiv("CDM"+i.pid+"i"+i.pofs+"h",i.w,i.h-4,i.oy+2,i.ox,0,0,4*i.level+2,"#F1AD0E","<div class='cdmitemeh'>"+i.name+"</div>");
      } else {
        var inn="<div class='cdmitem'>"+i.name+"</div>";
        if (i.type&cdmi_HasSubs)
          if (cdm_NN4) inn+="<layer top="+((i.h-14)/2)+" left="+(i.w-12)+" >"+cdm_ArrowGif+"</layer>";
          else inn+="<span style='position:absolute;top:"+((i.h-14)/2)+"px;left:"+(i.w-12)+"px'>"+cdm_ArrowGif+"</span>";
        s+=cdm_x4_sdiv("CDM"+i.pid+"i"+i.pofs+"v",i.w,i.h-6,i.oy+2,i.ox,-1,0,4*i.level+1,((i.type&cdmi_Current)?"#F1AD0E":"#FFFFFF"),inn);
        s+=cdm_x4_sdiv("CDM"+i.pid+"i"+i.pofs+"h",i.w,i.h-6,i.oy+2,i.ox,0,0,4*i.level+2,"#E7F3FF",inn);
      }
    }
    if (!(i.type&cdmi_Trim)) {
      if (cdm_NN4)
        s+=cdm_x4_sdiv("CDM"+i.pid+"i"+i.pofs    ,i.w,i.h,i.oy,i.ox,-1,0,4*i.level+3,null,"&nbsp;",
        " onmouseover='NN4_evt=1; return cdmById[NN4_pId="+i.pid+"].eFocus(NN4_pOfs="+i.pofs+")' onmouseout='NN4_evt=0; return cdmById["+i.pid+"].eBlur("+i.pofs+")' ");
      else
        s+=cdm_IE4_sdiv("CDM"+i.pid+"i"+i.pofs    ,i.w,i.h,i.oy,i.ox,-1,0,4*i.level+3,null,cdm_Egif(i.w,i.h),
          " onmouseover='return cdmById["+i.pid+"].eFocus("+i.pofs+")' onmouseout='return cdmById["+i.pid+"].eBlur("+i.pofs+")' onclick='return cdmById["+i.pid+"].eClick("+i.pofs+")' ");
    }
  }
  if (m.level==0) s+=cdm_xx_menuBg(m);
  return s;
}


function cdm_xx_menuBg(m) {
  var s="";
  if (m.level>0) {
    if (!cdm_DOM) s="<table border=0 cellpadding=1 cellspacing=0><tr><td bgColor=#4473B4><table border=0 cellpadding=0 cellspacing=0><tr><td bgColor=#E7F3FF>"+cdm_Egif(m.w-2,m.h-2)+"</td></tr></table></td></tr></table>";
  } else {
    s="<table border=0 cellpadding=0 cellspacing=0 >";
    for (var j=0; j<m.inum; j++)
    {
      var i=m.items[j];
      if ( i.type&cdmi_Inlined ) {
        if (i.oLevel<2) {
          if (i.type&cdmi_LastInlined)
            s+= "<tr><td bgColor=#FFFFFF>"+cdm_Egif(15,i.h-4)+cdm_CornerGif+cdm_Egif(m.w-31,i.h-4)+"</td></tr><tr><td bgColor=#FFFFFF>"+cdm_Egif(m.w,2)+"</td></tr><tr><td bgColor=#4473B4>"+cdm_Egif(m.w,2)+"</td></tr>";
          else
            s+= "<tr><td bgColor=#FFFFFF>"+cdm_Egif(15,i.h)+cdm_CornerGif+cdm_Egif(m.w-31,i.h)+"</td></tr>";
        } else {
          s+="<tr><td bgColor=#FFFFFF>"+cdm_Egif(m.w,2)+"</td></tr>";
          if (i.type&cdmi_LastInlined) {
            var f2=i.type&cdmi_LastInlined2;
            s+= "<tr><td bgColor=#FFFFFF>"+cdm_Egif(34,i.h-(f2?6:4))+cdm_CornerGif+cdm_Egif(m.w-50,i.h-(f2?6:4))+"</td></tr><tr><td bgColor=#FFFFFF>"+cdm_Egif(m.w,2)+"</td></tr>";
            if (f2) s+="<tr><td bgColor=#4473B4>"+cdm_Egif(m.w,2)+"</td></tr>";
          } else
            s+="<tr><td bgColor=#FFFFFF>"+cdm_Egif(34,i.h-2)+cdm_CornerGif+cdm_Egif(m.w-50,i.h-2)+"</td></tr>";
        }
      } else if ( i.type&cdmi_Expanded )
        s+= "<tr><td bgColor=#FFFFFF>"+cdm_Egif(m.w,i.h)+"</td></tr>";
      else
        s+= "<tr><td bgColor=#FFFFFF>"+cdm_Egif(m.w,i.h-2)+"</td></tr><tr><td bgColor=#4473B4>"+cdm_Egif(m.w,2)+"</td></tr>";
    }
    s+="</table>";
  }
  return s;
}

// Get element's absolute position...

var cdm_GEAP_x = 0;
var cdm_GEAP_y = 0;

function cdm_GEAP(o) {
  cdm_GEAP_x=cdm_GEAP_y=0;
  while (o!=null) {
    var x = parseInt(o.offsetLeft);
    var y = parseInt(o.offsetTop);
    if ( isNaN(x) || isNaN(y) ) return;
    cdm_GEAP_x += x; cdm_GEAP_y += y;
    o=o.offsetParent;
  }
}

// Show, hide etc.

function cdM_DOM_showSel(i,s) {
  var t=this.items[i].type;
  if (this.level>0)
    this.v_ls[i].style.textDecoration=s?"underline":"none";
  else if ( t&cdmi_Inlined )
    this.v_ls[i].style.color=s?"#4473B4":"black";
  else if ( t&cdmi_Expanded)
    this.v_ls[i].style.color=s?"#4473B4":"black";
  else
    this.v_ls[i].style.backgroundColor=s?"#E7F3FF":"white";
}

function cdM_NN4_showSel(i,s) { if (cdm_mLoaded) this.vh_ls[i].visibility= s?"show":"hide"; }
function cdM_IE4_showSel(i,s) { if (cdm_mLoaded) this.vh_ls[i].style.visibility= s?"visible":"hidden"; }

function cdM_DOM_showMenu(s) { if (cdm_mLoaded) this.b_lr.style.visibility= s?"visible":"hidden"; }
function cdM_NN4_showMenu(s) { if (cdm_mLoaded) this.b_lr.visibility= s?"show":"hide"; }
function cdM_IE4_showMenu(s) { if (cdm_mLoaded) this.b_lr.style.visibility= s?"visible":"hidden"; }

// Event handlers

function DOM_click() { return cdmById[this.cdmPId].eClick(this.cdmPOfs); }
function DOM_mover() { return cdmById[this.cdmPId].eFocus(this.cdmPOfs); }
function DOM_mout()  { return cdmById[this.cdmPId].eBlur(this.cdmPOfs); }

var NN4_evt=0;
var NN4_pId=null;
var NN4_pOfs=null;

function NN4_click(e) {
 if (NN4_evt) {
   var m=cdmById[NN4_pId];
   var i=m.items[NN4_pOfs];
   if (e.x>=0 && e.y>=0 && e.x<=i.w && e.y<=i.h) return m.eClick(NN4_pOfs);
 }
 return true;
}
// Site chart definition
// Version 2.0 (cd)

// ChartNodes flags...
var cn_Root = 1;
var cn_Menu = 2;
var cn_Map  = 4;
var cn_Current = 8; // V2.0
var cn_ToCurrent = 16; // V2.0
var cn_Trim = 32; // V2.0

var cn_External = 64; // V3.0
var cn_Script  = 128; // V3.0

var cn_Std  = cn_Menu|cn_Map; // Default flags

var cnById = new Array();

// ChartNode class
function ChartNode( ty, nm, des, hr, pgid ) {
  this.type  = ty;
  this.name  = nm;
  this.descr = des;
  this.href  = hr;
  this.pgid  = pgid;
  this.id    = cnById.length;
  this.pid   = null;
  this.pofs  = null;
  this.refs  = new Array();
  for (var i=0; i+5 < ChartNode.arguments.length; i++) {
    var t = ChartNode.arguments[i+5];
    t.pid = this.id;
    t.pofs= i;
    this.refs[i] = t;
  }
  // Methods
  this.child    = CN_child;
  this.children = CN_children;
  this.add_item = CN_add_item;
  this.insert_item = CN_insert_item;
  this.locate_item = CN_locate_item;
  this.locate_next = CN_locate_next;
  cnById[ this.id ] = this;
  return this;
}

function CN_child(ofs) {
  return (this.refs.length>ofs) ? this.refs[ofs] : null;
}

function CN_children() { return this.refs.length; }

function CN_add_item(it) { this.refs[it.pofs=this.refs.length]=it; it.pid=this.id; }

function CN_insert_item(it,ofs) {
  if (ofs<this.refs.length) {
    for (var i=this.refs.length; i>ofs; i--)
      this.refs[i] = this.refs[i-1];
  } else ofs = this.refs.length;
  this.refs[ofs]=it;
  it.pid=this.id;
  it.pofs=ofs;
  return ofs;
}

function CN_locate_item(predicate,si) { // V2.0
  var out = null;
  if ( eval(predicate) ) out=this;
  else {
    for (var i=((si==null)?0:si); (out==null) && (i<this.refs.length); i++) {
      if (this.refs[i]!=null) out=this.refs[i].locate_item(predicate);
    }
  }
  return out;
}

function CN_locate_next(predicate,si) { // V2.0
  var out=null;
  for (var i=((si==null)?0:si); (out==null) && (i<this.refs.length); i++) {
    if (this.refs[i]!=null) out=this.refs[i].locate_item(predicate);
  }
  if ((out==null) && (this.pid!=null)) {
    out=cnById[this.pid].locate_next(predicate,this.pofs+1);
  }
  return out;
}

////////////////////////

function newSiteMap(m) {
 if (btDOM && bstIE) document.styleSheets[0].addRule(".smFloatingDiv","float:left");
 
 if (m==null || m.inum<=0) return "";

 var s="", Map=new Array();

 for (var i=0; i<m.inum; i++) {
   var cm=m.menus[i] ? m.menus[i].inum : 0;

   if (cm>0) {
     var j=Map.length-1
     while (j>=0)
       if (m.menus[Map[j]] && m.menus[Map[j]].inum>=cm ) break;
       else j--;

     for (var k=Map.length; k>j; k--) Map[k]=Map[k-1];
     Map[j+1]=i;

   } else Map[Map.length]=i;
 }

 for (var i=0; i<m.inum; i++) {
   var it=m.items[Map[i]];
   s+="<div class='smFloatingDiv'>"
     +"<div class='smTitle'><nobr><a class='smTitle' href='"+it.href+"' "
     +(it.descr ? " title='"+it.descr+"' " : "")
     +">"+it.name+"</a></nobr></div>\n"
     +newSubSiteMap(m.menus[Map[i]])
     +"<div>"+cdm_Egif(250,18)+"</div>\n"
     +"</div>\n";
 }

 return s;
}

var cdm_smTLine="<img src='images/t-corner.gif' width=24 height=14 border=0 alt=''>";
var cdm_smLLine="<img src='images/l-corner.gif' width=24 height=14 border=0 alt=''>";

function newSubSiteMap(m) {
 if (m==null || m.inum<=0) return "";
 var s="";
 for (var i=0; i<m.inum; i++) {
   var it=m.items[i];
   s+="<div class='smItem'><nobr>"
     +( (i < m.inum-1 ) ? cdm_smTLine:cdm_smLLine)
     +"&nbsp;<a class='smItem' href='"+it.href+"' "
     +(it.descr ? " title='"+it.descr+"' " : "")
     +">"+it.name+"</a></nobr></div>\n";
 }
     
 return s;
}
