// **********************************************************************************************
//
// Project:      LA CITY PLANNING ZIMAS IMS
// Version:      Release 1.0
//
// File:         vars.js
// Language:     JavaScript 1.2
// Created:      2002
// Author:       Created: James Richards, LA DCP; Modified: Daniel Elroi, LA DCP
// Description:  Contains all of the global level variable definitions for ZIMAS.
//               Conventions for the definitions of these variables include:
//               - "constants", which are ALL_CAPS by convention.  Even though
//               JavaScript does not have a Const keyword, values that should
//               be constants are stored in variables with ALL_CAPS.  You
//               should never change the contents of a constant once it is
//               defined in this script.
//               - "member" level variables, which should follow the naming
//               convention "m_<type>VariableName", where type is a one
//               (or few) letter code specifying the type.  Even though
//               there is no strict typing of variable in JavaScript, it
//               is a good idea to name variables in this way for readability.
//               Examples: 
//                 m_bBalloonHelp - boolean indicating on/off state of help 
//                 m_sMessage - string to hold a message
//                 m_dMaxX - double to hold the maximum x value
//                 m_arCommands - array containing several elements
//               - Browser sniffing object: this file also contains the client
//               side script for sniffing and determining the hosting browser.
// Dependencies: aimsXML.js, ArcIMSparam.js, aimsCommon.js, aimsMap.js,
//               aimsLayers.js, aimsDHTML.js, aimsClick.js
// Issues:       Contains two sections (12/5/02) - "A" from the "old" ZIMAS and
//               "B" from the ArcIMS 4.0 HTML Viewer (source ArcIMSparam.js, 
//               aimsMap.js, and aimsXML.js)
//
// **********************************************************************************************

// **********************************************************************************************
//                                 S E C T I O N   A
// **********************************************************************************************

//
// "Constant" declarations
//

// Note: the command, tool, and panel constants should match exactly with the
// command and tool constants found in map_utils.asp on the server side.
// They are cAsE SENsiTiVE.
var CMD_ZOOM_BACK              = "lastView";
var CMD_ENTIRE_CITY            = "cityView";
var CMD_REPORT                 = "reports";
var CMD_PRINTABLE_MAP          = "printMap";
//var CMD_HELP                   = "help";
var CMD_TIPS				   = "tips";
var CMD_LOCATOR                = "locatorMap";
var CMD_LEGEND                 = "legend";

var CMD_ZOOM_TO_PIN            = "zoomToPIN";
var CMD_ZOOM_TO_INTERSECTION   = "zoomToIntersection";
var CMD_ZOOM_TO_COMMUNITY      = "zoomToCommunity";
var CMD_ZOOM_TO_MAPSHEET       = "zoomToMapsheet";

var RPT_MAILING_LABELS         = "mailingLabels";
var RPT_CASE_NUMBERS           = "caseReport";
var RPT_PARCEL_PROFILE         = "parcelReport";

var TOOL_ZOOM_IN = "zoomInTool";
var TOOL_ZOOM_OUT = "zoomOutTool";
var TOOL_PAN = "panTool";
var TOOL_IDENTIFY = "identifyTool";
var TOOL_SELECT_POINT = "selectPointTool";
var TOOL_SELECT_LINE = "selectLineTool";
var TOOL_SELECT_RECTANGLE = "selectRectangleTool";
var TOOL_SELECT_POLYGON = "selectPolygonTool";
var TOOL_MEASURE_DISTANCE   = "measureDistanceTool";
var TOOL_MEASURE_AREA   = "measureAreaTool";

var PANEL_ATTRIBUTES = "Attributes";
var PANEL_OVERVIEW = "Overview";
var PANEL_LEGEND = "Legend";

// Numeric "constants":
var MEASURE_GRAPHIC_HEIGHT = 44;
var MEASURE_GRAPHIC_WIDTH = 89;

// Enum based constants
var fsInternet = 0;
var fsIntranet = 1;
var fsDataEdit = 2;

//
// End constant declaration
//
// **********************************************************************************************

// **********************************************************************************************
//
// Member variable declarations
//

var m_iHorizontalPos;
var m_iVerticalPos;

// Map size
var m_iMapWidth;
var m_iMapHeight;
 
// map extent.
var m_dMapMinX;
var m_dMapMaxX;
var m_dMapMinY;
var m_dMapMaxY;

// new map extent
var m_dNewMapMinX = 0;
var m_dNewMapMinY = 0;
var m_dNewMapMaxX = 0;
var m_dNewMapMaxY = 0;

// other stuff
var m_bMapClickAsRecenter = true;
var m_bMapBoxAsZoom = true;
var m_bAllowRubberband = true;
var m_arDataTabs;

// Global vars to save mouse position
var m_iMouseX = 0;
var m_iMouseY = 0;
var m_iTrackingBoxLeft = 0;
var m_iTrackingBoxTop = 0;
var m_iTrackingBoxRight = 0;
var m_iTrackingBoxBottom = 0;
var m_iTrackingBoxMinX = 0;
var m_iTrackingBoxMaxX = 0;
var m_iTrackingBoxMaxY = 0;
var m_iTrackingBoxMinY = 0;
var m_iTrackingBoxWidth = 2;

var m_dMouseX = 0; 
var m_dMouseY = 0; 

var m_bPanning = false;
var m_bMeasuring = false;
var m_bTrackingRect = false;
var m_bTrackingLine = false;
var m_bTrackingPoly = false;
//
// End member variable declarations
//
// **********************************************************************************************

// **********************************************************************************************
// 
// Browser sniffing variables
//
var isIE = false;
var isNav = (navigator.appName.indexOf("Netscape") >= 0);
var isNav4 = false;
var isIE4 = false;
var is5up = false;
var isIE7 = false;
var isMac = false;
var isWin = false;

// Do the sniffing
if (isNav) {
  if (parseFloat(navigator.appVersion) < 5)
    isNav4=true;
  else
    is5up = true;
}
else {
  isIE4=true;
  isIE=true;
  if (navigator.appVersion.indexOf("MSIE 5") > 0) {
    isIE4 = false;
    is5up = true;
  }
  //Kavita Ravindran - Dec.07.2006 - Check for IE7 
  if (navigator.appVersion.indexOf("MSIE 7") > 0) {
    isIE7 = true;
  }//
}

if (navigator.userAgent.indexOf("Win") >= 0) 
  isWin = true;
else
  isMac = true;

//
// End of browser sniffing
//
// **********************************************************************************************








// **********************************************************************************************
//                                 S E C T I O N   B
// **********************************************************************************************

//
// "Constant" declarations
//


//
// "Variable" declarations
//

var eLeft;     // = -180.0;             // m_dMapMinX       - Left extent of map (in map units)
var eRight;    // =  180.0;             // m_dMapMaxX       - Right extent of map (in map units) 
var eTop;      // =   90.0;             // m_dMapMaxY       - Top extent of map (in map units)
var eBottom;   // =  -90.0;             // m_dMapMinY       - Bottom extent of map (in map units)
var xDistance; // = Math.abs(eRight-eLeft); // 
var yDistance; // = Math.abs(eTop-eBottom); // 
var m_dMapWidth;
var m_dMapHeight;

var enforceFullExtent = false;
var lastLeft = eLeft;
var lastRight = eRight;
var lastTop = eTop;
var lastBottom = eBottom;

var m_aTrackingCoordinates = new Array();
var m_iTrackingCoordinatesCounter = 0;
var m_aTrackingIntersections = new Array();
var m_dAreaFt = 0;

var m_dTotalDistanceFt = 0;
var m_dTotalDistanceMi = 0;
var m_bStartSegment = true;

var m_iDoubleClickCounter = 1;
var m_dFirstClick = new Date();
var m_dSecondClick;
var m_iDblClickMilliseconds = 500;

var m_bToolTips = true;

var timerID = null;
var m_bDrawALine = false;			// Used in measuring distances and areas
//
// "Constant" declarations
// 

var OVBOXSIZE = 3;
var ZOOMFACTOR = 2;

var TIP_ZOOMINTOOL;
var TIP_ZOOMOUTTOOL;
var TIP_PANTOOL;
var TIP_IDENTIFYTOOL;
var TIP_SELECT_POINT_TOOL;
var TIP_SELECT_LINE_TOOL;
var TIP_SELECT_RECTANGLE_TOOL;
var TIP_SELECT_POLYGON_TOOL;
var TIP_MEASURE_DISTANCE_TOOL;
var TIP_MEASURE_AREA_TOOL;
var TIP_ZOOMBACK;
var TIP_LOCATORMAP;
var TIP_LEGEND;
var TIP_REPORT;
var TIP_PRINTABLEMAP;
var TIP_TIPS;


var sLanguage = 'English';
//var sLanguage = 'Italian';
setToolTipLanguage(sLanguage);


// ^*********************************************************************************************
//
// Project:      LA CITY PLANNING ZIMAS IMS
// Version:      Release 1.0
//
// Script:       setToolTipLanguage()
// Type:         Function
// Description:  Writes the text for the tooltips in the selected language into global constants
// Called by:    vars.js
// Arguments in: 
// Globals in:   
// Calls:        
// Output:       
// Returns:      
// Globals out:  
// History:      Original - 12/31/02: Daniel Elroi, LADCP
//
// v*********************************************************************************************

function setToolTipLanguage(sLanguage){
switch (sLanguage) {
  case 'English':
    TIP_ZOOMINTOOL = 'Click, drag, and release the mouse to zoom in to a specific area, or click and release to zoom in by 50%.';
    TIP_ZOOMOUTTOOL = 'Click and release the mouse to zoom out by 50%.';
    TIP_PANTOOL = 'Click, drag, and release the mouse to move (recenter) the map.';
    TIP_IDENTIFYTOOL = 'Click on a parcel to display information about it in a pop-up window.';
    TIP_SELECT_POINT_TOOL = 'Click on a parcel to select it.  Hold the shift key down when clicking to add or remove a parcel to/from the current selection.  Hold the control key down when clicking on a selected parcel to show its data in the right hand portion of the display window.';
    TIP_SELECT_LINE_TOOL = 'Click two or more times on the map to draw a multi- segmented line.  Double-click to end the line and select all parcels that intersect the line.  Hold the shift key down when double-clicking to add or remove the parcels to/from the current selection.';
    TIP_SELECT_RECTANGLE_TOOL = 'Click, drag, and release the mouse to draw a box and select all parcels that intersect and fall within the box.  Hold the shift key down when releasing the mouse to add or remove the parcels to/from the current selection.';
    TIP_SELECT_POLYGON_TOOL = 'Click three or more times on the map to draw a multi- segmented polygon.  Double-click to end the polygon and select all parcels that intersect and fall within the polygon.  Hold the shift key down when double-clicking to add or remove the parcels to/from the current selection.';
    TIP_MEASURE_DISTANCE_TOOL = 'Click two or more times on the map to draw a multi- segmented line and display the last segment and cumulative distances of the line.  Double-click to end the line and start a new measurement.';
    TIP_MEASURE_AREA_TOOL = 'Click three or more times on the map to draw a multi- segmented polygon and display the last segment and cumulative distances of the polygon edges.  Double-click to end the polygon and display the total area in a pop-up window.';
    TIP_ZOOMBACK = 'Return to the previous area on the map.';
    TIP_LOCATORMAP = 'Bring up a map of Los Angeles that shows where the main map is currently focused.';
    TIP_LEGEND = 'Change the data currently displayed on the map, or see an explanation of the map symbols and colors.';
    TIP_REPORT = 'Generate a report for the selected parcel(s).';
    TIP_PRINTABLEMAP = 'Generate a map in a format suitable for printing.';
    TIP_TIPS = 'Turn on or off pop-up explanations for the buttons and tools.';
    break;
  }
}








