// ArcIMSparam.js
// javascript file with parameters specific to calling page


//var selectPoints = new Array();

//***************************************************************************
//*			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 cImsServer = 'Macao';
var cWebServer = 'www.gis.gov.mo';
var pImsServer = 'Port_Macao';
var pWebServer = 'www.gis.gov.mo';
var imageServerName = pImsServer;
var webServerName = pWebServer;
var imsURL = 'http://' + webServerName + '/servlet/com.esri.esrimap.Esrimap?ServiceName=' + imageServerName;
var imsOVURL =  'http://' + webServerName + '/servlet/com.esri.esrimap.Esrimap?ServiceName=' + imageServerName;
var imsQueryURL = '';
var imsGeocodeURL = '';

// variables for setting component colors

var mapBackColor = '145,233,225';
var ovBoxColor = '#ff0000';
var ovBoxSize = 1;
var zoomBoxColor = '#ff0000';

// variables for using individual components

var hasOVMap = true;
var hasTOC = true;
var useModeFrame = true;

//initial map extent
var startLeft = 18990.403;
var startRight = 26063.9458840978;
var startTop = 20635.226;
var startBottom = 8768.157;
//maximum map extent
var limitLeft = 18938.4399;
var limitRight = 26063.9458840979;
var limitTop = 20891.059525;
var limitBottom = 8768.157;

/*initial map extent
var startLeft = 17624.871;
var startRight = 26060.35003723002;
var startTop = 21193.3492652178;
var startBottom = 7044.439;
//maximum map extent
var limitLeft = 17624.871;
var limitRight = 26060.35003723002;
var limitTop = 21193.3492652178;
var limitBottom = 7044.439;*/

//Web site path
var formFilePath = "C:/ArcIMS/Website/Macau"
var usePan=false;
var usePanNorth=false;
var usePanWest=false;
var usePanEast=false;
var usePanSouth=false;
var useZoomIn=false;
var useZoomOut=false;
var useFullExtent=false;
var useZoomActive=false;
var useZoomLast=false;
var useIdentify=false;
var useMeasure=false;
var useSetUnits=false;
var useSelect=false;
var useQuery=false;
var useFind=false;
var useGeocode=false;
var useStoredQuery=false;
var useClearSelect=false;
var usePrint=false;
var useBuffer=false;
var useExtract=false;




var useSetUnits=false;
var useHyperLink=false;
var useStoredQueries=false;
var useBufferShape=false;
var hasToolBarOnLayer=false;
// file locations for servlet connector form creation
var headerFilePath = formFilePath + "/header.htm";
var footerFilePath = formFilePath + "/footer.htm";

/**************************************
* Basic Map parameters
**************************************/

// map extents. . . dynamically updated
var left = -180.0;
var right = 180.0;
var top = 90.0;
var bottom = -90.0;
var fullLeft = left;
var fullRight = right;
var fullTop = top;
var fullBottom = bottom;

// map size . . . dynamically updated
//var iWidth = 630;
//var iHeight = 512;

var iWidth = 650;
var iHeight = 532;

// location map size . . . dynamically updated
//var i2Width = 150;
//var i2Height = 120;

var i2Width = 130;
var i2Height = 120;

// variables for map offset
var hspc = 0;
var vspc = 0;

//panning factor for arrow buttons
var panFactor = 0.85;
//zoom factors for v.3
var zoomFactor = 1

// 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.20;
// margin margin factor for zooming in on selected points - based on full extent. . . margin will be selectPointMargin * fullWidth or fullHeight
//var selectPointMargin = 0.025
var selectPointMargin = 0.010

// show the scale factor
var showScalePercent=true;
// display coords in status line
var showXYs=true;

//variables for MapDrawing
	// North Arrow
var drawNorthArrow = true;
var NorthArrowType = "5";
var NorthArrowSize = "15";
var NorthArrowCoords = "20 30";
var NorthArrowAngle = "90";
	// Scale Bar
var drawScaleBar = true;
	// MapUnits=DEGREES,FEET,METERS
var MapUnits = "METERS";
	// can MapUnits be changed by user?
var setMapUnits=true;
	// ScaleBarUnits=KILOMETERS,METERS,MILES,FEET
var ScaleBarUnits = "METERS";
var ScaleBarBackground = "TRUE";
var ScaleBarBackColor = "0,0,0";
var ScaleBarFontColor = "255,255,255";
var ScaleBarColor = "192,192,192";
var ScaleBarFont = "Arial";
var ScaleBarStyle = "Bold";
var ScaleBarRound = "1";
var ScaleBarSize = "12";
var ScaleBarWidth = "5";
var ScaleBarPrecision = 2;
var numDecimals = ScaleBarPrecision;
	// Copyright blurb
var drawCopyright = true;
var CopyrightFont = "Arial";
var CopyrightStyle = "Bold";
var CopyrightSize = "8";
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 = "Map produced by DSCC - Copyright (C) 2001 DSCC.";
	// 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 (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=99;

// variables for using individual components
var useTextFrame=false;
// use external window for dialogs
var useExternalWindow=false;

// colors for tables 
var textFrameBackColor="Silver";
var tableBackColor="White";
var textFrameTextColor="Black";
var textFrameLinkColor="Blue";
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 = 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
//var pixelTolerance=4;
var pixelTolerance=18;
// color of selected features in decimal RGB format
var selectColor="255,0,0";
// color of highlighted feature in decimal RGB format
var highlightColor="255,255,125";
// level of transparency of selected and highlighted color
var transparentLevel = "0.5";

// fields to be returned in identify/selection/query request. . . #ALL#=all fields
var selectFields= "#ID# #SHAPE#";
//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;
// array for each layer's returned fields if swapSelectFields=true
var selFieldList = new Array();
// sample set for world - if not #ALL#, #ID# & #SHAPE# required.
selFieldList[0]="#ALL#";
selFieldList[1]="NAME #ID# #SHAPE# AREA";
selFieldList[2]="#ALL#";
selFieldList[3]="#ALL#";
selFieldList[4]="#ALL#";

// 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=true;
// will the returned features be drawn?
var showSelectedFeatures=true;
// maximum number of features returned from query
var maxFeaturesReturned=25;

// 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="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 = 5
var maxGeocodeCandidates=10;
// minimal acceptable geocode score for candidate
var minGeocodeScore=25;
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;
	debugOn = 0;
	//formTitle = parent.PostFrame.document.title;
	if (parent.PostFrame.document.forms[0]!=null) formExists = true;
	//alert(tURL);
	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 (parent.ToolFrame!=null) parent.ToolFrame.document.location="toolbar.htm";
	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;
		useStoredQueries=false;
	}
	if (!aimsSelectPresent) {
		aimsQueryPresent=false;
		aimsBufferPresent=false;
 		useSelect=false;
		useQuery=false;
		useFind=false;
		useBuffer=false;
		useStoredQueries=false;
		useClearSelect=false;
	}
	if (!aimsIdentifyPresent) {
		aimsSelectPresent=false;
		aimsQueryPresent=false;
		aimsBufferPresent=false;
		canQuery=false;
		useIdentify=false;
 		useSelect=false;
		useQuery=false;
		useFind=false;
		useBuffer=false;
		useStoredQueries=false;
		useHyperLink=false;
	}
	if (!aimsGeocodePresent) {
		useGeocode=false;
		useReverseGeocode=false;
	}
	if (!aimsPrintPresent) {
		usePrint=false;
	}
	if (!aimsOptionsPresent) {
		allowOptions=false;
	}
	if ((aimsXMLPresent) && (aimsMapPresent)) {
		startMap();
	} else {
		alert("Unable to load one of the following Javascript Libraries:\naimsCommon.js\naimsXML.js\naimsMap.js");
	}
}


