var timeout    = 0;
var closetimer = 0;
var dropdownitem = 0;

function dropdown_open()
{  dropdown_canceltimer();
   dropdown_close();
   dropdownitem = $(this).find('ul').css('visibility', 'visible');}

function dropdown_close()
{  if(dropdownitem) dropdownitem.css('visibility', 'hidden');}

function dropdown_timer()
{  closetimer = window.setTimeout(dropdown_close, timeout);}

function dropdown_canceltimer()
{  if(closetimer)
   {  window.clearTimeout(closetimer);
      closetimer = null;}}

$(document).ready(function()
{  $('#dropdown > li').bind('mouseover', dropdown_open)
   $('#dropdown > li').bind('mouseout',  dropdown_timer)});

document.onclick = dropdown_close;

function WM_toggle(id){
   if (document.all){
     if(document.all[id].style.display == 'none'){
       document.all[id].style.display = '';
     } else {
       document.all[id].style.display = 'none';
     }
  return false;
   } else if (document.getElementById){
     if(document.getElementById(id).style.display == 'none'){
       document.getElementById(id).style.display = 'block';
     } else {
       document.getElementById(id).style.display = 'none';
     }
  return false;
   }
 }