// aimsCustom.js
/*
*  JavaScript template file for ArcIMS HTML Viewer
*       dependent on aimsXML.js, ArcIMSparam.js, aimsCommon.js, aimsMap.js,
*       aimsLayers.js, aimsDHTML.js
*       aimsClick.js, aimsNavigation.js,
*/

// global variables
    aimsCustomPresent=false;
    // change these to send XML response to custom function.
    // use numbers >= 1000 and match in useCustomFunction()
    // defaults are defined in aimsXML.js and use standard functions
    
    // xml response mode for selection
    selectXMLMode = 6;
    // xml response mode for identify
    identifyXMLMode = 7;
    // xml response mode for query
    queryXMLMode = 8;
    // xml response mode for find
    findXMLMode = 14;
    // xml response mode hyperlink
    hyperlinkXMLMode = 15;
    
    // minimum zoom level stuff
    var minimumWidth = 1000; 
    var minimumHeight = 1000;
    
  
  //htmlhook
  var eventXML = "";
  //end htmlhook

// custom function for handling clicks 
//      flow redirected here when
//      toolMode set to >=1000
function customMapTool(e) {
                if (toolMode == 1001) {
                        // insert code here
                        return false;                    
                }
                if (toolMode == 1002) {
                        // insert code here
                }
}

// send  XML response to custom function
//      flow  redirected here when
//      XMLMode >=1000
function useCustomFunction(theReply) {
    if (XMLMode==1001) {
        // insert code here
    } else if (XMLMode==1002) {
      // insert code here
        window569 = window.open(makeXMLsafe(theReply));
    } else if (XMLMode==1005) {
        // insert code here
    } else {
        alert("Unknown Mode:" + XMLMode + "\nUnable to execute request.");
    }
    hideLayer("LoadData");
}

function enforceMinimumExtent() {
  // code from ArcScripts
  left = parseFloat(left);
  right = parseFloat(right);
  bottom = parseFloat(bottom);
  top = parseFloat(top);
  var currentWidth = right - left; 
  var currentHeight = top - bottom;
  var centerX = right - (currentWidth / 2);
  var centerY = top - (currentHeight / 2);
  if ((currentWidth<minimumWidth) || (currentHeight<minimumHeight)) {
    left = centerX - (minimumWidth / 2);
    right = centerX + (minimumWidth / 2);
    bottom = centerY - (minimumHeight / 2);
    top = centerY + (minimumHeight / 2);
  }
} 

function resetSizeAfterResize() {                             // tony new
  var mWidth = getMapWidth();
  var mHeight = getMapHeight();
  var sWidth = screen.width;
  var sHeight = screen.height;
  var ovRatio = mWidth / mHeight;
  var locHeight = parseInt(mHeight/5);
  var locWidth = parseInt(locHeight*ovRatio);
  var loadBannerLeft = parseInt((mWidth - 640)/2);
  var loadBannerTop = parseInt((mHeight - 30)/2);
  vspc2 = mHeight;
  iWidth =mWidth;
  iHeight = mHeight;
}
