/*
 *   Eric Bednarz <http://tagsoup.com>
 *    created @ 2006-08-25 00:31 CET @
 *   modified @ 2007-01-14 15:45 CET @
 *
 ******************************************************************************/

if(document.getElementById && document.createElement) {
   window.onload   = init;
   window.onunload = clearMenu;
   var subMarine, menuState, items = ['About','Portfolio','Contact','Cookbook'];
}

function init() {
   dropMenu();
   window.onscroll = splitIt;
}

function splitIt() {
   var img = document.images;
   img[0].src = '/img/graphics/mdo.png';
   img[(img.length - 1)].style.display = 'block';
}

////////////////////////////////////////////////////////////////////////////////

function makeMenu() {
   var menu = document.getElementById('breadcrumbs');
   var list = '<ul id="submenu">';
   var pc = location.pathname.split('/');
   for (var i = 0, c = items.length; i < c; i++) {
      if (items[i].toLowerCase() != pc[1]) {
	 list += '<li><a href="/' + items[i].toLowerCase() + '/">' + items[i] + '</a></li>';
      }
   }
   menu.innerHTML = '<div>' + menu.innerHTML + list + '</ul></div>';
}

function showMenu() {
   clearMenu();
   menuState = setTimeout("subMarine.style.display = 'block'", 300);
}

function hideMenu() {
   clearMenu();
   menuState = setTimeout("subMarine.style.display = 'none'", 600);
}

function keepMenu() {
   clearMenu();
   menuState = null;
}

function clearMenu() {
   this.onmouseout = null;
   if (typeof(menuState) != 'undefined') {
      clearTimeout(menuState);
   }
}

function dropMenu() {
   if (!document.getElementById('breadcrumbs')) {
      return;
   }
   makeMenu();
   var drop  = document.getElementById('breadcrumbs').getElementsByTagName('A');
   subMarine = document.getElementById('submenu');
   var c = drop.length;
   while (--c) {
      drop[c].onmouseover = keepMenu;
      drop[c].onfocus     = keepMenu;
      drop[c].onmouseout  = hideMenu;
      drop[c].onblur      = hideMenu;
   }
   drop[0].onmouseover = showMenu;
   drop[0].onfocus     = showMenu;
   drop[0].onmouseout  = hideMenu;
   drop[0].onblur      = hideMenu;
   subMarine.onclick   = clearMenu;
}

////////////////////////////////////////////////////////////////////////////////
