// Drop Down Menu - Head Script
// copyright Stephen Chapman, 4th March 2005, 5th February 2006
// you may copy this menu provided that you retain the copyright notice

var fix = 1; var delay = 200; var modd = 0;
var ndm = 7;

// do not change anything below this line
var blc = '#332A87';var blh = '#D3D6AB';var bla = '#3c2214';var lc = '#F6F2D5';var lh = '#938ADB';var la = '#8c8c8c';

function setMenuSize(i)
{
  ndm = i;
}

if (fix) window.onscroll=sMenu;
window.onload=iMenu;
var onm = null;
var ponm = null;
var podm = null;

function posY() 
{
 return typeof window.pageYOffset != 'undefined' ? window.pageYOffset:document.documentElement.scrollTop? document.documentElement.scrollTop: document.body.scrollTop?document.body.scrollTop:0;
}

function iMenu() 
{
  if (document.getElementById) 
  {
    document.onclick = mHide;
    for (i=1; i<=ndm; i++) 
    {
      menuName = 'dropMenu' + i; 
      navName = 'navMenu' + i;
      odm = document.getElementById(menuName);
      onm = document.getElementById(navName);
      if (odm != null)
      {
        odm.style.visibility = 'hidden';
        onm.onmouseover =  mHov;
        onm.onmouseout = mOut;
      }
      else
      {
        onm.onmouseover = linkHov;
        onm.onmouseout = linkOut;
      }
    } 
    onm = null;
  } 
  return;
}

function  mHov(e)
{
  if (modd) clearTimeout(modd);
  document.onclick = null;
  honm = document.getElementById(this.id);
  if (honm != onm) 
  {
    honm.style.color = lh;
    honm.style.backgroundColor = blh;
  }   menuName = 'drop' + this.id.substring(3,this.id.length);
  odm = document.getElementById(menuName);
  if (podm == odm) 
  {
    mHide();
    return;
  } 
  if (podm != null) mHide();
  onm = document.getElementById(this.id);
  if ((ponm != onm ) || (podm == null)) 
  {
    onm.style.color = la;
    onm.style.backgroundColor = bla;
  } 
  if (odm) 
  {
//    xPos = onm.offsetParent.offsetLeft + onm.offsetLeft;
//    yPos = onm.offsetParent.offsetTop + onm.offsetParent.offsetHeight;     odm.style.left = xPos + 'px';
    var parent = onm.offsetParent;
    xPos = 0;
    yPos = 0;
    while(parent)
    {
      xPos += parent.offsetLeft;
      yPos += parent.offsetTop;
      parent = parent.offsetParent;
    }
    xPos += onm.offsetLeft;
    yPos += onm.offsetParent.offsetHeight;
    odm.style.left = xPos + 'px';
    odm.style.top = yPos + 'px';
    odm.style.visibility = 'visible';
    odm.onmouseover = omov;
    odm.onmouseout = omot;
    podm = odm;
    ponm = onm;
  }
}

function  linkHov(e)
{
  if (modd) clearTimeout(modd);
  document.onclick = null;
  honm = document.getElementById(this.id);
  if (honm != null) 
  {
    honm.style.color = lh;
    honm.style.backgroundColor = blh;
  } 
}

function omov() {if (modd) clearTimeout(modd);}
function omot() {modd = setTimeout('mHide()',delay);}

function mOut(e)
{
  modd = setTimeout('mHide()',delay);
  document.onclick = mHide;
  oonm = document.getElementById(this.id);
  if (oonm != onm)
  {
    oonm.style.color = lc;
    oonm.style.backgroundColor = blc;
  }
}

function linkOut(e)
{
  oonm = document.getElementById(this.id);
  if (oonm != null)
  {
    oonm.style.color = lc;
    oonm.style.backgroundColor = blc;
  }
}

function mHide() 
{
  document.onclick = null;
  if (podm)
  {
    podm.style.visibility = 'hidden';
    podm = null;     ponm.style.color = lc;
    ponm.style.backgroundColor = blc;
  }
  onm = null;
}

if (fix)
{
  var ag = navigator.userAgent.toLowerCase();
  var isG = (ag.indexOf('gecko') != -1);
  var isR=0;
  if (isG)
  {
    t = ag.split("rv:");
    isR = parseFloat(t[1]);
  }
  if (isR && isR<1) setInterval('sMenu()',50);
}
