// $Id: navigation.js,v 1.1 2011-08-31 20:06:47 xim Exp $
$(document).ready(function() {

  showMe = function() {
    id = $(this).attr('id');
    if (!id) id = $(this).parent().attr('id');
    if (!id) return;
    if (hiding[id]) clearTimeout(hiding[id]);
    if ($("#"+id).is('.showing')) return; 

    $("#model-navigation > li.showing").removeClass('showing');
    $("#model-navigation .model-navigation-list-wrapper").css({'left' : '-9px'}).hide();

    $("#"+id).addClass('showing');

    $(".model-navigation-list-wrapper", $("#"+id)).css({'left' : '-9px'}).show();
  } 

  hideMe = function(id) {
    $('#'+id).removeClass('showing');
    $(".model-navigation-list-wrapper", '#'+id).css({'left' : '-9px'}).hide();
  }

  hideMeDelay = function () {
    id = $(this).attr('id');
    if (!id) id = $(this).parent().attr('id');
    if (!id) return;

    hiding[id] = window.setTimeout("hideMe('"+id+"')", hideDelay);
  }

  var hideDelay = 750; // number of millisecs before hiding occurs on mouseout
  var hiding = [];     // array to hold timeout indentifiers

  var hoverIntentConfig = {    
    sensitivity: 1,  // number = sensitivity threshold (must be 1 or higher)
    interval: 25,    // number = milliseconds for onMouseOver polling interval
    over: showMe,    // function = onMouseOver callback (REQUIRED)    
    out: hideMeDelay // function = onMouseOut callback (REQUIRED)    
  }

  $("#model-navigation .model-navigation-list-wrapper").addClass("js_on");
  
  $("#model-navigation > li").hoverIntent(hoverIntentConfig);

});
