/*************************************
* Main parameters file for setting  
* map and search display properties
*************************************/
// 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=";

//names of the map services (in quotes) for the map and overview map
//var imsURL = serverURL + "ahims_plus";
//var imsOVURL = serverURL + "basemap";
var imsURL = "ServiceName=stateveg"; // Replace servicename to the actual service name. eg: ParkView 
var imsOVURL = "ServiceName=basemap";

/*************************************
* Setup variables for filtering 
* of a layer based on a SESSIONID
* passed in on the calling URL
*************************************/

var filterLayer = "SITES";
//var filterField = "dec_ahims.dbo.coffs_sites_s_57.general_re";


/***********************************
*	Database and NPWS specific 
*	settings 
*	Field names and aliases are defined
* 	in NPWS.js
************************************/

var highlightIdentify=true;
var zoomToFeature=false; //zoom to identified features
var reserveLayerIndex=15;
var reserveLayer="3";
var reserveLayerType="polygon";
var PrintMode=""; //used in aimsPrint, portrait or landscape

var dbLinkLayer = "reserve_search";
var dbLinkLayerID = "3";
//var printBgtransparent="";
var enableWMS=false;
var OGCShowTOC=true;		

/*layer index is the reverse of the layer id in the map configuration file
eg map config
<LAYER type="image"  name="Hillshade" visible="true" id="0" minscale="1:250000" maxscale="1:3000000">
<LAYER type="image" name="Hillshade" visible="true" id="1" minscale="1:3000000" maxscale="1:15000000">
<LAYER type="featureclass" name="NPWS Admin Boundaries" visible="true" id="2">
<LAYER type="featureclass" name="reserve_search" visible="true" id="3">
<LAYER type="featureclass" name="Rivers" visible="false"  id="4" minscale="1:25000" maxscale="1:1000000">
<LAYER type="featureclass" name="Rivers" visible="false"  id="5" minscale="1:1000000" maxscale="1:15000000">
<LAYER type="featureclass" name="NSW Coast" visible="true"  id="6" maxscale="1:5000000">
<LAYER type="featureclass" name="Roads" visible="false"  id="7">
<LAYER type="featureclass" name="NPWS Offices" visible="true" id="8">
<LAYER type="featureclass" name="interstate" visible="true" id="9">
<LAYER type="featureclass" name="Local Government Areas" visible="false" id="lga">
<LAYER type="featureclass" name="Electorates" visible="false" id="electorates">
<LAYER type="featureclass" name="towns" visible="true"  id="10" minscale="1:1" maxscale="1:1000000" >

javascript layer array
layer[0]  //towns
layer[1]  //Electorates
layer[2]  //Local Government Areas
layer[3]  //interstate
layer[4]  //NPWS Offices
layer[5]  //Roads
layer[6]  //NSW Coast
layer[7]  //Rivers
layer[8]  //Rivers
layer[9]  //reserve_search
layer[10] //NPWS Admin Boundaries
layer[11] //Hillshade
layer[12] //Hillshade
*/
var dbLinkLayerIndex = 0;
//var ActiveLayer = "ASR.SITE";



// url for Custom QueryService if not ImageService(imsURL)...otherwise empty quotes
var imsQueryURL = "";
var imsGeocodeURL = "";

var sessionId="0"; //initialise the sessionId variable use for layer filtering in AHIMS
var useFancyTable = false;


var mapBackColor = "221,226,231";
var ovBoxColor = "255,0,0";
var ovBoxSize = 3;

var hasOVMap=true;
var hasTOC=true;
var useModeFrame=true;



//initial map extent
var startLeft = 140.331;
var startRight = 154.301;
var startTop = -27.691;
var startBottom = -37.974;
//maximum map extent
var limitLeft = 140.331;
var limitRight = 154.301;
var limitTop = -27.691;
var limitBottom = -37.974;

var fullLHLeft = 140.331;
var fullLHRight = 159.500;
var fullLHTop = -27.691;
var fullLHBottom = -37.974;


// flag available tools

var useLegend_top=false;
var useLegend_bottom=false;
var useOVMap_top=false;
var useOVMap_bottom=false;

var useSave_top=false;
var useSave_bottom=false;
var usePrint_top=false;
var usePrint_bottom=false;
var useHelp_top=false;
var useHelp_bottom=false;

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 useSelect=false;
var useQuery=false;
var useFind=false;
var useFindRes=false;
var useClearSelect=false;

var useBuffer=false;
var useResize=false;

var useGeocode=false;
var useExtract=false;

var useSetUnits=false;
var useStoredQuery=false;


var useHyperLink=false;
var useHyperLinkAny=false;
var useIdentifyAll=false;
var useBufferShape=false; 
var hasToolBarOnLayer=false;
	// useHyperLink takes priority - both cannot be true
if (useHyperLink) useHyperLinkAny=false;
	// useIdentify takes priority - both cannot be true
//if (useIdentify) useIdentifyAll=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 = 85/100;
//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 = 25/100;
// margin margin factor for zooming in on selected points - based on full extent. . . margin will be selectPointMargin * fullWidth or fullHeight
var selectPointMargin = 25/1000

// show the scale factor
var showScalePercent=true;
// display coords in status line
var showXYs=true;

// Have ArcXML responses URL encoded? Will not work with 2-byte characters
var doURLencode = false;

//variables for MapDrawing
	// North Arrow
var drawNorthArrow = true;
var NorthArrowType = "4";
var NorthArrowSize = "15";
var NorthArrowCoords = "20,30";
var NorthArrowAngle = "0";
	// Scale Bar
var drawScaleBar = true;
	// MapUnits=DEGREES,FEET,METERS
var MapUnits = "DEGREES";
	// can MapUnits be changed by user?
var setMapUnits=true;
	// ScaleBarUnits=KILOMETERS,METERS,MILES,FEET
var ScaleBarUnits = "KILOMETERS";
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 = "14";
var ScaleBarWidth = "7";
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 = "© DEC NSW 2005";
	// 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;

// map image background transparent? - requires gif or png8 types
var mapTransparent=true;

// setup test for Nav 4.0
var isIE = false;
var isNav = (navigator.appName.indexOf("Netscape")>=0);
var isNav4 = false;
var isIE4 = false;
var is5up = false;
//alert(navigator.appVersion);
if (isNav) {
	
	if (parseFloat(navigator.appVersion)<5) {
		isNav4=true;
		//alert("Netscape 4.x or older");
	} else {
		is5up = true;
	}
} else {
	isIE4=true;
	isIE=true;
	if (navigator.appVersion.indexOf("MSIE 5")>0) {
		isIE4 = false;
		is5up = true;
		//alert("IE5");
	}
}	
		


/**************************************
* 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=0;

// variables for using individual components
//var useQueryFrame=true;
var useQueryFrame=true;
// use external window for dialogs
var useExternalWindow=false;

// colors for tables 
var QueryFrameBackColor="Silver";
var tableBackColor="White";
var QueryFrameTextColor="Black";
var QueryFrameLinkColor="Blue";
var QueryFrameFormColor="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 = false;

// toggle the check of non-listing of layers in LayerList and Legend
// if true, noListLayer array must have an element defined for each layer
var hideLayersFromList=false;
// layers that will be listed in the LayerList or Legend
	// Note: This does not affect map display
var noListLayer = new Array();
// noListLayer[0] = false;
// noListLayer[1] = false;
// noListLayer[2] = false;
// noListLayer[3] = true;	// this one will not be listed
// noListLayer[4] = 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=2;
// color of selected features in decimal RGB format
var selectColor="255,255,0"
// color of highlighted feature in decimal RGB format
var highlightColor="255,0,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
/*
0
2
4
8
10
12
11
12
17
*/
selFieldList[0]="#ALL#";
selFieldList[1]="DEC_AHIMS.DBO.HENV_TOWNS_500K.NAME #ID# #SHAPE#";
selFieldList[2]="DEC_PARKVIEW.DEC.HENV_PARK_VIEW_ROAD_250K.NAME DEC_PARKVIEW.DEC.HENV_PARK_VIEW_ROAD_250K.CLASS #ID# #SHAPE#";
selFieldList[3]="dec_ahims.dbo.cma_subregions_v2_agd66.ID dec_ahims.dbo.cma_subregions_v2_agd66.CMA dec_ahims.dbo.cma_subregions_v2_agd66.WEBDISPLAY";
selFieldList[4]="DEC_AHIMS.DBO.CMA.CMA_NAME #ID# #SHAPE#";
selFieldList[5]="DEC_PARKVIEW.DEC.LANDSCAPE_V2.LANDSCAPE #ID# #SHAPE#";
selFieldList[6]="DEC_AHIMS.DBO.LGA.TAG #ID# #SHAPE#";
selFieldList[7]="DEC_AHIMS.DBO.IBRA_V6_POLYGON.REG_NAME";
selFieldList[8]="DEC_AHIMS.DBO.SF_BND.SFNAME";
selFieldList[9]="DEC_AHIMS.DBO.LAND_NPWS_ESTATE.RES_NO DEC_AHIMS.DBO.LAND_NPWS_ESTATE.NAME_SHORT DEC_AHIMS.DBO.LAND_NPWS_ESTATE.GAZ_DATE #ID# #SHAPE#";

// Hide the ID field display? The ID Field must be included in field list, but we don't have to show it.
var hideIDFieldData = true;
// Hide the shape field display? The Shape Field must be included in field list, but we don't have to show it.
var hideShapeFieldData = true;

// 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=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 ("")
fieldAliasList[0]="";
fieldAliasList[1]="dec_ahims.dbo.HENV_TOWNS_500K.NAME:Locality Name";
fieldAliasList[2]="dec_parkview.dec.HENV_PARK_VIEW_ROAD_250K.NAME:Road Name|dec_parkview.dec.HENV_PARK_VIEW_ROAD_250K.CLASS:Class";
fieldAliasList[3]="dec_ahims.dbo.cma_subregions_v2_agd66.ID:ID|dec_ahims.dbo.cma_subregions_v2_agd66.CMA:CMA Name|dec_ahims.dbo.cma_subregions_v2_agd66.WEBDISPLAY:CMA Subregion Name";
fieldAliasList[4]="DEC_AHIMS.DBO.CMA.CMA_NAME:CMA Name";
fieldAliasList[5]="dec_parkview.dec.landscape_v2.LANDSCAPE:Landscape Name";
fieldAliasList[6]="DEC_AHIMS.DBO.LGA.TAG:LGA Name";
fieldAliasList[7]="dec_ahims.dbo.ibra_v6_polygon.REG_NAME:Name"; 
fieldAliasList[8]="dec_ahims.dbo.sf_bnd.SFNAME:Name"; 
fieldAliasList[9]="DEC_AHIMS.DBO.LAND_NPWS_ESTATE.RES_NO:Code|DEC_AHIMS.DBO.LAND_NPWS_ESTATE.NAME_SHORT:Reserve Name|DEC_AHIMS.DBO.LAND_NPWS_ESTATE.GAZ_DATE:Gazette Date";

// 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
var hyperLinkPrefix = new Array();  // prefix (if any) to place before field value to make hyperlink url
var hyperLinkSuffix = new Array();  // suffix (if any) to place after field value to make hyperlink url
// hyperLinkLayers[0] = "NPWS Reserves";
hyperLinkFields[0] = "RES_CODE";
hyperLinkPrefix[0] = "../dev/test/";
hyperLinkSuffix[0] = ".htm";

// array of layers that can be extracted. 
// Note: only feature layers can be extracted setting this to true won't help
// for images and grids
var canExtract = new Array();
canExtract[0] = false;
canExtract[1] = false;
canExtract[2] = false;
canExtract[3] = false;
canExtract[4] = false;
canExtract[5] = false;
canExtract[6] = false;
canExtract[7] = false;
canExtract[8] = false;

// Ajay
// Metadata links for the layers. Used by showLayerMetadata() in aimsLayers.js
var layerMetadataList  = new Array();
/*
layerMetadataList[0]="";
layerMetadataList[1]="";
layerMetadataList[2]="http://canri.nsw.gov.au/nrdd/records/ANZNS0404001262.html";
//layerMetadataList[3]="http://canri.nsw.gov.au/nrdd/records/ANZNS0404001262.html";
layerMetadataList[4]="http://canri.nsw.gov.au/nrdd/records/ANZNS0404000873.html";
//layerMetadataList[5]="http://canri.nsw.gov.au/nrdd/records/ANZNS0404000872.html";
//layerMetadataList[6]="http://canri.nsw.gov.au/nrdd/records/ANZNS0404000872.html";
//layerMetadataList[7]="http://canri.nsw.gov.au/nrdd/records/ANZNS0404000747.html";
layerMetadataList[8]="http://canri.nsw.gov.au/nrdd/records/ANZNS0359100100.html";
//layerMetadataList[9]="http://canri.nsw.gov.au/nrdd/records/ANZNS0404001014.html";
layerMetadataList[10]="";
layerMetadataList[11]="http://canri.nsw.gov.au/nrdd/records/ANZNS0404000748.html";
layerMetadataList[12]="";
//layerMetadataList[13]="";
//layerMetadataList[14]="";
//layerMetadataList[15]="";
//layerMetadataList[16]="";
layerMetadataList[17]="http://canri.nsw.gov.au/nrdd/records/ANZNS0208000008.html";
//layerMetadataList[18]="http://www.ga.gov.au/meta/ANZCW0703006621.html";
//layerMetadataList[19]="http://www.ga.gov.au/meta/ANZCW0703005457.html";
//layerMetadataList[20]="";
//layerMetadataList[21]="";
*/
layerMetadataList[0]="";
layerMetadataList[1]="http://canri.nsw.gov.au/nrdd/records/ANZNS0404001262.html";
layerMetadataList[2]="http://canri.nsw.gov.au/nrdd/records/ANZNS0404001262.html";
layerMetadataList[3]="";
layerMetadataList[4]="http://canri.nsw.gov.au/nrdd/records/ANZNS0359100100.html";
layerMetadataList[5]="";
layerMetadataList[6]="http://canri.nsw.gov.au/nrdd/records/ANZNS0404000748.html";
layerMetadataList[7]="";
layerMetadataList[8]="http://canri.nsw.gov.au/nrdd/records/ANZNS0167000004.html ";
layerMetadataList[9]="http://canri.nsw.gov.au/nrdd/records/ANZNS0208000008.html";
layerMetadataList[10]="";
layerMetadataList[11]="";
layerMetadataList[12]="";

// Ajay
// Vegetation Formation layer id
// the VegFormLayer comes in from the default.htm (which can be set from URL) 
var VegFormLayer = 0; 
var VegFormLayerCol = "DEC_AHIMS.DBO.VEG_NSWMAP_2_2_EXT.NSW"; 

// the next 3 var's are for veg formation
var vegFormationId = 98; 
var vegFormationName = "Vegetation Formation";
var vegFormationLookupField = "DEC_AHIMS.DBO.VEG_NSWMAP_2_2_EXT.MAJ_FORM";

// the next 3 var's are for veg classes
var vegSelectId = 99; 
var vegSelectedName = top.theCmdVegLayerText; 
// theCmdVegLayer comes in from the URL in default.htm
var vegLookupField = VegFormLayerCol + top.theCmdVegLayer;

var VegFormLayerIDCol = "DEC_AHIMS.DBO.VEG_NSWMAP_2_2_EXT.NEWID";
var VegFormLayerHACol = "DEC_AHIMS.DBO.VEG_NSWMAP_2_2_EXT.HECTARES"; 

/*
// Vegetation formation 
NA - 255, 255, 255 - > 70% Cleared
F1 - 202, 0, 219 - Rainforests
F2 - 194, 251, 254 - Wet sclerophyll forests (Grassy subformation)
F3 - 0, 208, 219 - Wet sclerophyll forests (Shrubby subformation)
F4 - 255, 255, 0 - Grassy woodlands
F5 - 2, 219, 0 - Dry sclerophyll forests (Shrub/grass subformation)
F6 - 1, 99, 0 - Dry sclerophyll forests (Shrubby subformation)
F7 - 254, 190, 0 - Semi-arid woodlands (Grassy subformation)
F8 - 198, 123, 62 - Semi-arid woodlands (Shrubby subformation)
F9 - 151, 71, 73 - Heathlands
F10 - 0, 0, 0 - Alpine complex
F11 - 254, 250, 194 - Grasslands
F12 - 13, 0, 129 - Freshwater wetlands
F13 - 0, 129, 254 - Forested wetlands
F14 - 234, 51, 162 - Saline wetlands
F15 - 255, 0, 0 - Arid shrublands (Acacia subformation)
F16 - 254, 164, 164 - Arid shrublands (Chenopod subformation)
*/

// if -1, then display all formations
// else display the selected.
// set in vegformopts.html 
var formationDisplay = top.theCmdVegLayer; //-1; 


var fldValues = new Array();
fldValues[0] = "clr70"; 
fldValues[1] = "f1"; 
fldValues[2] = "f2"; 
fldValues[3] = "f3"; 
fldValues[4] = "f4"; 
fldValues[5] = "f5"; 
fldValues[6] = "f6"; 
fldValues[7] = "f7"; 
fldValues[8] = "f8"; 
fldValues[9] = "f9"; 
fldValues[10] = "f10"; 
fldValues[11] = "f11"; 
fldValues[12] = "f12"; 
fldValues[13] = "f13"; 
fldValues[14] = "f14"; 
fldValues[15] = "f15"; 
fldValues[16] = "f16"; 

var fldRBGValues = new Array();
fldRBGValues[0] = "255, 255, 255"; 
fldRBGValues[1] = "202, 0, 219"; 
fldRBGValues[2] = "194, 251, 254"; 
fldRBGValues[3] = "0, 208, 219"; 
fldRBGValues[4] = "255, 255, 0"; 
fldRBGValues[5] = "2, 219, 0"; 
fldRBGValues[6] = "1, 99, 0"; 
fldRBGValues[7] = "254, 190, 0"; 
fldRBGValues[8] = "198, 123, 62"; 
fldRBGValues[9] = "151, 71, 73"; 
fldRBGValues[10] = "0, 0, 0"; 
fldRBGValues[11] = "254, 250, 194"; 
fldRBGValues[12] = "13, 0, 129"; 
fldRBGValues[13] = "0, 129, 254"; 
fldRBGValues[14] = "234, 51, 162"; 
fldRBGValues[15] = "255, 0, 0"; 
fldRBGValues[16] = "254, 164, 164"; 

var fldText = new Array();
fldText[0] = "70% Cleared"; 
fldText[1] = "Rainforests"; 
fldText[2] = "Wet sclerophyll forests (Grassy subformation)"; 
fldText[3] = "Wet sclerophyll forests (Shrubby subformation)"; 
fldText[4] = "Grassy woodlands"; 
fldText[5] = "Dry sclerophyll forests (Shrub/grass subformation)"; 
fldText[6] = "Dry sclerophyll forests (Shrubby subformation)"; 
fldText[7] = "Semi-arid woodlands (Grassy subformation)"; 
fldText[8] = "Semi-arid woodlands (Shrubby subformation)"; 
fldText[9] = "Heathlands"; 
fldText[10] = "Alpine complex"; 
fldText[11] = "Grasslands"; 
fldText[12] = "Freshwater wetlands"; 
fldText[13] = "Forested wetlands"; 
fldText[14] = "Saline wetlands"; 
fldText[15] = "Arid shrublands (Acacia subformation)"; 
fldText[16] = "Arid shrublands (Chenopod subformation)"; 

// Ajay
// Vegetation formation layer percentages
var flist = new Array(); 
var codelist = new Array();   

var nswmaplbls = new Array(); 
areaclasspcs = ["", "(<1%)", "(1 - 10%)", "(10 - 50%)", "(>50%)"];
areaclasspcs_esc = ["absent", "(less than 1%) land cover", "(1 - 10%) land cover", "(10 - 50%) land cover", "(greater than 50%) land cover"];

var orderedCodes = new Array(); 
orderedCodes = [1, 2, 75, 3, 4, 119, 5, 117, 118, 6, 7, 8, 9, 21, 24, 10, 11, 78, 72, 40, 41, 
  86, 45, 42, 109, 116, 46, 110, 91, 47, 67, 69, 80, 81, 66, 79, 68, 84, 113, 30, 
  19, 20, 15, 16, 64, 22, 26, 82, 25, 17, 27, 28, 29, 106, 70, 31, 32, 65, 33, 34, 
  35, 36, 104, 114, 115, 54, 55, 56, 74, 108, 92, 48, 50, 51, 52, 58, 71, 112, 57, 
  53, 97, 90, 101, 107, 88, 89, 94, 44, 61, 62, 63, 95, 59, 60, 98, 102, 103, 99, 100, 0];


// Ajay
// Vegetation formation layer defs
var nswmaplbls = new Array(); 
nswmaplbls = [
[0, "Cleared", "", ""],
[1, "Subtropical Rainforests", "Rainforests", "RF"],
[2, "Northern Warm Temperate Rainforests", "Rainforests", "RF"],
[75, "Southern Warm Temperate Rainforests", "Rainforests", "RF"],
[3, "Cool Temperate Rainforests", "Rainforests", "RF"],
[4, "Dry Rainforests", "Rainforests", "RF"],
[119, "Western Vine Thickets", "Rainforests", "RF"],
[5, "Littoral Rainforests", "Rainforests", "RF"],
[117, "Oceanic Rainforests", "Rainforests", "RF"],
[118, "Oceanic Cloud Forests", "Rainforests", "RF"],
[6, "North Coast Wet Sclerophyll Forests", "Wet sclerophyll forests (Shrubby subformation)", "WSF(s)"],
[7, "South Coast Wet Sclerophyll Forests", "Wet sclerophyll forests (Shrubby subformation)", "WSF(s)"],
[8, "Northern Escarpment Wet Sclerophyll Forests", "Wet sclerophyll forests (Shrubby subformation)", "WSF(s)"],
[9, "Southern Escarpment Wet Sclerophyll Forests", "Wet sclerophyll forests (Shrubby subformation)", "WSF(s)"],
[21, "Northern Hinterland Wet Sclerophyll Forests", "Wet sclerophyll forests (Grassy subformation)", "WSF(g)"],
[24, "Southern Lowland Wet Sclerophyll Forests", "Wet sclerophyll forests (Grassy subformation)", "WSF(g)"],
[10, "Northern Tableland Wet Sclerophyll Forests", "Wet sclerophyll forests (Grassy subformation)", "WSF(g)"],
[11, "Southern Tableland Wet Sclerophyll Forests", "Wet sclerophyll forests (Grassy subformation)", "WSF(g)"],
[78, "Montane Wet Sclerophyll Forests", "Wet sclerophyll forests (Grassy subformation)", "WSF(g)"],
[72, "Coastal Valley Grassy Woodlands", "Grassy woodlands", "GW"],
[40, "Tableland Clay Grassy Woodlands", "Grassy woodlands", "GW"],
[41, "New England Grassy Woodlands", "Grassy woodlands", "GW"],
[86, "Southern Tableland Grassy Woodlands", "Grassy woodlands", "GW"],
[45, "Subalpine Woodlands", "Grassy woodlands", "GW"],
[42, "Western Slopes Grassy Woodlands", "Grassy woodlands", "GW"],
[109, "Floodplain Transition Woodlands", "Grassy woodlands", "GW"],
[116, "Maritime Grasslands", "Grasslands", "GL"],
[46, "Temperate Montane Grasslands", "Grasslands", "GL"],
[110, "Western Slopes Grasslands", "Grasslands", "GL"],
[91, "Riverine Plain Grasslands", "Grasslands", "GL"],
[47, "Semi-arid Floodplain Grasslands", "Grasslands", "GL"],
[67, "Clarence Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrub/grass subformation)", "DSF(sg)"],
[69, "Hunter-Macleay Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrub/grass subformation)", "DSF(sg)"],
[80, "Cumberland Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrub/grass subformation)", "DSF(sg)"],
[81, "Southern Hinterland Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrub/grass subformation)", "DSF(sg)"],
[66, "Northern Gorge Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrub/grass subformation)", "DSF(sg)"],
[79, "Central Gorge Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrub/grass subformation)", "DSF(sg)"],
[68, "New England Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrub/grass subformation)", "DSF(sg)"],
[84, "Upper Riverina Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrub/grass subformation)", "DSF(sg)"],
[113, "North-west Slopes Dry Sclerophyll Woodlands", "Dry sclerophyll forests (Shrub/grass subformation)", "DSF(sg)"],
[30, "Pilliga Outwash Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrub/grass subformation)", "DSF(sg)"],
[19, "Coastal Dune Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[20, "North Coast Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[15, "Sydney Coastal Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[16, "Sydney Hinterland Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[64, "Sydney Sand Flats Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[22, "South Coast Sands Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[26, "South East Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[82, "Southern Wattle Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[25, "Northern Escarpment Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[17, "Sydney Montane Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[27, "Northern Tableland Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[28, "Southern Tableland Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[29, "Western Slopes Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[106, "Yetman Dry Sclerophyll Forests", "Dry sclerophyll forests (Shrubby subformation)", "DSF(sh)"],
[70, "Coastal Headland Heaths", "Heathlands", "HL"],
[31, "Wallum Sand Heaths", "Heathlands", "HL"],
[32, "Sydney Coastal Heaths", "Heathlands", "HL"],
[65, "South Coast Heaths", "Heathlands", "HL"],
[33, "Northern Montane Heaths", "Heathlands", "HL"],
[34, "Sydney Montane Heaths", "Heathlands", "HL"],
[35, "Southern Montane Heaths", "Heathlands", "HL"],
[36, "Alpine Heaths", "Alpine complex", "AC"],
[104, "Alpine Fjaeldmarks", "Alpine complex", "AC"],
[114, "Alpine Herbfields", "Alpine complex", "AC"],
[115, "Alpine Bogs and Fens", "Alpine complex", "AC"],
[54, "Coastal Heath Swamps", "Freshwater wetlands", "FRW"],
[55, "Montane Bogs and Fens", "Freshwater wetlands", "FRW"],
[56, "Coastal Freshwater Lagoons", "Freshwater wetlands", "FRW"],
[74, "Montane Lakes", "Freshwater wetlands", "FRW"],
[108, "Inland Floodplain Swamps", "Freshwater wetlands", "FRW"],
[92, "Inland Floodplain Shrublands", "Freshwater wetlands", "FRW"],
[48, "Coastal Swamp Forests", "Forested wetlands", "FOW"],
[50, "Coastal Floodplain Wetlands", "Forested wetlands", "FOW"],
[51, "Coast and Tableland Riverine Forests", "Forested wetlands", "FOW"],
[52, "Inland Riverine Forests", "Forested wetlands", "FOW"],
[58, "Mangrove Swamps", "Saline  wetlands", "SL"],
[71, "Saltmarshes", "Saline  wetlands", "SL"],
[112, "Seagrass Meadows", "Saline  wetlands", "SL"],
[57, "Inland Saline Lakes", "Saline  wetlands", "SL"],
[53, "Inland Floodplain Woodlands", "Semi-arid woodlands (Grassy subformation)", "SAW(g)"],
[97, "North-west Floodplain Woodlands", "Semi-arid woodlands (Grassy subformation)", "SAW(g)"],
[90, "Riverine Plain Woodlands", "Semi-arid woodlands (Grassy subformation)", "SAW(g)"],
[101, "Brigalow Clay Plain Woodlands", "Semi-arid woodlands (Grassy subformation)", "SAW(g)"],
[107, "North-west Alluvial Sand Woodlands", "Semi-arid woodlands (Shrubby subformation)", "SAW(s)"],
[88, "Riverine Sandhill Woodlands", "Semi-arid woodlands (Shrubby subformation)", "SAW(s)"],
[89, "Inland Rocky Hill Woodlands", "Semi-arid woodlands (Shrubby subformation)", "SAW(s)"],
[94, "Subtropical Semi-arid Woodlands", "Semi-arid woodlands (Shrubby subformation)", "SAW(s)"],
[44, "Western Peneplain Woodlands", "Semi-arid woodlands (Shrubby subformation)", "SAW(s)"],
[61, "Dune Mallee Woodlands", "Semi-arid woodlands (Shrubby subformation)", "SAW(s)"],
[62, "Sand Plain Mallee Woodlands", "Semi-arid woodlands (Shrubby subformation)", "SAW(s)"],
[63, "Semi-arid Sand Plain Woodlands", "Semi-arid woodlands (Shrubby subformation)", "SAW(s)"],
[95, "Desert Woodlands", "Semi-arid woodlands (Shrubby subformation)", "SAW(s)"],
[59, "Riverine Chenopod Shrublands", "Arid shrublands (Chenopod subformation)", "AS(c)"],
[60, "Aeolian Chenopod Shrublands", "Arid shrublands (Chenopod subformation)", "AS(c)"],
[98, "Gibber Chenopod Shrublands", "Arid shrublands (Chenopod subformation)", "AS(c)"],
[102, "North-west Plain Shrublands", "Arid shrublands (Acacia subformation)", "AS(a)"],
[103, "Gibber Transition Shrublands", "Arid shrublands (Acacia subformation)", "AS(a)"],
[99, "Stony Desert Mulga Shrublands", "Arid shrublands (Acacia subformation)", "AS(a)"],
[100, "Sand Plain Mulga Shrublands", "Arid shrublands (Acacia subformation)", "AS(a)"]
];




// 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;

// for ID All - List all visible layers in response - default is false
	// if false only visible layers with idenitified features written to table
	// if true the names of all visible layers will be diplayed even if no features returned
var listAllLayersInIDAll = false;

// 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] = "3";
ClassRenderString[0] = "";
ClassRenderLayer[1] = "lga";
ClassRenderString[1] = "";
ClassRenderLayer[2] = "electorates";
ClassRenderString[2] = "";

var numStatDecimals = 4;

// functions to set up toolbar options

function clearTools() {

	parent.MapFrame.useLegend_bottom=false;
	parent.MapFrame.useOVMap_bottom=false;

	parent.MapFrame.useSave_bottom=false;
	parent.MapFrame.usePrint_bottom=false;
	parent.MapFrame. useHelp_bottom=false;

	parent.MapFrame.usePan=false;
	parent.MapFrame.usePanNorth=false;
	parent.MapFrame.usePanWest=false;
	parent.MapFrame.usePanEast=false;
	parent.MapFrame.usePanSouth=false;

	parent.MapFrame.useZoomIn=false;
	parent.MapFrame.useZoomOut=false
	parent.MapFrame.useFullExtent=false;
	parent.MapFrame.useZoomActive=false;
	parent.MapFrame.useZoomLast=false;

	parent.MapFrame.useIdentify=false;
	parent.MapFrame.useMeasure=false;
	parent.MapFrame.useSelect=false;
	parent.MapFrame.useQuery=false;
	parent.MapFrame.useFind=false;
	parent.MapFrame.useFindRes=false;
	parent.MapFrame.useClearSelect=false;

	parent.MapFrame.useBuffer=false;
	parent.MapFrame.useResize=false;

	parent.MapFrame.useGeocode=false;
	parent.MapFrame.useExtract=false;
	parent.MapFrame.allowOptions=false;

	parent.MapFrame.useSetUnits=false;
	parent.MapFrame.useStoredQuery=false;

	parent.MapFrame.useHyperLink=false;
	parent.MapFrame.useHyperLinkAny=false;
	parent.MapFrame.useIdentifyAll=false;
	parent.MapFrame.useBufferShape=false; 
}


function basicTools() {
	
	clearTools();
	
	parent.MapFrame.usePan=true;
	parent.MapFrame.useZoomIn=true;
	parent.MapFrame.useZoomOut=true
	parent.MapFrame.useNSWExtent=true;
	parent.MapFrame.useFullExtent=true;
	parent.MapFrame.useZoomActive=false;
	parent.MapFrame.useZoomLast=true;

	parent.MapFrame.useIdentify=true;
	parent.MapFrame.useIdentifyAll=false;
	
	parent.MapFrame.useLegend_bottom=false;
	parent.MapFrame.useOVMap_bottom=true;

	parent.MapFrame.useSave_bottom=false;
	parent.MapFrame.usePrint_bottom=false;
	parent.MapFrame. useHelp_bottom=false;

	parent.SimpleToolFrame.document.location= "Toolbar.htm";
}

function navTools() {

	clearTools();
	
	parent.MapFrame.usePan=true;
	parent.MapFrame.usePanNorth=true;
	parent.MapFrame.usePanWest=true;
	parent.MapFrame.usePanEast=true;
	parent.MapFrame.usePanSouth=true;

	parent.MapFrame.useZoomIn=true;
	parent.MapFrame.useZoomOut=true
	parent.MapFrame.useFullExtent=true;
	parent.MapFrame.useZoomActive=true;
	parent.MapFrame.useZoomLast=true;

	parent.SimpleToolFrame.document.location= "Toolbar.htm";
}

function selectTools() {

	clearTools();
	
	parent.MapFrame.usePan=true;

	parent.MapFrame.useZoomIn=true;
	parent.MapFrame.useZoomOut=true
	parent.MapFrame.useFullExtent=true;
	parent.MapFrame.useZoomActive=false;
	parent.MapFrame.useZoomLast=false;


	parent.MapFrame.useIdentify=true;
	parent.MapFrame.useMeasure=false;
	parent.MapFrame.useSelect=true;
	parent.MapFrame.useClearSelect=true;

	parent.MapFrame.useBuffer=true;

	parent.SimpleToolFrame.document.location= "Toolbar.htm";
}

function queryTools() {

	clearTools();

	parent.MapFrame.usePan=true;

	parent.MapFrame.useZoomIn=true;
	parent.MapFrame.useZoomOut=true
	parent.MapFrame.useFullExtent=true;
	parent.MapFrame.useZoomActive=false;
	parent.MapFrame.useZoomLast=false;

	parent.MapFrame.useIdentify=true;
	parent.MapFrame.useQuery=true;
	parent.MapFrame.useFindRes=false;
	parent.MapFrame.useFind=false;
	parent.MapFrame.useClearSelect=true;

	parent.MapFrame.useHyperLink=false;
	parent.MapFrame.useHyperLinkAny=false;
	parent.MapFrame.useIdentifyAll=true;

	parent.SimpleToolFrame.document.location= "Toolbar.htm";
}

function utilityTools() {

	clearTools();

	parent.MapFrame.useExtract=true;
	parent.MapFrame.allowOptions=true;

	parent.SimpleToolFrame.document.location= "Toolbar.htm";
}

function titleTools() {
	parent.MapFrame.useLegend_top=false;
	parent.MapFrame.useOVMap_top=false;
	parent.MapFrame.usePrint_top=true;
	parent.MapFrame.useSave_top=true;
	parent.MapFrame.useHelp_top=false;
	parent.TitleFrame.document.location= "Title.htm";
}




// the starting point. . . it all starts here on loading
function checkParams() {

	appDir = getPath(document.location.pathname);

	// load initial tool bar
	basicTools();

	//load Tools in title frame
	titleTools();

	// Set Hyperlink parameters for active layer so links will work in identify etc.
	checkHyperLinkLayer(ActiveLayerIndex);


	// global for overview map. . . change if not on same frame as Map
	ovImageVar = document.ovImage;
	debugOn = 0;
	formTitle = parent.PostFrame.document.title;
	if (parent.PostFrame.document.forms[0]!=null) formExists = true;
	//alert(tURL);
	//alert(parent.QueryFrame);
	//MES
	if (parent.QueryFrame==null){
		useQueryFrame = 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 (!isNav)	{
		if (hasLayer("theTop")) document.all.theTop.style.cursor = "crosshair";
		if (hasOVMap) ovImageVar.style.cursor = "hand";
	}
	if (hasOVMap) {
		// size of ov map image
		i2Width = parseInt(ovImageVar.width);
		i2Height = parseInt(ovImageVar.height);
		forceNewOVMap = false;
		// 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);
	checkCoords();
	if (aimsNavigationPresent) {
		// Set up event capture for mouse movement
		if (isNav) {
			document.captureEvents(Event.MOUSEMOVE);
			document.captureEvents(Event.MOUSEDOWN);
			document.captureEvents(Event.MOUSEUP);
			//document.captureEvents(Event.MOUSEDOWN | Event.MOUSEMOVE | Event.MOUSEUP);
		}
		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;
		useHyperLinkAny=false;
		useIdentifyAll=false;
	}
	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");
	}
}

function reloadApp() {
		parent.document.location = "default.htm";
}	

