    function checkMainTableWidth(){
      var w=(document.body.clientWidth)?document.body.clientWidth:window.innerWidth;
      document.getElementById('maintable').style.width=(w>990)?'990px':'';
    }
    checkMainTableWidth();
    window.onresize=checkMainTableWidth;

    var curmenu = null;
    
    function showsub(strmenu,sender,evnt){
      if(strmenu==curmenu)return;
      if(curmenu!=null)hidesub(null);
      var hm = document.getElementById('mainmenu_' + strmenu);
      var sm = document.getElementById('submenu_' + strmenu);
      if(sm){
      	with(sm.style){
      		if(display=='none'){
      			top = getOffsetTop(hm)+25;
      			left = getOffsetLeft(hm);
      			display = '';
      		}
      		curmenu = strmenu;
      	}
      }
    }
    
    function hidesub(evnt){
      if(curmenu==null)return;
      var sm = document.getElementById('submenu_' + curmenu);
      var t=null;
      if(evnt)t = evnt.target ? evnt.target : evnt.srcElement;
      var hm = document.getElementById('mainmenu_' + curmenu);
      while(t!=null){
      	if((t==hm)||(t==sm))return;
      	t = t.parentNode;
      }
      if(sm)sm.style.display = 'none';
      curmenu = null;
    }
    
    function smu(sender){
      sender.className='submenuitem';
    }
    function smo(sender){
      sender.className='submenuitem_over';
    }
    
    function getOffsetLeft (el) {
     var ol = el.offsetLeft;
     while ((el = el.offsetParent) != null)ol += el.offsetLeft;
     return ol;
    }
    function getOffsetTop (el) {
     var ot = el.offsetTop;
     while((el = el.offsetParent) != null)ot += el.offsetTop;
     return ot;
    }
    
    function addEventHandler(anObject, anEvent, aFunction) {
      if (anObject.attachEvent) {
      	anObject.attachEvent('on' + anEvent, aFunction);
      }	else {
      	anObject.addEventListener(anEvent, aFunction, false);
      }
    }
    
    addEventHandler(document, "mouseover", hidesub);    
