var undefined;			
/**Showing sub elements**/
makeCM.prototype.showsub=function(el){ //Changed v4.06
  var c=this,pm=c.m[el],m,o,nl;
// Andreas: opening page for first time - top frame loads first (lower frame not yet opened) and if I move mouse over any button - I get the error :
// A Runtime Error has occured.
if(MenuReady==0) return; 

  mactive = this.findactive();
  if(!pm.b||(c.isresized&&pm.lev>0)) pm.b=c.l[pm.lev].b; c.isover=1
  clearTimeout(c.tim);
  var ln=pm.subs.length,l=pm.lev+1
  if(c.l[pm.lev].a==el&&l!=c.l.length && !c.openOnClick){if(c.l[pm.lev+1].a) c.hidesub(l+1,el); return}
  c.hidesub(l,el); if(pm.mover) eval(pm.mover); if(!pm.isactive) pm.active(1);
  c.l[pm.lev].a = el; if(ln==0) return; 
  if(c.openOnClick && !c.clicked) return//Added v4.06
  if(!c.l[l].b) return //Added v4.05
  var b = c.l[l].b, bx=c.l[l].borderX, by=c.l[l].borderY, rows=pm.rows
  var rb=c.l[l].roundBorder;//added 4.06
  var x=bx+rb,y=by+rb,maxw=0,maxh=0,cn=0; b.hideIt()
  for(var i=0;i<c.l[l].m.length;i++){  
    if(!bw.reuse) m=c.m[c.l[l].m[i]]
    else m=c.m[c.m[el].subs[i]]
    if(m && m.parent==el&&!m.hide){
      if(!bw.reuse) o=m.o; else o=m.o=c.l[l].o[i]
      if(x!=o.x||y!=o.y) o.moveIt(x,y); nl=m.subs.length //changed 4.06
      if(bw.reuse){
        if(o.w!=m.w || o.h!=m.h) o.clipTo(0,m.w,m.h,0,1)
        if(o.evnt.className!=m.cl){ 
          m.isactive=0; o.evnt.className=m.cl
          if(bw.ns6){o.hideIt(); o.css.visibility='inherit'} //NS6 bugfix
        }if(bw.ie6) b.showIt()//IE6 bugfix (scrollbars)
        o.evnt.innerHTML=m.txt; if(bw.ie6) b.hideIt() 
        if(!m.nolink){
          o.evnt.onmouseover=new Function(c.name+".showsub('"+m.name+"')")
          o.evnt.onmouseout=new Function(c.name+".mout('"+m.name+"')") //Added v4.05
          o.evnt.onclick=new Function(c.name+".onclck('"+m.name+"')")
          if(o.oldcursor){o.css.cursor=o.oldcursor; o.oldcursor=0;}
        }else{o.evnt.onmouseover=''; o.evnt.onclick='';  if(o.css.cursor=='') o.oldcursor=bw.ns6?"pointer":"hand"; else o.oldcursor=o.css.cursor; o.css.cursor="auto"}        
      }if(m.arr){o.arr=c.l[l].arr[cn]; o.arr.moveIt(x + m.w-c.l[l].arrowWidth-3,y+m.h/2-(c.l[l].arrowHeight/2)); 
      o.arr.css.visibility="inherit"; cn++;} else o.arr=0
      if(!rows){y+=m.h+by; if(m.w>maxw) maxw=m.w; maxh=y}
      else{x+=m.w+bx; if(m.h>maxh) maxh=m.h; maxw=x;}
      o.css.visibility="inherit"; if(bw.op5||bw.op6) o.showIt()
    }else{o = c.m[c.l[l].m[i]].o; o.hideIt();} }
  if(!rows) maxw+=bx*2+rb; else maxh+=by*2+rb; //changed 4.06
  if(rb){maxw+=rb; maxh+=rb}//added 4.06
  b.clipTo(0,maxw,maxh,0,1)
  //Check frame scroll
if(c.chkscroll) c.chkscroll() //Added v4.05 - not the best solution
if(l>=c.frameStartLevel+1&&l>oldl) {pm.b.y=oldy; pm.b.x=oldx;}
if(c.chkscroll||!pm.subx||!pm.suby||c.scrollY>-1||c.isresized) c.getcoords(pm,c.l[l-1].borderX,c.l[l-1].borderY,pm.b.x,pm.b.y,maxw,maxh,c.l[l-1].offsetX,c.l[l-1].offsetY) //Changed 4.06
x=pm.subx; if(c.chkscroll&&l==c.frameStartLevel){pm.suby+=c.scrollY;}oldy=pm.suby;oldx=pm.subx;oldl=l;y=pm.suby; b.moveIt(x,y); if(c.onshow) eval(c.onshow); b.showIt()
}
var oldy=0;
var oldx=0;
var oldl=0;

/**Hide sub elements **/
makeCM.prototype.hidesub=function(l,el,el2){ //Changed v4.05
  if(MenuReady==0) return;
  mactive = this.findactive();
  var c = this,tmp,m,i,j,hide
  if(!l) {l=1; hide=1; c.clicked=0}
  for(i=l-1;i<c.l.length;i++){
    	if(i>0&&i>l-1) if(c.l[i].b) c.l[i].b.hideIt()//Changed v4.05
    	if(c.l[i].a&&c.l[i].a!=el){
      		m=c.m[c.l[i].a]; m.active(0,1); if(m.mout) eval(m.mout); c.l[i].a=0
      		if(i>0&&i>l-1) if(bw.op5||bw.op6) for(j=0;j<c.l[i].m.length;j++) c.m[c.l[i].m[j]].o.hideIt()
	   }
	   if(i>l){
	   		for(j=0;j<c.l[i-1].arnum;j++){
	   			c.l[i-1].arr[j].hideIt();
	  			if(bw.op6) c.l[i-1].arr[j].moveIt(-1000,-1000)
			}
		} //opera bug
  }
  if(hide&&c.onhide) eval(c.onhide) //onhide event

  if ((mactive) && (el == undefined) && (el2 == undefined)){ this.showsub(mactive.name);}
}

/**Onclick of an item**/
makeCM.prototype.onclck=function(m){ //Changed v4.06
if(MenuReady==0) return false; 
  m = this.m[m]
  if(m.onclck) eval(m.onclck);

// Andreas: return false instead of return, solves the netscape bug lower 4.6 (bw has no properties)!

  if(this.openOnClick && m.subs.length>0){
    this.clicked = 1; this.showsub(m.name); return false
  }
// Andreas: The old problem (sub stays open after click) should be solved now!
// Laurens: Main menu items without a link don't have to hide submenu
  if (m.lnk != '') {
  	  for (var menu in this.m) {
	  	this.m[menu].activeitem = false;
	  }
	  //this.hidesub()
  }
  var lnk=m.lnk, targ=m.targ
  
  if(lnk){
    if(lnk.indexOf("mailto")!=0 && lnk.indexOf("http")!=0) lnk=this.root+lnk
    if(String(targ)=="undefined" || targ=="" || targ==0 || targ=="_self"){
	  if(this.frames){ //Turning of all level 1 + vars
        if(this.l[0].a){
          this.m[this.l[0].a].active(0,1)
          this.l[0].a =0
        }
        for(i=this.frameStartLevel;i<this.l.length;i++){
          if(this.l[i].b){
            this.l[i].b.hideIt()
            this.l[i].b = null
            for(j=0;j<this.l[i].m.length;j++){
              this.m[this.l[i].m[j]].b = null;
            }
          }
        }
        this.isover=0
      }
      this.deftarget.location.href=lnk
    }
    else if(targ=="_blank") window.open(lnk)
    else if(targ=="_top") {parent.top.location.href=lnk}
    else if(targ=="window") {cm4dataframe.location.href=lnk}

//  PKLEIN : Because the target frame will be searched for, their is no need to check the parent
//           or Top for the frameobject
//  else if(top[targ]) top[targ].location.href=lnk
//  else if(parent[targ]) parent[targ].location.href=lnk

   else if(cm_findFrame(targ)) cm_findFrame(targ).location.href=lnk
  }else return false
}

