
//  -----------------------------------------------------------------
//    Notes:	The purpose of this Javascript File is to control the div resize functionality Either not handled by x_
//              Code or need to setup the use of the X_ code
//
//    Global Variables Delcared:         
//           NONE
//
//    Arguments:   
//    Returns:	N/A
//  		E:\WebSite_Default\ArcIMSFrameWorkSource\JavaScript\ArcIMSFrameWork_Div.js
//   -----------------------------------------------------------------
//    Orginization:	City of Asheville IT Services
//    Original Code: 	Dave Michelson 1/31/2006
//    Last Update:	Dave Michelson 1/31/2006
//

//*************************************
//*************************************
// X_ Code setup
//*************************************
//*************************************

  function setScrollTop( mValueObj , mObj ){
    mValueObj.value=mObj.scrollTop;
  }

  function DragSetup( mName )
  {   
    menuName = mName;

    var rBtn = xGetElementById( mName + 'Resize');
    var dBtn = xGetElementById( mName + 'Drag');

    xEnableDrag( dBtn , DragStart( mName + 'Drag'  ) , OnDrag , null);

    //if(!isNav){
      xEnableDrag( rBtn , ResizeStart( mName + 'Resize'  ) , OnResize , null);
    //}

    xShow( mName );
    Paint( mName );
  }

  function DragStart( ele , mx, my)
  {
    xZIndex( ele , highZ++ );
  }

  function OnDrag( ele , mdx, mdy)
  {
    xMoveTo( menuName , xLeft( menuName ) + mdx, xTop( menuName  ) + mdy);
  }

  function ResizeStart( ele , mx, my)
  {
    xZIndex( ele , highZ++ );
  }

  function OnResize(ele, mdx, mdy)
  {
    xResizeTo( menuName , xWidth( menuName ) + mdx, xHeight( menuName ) + mdy);    
    Paint( menuName );
  }

  function Paint( mName )
  {
    var mEle = xGetElementById( mName );
    var rBtn = xGetElementById( mName + 'Resize' );
    xMoveTo(rBtn, xWidth(mEle) - xWidth(rBtn), xHeight(mEle) - xHeight(rBtn));
  }


//*************************************
//*************************************
// Increased/added functionality
//*************************************
//*************************************

  function DisplayDiv( DIVName , xOffset , yOffset ){

    if (DIVName.length > 0){

      var theTOC = GetProperties('mapTOC');
      var theTocWidth = Number(theTOC.width.replace('px',''));
      var theHeight = 75;
      document.getElementById( DIVName ).style.visibility = 'visible';
      if ( xOffset != ''){
        document.getElementById( DIVName ).style.left = theTocWidth + (mapWidth * xOffset ) + 'px';
      }
      if ( yOffset != ''){
        document.getElementById( DIVName ).style.top = theHeight + ( mapHeight * yOffset ) + 'px';
      }
    }

  }

  function ResizeInDiv( mDivName , mToDIVName , mHieght )
  {

    var mDiv = document.getElementById( mDivName );
    var mToDiv = document.getElementById( mToDIVName );
    var mHWDiv = document.getElementById( mToDIVName + 'HW' );
    var mNewWidth = (mToDiv.style.width.substr( 0 , mToDiv.style.width.length - 2 )-15);
    var mNewHeight = (mToDiv.style.height.substr( 0 , mToDiv.style.height.length - 2 )-mHieght);

    if (mDivName != ''){
      if ( mNewWidth > 125){
        mDiv.style.width = mNewWidth+'px';
      }
    }

    if (mHieght > 0 ){
      if ( mNewHeight > 75){
        mDiv.style.height = mNewHeight+'px';
      }
    }

    if(isNav){
      var mDDiv = document.getElementById( mToDIVName + 'Drag');
      mDDiv.style.width = (mToDiv.style.width.substr( 0 , mToDiv.style.width.length - 2 )-3)+'px';
    }

    mHWDiv.style.top = mToDiv.style.top.substr( 0 , mToDiv.style.top.length - 2 )+'px';;
    mHWDiv.style.left = mToDiv.style.left.substr( 0 , mToDiv.style.left.length - 2 )+'px';
    mHWDiv.style.width = mToDiv.style.width.substr( 0 , mToDiv.style.width.length - 2 )+'px';
    mHWDiv.style.height = mToDiv.style.height.substr( 0 , mToDiv.style.height.length - 2 )+'px';
    mHWDiv.style.zIndex = highZ - 1;
    mHWDiv.style.display = 'inline';
    
  }
