// ArcIMSparam.js
// javascript file with parameters specific to calling page

//***************************************************************************
//*			parameters File for HTML Template		    *
//***************************************************************************
// get machine name
var hostName = document.location.host;
// make URL for getting mapservice catalog
var catURL = "http://" + hostName + "/servlet/com.esri.esrimap.Esrimap?ServiceName=catalog";
// make prefix for URL
var serverURL  = "http://" + hostName + "/servlet/com.esri.esrimap.Esrimap?ServiceName=";


//*********************************************************************
//*			parameters set by Designer			                     *
//*********************************************************************
var imsMAP = 'publicmap';

var imsURL = 'http://' + hostName + '/servlet/com.esri.esrimap.Esrimap?ServiceName=' + imsMAP;

var imsOVURL =  'http://' + hostName + '/servlet/com.esri.esrimap.Esrimap?ServiceName=publickeymap';

var imsQueryURL = '';
var imsGeocodeURL = '';

var app_path = "http://" + hostName + "/"+imsMAP+"/";
var asp_path = "http://" + hostName + "/"+imsMAP+"/asp/";
var gif_path = "http://" + hostName + "/gif/";
var svy_path = "http://" + hostName + "/bby_images/web_images/jpeg_svy/";
var basemap_path = "http://" + hostName + "/pdfs/Basemap_BW/";
var parks_rec_path = "http://" + hostName + "/bby_images/web_images/park_images/";
var CAM_path = "http://" + hostName + "/pdfs/CAM/Census_Profile/";

var buffer_limit = 500;
var buffer_default= 30.5;
var mailingFence = 8000000;
// new asbuilt
var asbuiltFence = 150000;

// flag triggers zoom to envelope in aimsIdentify, displayAttributeData
var zoomToMultiple = true;

// create variables to store the index values of specific layers for use by custom functions
// the values are assigned in toc.htm, function writeCustomLayerIndexes()
var ContoursLayerIndex;
var StreetIntersectionLayerIndex;
var LotLayerIndex;
var ParksLayerIndex;
var EasementLayerIndex;
var RowLayerIndex;
var FacetLayerIndex;
var BlockLayerIndex;
var BoundaryLayerIndex;
var DraLayerIndex;
var SanLayerIndex;
var CmbLayerIndex;
var DraMHLayerIndex;
var SanMHLayerIndex;
var CmbMHLayerIndex;
var WtrLayerIndex;
var WtrFitLayerIndex;
var StrataLayerIndex;
var MonumentLayerIndex;
var RCMPAtomLayerIndex;
var GbgCollectionLayerIndex;
var DLotsLayerIndex;
var PlacesLayerIndex;
var RoadsLayerIndex;
var PostPlansLayerIndex;
var HundredBlocksLayerIndex;
var PSALayerIndex;
var BikeRoutesLayerIndex;
var TCTLayerIndex;
var UrbanTrailsLayerIndex;
var SpeedHumpsLayerIndex;
var ALRLayerIndex;
var TransitLayerIndex;
var WaterwaysSHIMLayerIndex;
var BPBMLayerIndex;
var AddressesLayerIndex;
var AssetMappingLayerIndex;
var DissemAreasLayerIndex;
var AirSpaceLayerIndex;

var PrintReportFlag = false;
var LayerReportFlag = false;
// static maps
var loadCachedKeymap = false;
var loadCachedMap = true;
var testlink= new Array();
// end of custom variables

// variables for setting component colors

var mapBackColor = '255,255,255';
var ovBoxColor = '#ff0000';
var ovBoxSize = 2;
var zoomBoxColor = '#ff0000';

// custom boolean
var customShowSelectedData = true;


// variables for using individual components

var hasOVMap = true;
var hasTOC = true;
var useModeFrame = false;

//initial map extent
var startLeft = 0.0;
var startRight = 0.0;
var startTop = 0.0;
var startBottom = 0.0;
//maximum map extent
var limitLeft = 494641.543445;
var limitRight = 510766.832954;
var limitTop = 5460457.51209;
var limitBottom = 5447200.1432;

var usePan=true;
var usePanNorth=false;
var usePanWest=false;
var usePanEast=false;
var usePanSouth=false;
var useZoomIn=true;
var useZoomOut=true;
var useFullExtent=true;
var useZoomActive=true;
var useZoomLast=true;
var useIdentify=true;
var useMeasure=true;
var useSetUnits=false;
var useSelect=true;
var useQuery=false;
var useFind=false;
var useGeocode=false;
var useStoredQuery=false;
var useClearSelect=true;
var usePrint=true;
var useBuffer=true;
var useExtract=false;

var MapUnits = "Meters";
var ScaleBarUnits = "Meters";



// End of Designer set parameters

var useHyperLink=false;
var hasToolBarOnLayer=false;

/**************************************
* Basic Map parameters
**************************************/

// variables for map pixel offset from upper left corner of frame
	// horizontal offset
var hspc = 0;
	// vertical offset
var vspc = 0;

//panning factor for arrow buttons
var panFactor = 0.85;
//zoom factors for v.3
var zoomFactor = 2;

// margin factor for zooming in on selected lines and polygons - based on feature width and height. . . margin will be selectMargin * width or height
var selectMargin = 0.5;
var addressSelectMargin = 1.25;
//var selectMargin = 0.25;
// margin margin factor for zooming in on selected points - based on full extent. . . margin will be selectPointMargin * fullWidth or fullHeight
var selectPointMargin = 0.020
//var selectPointMargin = 0.025

// Custom Survey Zoom factor for zooming in on selected points - based on full extent. . . margin will be CustomPointMargin * fullWidth or fullHeight
var CustomPointMargin = 0.0107;

// show the scale factor
var showScalePercent=false;
// display coords in status line
var showXYs=true;

//variables for MapDrawing
	// North Arrow
var drawNorthArrow = true;
var NorthArrowType = "7";
var NorthArrowSize = "15";
var NorthArrowCoords = "20 45";
var NorthArrowAngle = "0";
	// Scale Bar
var drawScaleBar = false;
	// MapUnits=DEGREES,FEET,METERS
var setMapUnits=true;
	// ScaleBarUnits=KILOMETERS,METERS,MILES,FEET
var ScaleBarBackground = "false";
var ScaleBarBackColor = "0,0,0";
var ScaleBarFontColor = "255,255,255";
var ScaleBarColor = "192,192,192";
var ScaleBarFont = "Arial";
//var ScaleBarStyle = "Bold";
var ScaleBarStyle = "Regular";
var ScaleBarRound = "1";
//var ScaleBarSize = "14";
var ScaleBarSize = "11";
var ScaleBarWidth = "7";
var ScaleBarPrecision = 2;
var numDecimals = ScaleBarPrecision;
	// Copyright blurb
var drawCopyright = true;
var CopyrightFont = "Arial";
var CopyrightStyle = "Bold";
//var CopyrightStyle = "Regular";
var CopyrightSize = "8";
//var CopyrightCoords = "8 15";
var CopyrightCoords = "5 3";
//var CopyrightColor = "255,255,255";
var CopyrightColor = "0,0,0";
var CopyrightBackground = "True";
var CopyrightBGColor = "255,255,255";
var CopyrightGlow = "False";
var CopyrightGlowColor = "255,255,255";
var CopyrightText = "City of Burnaby - Copyright (C) 2003   Accuracy and correctness not guaranteed.";
// Mode on Map
var drawModeOnMap = false;
var modeRefreshMap = false;
var modeMapColor = "255,255,255";
var modeMapGlow = "128,0,255";

var ovImageVar;
var ovBorderWidth = 2;
var ovExtentBoxSize = 2;

// setup test for Nav 4.0
var isNav4 = false;
var isNav5up = false;
var isNav = false;
var isIE = false;
if (navigator.appName == "Netscape") {
	isNav =true;
	if (parseFloat(navigator.appVersion)<5)
   		isNav4 = true;
	else isNav5up = true;

	}
else
	isIE = true;

/**************************************
* Extended Map parameters
**************************************/

// variables for ovmap offset
var ovHspc = 0;
var ovVspc = 0;

// color for Main Map zoombox in html hex RGB format
//var zoomBoxColor = "#ff0000";

// index of initial active layer. . . if more than or equal to layer count top layer used
//var ActiveLayerIndex=99;
var ActiveLayerIndex=9;

// variables for using individual components
var useTextFrame=true;
// use external window for dialogs
var useExternalWindow=false;

// colors for tables
var textFrameBackColor="#D1D9CC";
var tableBackColor="#D1D9CC";
var textFrameTextColor="Black";
var textFrameLinkColor="Blue";
var textFrameFormColor="#D1D9CC";

// LayerList visible at service load
var showTOC=true;
// set layer visibility according to LayerList or by custom programming
var toggleVisible = true;
// set layer visibility of OVMap according to LayerList or by custom programming
	// imsURL must equal imsOVMap - depends on one LayerList
var toggleOVVisible = false;
// will the LayerList show all layers, not just those available at current scale
var listAllLayers = false;

	// Mode on floating layer
var drawFloatingMode = false;
var modeLayerOn = false;
var modeLayerColor = "Black";
var modeLayerShadowColor = "White";
var modeLayerFont = "Arial";
var modeLayerSize = "4";

	// does the overview map a layer on top of map?...
var ovMapIsLayer=true;

var webParams = "";
if (parent.MapFrame!=null) {
	webParams = parent.document.location.search;
} else {
	webParams = document.location.search;
}

/**************************************
* Interactive Map parameters
**************************************/

// Click points - Measure/Shape Select/Shape Buffer
var clickMarkerColor="255,0,0";
var clickMarkerType="Circle";
var clickMarkerSize="6";


/**************************************
* Identify/Select/Query/Buffer parameters
**************************************/

// search tolerance in pixels around click (default is 2)
var pixelTolerance=4;
// color of selected features in decimal RGB format
//var selectColor="255,204,255";
var selectColor="255,153,204";
// color of highlighted feature in decimal RGB format
//var highlightColor="255,204,255";
var highlightColor="255,153,204";
// level of transparency of selected and highlighted color
var transparentLevel = "0.5";
// zoom to selected feature if only one is returned?
var zoomToSingleSelect = true;

// fields to be returned in identify/selection/query request. . . #ALL#=all fields
var selectFields= "#ALL#";
//var selectFields= "#ID# #SHAPE#";
// swap out the list of returned fields?
//If true, a list must be defined in selFieldList[n] for each layer to update selectFields
var swapSelectFields=false; //default is true
// array for each layer's returned fields if swapSelectFields=true
var selFieldList = new Array();
// sample set for world - if not #ALL#, id and shape fields required. Separate with a space


// use the field alias in the data display?
//If true, a list must be defined in fieldAliasList[n] for each layer defining aliases for those fields needing them
var useFieldAlias=false; //default is true
// array for aliases for each layer's returned fields if useFieldAlias=true
var fieldAliasList  = new Array();
// sample set for world - fieldname:alias pairs separated by a bar (|)... if no aliases, use empty string ("")

// parameters for setting up hyperlinks in data display
var hyperLinkLayers = new Array(); // layers to have hyperlink
var hyperLinkFields = new Array();	// field in those layers to be used for hyperlink
hyperLinkLayers[0] = "Image";
hyperLinkFields[0] = "URL";

// will the returned data be displayed in text frame?
var showSelectedData=false;
// will the returned features be drawn?
var showSelectedFeatures=true;
// maximum number of features returned from query
var maxFeaturesReturned=5000;

// number of data samples retrieved for query form
var numberDataSamples = 50;



/**************************************
* Legend parameters - aimsLegend.js
**************************************/

// legend map size
var legWidth=170;
var legHeight=300;
var legFont="Arial";
var legTitle="BurnabyMap Legend";

/**************************************
* Options parameters - aimsOptions.js
**************************************/

// allowing user to set options
var allowOptions=false;

/**************************************
* ClassRender parameters - aimsClassRender.js
**************************************/

// parameters for custom class rendering... overrides default renderer
var ClassRenderLayer = new Array();  // layers to have custom renderers
var ClassRenderString = new Array(); // initial custom renderer XML string for the layers
ClassRenderLayer[0] = "";
ClassRenderString[0] = "";

/**************************************
* Geocode parameters - aimsGeocode.js
**************************************/

// maximum geocode candidates returned - default = 20
var maxGeocodeCandidates=20;
// minimal acceptable geocode score for candidate
var minGeocodeScore=50;
var geocodePointColor = "255,0,0";
var geocodePointSize = "15";
var geocodeLabelSize = "12";
// custom functions needed for Reverse Geocoding
var useReverseGeocode = false;

// the starting point. . . it all starts here on loading
function checkParams() {
	appDir = getPath(document.location.pathname);
	// global for overview map. . . change if not on same frame as Map
	ovImageVar = document.ovImage;
	debugOn = 0;
	if (parent.TextFrame==null) {
		useTextFrame = false;
		useExternalWindow=true;
	}
	if (!hasLayer("measureBox")) useMeasure=false;
	if ((!useMeasure) && (!drawScaleBar)) useSetUnits=false;
	if (ovImageVar==null) hasOVMap = false;
	if (parent.TOCFrame==null) hasTOC = false;
	if (parent.ModeFrame==null) useModeFrame = false;

	if (!document.layers)	{
		if (hasLayer("theTop")) document.all.theTop.style.cursor = "crosshair";
		if (hasOVMap) ovImageVar.style.cursor = "hand";
	}

	if (hasOVMap) {
		// size of ov map image
		i2Width = ovImageVar.width;
		i2Height = ovImageVar.height;
		// position of ov map
		//ovMapLeft = iWidth - (i2Width + 6);
		//ovMapTop = 2;
	}
	if (webParams!="") {
		//alert(webParams);
		getCommandLineParams(webParams);
	}
	// if starting extents zero'd then flag to get start from mapservice
	if ((startLeft!=0) && (startRight!=0)) getStartingExtent=false;
	// if limit extents zero'd then flag to get max from mapservice
	if ((limitLeft!=0) && (limitRight!=0)) {
		getLimitExtent=false;
		enforceFullExtent=true;
	}
	if (ovBoxColor=="") ovBoxColor = "255,0,0";
	//ovBoxColor = convertHexToDec(ovBoxColor);
	if (aimsNavigationPresent) {
		// Set up event capture for mouse movement
		if (isNav4) {
			document.captureEvents(Event.MOUSEMOVE);
			document.captureEvents(Event.MOUSEDOWN);
			document.captureEvents(Event.MOUSEUP);
			//document.captureEvents(Event.MOUSEOUT);
		}
		document.onmousemove = getMouse;
		//document.onmousedown = chkMouseDown;
		document.onmousedown = mapTool;
		document.onmouseup = chkMouseUp;
		//document.onmouseout = chkMouseOut;
	} else {
		usePan=false;
		usePanNorth=false;
		usePanWest=false;
		usePanEast=false;
		usePanSouth=false;
		useMeasure=false;
		useZoomIn=false;
		useZoomOut=false
		//useFullExtent=false;
		useZoomActive=false;
		//useZoomLast=false;
	}

	if (!aimsBufferPresent) {
		useBuffer=false;
	}
	if (!aimsQueryPresent) {
		aimsBufferPresent=false;
		useQuery=false;
		useFind=false;
		useBuffer=false;
		useStoredQuery=false;
	}
	if (!aimsSelectPresent) {
		aimsQueryPresent=false;
		aimsBufferPresent=false;
 		useSelect=false;
		useQuery=false;
		useFind=false;
		useBuffer=false;
		useStoredQuery=false;
		useClearSelect=false;
	}
	if (!aimsIdentifyPresent) {
		aimsSelectPresent=false;
		aimsQueryPresent=false;
		aimsBufferPresent=false;
		canQuery=false;
		useIdentify=false;
 		useSelect=false;
		useQuery=false;
		useFind=false;
		useBuffer=false;
		useStoredQuery=false;
		useHyperLink=false;
	}
	if (!aimsGeocodePresent) {
		useGeocode=false;
		useReverseGeocode=false;
	}
	if (!aimsPrintPresent) {
		usePrint=false;
	}
	if (!aimsOptionsPresent) {
		allowOptions=false;
	}
	if ((aimsXMLPresent) && (aimsMapPresent)) {
		if (aimsClickPresent) clickFunction("zoomin");
		// edited by Chris Macleod Nov 6/2002 - replaced toolbar.htm with toolbar.asp
//		if (parent.ToolFrame!=null) parent.ToolFrame.document.location="toolbar.asp";
// feb 13th 2003 - using mailing labels login page
		if (parent.ToolFrame!=null) parent.ToolFrame.document.location="toolbar.htm";
		startMap();
	} else {
		alert("Unable to load one of the following Javascript Libraries:\naimsCommon.js\naimsXML.js\naimsMap.js");
	}
}



