/**
 *
 *	Dropdown menu
 *
 * Some functions to enable drop and submenu 
 *
 * @author 		jaz303 (http://onehackoranother.com/projects/jquery/droppy/) Edited version
 *
 */

$.fn.droppy = function() {
  
  this.each(function() {
    
    var root = this, zIndex = 1000;
    
    function getSubnav(ele) {
      if (ele.nodeName.toLowerCase() == 'li') {
        var subnav = $('> ul', ele);
        return subnav.length ? subnav[0] : null;
      } else {
        return ele;
      }
    }
    
    function getActuator(ele) {
      if (ele.nodeName.toLowerCase() == 'ul') {
        return $(ele).parents('li')[0];
      } else {
        return ele;
      }
    }
    
    function hide() {
      var subnav = getSubnav(this);
      if (!subnav) return;
      $.data(subnav, 'cancelHide', false);
      setTimeout(function() {
        if (!$.data(subnav, 'cancelHide')) {
          $(subnav).hide();
        }
      }, 250);
    }
  
    function show() {
      var subnav = getSubnav(this);
      if (!subnav) return;
      $.data(subnav, 'cancelHide', true);
      $(subnav).css({zIndex: zIndex++}).show();
    }
   
    $('ul, li', this).hover(show, hide);
    
  });
};

/**
 *
 *	Dropdown menu
 *
 * Apply drop menu to all elements with "drop" class set
 *
 * @author 		DCHublist.com Team (admin@dchublist.com)
 *
 */

$(function() {
    $('.drop').droppy();
 });