
libMenuCounter = 0
libMenuArray = new Array()
libMenuArrayCount = 0
libMenuTriStyle = "background-repeat:no-repeat; background-position:center right; background-image: url('tri.gif') ;" 

libMenuKillMe=false
libMenuStillKill = false
  arrMenuParm = new Array(69,17,0,1,'h',
  'width:69; text-align:right; font-weight:bold; border-style:solid; border-width:1 1 1 1; border-color:black; background-color:#FFCC99; color:black; padding-left:2; padding-right:2; font-family:Arial; font-weight:bold; font-size:11;',
//  'background-color:blue;padding-left:2; padding-right:2; font-weight:bold; font-family:Arial; font-size:12;',
  'width:69; text-align:right; border-style:solid; border-width:1; border-color:black; background-color:#FFCC99; color:black; padding-left:2; padding-right:2; font-family:Arial; font-size:10;',
  'width:69; text-align:right; border-style:solid; border-width:1; border-color:black; background-color:#FF6600; color:white; padding-left:2; padding-right:2; font-family:Arial; font-weight:bold; font-size:11;',
//  'background-color:red;padding-left:2; padding-right:2; font-weight:bold; font-family:Arial; font-size:12;',
  0,0,17,-1,1,'position:absolute;',0
  ) 
  arrMenuSubParm = new Array(100,0,1,1,'v',
  'background-color:#FF6600; color: white; border-bottom:solid 1 black ;',
  'font-weight:bold; background-color:#000000; color: white; ',
  'background-color:#FF6600; color: black; border-bottom:solid 1 black',
  1,0,0,0,1,'position:absolute; border-left:solid 1 black; border-right:solid 1 black',0
  ) 

//padContentMenu= new Array("Regio",0,"1","Nieuws",0,"2","Forum",12,"","<end>",0,"0","Belasting",0,"3","Verzekering",0,"4","Beleggen",0,"6","Assurantie",0,"5","<end>",0,0)
/*
padContentMenu = new Array(
'Welkom',0,'BACK',
'Inhoud',0,'FORWARD',
'Nieuws',21,0,
'Zoeken',39,0,      //9
'Forum',51,0,      //12
'Links',51,0,
'<end>',0,0,
'Meer voordeel voor aandeelhouders..',0,"M1",      // 21
'Verzekeringsplicht honden..',0,"M2",
'Wegenbelasting omlaag',0,"M4",
'<split>',0,0,
'Meer nieuws',0,"M5",
'<end>',0,0,     // 36
'Veel gestelde vragen',0,12,
'Woordenlijst',0,12,
'Door de text zoeken',0,"M6",
'<end>',0,0,
'Forum lezen',0,"M6",
'<end>',0,0
) 
*/
	//	alert(padContentMenu)

function libMenuOnClose(obj){
    objMenu = obj.parentElement.parentElement.parentElement.parentElement
    obj.style.cssText = objMenu.Params[5]
    obj.opened = false  
}

function libMenuOnClick(obj){
    libMenuStillKill = false
    objMenu = obj.parentElement.parentElement.parentElement.parentElement
    if (objMenu.Params[12]!=1){
      obj.opened == true
      if (obj.tri== 'true')
        obj.style.cssText = objMenu.Params[7] + libMenuTriStyle
      else
        obj.style.cssText = objMenu.Params[7]
      objMenu.active=true
      if (obj.subMenu != 0) {
  //		if (objMenu.Pad!=padTaskActive) {padTaskTop(objMenu.Pad)}	//CM 17-7
        libMenuExpand(objMenu, obj.subMenuIndex, obj.offsetLeft, obj.parentElement.offsetTop, obj.offsetWidth, obj.menu)
      }
	  else{
        libMenuShrink()
        objMenu.active = false
        if (obj.contentID != 0)
          objMenu.Handler(obj.contentID, objMenu)
        }
    }
    else{
        libMenuShrink()
        objMenu.active = false
        if (obj.contentID != 0)        
          objMenu.Handler(obj.contentID, objMenu)
        libMenuKillMe = true
    }
}


function libMenuOnOver(obj){
    objMenu = obj.parentElement.parentElement.parentElement.parentElement
    libMenuStillKill = false
    if (obj.children(0))
    {
      if (obj.children(0).over)
        obj.children(0).src = obj.children(0).over  
    }
    if (objMenu.Params[12]==2)
      if (objMenu.active == true){
        if (obj.tri == 'true'){
           obj.style.cssText = objMenu.Params[7] + libMenuTriStyle
         }
        else
           obj.style.cssText = objMenu.Params[7]
        if (obj.subMenu!=0)
          libMenuExpand(objMenu, obj.subMenuIndex, obj.offsetLeft, obj.parentElement.offsetTop, obj.offsetWidth, obj.menu)
        else
          libMenuShrinkTo(obj.menu, objMenu.MyArray)
      }
      else
        if (obj.tri == 'true')
          obj.style.cssText = objMenu.Params[6] + libMenuTriStyle
        else
          obj.style.cssText = objMenu.Params[6]
    if (objMenu.Params[12]==1)
      if (obj.opened != true){
        if (obj.tri == 'true')
          obj.style.cssText = objMenu.Params[7] + libMenuTriStyle
        else
          obj.style.cssText = objMenu.Params[7]
        if (obj.subMenu !=0)
          libMenuExpand(objMenu, obj.subMenuIndex, obj.offsetLeft, obj.parentElement.offsetTop, obj.offsetWidth, obj.menu)      
        else
          libMenuShrinkTo(obj.menu, objMenu.MyArray)
        }
    if (objMenu.Params[12]==0)
      if (obj.opened != true)
        if (obj.tri == 'true')
          obj.style.cssText = objMenu.Params[6] + libMenuTriStyle
        else
          obj.style.cssText = objMenu.Params[6]
}

function libMenuOnOut(obj){
//    if (libMenuKillMe && libAPIBrowserVersion==4)   // Dirty IE 4 fix, must be done better!
 //   {
  //     libMenuKillMe=false
   //    return
    //  }
      
    if (typeof(obj.children(0))=='undefined')
    {
      if (obj.children(0).normal)
        obj.children(0).src = obj.children(0).normal  
    }
  
    objMenu = obj.parentElement.parentElement.parentElement.parentElement
      if (obj.tri == 'true')
        obj.style.cssText = objMenu.Params[5] + libMenuTriStyle
      else
        obj.style.cssText = objMenu.Params[5]
    obj.opened = false
}



function libMenuHideout(obj){
  var l_strTagName
  
  if (event.toElement){
      l_strTagName =event.toElement.tagName
//    if (l_strTagName !='TABLE' && l_strTagName !='TD' && l_strTagName !='TR'){
       libMenuStillKill = true
       setTimeout('libMenuDoKill("'+obj.id+'")',500) 
//    }  
  }
}

function libMenuDoKill(obj){
  
  if (libMenuStillKill && document.all(obj)){      
    document.all(obj).active=false
    libMenuShrink()
    libMenuStillKill = false
  }
}


function libMenuShrinkTo(menu, MyArray){
  while(libMenuArrayCount!=0 && (libMenuArray[((libMenuArrayCount-1)*3)]!=MyArray || libMenuArray[((libMenuArrayCount-1)*3)+1]!= menu))
  {
      document.all('libMenu'+libMenuArray[((libMenuArrayCount-1)*3)+2]).outerHTML=''
      libMenuArrayCount--
  }  
  libMenuStillKill = false
}


function libMenuExpand(obj, index, depthLeft, depthTop, depthWidth, menu){
  var MyZindex

  if (Number(index)==0)
    return  
  while(libMenuArrayCount!=0 && (libMenuArray[((libMenuArrayCount-1)*3)]!=obj.MyArray || libMenuArray[((libMenuArrayCount-1)*3)+1]!= menu))
  {
      document.all('libMenu'+libMenuArray[((libMenuArrayCount-1)*3)+2]).outerHTML=''
      libMenuArrayCount--
  }
  newLeft = obj.Placing.style.pixelLeft + obj.Params[11] +depthLeft
  if (obj.Params[4]=='v')
    newLeft +=depthWidth
  newTop =  obj.Placing.style.pixelTop+ obj.Params[10] + depthTop
  if (obj.zdexer == true)
    MyZindex = obj.style.zIndex+1
  else
    MyZindex = padZIndex++

  libMenuCreate(obj.MyArray, obj.MyArray[Number(index)], newLeft,newTop,null, obj.Handler, false, null, obj.SubParams, obj.SubParams, true, obj.MyImages, obj.Pad, MyZindex )
}

function libMenuNeutralise(){
  event.cancelBubble=true  
}

function libMenuCreate(TheArray, Index, Left,Top,ParentDiv, Handler, IsRoot, PageParent, Params, SubParams, AutoKill, arrImages, pad, myZindex){
  var l_strEl, l_strStyle
  var l_lngLoop = Index
  var l_blnVertical = false
  var l_lngWidth
  var l_blnTri=false
  var obj
  l_strEl = "<DIV onmousedown='libMenuNeutralise()' onmouseout='libMenuHideout(this)' id='libMenu"+libMenuCounter+"' style='position:absolute; top:"+Top+"; left:"+Left+"; cursor:hand;'>"
  l_strEl +="<TABLE style='"+Params[13]+"' cellpadding="+Params[8]+" cellspacing="+Params[9]+" id='libMenuTable"+libMenuCounter+"' style='font:normal 8pt Arial;'>"
  
  if (Params[4]=='v')     
    l_blnVertical = true
  else
    l_strEl += "<tr height="+Params[1]+">"
 	while(TheArray[l_lngLoop]!='<end>')
 	{
     l_strStyle = Params[5]
    if (TheArray[l_lngLoop+1]!=0 && Params[2]==1){
        l_blnTri = true
        l_strStyle += libMenuTriStyle       
    } 
    else
      l_blnTri=false
    if (l_blnVertical)
    {
      if (TheArray[l_lngLoop]=='<split>'){
        l_strEl += "<TR height=1><TD></td></tr>"
        l_strEl += "<TR height=1><TD style='background-color:#B59A7F;'></td></tr>"
        l_strEl += "<TR height=1><TD style='background-color:#B59A7F;'></td></tr>" 
        l_strEl += "<TR height=2><TD></td></tr>"
      }else{
        l_strEl += "<tr><td height="+Params[1]+" tri="+l_blnTri+" menu="+Index+" subMenu="+TheArray[l_lngLoop+1]+" subMenuIndex="+(l_lngLoop+1)+" contentID="+TheArray[l_lngLoop+2]+" onclick='libMenuOnClick(this)' onmouseout='libMenuOnOut(this)' onmouseover='libMenuOnOver(this)' style='"+l_strStyle +"' nowrap=true>"
        if (eval('typeof(arrImages)')!='undefined'){
          if (arrImages!=null)
            l_strEl += "&nbsp;<img src='images/padTask/"+arrImages[TheArray[l_lngLoop+3]]+"'><span style='position:relative; top:-4;'>"+TheArray[l_lngLoop]+"</span></td></tr>"
          else
            l_strEl += "&nbsp;"+TheArray[l_lngLoop]+"</td></tr>"
        }
        else
          l_strEl += "&nbsp;"+TheArray[l_lngLoop]+"</td></tr>"
      }  
    }
    else
    {
      l_strEl += "<td tri="+l_blnTri+" menu="+Index+" subMenu="+TheArray[l_lngLoop+1]+" subMenuIndex="+(l_lngLoop+1)+" contentID="+TheArray[l_lngLoop+2]+" onclick='libMenuOnClick(this)' onmouseout='libMenuOnOut(this)' onmouseover='libMenuOnOver(this)' style='"+ l_strStyle+"' nowrap=true>"
      l_strEl += "&nbsp;&nbsp;"+TheArray[l_lngLoop]+"&nbsp;&nbsp;</td>"  
    }
    if (typeof(arrImages)=='undefined' )
      l_lngLoop+=3
    else{
      if (arrImages!=null)
        l_lngLoop+=4
      else
        l_lngLoop+=3
    }
 	}

  if (!l_blnVertical)
    l_strEl += "</tr>"

  l_strEl+="</TABLE></DIV>"
  
  if (ParentDiv)
    ParentDiv.insertAdjacentHTML("afterBegin",l_strEl);
  else
  	document.body.insertAdjacentHTML("afterBegin",l_strEl);
  
  l_lngWidth = document.all['libMenuTable'+libMenuCounter].offsetWidth

  if (l_blnTri)
    l_lngWidth +=10

  if (l_lngWidth < Params[0])
    l_lngWidth = Params[0]

  l_objMenu = document.all['libMenu'+libMenuCounter]

	document.all['libMenuTable'+libMenuCounter].style.width = l_lngWidth
	l_objMenu.style.width = l_lngWidth
	
	l_lngHeight = document.all['libMenuTable'+libMenuCounter].children(0).offsetHeight

  if (typeof(myZindex) == 'undefined'){
  	l_objMenu.style.zIndex = padZIndex++
  	l_objMenu.zdexer = false
  }else{
  	l_objMenu.style.zIndex = myZindex    
    l_objMenu.zdexer = true
  }
  l_objMenu.MyArray = TheArray
  l_objMenu.MyImages = arrImages
  l_objMenu.Params = Params
  l_objMenu.Handler = Handler
  l_objMenu.SubParams = SubParams
  l_objMenu.Pad = pad
  if (PageParent)
    l_objMenu.Placing = PageParent
  else
    l_objMenu.Placing = l_objMenu

  if (AutoKill)
  {
    libMenuArray[libMenuArrayCount*3]=TheArray
    libMenuArray[(libMenuArrayCount*3)+1]=Index
    libMenuArray[(libMenuArrayCount*3)+2]=libMenuCounter
    libMenuArrayCount++
  }
  document.body.onmousedown=libMenuShrink
  
  return libMenuCounter++
}

function libMenuShrink(){
  libMenuStillKill = false
  while(libMenuArrayCount!=0)
  {
    document.all('libMenu'+libMenuArray[((libMenuArrayCount-1)*3)+2]).outerHTML=''
    libMenuArrayCount--
  }
  document.body.onmousedown=null  
}


