function lib_bwcheck() {
this.ver=navigator.appVersion
this.agent=navigator.userAgent
this.dom=document.getElementById?1:0
this.opera5=this.agent.indexOf("Opera 5")>-1
this.ie5=(this.ver.indexOf("MSIE 5")>-1 && this.dom && !this.opera5)?1:0;
this.ie6=(this.ver.indexOf("MSIE 6")>-1 && this.dom && !this.opera5)?1:0;
this.ie7=(this.ver.indexOf("MSIE 7")>-1 && this.dom)?1:0;
this.ie4=(document.all && !this.dom && !this.opera5)?1:0;
this.ie=this.ie4||this.ie5||this.ie6||this.ie7
this.mac=this.agent.indexOf("Mac")>-1
this.ns6=(this.dom && parseInt(this.ver) >= 5) ?1:0;
this.ns4=(document.layers && !this.dom)?1:0;
this.bw=(this.ie7 ||this.ie6 || this.ie5 || this.ie4 || this.ns4 || this.ns6 || this.opera5)
return this
}

function build(arr,lvl) {
  var ul = document.createElement('ul');
  ul.className = 'l' + lvl;
  for(var i = 0; i < arr.length; i++) {
    var li = document.createElement('li');
    li.className = 'l' + lvl;
    ul.appendChild(li);
    try{
    	var txt = arr[i][0];
    } catch(e){
    	continue;
    }
    txt = txt.replace(/ /g, "&nbsp;");
    var tgt = arr[i][1];
    if(tgt instanceof Array) {
      li.className += ' popup';
      var e = document.createElement('span');
      e.innerHTML = txt;
      li.appendChild(e);
      var e2 = li.appendChild(build(tgt,lvl+1));
      e.e2 = e2;
      e2.e1 = e;
      e2.ise2 = true;
      e.parentNode.onmouseout = e.onmouseout = function(ev) {
        b = lib_bwcheck();
	if(!b.ie6 || b.ie7) return;
	var e1 = window.event.srcElement;
	var to = window.event.toElement;
	while(to && to != ftMenu)
		to = to.parentNode;

	if(to != ftMenu) 
	  if(ftMenu.e2) {
	    ftMenu.e2.style.display = 'none';
	    var li = ftMenu.e2.e1.parentNode;
	    li.style.borderLeft = '3px #3f678f solid';
	    li.style.borderRight = '3px #3f678f solid';
	    li.style.position = 'static';
	    li.style.paddingTop = '5px';
	  }
      }
      e.onmouseover = function(ev) {
        b = lib_bwcheck();
        if(!b.ie6 || b.ie7) return;
        var e1 = window.event ? window.event.srcElement : ev.target;
        if(!e1.e2) {
          return;
        }
        var e2 = e1.e2;
        if(e2.ise2) {
          if(ftMenu.e2) {
            ftMenu.e2.style.display = 'none';
            var li = ftMenu.e2.e1.parentNode;
	    li.style.borderLeft = '3px #3f678f solid';
	    li.style.borderRight = '3px #3f678f solid';
	    li.style.position = 'static';
	     li.style.paddingTop = '5px';
          }
	  e1.parentNode.style.paddingBottom = '5px';
	  e1.parentNode.style.marginBottom = '-5px';
	  e1.parentNode.style.borderLeft = '3px #fff solid';
	  e1.parentNode.style.borderRight = '3px #fff solid';
	  e1.parentNode.style.position = 'relative';
	  e1.parentNode.style.paddingTop = '6px';
	  e1.parentNode.style.top = '-1px';
	  e1.parentNode.style.height = '18px';
          
	  e2.style.top = '29px';
	  e2.style.left = '0px';
          e2.style.display = 'block';
          ftMenu.e2 = e2;
        }
      }
    } else {
      var e = document.createElement('a');
      e.innerHTML = txt;
      if(tgt.substr(0,1) == '/')
        e.href = tgt;
      else
        e.href = window.menuURL + tgt;
      li.appendChild(e);
    }
  }
  return ul;
}

function buildMenu(tree, url) {
  window.menuURL = url;
  document.write("<div id='dummy'></div>");
  var menu = build(tree,1);
  ftMenu = menu;
  var breaker = menu.appendChild(document.createElement('li'));
  breaker.style.cssFloat = 'none';
  breaker.style.border = 'none';
  breaker.previousSibling.style.border = 'none';
  breaker.innerHTML = '&nbsp;';
  breaker.className = 'l1';
  menu.className = 'menu';
  menu.id = 'ft_menu';
  document.getElementById('dummy').appendChild(menu);
}

function showurl(id) {
  var e = document.getElementById('ew_url_' + id);
  if(window.globE && window.globE.parentNode != e) {
    window.globE.parentNode.removeChild(window.globE);
    window.globE = false;
  }
  var div = document.createElement('a');
  div.href = e.parentNode.href;
  div.innerHTML = e.parentNode.href;
  div.style.display = 'inline';
  div.style.position = 'absolute';
  div.style.marginTop = '8px';
  div.style.whiteSpace = 'nowrap';
  div.style.marginLeft = '7px';
  div.style.padding = '3px';
  div.style.border = '1px #666 solid';
  div.style.zIndex = '500';
  div.style.backgroundColor = '#eee';
//  e.parentNode.insertBefore(div, e);
  e.parentNode.insertBefore(div, e);
  window.globE = div;
  e.onmouseout = div.onmouseout = e.parentNode.onmouseout = function(ev) {
     var e1 = window.event ? window.event.toElement : ev.relatedTarget;
     if(window.globE && e1 != globE.parentNode &&
			e1 != globE) {
       window.globE.style.display = 'none';
  /*     window.globE.parentNode.removeChild(window.globE);*/
       window.globE = false;
     }
  }
}

function showscr(id) {
  var e = document.getElementById('ew_scr_' + id);
  var txt = document.getElementById('ew_scr_txt_' + id).innerHTML;
  if(window.globE && window.globE.parentNode != e) {
    window.globE.parentNode.removeChild(window.globE);
    window.globE = false;
  }
  var div = document.createElement('div');
//  div.href = e.parentNode.href;
  div.innerHTML = txt;
  div.style.display = 'inline';
  div.style.position = 'absolute';
  div.style.marginTop = '8px';
  //div.style.whiteSpace = 'nowrap';
  div.style.marginLeft = '7px';
  div.style.padding = '3px';
  div.style.border = '1px #666 solid';
  div.style.zIndex = '500';
  div.style.backgroundColor = '#eee';
//  e.parentNode.insertBefore(div, e);
  e.parentNode.insertBefore(div, e);
  window.globE = div;
  e.onmouseout = div.onmouseout = e.parentNode.onmouseout = function(ev) {
     var e1 = window.event ? window.event.toElement : ev.relatedTarget;
     if(window.globE && e1 != globE.parentNode &&
                        e1 != globE) {
       window.globE.style.display = 'none';
  /*     window.globE.parentNode.removeChild(window.globE);*/
       window.globE = false;
     }
  }
}

function showscr2(id) {
  var e = document.getElementById('ew_scr2_' + id);
  var txt = document.getElementById('ew_scr2_txt_' + id).innerHTML;
  if(window.globE && window.globE.parentNode != e) {
    window.globE.parentNode.removeChild(window.globE);
    window.globE = false;
  }
  var div = document.createElement('div');
//  div.href = e.parentNode.href;
  div.innerHTML = txt;
  div.style.display = 'inline';
  div.style.position = 'absolute';
  div.style.marginTop = '8px';
  //div.style.whiteSpace = 'nowrap';
  div.style.textAlign = 'left';
  div.style.marginLeft = '7px';
  div.style.padding = '3px';
  div.style.border = '1px #666 solid';
  div.style.zIndex = '500';
  div.style.backgroundColor = '#eee';
//  e.parentNode.insertBefore(div, e);
  e.parentNode.insertBefore(div, e);
  window.globE = div;
  e.onmouseout = div.onmouseout = e.parentNode.onmouseout = function(ev) {
     var e1 = window.event ? window.event.toElement : ev.relatedTarget;
     if(window.globE && e1 != globE.parentNode &&
                        e1 != globE) {
       window.globE.style.display = 'none';
  /*     window.globE.parentNode.removeChild(window.globE);*/
       window.globE = false;
     }
  }
}


function showimg(id) {
  var e = document.getElementById('ew_img_' + id);
  if(window.globE && window.globE.parentNode != e) {
    window.globE.parentNode.removeChild(window.globE);
    window.globE = false;
  }
  var div = document.createElement('img');
  div.src = e.parentNode.href;
  div.style.display = 'block';
  div.style.position = 'absolute';
  div.style.marginTop = '8px';
//  div.style.whiteSpace = 'nowrap';
  div.style.marginLeft = '7px';
  div.style.padding = '3px';
  div.style.border = '1px #666 solid';
//  div.style.zIndex = '500';
  div.style.backgroundColor = '#eee';
  e.parentNode.insertBefore(div, e);
  window.globE = div;
  e.onmouseout = div.onmouseout = e.parentNode.onmouseout = function(ev) {
     var e1 = window.event ? window.event.toElement : ev.relatedTarget;
     if(window.globE && e1 != globE.parentNode &&
                        e1 != globE) {
       window.globE.style.display = 'none';
/*       window.globE.parentNode.removeChild(window.globE);*/
       window.globE = false;
     }
  }
}


