// Cascading Popup Menus v5.2 - Single Frame Menu example script.


// If you're upgrading from v5.1, you can paste your existing menu data in, and if you're
// upgrading from v5.0 you need to add 'cursor' settings to your ItemStyles.
//
// And before going ANY further, you must have READ and AGREE TO the script license!
// It can be found on my site, in the syntax helpfile, or in the demo script document.


// 'horizontal Bar' style: menu items that use this ItemStyle are 40px wide, have 10px gaps
// between them, no popout indicator (the ">" in some menus) or popout indicator position,
// 0px padding of the text within items, #336699 background colour, a hover colour of #6699CC,
// 'highText' is the stylesheet class used for the menu text both normally and when highlighted,
// no border styles, 'null' means fully opaque items (set them to numbers between 0 and 100 to
// enable semitranslucency), and the 'hand'/'default' cursors are used for linked/submenu items.
var hBar = new ItemStyle(150, 0, '', -15, 3, 'images/bt-ohprogram_off.gif', 'images/bt-ohprogram_on.gif', 'highText', 'lowText', '', '',
 null, null, 'hand', 'default');
var hBar1 = new ItemStyle(75, 0, '', -15, 3, 'images/bt-hormones_off.gif', 'images/bt-hormones_on.gif', 'highText', 'lowText', '', '',
 null, null, 'hand', 'default');
var hBar2 = new ItemStyle(140, 0, '', -15, 3, 'images/bt-nutritionalsupport_off.gif', 'images/bt-nutritionalsupport_on.gif', 'highText', 'lowText', '', '',
 null, null, 'hand', 'default');
var hBar3 = new ItemStyle(140, 0, '', -15, 3, 'images/bt-researcharticles_off.gif', 'images/bt-researcharticles_on.gif', 'highText', 'lowText', '', '',
 null, null, 'hand', 'default');
var hBar4 = new ItemStyle(150, 0, '', -15, 3, 'images/bt-meetboxerwachler_off.gif', 'images/bt-meetboxerwachler_on.gif', 'highText', 'lowText', '', '',
 null, null, 'hand', 'default');
var hBar5 = new ItemStyle(75, 0, '', -15, 3, 'images/bt-contactus_off.gif', 'images/bt-contactus_on.gif', 'highText', 'lowText', '', '',
 null, null, 'hand', 'default');
var hBar6 = new ItemStyle(50, 0, '', -15, 3, 'images/bt-home_off.gif', 'images/bt-home_on.gif', 'highText', 'lowText', '', '',
 null, null, 'hand', 'default');

// The 'sub Menu' items: these have popout indicators of "Greater Than" signs ">" 15px from their
// right edge, and CSS borders. Text class also changes on mouseover.


var sBar = new ItemStyle(20, 1, '', -15, 3, '25#ffffff', '20#a1d6b8', 'lowText', 'highText',
 'itemBorder', 'itemBorder', null, null, 'hand', 'default');

// 'subBlank' is similar, but has an 'off' border the same colour as its background so it
// appears borderless when dim, and 1px spacing between items to show the hover border.
var subBlank = new ItemStyle(22, 1, '&gt;', -15, 3, '#CCCCDD', '#6699CC', 'lowText', 'highText',
 'itemBorderBlank', 'itemBorder', null, null, 'hand', 'default');

// The purplish 'button' style also has 1px spacing to show up the fancy border, and it has
// different colours/text and less padding. They also have translucency set -- these items
// are 80% opaque when dim and 95% when highlighted. It uses the 'crosshair' cursor for items.
var button = new ItemStyle(22, 1, '&gt;', -15, 2, '10#006633', '10#CC6600', 'buttonText', 'buttonHover',
 'buttonBorder', 'buttonBorderOver', 80, 95, 'crosshair', 'default');





// Create a PopupMenu() object, and pass its own name so it can reference itself later on.
// We also use a 'with' block to work with its properties and functions below.

var pMenu = new PopupMenu('pMenu');
with (pMenu)
{

// Here's what the values in the next startMenu() command mean, in order:
//  'root': the name of this menu.
//   false: orientated as a horizontal menu (true creates a vertical menu).
//      10: the 'left' offset of this menu in pixels.
//       0: the 'top' offset of this menu in pixels.
//      17: the height of this menu (for vertical menus, this becomes the menu width).
//    hBar: the ItemStyle used to give this menu colours and layout/formatting.
//      '': this menu does not display within a frame (see the Frameset Example Script to do that).
//   false: this menu shows submenus on mouseover. 'true' means show on click.
//
// Most of the items are 'sm:' items popping out submenus, except the last 'js:' JavaScript command
// to pop open a new window. I've also given each item a length in pixels, overriding the ItemStyle.

startMenu('root', false, 'window.page.elmPos("menustart").x + 0', 'window.page.elmPos("menustart").y + 0', 20, hBar, '', false);
addItem('', 'mProgram', 'sm:', null, 150);
startMenu('root1', false, 'window.page.elmPos("menustart").x + 150', 'window.page.elmPos("menustart").y + 0', 20, hBar1, '', false);
addItem('', 'mHormones', 'sm:', null, 75);
startMenu('root2', false, 'window.page.elmPos("menustart").x + 225', 'window.page.elmPos("menustart").y + 0', 20, hBar2, '', false);
addItem('', 'nutritional_support.html', '', null, 140);
startMenu('root3', false, 'window.page.elmPos("menustart").x + 365', 'window.page.elmPos("menustart").y + 0', 20, hBar3, '', false);
addItem('', 'research_articles.html', '', null, 140);
startMenu('root4', false, 'window.page.elmPos("menustart").x + 505', 'window.page.elmPos("menustart").y + 0', 20, hBar4, '', false);
addItem('', 'meet_dr_boxer_wachler.html', '', null, 150);
startMenu('root5', false, 'window.page.elmPos("menustart").x + 655', 'window.page.elmPos("menustart").y + 0', 20, hBar5, '', false);
addItem('', 'contact_us.html', '', null, 75);
startMenu('root6', false, 'window.page.elmPos("menustart").x + 730', 'window.page.elmPos("menustart").y + 0', 20, hBar6, '', false);
addItem('', 'index.html', '', null, 50);

startMenu('mProgram', true, 0, 20, 151, sBar, '', false);
addItem('&nbsp; Overview', 'optimal_health_program.html', '');
addItem('&nbsp; Assessment', 'oh-assessment.html', '');
addItem('&nbsp; Rejuvinating Skin Care', 'rej_skincare.html', '');

startMenu('mHormones', true, -1, 20, 217, sBar, '', false);
addItem('&nbsp; Overview', 'hormones.html', '');
addItem('&nbsp; Natural vs. Synthetic', 'synthetic_vs_natural.html', '');
addItem('&nbsp; Signs & Symptoms of Deficiency', 'signs_symptoms.html', '');
addItem('&nbsp; Testosterone', 'testosterone.html', '');
addItem('&nbsp; Thyroid', 'thyroid.html', '');
addItem('&nbsp; DHEA', 'dhea.html', '');
addItem('&nbsp; Progesterone', 'progesterone.html', '');
addItem('&nbsp; Estrogen', 'estrogen.html', '');
addItem('&nbsp; Cortisol', 'cortisol.html', '');
addItem('&nbsp; Melatonin', 'melatonin.html', '');


// This is the "positioning from page anchors" code used by the advanced positioning expressions.
page.elmPos=function(e,p)
{
 var x=0,y=0,w=p?p:this.win;
 e=e?(e.substr?(isNS4?w.document.anchors[e]:getRef(e,w)):e):p;
 if(isNS4){if(e&&(e!=p)){x=e.x;y=e.y};if(p){x+=p.pageX;y+=p.pageY}}
 if (e && this.MS && navigator.platform.indexOf('Mac')>-1 && e.tagName=='A')
 {
  e.onfocus = new Function('with(event){self.tmpX=clientX-offsetX;' +
   'self.tmpY=clientY-offsetY}');
  e.focus();x=tmpX;y=tmpY;e.blur()
 }
 else while(e){x+=e.offsetLeft;y+=e.offsetTop;e=e.offsetParent}
 return{x:x,y:y};
};

PopupMenu.prototype.elementHide = function(mN, show)
{
 var hideTags = [];
 // <select> is hidden in all IE versions, and Opera < 7.0.
 if ((isIE && !isOp) || (isOp && !document.documentElement))
  hideTags[hideTags.length] = 'SELECT';
 // <iframe> is hidden in IE < 5.5, all Opera versions, and Mozilla < 1.0.
 if ((isIE && !isOp && !window.createPopup) || isOp ||
  navigator.userAgent.match('rv:0.')) hideTags[hideTags.length] = 'IFRAME';
 // <object> and <applet> are hidden in all browsers.
 hideTags[hideTags.length] = 'OBJECT';
 hideTags[hideTags.length] = 'APPLET';

 with (this.menu[mN][0])
 {
  if (!lyr || !lyr.ref) return;

  var oldFn = show ? 'ehShow' : 'ehHide';
  if (this[oldFn]) this[oldFn](mN);
  else this.menu[mN][0].lyr.vis(show ? 'visible' : 'hidden');
  if (!isDOM && !isIE) return;
  if (hideTags.length == -1) return;

  var w = par?eval(par):self;
  if (!w.hideElms) w.hideElms = [];
  var hE = w.hideElms;

  if (show)
  {
   var elms = [];
   for (var t = 0; t < hideTags.length; t++)
   {
    var tags = isDOM ? w.document.getElementsByTagName(hideTags[t]) :
     isIE ? w.document.all.tags(hideTags[t]) : null;
    for (var i = 0; i < tags.length; i++) elms[elms.length] = tags[i];
   }
   for (var eN = 0; eN < elms.length; eN++)
   {
    var eRef = elms[eN];
    with (w.page.elmPos(eRef)) var eX = x, eY = y;
    if (!(lyr.x()+menuW<eX || lyr.x()>eX+eRef.offsetWidth) &&
        !(lyr.y()+menuH<eY || lyr.y()>eY+eRef.offsetHeight))
    {
     if (!hE[eN]) hE[eN] = { ref: eRef, menus: [] };
     hE[eN].menus[mN] = true;
     eRef.style.visibility = 'hidden';
    }
   }
  }
  else for (var eN in hE)
  {
   var reShow = 1, eD = hE[eN];
   eD.menus[mN] = false;
   for (var eM in eD.menus) reShow &= !eD.menus[eM];
   if (reShow && eD.ref)
   {
    eD.ref.style.visibility = 'visible';
    delete hE[eN];
   }
  }
 }
 return;
}
for (var p in PopupMenu.list)
{
 var pm = PopupMenu.list[p];
 pm.ehShow = pm.showMenu;
 pm.showMenu = new Function('mN','this.elementHide(mN, true)');
 pm.ehHide = pm.hideMenu;
 pm.hideMenu = new Function('mN','this.elementHide(mN, false)');
}

};