// ------------------------------------------------------------------
// site helper panel
// ------------------------------------------------------------------
var siteHelperPanelTimer = 0;

// this callback must be run when the helper panel position must be
// updated (when a window is resized or the panel size is changed
// for the IE it must be called on every scroll, due to it does not
// support 'fixed' position of elements
function siteHelperPanelUpdatePosition()
{
  var msieVersion = getMsieVersion();
  if ( msieVersion && msieVersion < 7 )
  {
    setElementBottomFixedById( 'siteHelperPanel', getWindowHeight() );
  }
};

// this callback must be assigned to the mouse out and mouse over event 
// of the site helper panel to change it's height
function siteHelperPanelStartChangingHeight( newHeight )
{
  // every event has the priority, so clearing the timer first
  if ( siteHelperPanelTimer != 0 )
    clearTimeout( siteHelperPanelTimer );
    
  // opening or closing the navigation box, if required
  setElementHeightById( navigationBoxId, getNavigationBoxHeight() );

  // checking, if the height must be changed and setting the timer for this
  var currentHeight = getElementHeightById( siteHelperPanelId );
  if ( currentHeight != newHeight )
  {
    // changing the site helper panel
    siteHelperPanelTimer = setTimeout( function()
      {
        // the site helper panel is in movement
        siteHelperPanelOpened = false;
        
        var currentHeight = getElementHeightById( siteHelperPanelId );
        var deltaHeight = Math.ceil( (newHeight-currentHeight) / 2 );
        // making sure the movement fully stops
        if ( Math.abs( deltaHeight ) < 2 )
          setElementHeightById( siteHelperPanelId, newHeight );
        else
          setElementHeightById( siteHelperPanelId, currentHeight + deltaHeight );
        
        // the height of the panel is changed, so now it is required to redraw it's position
        siteHelperPanelUpdatePosition();
        // recalling the callback to make the new resize step, if required
        siteHelperPanelStartChangingHeight( newHeight );
      },
      siteHelperPanelTimeout
    )
  }
  else if ( currentHeight == getSiteHelperPanelMaxHeight() )
  {
    // the site helper panel is opened
    siteHelperPanelOpened = true;
    setDisplayState(obtainElementById( 'hideHelperPanelButton' ), 'block');
  }
  else if ( currentHeight == getSiteHelperPanelMinHeight() )
  {
    // resetting the maxheight of the site helper panel
    displayFullNavigationBox = false;
    setDisplayState(obtainElementById( 'hideHelperPanelButton' ), 'none');
  }
}

