/**
  Dropdown navigation
  Author: Oli Matthews
**/

(function($){//Dropdown
 jQuery.fn.dropdown = function(settings) {
   settings = jQuery.extend({
     speed: 200
   }, settings);
   return this.each(function(){
     var nav = $(this);
     var toggles = nav.find('.dd');
     var i;
     nav.find('.children').css('display','none').addClass('children-rendered')
     toggles.hover(
       function() {
         var thisLink = $(this);
         $('ul', this).fadeIn(settings.speed,function(){
           thisLink.addClass('open').find('ul').css('display','block');
         });
         thisLink.addClass('open');
       },
       function() {
         var thisLink = $(this);
         $('ul', this).fadeOut(settings.speed,function(){
           thisLink.removeClass('open').find('ul').css('display','none');
         });
     }).click(function (){
		return false;
	});
   });
 };
})(jQuery);

// Menu initialization
jQuery(document).ready(function(){
  jQuery('#navigation').dropdown();
});


/*
(function($){
  jQuery.fn.dropdown = function(settings) {
    settings = jQuery.extend({
      disableLink: true,
      timeout: 500
    }, settings);
    
    return this.each(function(){
      
      dropdown = jQuery(this);
      toggler = dropdown.find('.link-item');
      var closeTimer = 0;
      var ddItem = 0;
      
      function subOpen() {
        cancelTimer();
        subClose();
        ddItem = $(this).find('.sub').css('display', 'block');
      };
      
      function subClose() { if(ddItem) ddItem.css('display', 'none'); };
      
      function subTimer() { closeTimer = window.setTimeout(subClose, settings.timeout); };
      
      function cancelTimer() {
        if(closeTimer) {
          window.clearTimeout(closeTimer);
          closeTimer = null;
        };
      };
      
      toggler.find('.link').click(function(){
        return false;
      })
      
      toggler.bind('mouseover', subOpen);
      toggler.bind('mouseout',  subTimer);
      
      
      document.onclick = subClose;
      
    });
  };
})(jQuery);
*/