(function($) {
  
	$.fn.gendexInterface = function(settings) {
		settings = jQuery.extend({
		  onHoverTime:100,
		  offHoverTimeout:500
		},settings);
		
    var jQueryMatchedObj = this;
    
		function _initialize() {
			_start(this,jQueryMatchedObj);
			return false; }
		
		function _start(objClicked,jQueryMatchedObj) {
      _set_interface();
      return; }
    
    function _set_interface() {
      $('#header_menu .menu>li:has(.submenu_container)').each( function(){
        _set_menu( $( this ));
      } );
      $('#header_menu .menu>li .submenu>li:has(.submenu_container)').each( function(){
        _set_menu( $( this ));
      } );
      return; }

    function _set_menu(where) {
      var active = null;
      var onTimer = null;
      var offTimer = null;
      $(where).hover(function() {
        if(active==null) {
          var hoved=this;
          onTimer=setTimeout(function() {
            active=hoved;
            $(active).addClass('hover');
            $(active).children('.submenu_container').fadeIn('fast');
          },settings.onHoverTime);
        }
        else if(active==this) {
          clearTimeout(offTimer);
        }
      },function(){
        clearTimeout(onTimer);
        if(active!=null) {
          offTimer=setTimeout(function(){
            $(active).children('.submenu_container').fadeOut('fast',function(){
              $(active).removeClass('hover');
              active=null;
            }); 
          },settings.offHoverTimeout);
        }
      });
      return; }

    this.each(function() {
      _initialize(); });

    return this; }

})(jQuery);


