var hostName = document.location.host;
var localhostName= "carto.mairie-meudon.fr";
var catURL = "http://carto.mairie-meudon.fr/servlet/com.esri.esrimap.Esrimap?ServiceName=catalog";
var serverURL  = "http://carto.mairie-meudon.fr/servlet/com.esri.esrimap.Esrimap?ServiceName=";
var imsURL = "http://carto.mairie-meudon.fr/servlet/com.esri.esrimap.Esrimap?ServiceName=PlanServitudes";
var imsOVURL =  "http://carto.mairie-meudon.fr/servlet/com.esri.esrimap.Esrimap?ServiceName=PlanSituation";
var imsQueryURL = '';
var imsGeocodeURL = '';
var mapBackColor = '225,225,225';
var ovBoxColor = '#ff0000';
var ovBoxSize = 3;
var zoomBoxColor = '#ff0000';
var legWidth=170;
var legHeight=170;
var legFont="Arial";
var legTitle=" Légende ";
var hasOVMap = true;
var startLeft = 588237.196946611;
var startRight = 596514.402513668;
var startTop = 126367.99051121;
var startBottom = 119914.229379987;
var MSstartLeft = 588237.196946611;
var MSstartRight = 596514.402513668;
var MSstartTop = 126367.99051121;
var MSstartBottom = 119914.229379987;var InActiveArea=true;
var limitLeft = 588237.196946611;
var limitRight = 596514.402513668;
var limitTop = 128072.542142107;
var limitBottom = 119307.569067766;

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 useMeasure=true;
var useSetUnits=true;
var useQuery=true;
var useFind=true;
var useStoredQuery=false;
var usePrint=true;
var useGeoNetwork=false;
var useExtract=false;
var MapUnits = "Meters";
var ScaleBarUnits = "Kilometers";
var hasToolBarOnLayer=false;
var setDebug=true;


/**************************************
* 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


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

// Have ArcXML responses URL encoded? Will not work with multi-byte characters
var doURLencode = false;

//variables for MapDrawing
	// North Arrow
var drawNorthArrow = true;
var NorthArrowType = "1";
var NorthArrowSize = "17";
var NorthArrowCoords = "600 80";
var NorthArrowAngle="0";
	// Scale Bar
var drawScaleBar = false;
	// MapUnits=DEGREES,FEET,METERS
	// can MapUnits be changed by user?
var setMapUnits=false;
	// ScaleBarUnits=KILOMETERS,METERS,MILES,FEET
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 = "14";
var CopyrightCoordsY = 0.13;
var CopyrightCoordsX = 0.09;
var CopyrightCoords = "";
var CopyrightColor = "255,255,255";
var CopyrightBackground = "true";
var CopyrightBGColor = "0,0,0";
var CopyrightGlow = "False";
var CopyrightGlowColor = "255,255,255";
var CopyrightText = "."
var Map_Description = new Array();
Map_Description[16] = "Aucun plan disponible au XVIème siècle"
Map_Description[17] = "Plan du château, jardins et conduites (1697)"
Map_Description[18] = "Carte générale des parcs et jardins (1723)"
Map_Description[19] = "Assemblage du cadastre Napoléonien (1816)"
Map_Description[20] = "Plan (1925)"
	// 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=false;

// 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;
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;
	}
}	
		
/**************************************
* Extended Map parameters
**************************************/

// variables for ovmap offset
//var ovHspc =0;
//MS Modif
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=true;
// 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";

// 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;

// 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 = parent.document.location.search;

/**************************************
* Interactive Map parameters
**************************************/

// Click points - Measure/Shape Select/Shape Buffer
var clickMarkerColor="255,0,0";
var clickMarkerType="Circle";
var clickMarkerSize="6";




// 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 (isIE)	{
		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 - 9/10* i2Width;
		ovMapTop =-1/20*i2Width;
		ovHspc=ovMapLeft;
	}
	if (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;
	}
	// modif max 2003/09
	enforceFullExtent = false;

	if (ovBoxColor=="") ovBoxColor = "255,0,0";
	//ovBoxColor = convertHexToDec(ovBoxColor);
	checkCoords();
	if (aimsNavigationPresent) {
		// Set up event capture for mouse movement
		if (isNav4) {
			document.captureEvents(Event.MOUSEMOVE);
			document.captureEvents(Event.MOUSEDOWN);
			document.captureEvents(Event.MOUSEUP);
		}
		document.onmousemove = getMouse;
		document.onmousedown = mapTool;
		document.onmouseup = chkMouseUp;
	} else {
		usePan=false;
		usePanNorth=false;
		usePanWest=false;
		usePanEast=false;
		usePanSouth=false;
		useMeasure=false;
		useZoomIn=false;
		useZoomOut=false
		//useFullExtent=false;
		useZoomActive=false;
		//useZoomLast=false;	
	}
	if ((aimsXMLPresent) && (aimsMapPresent)) {
		startMap();
	} else {
		alert(msgList[0]);
	}
}
//**************************************************
//**************************************************
// Mettre ici les parametres du site				
//**************************************************
//**************************************************
//var PhotoMapService='ImageMeudon';
// Liste des descriptif de voies
var descr_v = new Array();

descr_v[1] = "RUE"
descr_v[0] = "AVENUE"
descr_v[2] = "BOULEVARD"
descr_v[3] = "PLACE"
descr_v[4] = "IMPASSE"
descr_v[5] = "QUAI"
descr_v[6] = "SENTIER"
