// constructor
// ========================================================
function StarklLocationMenuClass() 
// ========================================================
{
  this.init();
}

//========================================================
StarklLocationMenuClass.prototype = 
//========================================================
{
  // ------------------------------------------------------
  init : function() 
  // ------------------------------------------------------
  {
    this.TIMEOUT_IN = 500;
    this.TIMEOUT_OUT = 700;
    this.bActive = false;
    this.JS_MENU_ID = "starkl_location_menu";
    this.JS_MENU_SELECTION_ID = "starkl_location_menu_selection";
    this.JS_MENU_CONTENT_ID = "starkl_location_menu_content";
    this._bCloseTriggered = false;
    this._bOpenTriggered = false;
  },
  
  //------------------------------------------------------
  openMenu : function() 
  // ------------------------------------------------------
  {
    this.openMenuAfterTimeout(this.TIMEOUT_IN);
  },    

  //------------------------------------------------------
  openMenuAfterTimeout : function(nTimeOut) 
  // ------------------------------------------------------
  {
    if (!this._bOpenTriggered || nTimeOut == 0)
    {
      this._bOpenTriggered = true;
      this._bCloseTriggered = false;
      if (!this.bActive)
      {
        if (nTimeOut == 0)
          StarklLocationMenu.openMenuInternal();
        else
          window.setTimeout(function (){ StarklLocationMenu.openMenuInternal(); }, nTimeOut);
      }
    }
  },    

  //------------------------------------------------------
  closeMenu : function() 
  // ------------------------------------------------------
  {
    if (!this._bCloseTriggered)
    {
      this._bOpenTriggered = false;
      this._bCloseTriggered = true;
      window.setTimeout(function (){ StarklLocationMenu.closeMenuInternal(); }, this.TIMEOUT_OUT);
    }
  },    

  //------------------------------------------------------
  openMenuInternal : function() 
  // ------------------------------------------------------
  {
    if (this._bOpenTriggered && !this._bCloseTriggered)
    {
      jphloc.show(jphloc.ge(this.JS_MENU_CONTENT_ID));
      this._bOpenTriggered = false;
      this.bActive = true;
    }
  }, 
  
  //------------------------------------------------------
  closeMenuInternal : function() 
  // ------------------------------------------------------
  {
    if (this._bCloseTriggered && !this._bOpenTriggered)
    {
      jphloc.hide(jphloc.ge(this.JS_MENU_CONTENT_ID));
      this._bCloseTriggered = false;
      this.bActive = false;
    }
  }
}
  
StarklLocationMenu = window.StarklLocationMenu = new StarklLocationMenuClass();

