// ArcIMSparam.js
// javascript file with parameters specific to calling page

//***************************************************************************
//*			parameters File for HTML Template		    *
//***************************************************************************
// get machine name
var hostName = document.location.host;
//alert(hostName);
// make URL for getting mapservice catalog
var catURL = 'http://' + hostName + '/ReedsburgCity/ims?ServiceName=catalog';
// make prefix for URL
var serverURL  = 'http://' + hostName + '/ReedsburgCity/ims?ServiceName=';


//*********************************************************************
//*			parameters set by Designer			                     *
//*********************************************************************
//var imsURL = 'http://rmgis.ruekert-mielke.com/servlet/com.esri.esrimap.Esrimap?ServiceName=reedsburg';
//var imsOVURL =  'http://rmgis.ruekert-mielke.com/servlet/com.esri.esrimap.Esrimap?ServiceName=reedsburgOV';

var imsURL = 'http://'+ hostName +'/ReedsburgCity/ims?ServiceName=Reedsburg';
var imsOVURL =  'http://'+ hostName +'/ReedsburgCity/ims?ServiceName=ReedsburgOV';

var imsQueryURL = '';
var imsGeocodeURL = '';

// variables for setting component colors

var mapBackColor = '255,255,255';
var ovBoxColor = '#ff0000';
var ovBoxSize = 3;
var zoomBoxColor = '#ff0000';

// variables for using individual components

var hasOVMap = true;
var hasTOC = true;
var useModeFrame = true;

//initial map extent

var startLeft = 581009.09;
var startRight = 591259.8;
var startTop = 253603.25;
var startBottom = 260437.05;

//maximum map extent
//var limitLeft = 2499164.14;
//var limitRight = 2518082.91;
//var limitTop = 395310.97;
//var limitBottom = 378529.11;

var limitLeft = 574360;
var limitRight = 593329;
var limitTop = 270000;
var limitBottom = 247003;

var mapIDField = "PIN"

//Web site path
var formFilePath = "Q:/ArcIMS/Reed"
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=true;
var useSelect=true;
var useQuery=true;
var useFind=true;
var useGeocode=false;
var useStoredQuery=false;
var useClearSelect=true;
var usePrint=true;
var useBuffer=true;
var useExtract=false;

var MapUnits = "Feet";
var ScaleBarUnits = "Feet";

var parcelSearch=false;

// End of Designer set parameters

var useHyperLink=true;
//var useBufferShape=false; // not implemented
var hasToolBarOnLayer=false;
// file locations for servlet connector form creation
var headerFilePath = formFilePath + "/header.htm";
var footerFilePath = formFilePath + "/footer.htm";

/**************************************
* 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 = 3.5;
// margin margin factor for zooming in on selected points - based on full extent. . . margin will be selectPointMargin * fullWidth or fullHeight
var selectPointMargin = 3.5;

// show the scale factor
var showScalePercent=true;
// display coords in status line
var showXYs=true;

//variables for MapDrawing
	// North Arrow
var drawNorthArrow = false;
var NorthArrowType = "3";
var NorthArrowSize = "25";
var NorthArrowCoords = "75 43";
var NorthArrowAngle = "0";
	// Scale Bar
var drawScaleBar = true;
	// MapUnits=DEGREES,FEET,METERS
	// can MapUnits be changed by user?
var setMapUnits=true;
	// ScaleBarUnits=KILOMETERS,METERS,MILES,FEET
var ScaleBarBackground = "TRUE";
var ScaleBarBackColor = "0,0,0";
var ScaleBarFontColor = "0,0,0";
var ScaleBarColor = "192,192,192";
var ScaleBarFont = "Arial";
var ScaleBarStyle = "Bold";
var ScaleBarRound = "1";
var ScaleBarSize = "10";
var ScaleBarWidth = "7";
var ScaleBarPrecision = 2;
var numDecimals = ScaleBarPrecision;
	// Copyright blurb
var drawCopyright = true;
var CopyrightFont = "Arial";
var CopyrightStyle = "Bold";
var CopyrightSize = "11";
var CopyrightCoords = "4 4";
var CopyrightColor = "0,0,0";
var CopyrightBackground = "False";
var CopyrightBGColor = "255,255,255";
var CopyrightGlow = "true";
var CopyrightGlowColor = "255,255,255";
var CopyrightText = " ";
	// Mode on Map
var drawModeOnMap = false;
var modeRefreshMap = false;
var modeMapColor = "White";
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 (navigator.appVersion.search("5.0") == -1)
   		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 = 18;
var ActiveHistory = 18;
var dblayer = 18;
var bufLayer=34;
var NumGroups=9;
var Groups=["Districts","Transportation","Parcels","Environmental","Utilities","Water","Storm Sewer","Sanitary Sewer","Industrial_Business Center","Aerial Photograph"];

var Districts=[26,30,"Sections"];
var Transportation=[10,13,"Local Road Centerlines"];
var Parcels=[18,25,"Structures"];
var Environmental=[17,17,"Floodplain"];
var Utilities=[,,"Utilities"];
var Water=[0,2,"Water"];
var SanitarySewer = [7,9,"Pavement"];
var StormSewer=[3,6,"stormwater"];
var Industrial_BusinessCenter=[14,16,"Parks"];
var AerialPhotograph=[31,33,"Aerial Photoes"];

// variables for using individual components
var useTextFrame=true;
// use external window for dialogs
var useExternalWindow=false;

// colors for tables 
var textFrameBackColor="/images/blue.gif";
var tableBackColor="/images/blue.gif";
var textFrameTextColor="White";
var textFrameLinkColor="Gray";
var textFrameFormColor="Gray";

// 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 = true;
// will the LayerList show all layers, not just those available at current scale
var listAllLayers = true;

	// Mode on floating layer
var drawFloatingMode = false;
var modeLayerOn = false;
var modeLayerColor = "White";
var modeLayerShadowColor = "White";
var modeLayerFont = "Tahoma";
var modeLayerSize = "4";

	// does the overview map a layer on top of map?... 
var ovMapIsLayer=false;

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
var pixelTolerance=.5;
// color of selected features in decimal RGB format
var selectColor="255,255,0";
// color of highlighted feature in decimal RGB format
var highlightColor="255,200,0";
// 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=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
selFieldList[0]=" #ALL#";
selFieldList[1]=" #ALL#";
selFieldList[2]=" #ALL#";
selFieldList[3]=" #ALL#";
selFieldList[4]=" #ALL#";
selFieldList[5]=" #ALL#";
selFieldList[6]=" #ALL#";
selFieldList[7]=" #ALL#";
selFieldList[8]=" #ALL#";
selFieldList[9]=" #ALL#";
selFieldList[10]=" TEXT #ID# #SHAPE#";
selFieldList[11]=" #ALL#";
selFieldList[12]=" LENGTH #ID# #SHAPE#";
selFieldList[13]=" LENGTH #ID# #SHAPE#";
selFieldList[14]=" TEXT #ID# #SHAPE#";	
selFieldList[15]=" TEXT #ID# #SHAPE#";
selFieldList[16]=" TEXT #ID# #SHAPE#";
selFieldList[17]=" AREA FLOOD_ID CLASS #ID# #SHAPE#";
selFieldList[18]=" PIN #ID# #SHAPE#";	
selFieldList[19]=" PIN #ID# #SHAPE#";
selFieldList[20]=" PIN #ID# #SHAPE#";
selFieldList[21]=" #ALL#";
selFieldList[22]=" #ALL#";
selFieldList[23]=" #ALL#";
selFieldList[24]=" #ALL#";
selFieldList[25]=" TEXT #ID# #SHAPE#";
selFieldList[26]=" TEXT #ID# #SHAPE#";
selFieldList[27]=" TEXT #ID# #SHAPE#";
selFieldList[28]=" TEXT #ID# #SHAPE#";
selFieldList[29]=" #ALL#";
selFieldList[30]=" #ALL#";
selFieldList[31]=" #ALL#";
selFieldList[34]=" PIN #ID# #SHAPE#";
selFieldList[32]=" #ALL#";
selFieldList[33]=" #ALL#";
selFieldList[35]=" #ALL#";

// Hide the ID field display? The ID Field must be included in field list, but we don't have to show it.
var hideIDFieldData = false;
// Hide the shape field display? The Shape Field must be included in field list, but we don't have to show it.
var hideShapeFieldData = false;

// 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;
// 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 ("")
fieldAliasList[0]="NAME:City Name|POPULATION:Population";
fieldAliasList[1]="";
fieldAliasList[2]="";
fieldAliasList[3]="";
fieldAliasList[4]="";
fieldAliasList[5]="NAME:CountryName";
fieldAliasList[6]="";

// 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] = "Parcels";
hyperLinkFields[0] = "Common";

// will the returned data be displayed in text frame?
var showSelectedData=true;
// will the returned features be drawn?
var showSelectedFeatures=true;
// maximum number of features returned from query 25
var maxFeaturesReturned=1000;

// number of data samples retrieved for query form 50
var numberDataSamples = 100;

/**************************************
* Legend parameters - aimsLegend.js
**************************************/

// legend map size
var legWidth=170;
var legHeight=300;
var legFont="Arial";
var legTitle="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] = "Cities";
ClassRenderString[0] = "";

/*
ClassRenderString[0] ='<VALUEMAPRENDERER lookupfield="population">\n<RANGE LOWER="0" UPPER="1000000">\n<SIMPLEMARKERSYMBOL color="255,0,255" type="circle" size="4" />\n</RANGE>';
ClassRenderString[0] = ClassRenderString[0] + '<RANGE LOWER="1000000" UPPER="2500000">\n<SIMPLEMARKERSYMBOL color="255,0,255" type="circle" size="6" />\n</RANGE>';
ClassRenderString[0] = ClassRenderString[0] + '<RANGE LOWER="2500000" UPPER="5000000">\n<SIMPLEMARKERSYMBOL color="255,0,255" type="circle" size="9" />\n</RANGE>';
ClassRenderString[0] = ClassRenderString[0] + '<RANGE LOWER="5000000" UPPER="10000000">\n<SIMPLEMARKERSYMBOL color="255,0,255" type="circle" size="12" />\n</RANGE>';
ClassRenderString[0] = ClassRenderString[0] + '<RANGE LOWER="10000000" UPPER="30000000">\n<SIMPLEMARKERSYMBOL color="255,0,255" type="circle" size="16" />\n</RANGE>\n</VALUEMAPRENDERER>';
*/

/**************************************
* 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=true;
	}
	if (!aimsGeocodePresent) {
		useGeocode=false;
		useReverseGeocode=false;
	}
	if (!aimsPrintPresent) {
		usePrint=false;
	}
	if (!aimsOptionsPresent) {
		allowOptions=false;
		
	}
	
	
	if ((aimsXMLPresent) && (aimsMapPresent)) {
		
		if (aimsClickPresent) clickFunction("zoomin");
		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");
	}
}


