<!--

//simple browser check
f7_v4      = (parseInt(navigator.appVersion)>=4 && parseInt(navigator.appVersion)<=5)?1:0
f7_ie      = (document.all && f7_v4)?1:0
f7_ns      = (document.layers && f7_v4)?1:0
f7_ns6     = (document.getElementById && !document.all)?1:0
all_layers = new Array();
heirarchy  = new Array();

//code for drops

function getBoundingBox(elm)
  {
  var rd = { l:0, t:0, b:0, r:0 };

  var height = elm.offsetHeight;
  var width  = elm.offsetWidth;

  do
    {
    rd.l += parseInt(elm.offsetLeft);
    rd.t += parseInt(elm.offsetTop);
    elm = elm.offsetParent;
    } while (elm);

  rd.b = rd.t + height;
  rd.r = rd.l + width;

  return rd;
  }

function f7_showdrop(thelayer, obj, submenu)
  {
  if (!all_layers[thelayer])
    all_layers[thelayer] = new Array(obj, 0);

  if (all_layers[thelayer][1] == 1)
    return; // this drop menu is already visible

  if (!submenu)
    {
    // This is a regular menu (not a submenu), so it should be the only menu in the heirachy
    heirarchy = new Array(thelayer);

    // Hide all menus that are currently open
    for (var key in all_layers)
      {
      f7_hideit(key);
      }
    }
  else
    {
    // Starting with the most recently opened submenu, cycle through (back towards the first submenu) and close
    // submenus until we find the submenu that the mouse is currently hovering over. This leaves the current menu
    // and all of its parent menus open, but closes all of its child menus
    while (f7_checkmousepos(heirarchy[heirarchy.length-1], false) == 1)
      {
      f7_hideit(heirarchy[heirarchy.length-1]);
      heirarchy.pop();
      }

    // Append this menu to the heirarchy
    heirarchy[heirarchy.length] = thelayer;
    }

  if (obj)
    {
    var bounds = getBoundingBox(obj);
    var posx   = bounds.l;
    var posy   = bounds.t;
    if (!submenu)
      posy = bounds.b;
    else
      posx = bounds.r;

    if (f7_ns)
      {
      eval('document.'+thelayer+'.left='+(posx));
      eval('document.'+thelayer+'.top='+(posy));
      }
    else if (f7_ie)
      {
      eval(thelayer+'.style.left="'+(posx)+'px"');
      eval(thelayer+'.style.top="'+(posy)+'px"');
      }
    else if (f7_ns6)
      {
      document.getElementById(thelayer).style.left = eval('"'+(posx)+'px"');
      document.getElementById(thelayer).style.top  = eval('"'+(posy)+'px"');
      }
    }

  // Show this menu
  f7_showit(thelayer)
  }


function f7_showit(thelayer)
  {
  if (f7_ie)  { eval(thelayer+'.style.visibility="visible"'); }
  if (f7_ns)  { eval('document.'+thelayer+'.visibility="show"');}
  if (f7_ns6) { document.getElementById(thelayer).style.visibility="visible"; }

  all_layers[thelayer][1] = 1;
  }

function f7_hideit(thelayer)
  {
  if (f7_ie)  { eval(thelayer+'.style.visibility="hidden"'); }
  if (f7_ns)  { eval('document.'+thelayer+'.visibility="hide"');}
  if (f7_ns6) { document.getElementById(thelayer).style.visibility="hidden"; }

  all_layers[thelayer][1] = 0;

  //f7_hideit(thelayer);
  //setTimeout('f7_hideit("'+thelayer+'")', 500);
  }

function f7_checkmousepos(thelayer, useopener)
  {
  var hideit=0;

  if (!all_layers[thelayer])
    return hideit;

  theopener = all_layers[thelayer][0];

  if (f7_ie)  { thelayer = eval(thelayer); }
  if (f7_ns)  { thelayer = eval('document.'+thelayer); }
  if (f7_ns6) { thelayer = document.getElementById(thelayer); }

  layerbounds  = getBoundingBox(thelayer);
  openerbounds = getBoundingBox(theopener);
  if (f7_mousex >= layerbounds.l && f7_mousex <= layerbounds.r && f7_mousey >= layerbounds.t && f7_mousey <= layerbounds.b)
    hideit = 0;
  else if (useopener && (f7_mousex >= openerbounds.l && f7_mousex <= openerbounds.r && f7_mousey >= openerbounds.t && f7_mousey <= openerbounds.b))
    hideit = 0;
  else
    hideit = 1;

  return hideit
  }


//deal with cursor over layer
if (!f7_ie)
  document.captureEvents(Event.MOUSEMOVE);

document.onmousemove = f7_getmousepos;

function f7_getmousepos(e)
  {
  if (f7_ns || f7_ns6) { f7_mousex=e.pageX; f7_mousey=e.pageY; }
  if (f7_ie)           { f7_mousex=event.clientX; f7_mousey=event.clientY; }

  if (f7_mousex < 0) f7_mousex = 0;
  if (f7_mousey < 0) f7_mousey = 0;

  if (heirarchy.length > 0)
    {
    // Cycle through the menu heirarchy backwards, hiding each menu until we find the menu that the mouse is over.
    // Once the menu that the mouse is over is found, we can stop hiding menus
    for (var i=heirarchy.length-1; i>=0; i--)
      {
      if (f7_checkmousepos(heirarchy[i], true) == 1)
        {
        f7_hideit(heirarchy[i]);
        heirarchy.pop();
        }
      else
        break;
      }
    }
  }

//-->
