
var state = new Object();
var items = new Object();
var blocks = new Object();

var colors = new Object();
var bgcolors = new Object();

function show(item, menuID, submenuID, fName, side) {
 highlight(item, fName);
 var submenu = document.getElementById(submenuID);
 if (submenu) {
  lock(submenu);
  items[submenuID] = item;
  if (menuID) {
   var menu = document.getElementById(menuID);
   blocks[submenuID] = menu;
  }
  var y=item.offsetTop;
  var x=item.offsetLeft;
  var po = item.offsetParent;
  while (po) {
   y+=po.offsetTop;
   x+=po.offsetLeft;
   po=po.offsetParent;
  }
  if (side && side=="bottom") {
   y+=item.offsetHeight;
   x-=1;
  } else {
   x+=item.offsetWidth;
   y-=1;
  }
  submenu.style.top=y;
  submenu.style.left=x;
  submenu.style.visibility='visible';
 }
}

function hide(submenuID, fName, color, bgcolor) {
 var submenu = document.getElementById(submenuID);
 if (submenu) {
  unlock(submenu);
  window.setTimeout('delayedHide(\''+submenu.id+'\')', 10);
  var menu=blocks[submenu.id];
  if (menu) {
   unlock(menu);
   window.setTimeout('delayedHide(\''+menu.id+'\')', 10);
  }
 }
}

function glue(submenu) {
 lock(submenu);
 var menu=blocks[submenu.id]; 
 if (menu)
  lock(menu);
}

function delayedHide(sID) {
 if (state[sID]==0) {
  darklight(items[sID]);
  document.getElementById(sID).style.visibility='hidden';
 }
}

function highlight(elem, fName) {
 if (!colors[elem.id]) {
  if (elem.tagName=='A')
   colors[elem.id]=getStyle(elem,'color','');
  else
   colors[elem.id]=getStyle(elem,'color','color');
 }
 if (!bgcolors[elem.id])
  bgcolors[elem.id]=getStyle(elem,'backgroundColor','background-color');
 if (fName) {
  fName(elem);
  var ch = elem.children;
  if (ch)
   for(i=0;i<ch.length;i++)
    fName(ch.item(i));
 }
}

function darklight(elem) {
 if (elem) { 
   elem.style.color=colors[elem.id];
   elem.style.backgroundColor=bgcolors[elem.id];
   var ch = elem.children;
   if (ch)
    for(i=0;i<ch.length;i++){
      ch.item(i).style.color=colors[elem.id];
      ch.item(i).style.backgroundColor=bgcolors[elem.id];
    }
   
 }
}

function lock(obj) {
 state[obj.id]=1;
}

function unlock(obj) {
 state[obj.id]=0;
}

function getStyle(elem, IE, CSS) {
 if (elem.currentStyle)
  return elem.currentStyle[IE];
 else if (window.getComputedStyle) {
  var compStyle = window.getComputedStyle(elem,"");
  return compStyle.getPropertyValue(CSS);
 }
}

function hL(obj){paint(obj,'#FFDF8D')}

function hM(obj){paint(obj,'#FFEEB8','295393')}

function hT(obj){paint(obj,'#5FA2D3')}

function hTM(obj){paint(obj,'#004885','#FFEDB5')}

function paint(obj, c, bg) {
if (c)
 obj.style.color=c;
if (bg)
 obj.style.backgroundColor=bg;  
}

function AM(Node,DivId) {
 document.getElementById('main').style.display='none';
 document.getElementById('shares').style.display='none';
 document.getElementById('fixed-income').style.display='none';
 document.getElementById(DivId).style.display='';
 var AllNodes=Node.parentElement;
 for(var i=0; i<AllNodes.children.length; i++) {
  if (AllNodes.children[i].className=='mainA') {
   AllNodes.children[i].className='main';
   break;
  }
 }
 Node.className='mainA';
}
