
<!-- **************************************************************** -->
<!-- *************    Script de navigation sur la carte ************* -->
<!-- **************************************************************** -->

var seuilEchelle = new Array(160000,40000,19000,7400);

function Point(x,y){this.x=x;this.y=y;}
function Rectangle(x,y,width,height){this.x=x;this.y=y;this.width=width;this.height=height}
var mouseisdown = 0;
var ptDepart;
var ptCourant = new Point(0,0);
var xmlFileSRC = "";
var isloading = false;
var imgEchelle="";

var offsetMapX = 9;
var offsetMapY= 157;

//timing de chargement

var timerRepaint;
var timerRedraw;

var legendeIsLoaded = false;

function toolBarClicked()
{
curTool = -1;

}
<!-- ----------------------------------------------------------------- -->
<!-- ------ Mise ? jour de la position de la souris					  -------- -->
<!-- ----------------------------------------------------------------- -->
function UpdateMousePosition(x,y)
{

}
<!-- ----------------------------------------------------------------- -->
<!-- ------ Mise ? jour de la variable curTool sur les plugin -------- -->
<!-- ----------------------------------------------------------------- -->
function UpdateToolPlugins()
{
 if(szFormat=="4"){//format Flash
  var objFlash = document.getElementById("IMG");
  if(objFlash!=null){
   var strCurTool = "" + curTool;
   //objFlash.SetVariable('curTool',strCurTool);
   document.IMG.SetVariable('CurTool',strCurTool);
  }
 }
}

<!-- ----------------------------------------------------------------- -->
<!-- -------------   Redessine la carte courante ------------------ -->
<!-- ----------------------------------------------------------------- -->
function RedrawMap()
{
if(infoBulle!=null)
{
	infoBulle.mustMove = false;
	infoBulle.setVisible(false);
}
var i = 0;
var loc = location.href;
var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" +  (maptop - mapbottom) + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;
			
	updateBufferMap(chaine);

}
<!-- ----------------------------------------------------------------- -->
<!-- -------------   Selectionne l'outil zoom moins ------------------ -->
<!-- ----------------------------------------------------------------- -->
function SetToolZoomPlus()
{
 if(szdrawMode==1)
                drawMode();
 curTool = 209;
 var obj = document.getElementById("divMap");
	//obj.style.cursor = "crosshair";
	UpdateToolPlugins();


}
<!-- ----------------------------------------------------------------- -->
<!-- -------------   Selectionne l'outil zoom plus  ------------------ -->
<!-- ----------------------------------------------------------------- -->
function SetToolZoomMoins()
{
if(infoBulle!=null)
{
	infoBulle.mustMove = false;
	infoBulle.setVisible(false);
}
 if(szdrawMode==1)
                drawMode();
 curTool = 210;
var obj = document.getElementById("divMap");
	//obj.style.cursor = "crosshair";
	var loc = location.href;
	UpdateToolPlugins();
	  var newtop;
		var newleft;
		var newwidth;
		var newheight;
		var loc = location.href;
		newwidth = (mapright - mapleft)*2;
	  newheight = (maptop - mapbottom)*2;
		newbottom = (maptop+mapbottom)/2 - newheight/2;
		newleft = (mapright+mapleft)/2 - newwidth/2;
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
	
	
								if(editSvg)
								{
								
								var conf = haveTosend();
								if(conf==true)
								{
								
								 var chaineSvg = szHttpServeur  +
								 "&ACTION=EditLayer!NAME="+currentEditedLayer+"!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +"!LOCATION=" + loc + "!LAYER_EDITION";
								 updateBufferEditLayer(chaineSvg);
								 editSvg=true;
		
								 showObject("divEditLayer");
								 }
								 }
	
	
}

<!-- ----------------------------------------------------------------- -->
<!-- -------------   Affiche une infobulle (uniquement en IE)  ------------------ -->
<!-- ----------------------------------------------------------------- -->
function processToolTipPng(e,strToolTip)
{
 				 var obj = document.getElementById("tooltip");
				
				 if(obj!=null)
				 {
 			
				
					if(e==null)
					{
					obj.style.visibility = "hidden";
					
					return;
					}
					else
					{
					obj.style.visibility = "visible";
					}
					
						 var ptMouse = getMousePosition(e);
				
				ptMouse.x =  ptCourant.x + 30;
				ptMouse.y =  ptCourant.y + 30;
					obj.style.top = ptMouse.y;
					obj.style.left = ptMouse.x;
					
					var inner = "";
					if(strToolTip.length>0)
					{
					var tToolTip = strToolTip.split('|');
					var k = 0;
					inner = "<table>"; 
					for(k=0;k<tToolTip.length;k++)
					{				
									var ttToolTip = tToolTip[k].split(':');
									
									inner = inner + "<tr><td style=\"font-size: 10px;\">"	;							
					 				inner = inner + 		ttToolTip[0];	
									inner = inner + "</td>";
									var j=1;
									for(j=1;j<ttToolTip.length;j++)
									{
									inner = inner + "<td style=\"font-weight: bold;font-size: 10px;\">"	;		
									inner = inner + " : " +	ttToolTip[j];	
									inner = inner + "</td>";			
									}
									
									inner = inner + "</tr>";						
					}
					inner = inner + "</table>";
					}
					else
					{
					obj.style.visibility = "hidden";
					}
					
					obj.innerHTML = inner;
					}
					
}
<!-- ----------------------------------------------------------------- -->
<!-- -------------   Selectionne l'outil est le Pan sur la map  ------------------ -->
<!-- ----------------------------------------------------------------- -->
function SetToolPan()
{
 if(szdrawMode==1)
                drawMode();
 curTool = 213;
  var obj = document.getElementById("divMap");
	//obj.style.cursor = "move";
	UpdateToolPlugins();

}
<!-- ----------------------------------------------------------------- -->
<!-- -------------   Selectionne l'outil Selection Carte ------------- -->
<!-- ----------------------------------------------------------------- -->
function SetToolSelectionCarte()
{
if(editSvg)
					alert(msgEditionInProgress)
					else
					{
 if(szdrawMode==1)
                drawMode();
 curTool = 211;
 
	 var obj = document.getElementById("divMap");
	//obj.style.cursor = "help";
	UpdateToolPlugins();
	}

}
<!-- ----------------------------------------------------------------- -->
<!-- -------------   Selectionne l'outil zoom sur objet click? ------------- -->
<!-- ----------------------------------------------------------------- -->
function SetToolZoomObjet()
{
 if(szdrawMode==1)
                drawMode();
 curTool = 212;
var obj = document.getElementById("divMap");
	//obj.style.cursor = "crosshair";
	UpdateToolPlugins();

}

<!-- ----------------------------------------------------------------- -->
<!-- -------------   mise ? jour de la fenetre d'echelle  ------------- -->
<!-- ----------------------------------------------------------------- -->
function SetEchelle(newEchelle)
{
 var saisieEchelle = document.getElementById('saisieEchelle');
 if(saisieEchelle!=null)
 {
 saisieEchelle.value = Math.floor(newEchelle);
 }
 // getIScale(newEchelle);
}

<!-- ----------------------------------------------------------------- -->
<!-- -------------   mise ? jour de la fenetre d'echelle en fonction de la carte ------------- -->
<!-- ----------------------------------------------------------------- -->
function GetEchelleMap()
{
 var ws = 0.0;

var clW = 0.0;

var wScreen = 0.0;
var mapCenterX = 0.0;
var mapCenterY = 0.0;
var newwidth = 0.0;
var newheight = 0.0;
var curwidth = 0.0;
ws = window.screen.width;
ws = 1280;
clW = mapClientwidth;

//ecran 17 pouces
wScreen =  (clW/ws) *(4.0/5.0)*17*2.54/100.0;

curwidth = mapright-mapleft;
SetEchelle(curwidth/wScreen);
return(curwidth/wScreen);
}

<!-- ----------------------------------------------------------------- -->
<!-- -----   mise ? jour de la carte par saisie Dans le flash ------ -->
<!-- ----------------------------------------------------------------- -->
function SetScale(iScale)
{
  if(iScale==4)
  {
  UpdateMapEchelle(seuilEchelle[iScale-1]);
  }
  if(iScale==3)
  {
   UpdateMapEchelle(seuilEchelle[iScale-1]);
  }
  if(iScale==2)
  {
   UpdateMapEchelle(seuilEchelle[iScale-1]);
  }
  if(iScale==1)
  {
	FitImage()
  }
}
<!-- ----------------------------------------------------------------- -->
<!-- -------------   mise ? jour de la carte par saisie d'une nouvelle echelle  ------------- -->
<!-- ----------------------------------------------------------------- -->
function UpdateMapEchelle(echelle)
{
if(infoBulle!=null)
{
	infoBulle.mustMove = false;
	infoBulle.setVisible(false);
}
var ws = 0.0;

var clW = 0.0;

var wScreen = 0.0;
var mapCenterX = 0.0;
var mapCenterY = 0.0;
var newwidth = 0.0;
var newheight = 0.0;
var loc = location.href;
ws = window.screen.width;
ws = 1280;
clW = mapClientwidth;

//ecran 17 pouces
wScreen =  (clW/ws) *(4.0/5.0)*17*2.54/100.0;
newwidth = wScreen*echelle;
newheight = (mapClientheight/clW)*newwidth;

mapCenterX = (mapright+mapleft)/2.0;
mapCenterY = (maptop+mapbottom)/2.0;

newleft = mapCenterX-newwidth/2.0;
newbottom = mapCenterY-newheight/2.0;

var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);

}
<!----------------------------------------------------------------------->
<!-- fonction appell?e par le navigateur flash au mouseMove            -->
<!----------------------------------------------------------------------->

function updateMousePosition(x,y)
{
}
<!-- ----------------------------------------------------------------- -->
<!-- -------------   mise ? jour de la carte        ------------------ -->
<!-- charge dans la frame cach?e BufferMap la page HTML issu du parse  -->
<!-- serveur du flux XML, transform? par la feuille de style carte.XSL -->  
<!-- OnLoad cette frame appel loadMap pour mettre ? jour le divMAP     -->       
<!-- ----------------------------------------------------------------- -->
function updateBufferMap(target) 
{
if(!isloading)
{

  isloading = true;
  showObject("divProgress");
  var movieprogress = document.getElementById('movieprogress');
 var szShowLegende = "";
/* if(legendeIsLoaded)
 {
    szShowLegende = "!SHOWLEGENDE=0"
 }*/
	if(szFormat=="4")
	{
	frames['bufferMap'].location.href=target+  "!SHOWECHELLE=" + szShowEchelle + szShowLegende +"&FORMAT=" + szFormat + "&XSL=carteFlash.xsl&DUMMY=" + new Date().getTime()+"&PORT=" + szPort;  
	}
	else
	{
	frames['bufferMap'].location.href=target+  "!SHOWECHELLE=" + szShowEchelle + szShowLegende +"&FORMAT=" + szFormat + "&PORT=" + szPort; 
	}
	if(movieprogress!= null)
	{
	if(!isMinNS4)
	{
	movieprogress.rewind();
	movieprogress.play();
	}
	
	}
	timerRepaint = setTimeout("resetIsLoading()",5000);
	}
	else
	{
	 timerRepaint = setTimeout("resetIsLoading()",5000);
	}
	
}

function resetIsLoading()
{
isloading=false;
hideObject("divProgress");
clearTimeout(timerRepaint);
}

function FlashLoaded()
{
UpdateToolPlugins();
}



function loadEchelle()
{
if(frames['bufferMap'].document.getElementById('buffEchelle')!=null)
{
if(document.getElementById('divEchelle')!=null)
{

 document.getElementById('divEchelle').innerHTML = frames['bufferMap'].document.getElementById('buffEchelle').innerHTML;

 }
}
}



function  getIScale(newScale)
{

 var arrecart=new Array;
 for(i=0;i<seuilEchelle.length;i++)
 {
 arrecart.push(Math.abs(newScale-seuilEchelle[i]));
 }
 var curecart = arrecart[0];
 var curScale = 0;
 for(i=1;i<seuilEchelle.length;i++)
 {
		 if(arrecart[i]<curecart)
		 {
			curScale = i;	
			curecart = arrecart[i];
		 }
 }
doPassScale(""+(curScale+1)+"");
}




function loadLegende()
{
    if(document.getElementById('fLegende')!=null)
    {
//	if(!legendeIsLoaded)
	{
        if(legvisible==1)
        {
 			showObject("fLegende");
			showObject("divlegende");
        }
        //frames['fLegende'].document.body.innerHTML = document.getElementById('buffleg').innerHTML;
        if(frames['bufferMap'].document.getElementById('buffleg')!=null)
        {
         document.getElementById('fLegende').innerHTML = frames['bufferMap'].document.getElementById('buffleg').innerHTML;
	
         setStateGroupes();
		 scroller.updateScroller();
		 legendeIsLoaded = true;
		}
		if(document.getElementById('buffleg')!=null)
		{
       		document.getElementById('buffleg').innerHTML = "";
		}
		}
    }
   
}

var showFlashTb = true;

function doPassVar(args){
 var sendText = args;
 document.getElementById("IMG").SetVariable("myVar", sendText);
}

function doPassScale(args){
 var sendText = args;
 if((document.getElementById("IMG")!=null)&&(fo!=null))
 {
	document.getElementById("IMG").SetVariable("myScale", sendText);
 }

}

function doShowTb(args){
 document.getElementById("IMG").SetVariable("showTb", args);
}

var fo;

function loadMap(){

 hideObject("divProgress");
 hideObject("divBubble");
 var divMap = document.getElementById('divMap');
 isloading = false;
 if(needNewMap == true){
  if(szFormat=="4"){
   if(xmlFileSRC!=""){
    if( fo != null ){
     doPassVar(xmlFileSRC);
     //if( showFlashTb ) doShowTb("1"); 
     //else doShowTb("0");	
	 loadLegende();
	 loadEchelle();
	//   GetEchelleMap();
	 	if((infoBulle!=null)&&(infoBulle.mustMove))
		  {
		  
			moveBulle(false);
			infoBulle.setVisible(true);
			infoBulle.mustMove = false;
		  }
    }
    else{

     fo = new FlashObject("swf/carto.swf", "IMG", 570, 652, "7", "#FFFFFF");
	 fo.addParam("allowScriptAccess", "sameDomain");
     fo.addVariable("xmlFile", xmlFileSRC);
     fo.addParam("salign","LT");
     fo.addParam("swLiveConnect","true");
     fo.addParam("WMode","transparent");
     fo.write("divMap");

	 mapleftinit = mapleft;
	 mapbottominit = mapbottom;
	 maprightinit = mapright;
	 maptopinit = maptop;
	UpdateUserConnection();
	loadLegende();
  	resizeMainWindow();
	//loadEchelle();
	
    //if( showFlashTb ) doShowTb("1"); 
    //else doShowTb("0");    	
     //  divMap.innerHTML=szInner + frames['bufferMap'].document.body.innerHTML;
    }
   
   //var objDivEdit = document.getElementById("divEditLayer");
   //var objDivMap = document.getElementById("divMap");
   //objDivEdit.style.left = objDivMap.offsetLeft+2;
   //objDivEdit.style.top = objDivMap.offsetTop+2;
   }
  }
  else{
   divMap.innerHTML=frames['bufferMap'].document.body.innerHTML;
   loadLegende();
   loadEchelle();
   processToolTipPng(null,"");
  }
  document.onmousemove = null;

  drawMiniRect();
 
 }
 else{
  alert("Pas d'objet cartographique");
  if (currentProcess=="graphicSearch"){ LanceRechercheGraphique();}
  currentProcess="";
 }
}

function loadSwf(container, swfName, swfId, w, h, bgcolor){
 var fo;
 fo = new FlashObject("swf/"+swfName+".swf", swfId, w, h, "7", bgcolor);
 fo.addParam("salign","LT");
 fo.addParam("WMode","transparent"); 
 fo.write(container);
}
<!-- ----------------------------------------------------------------- -->
<!-- --  Converti les coordon?e ecran en coordon?e system (r?elle) ----- -->
<!-- ----------------------------------------------------------------- -->
function ConvertViewToSys(x,y)
{
	var bndTop;
	var bndLeft;
	var mapWidth;
	var mapHeigth;
	mapWidth = mapright-mapleft;
	var zoom;
	zoom = 0.0;
	zoom = mapClientwidth/mapWidth;
	
	if(szFormat=="4")
	{
	bndLeft = 0;
	bndTop = 0;
	}
	else
	{
        obj = document.getElementById("divMap");
     
	bndLeft =obj.offsetLeft + offsetMapX;
        
  	bndTop = obj.offsetTop + offsetMapY;
		}
	mapCurrentX = (x - bndLeft)/zoom + mapleft;
	//alert(mapleft);
	mapCurrentY = maptop - (y - bndTop)/zoom;

}
function GetMapEmpriseView()
{
    
        var obj = document.getElementById("divMap");
        var objimg = document.getElementById("IMG");
        var rect = new Rectangle(0,0,0,0);
        rect.x = obj.offsetLeft + offsetMapX;
        rect.y = obj.offsetTop + offsetMapY;
		if(isMinNS4)
		{
			rect.width = objimg.clientWidth - offsetMapX;
			rect.height = objimg.clientHeight - offsetMapY;
		}
		else
		{
			rect.width = objimg.width - offsetMapX;
			rect.height = objimg.height - offsetMapY-9;
		}
	return(rect);
} 
<!-- ----------------------------------------------------------------- -->
<!-- -- Converti les coordon?e ecran en coordon?e system (réelle)----- -->
<!-- ----------------------------------------------------------------- -->
function ConvertSysToView(x,y)
{
	var bndTop;
	var bndLeft;
	var mapWidth;
	var mapHeigth;
	mapWidth = mapright-mapleft;
	var zoom;
	zoom = 0.0;
	zoom = mapClientwidth/mapWidth;
        obj = document.getElementById("divMap");
	bndLeft = obj.offsetLeft;
 	bndTop = obj.offsetTop;

	viewCurrentX = (x  - mapleft)*zoom + bndLeft + offsetMapX;
	viewCurrentY = -(y  - maptop)*zoom + bndTop + offsetMapY;
	
	mapCurrentY = maptop - (y - bndTop)/zoom;

}
<!-- ----------------------------------------------------------------- -->
<!-- ---------------- ?venement souris bouge sur la carte ------------ -->
<!-- ----------------------------------------------------------------- -->
function getmousetool(e)
{

var pt= getMousePosition(e);

}
function getMousePosition(e)
{
      var pt = new Point(0,0);
      
     
        if(isMinNS4)
        {
                pt.x=e.pageX;
                pt.y=e.pageY;
        }
        else
        {
                pt.x=event.x+idBody.scrollLeft;
                pt.y=event.y+idBody.scrollTop;
        }
				if(pt.x!=0)
				{
				ptCourant.x = pt.x;
				ptCourant.y = pt.y;
				}
        return(pt);
      
}

function recenterMap(x,y)
{

var loc = location.href;
 hideObject("divRect");
   var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
	  newheight = (maptop - mapbottom);
		newbottom = y - newheight/2.0;
		newleft = x - newwidth/2.0;
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
}
<!-- ----------------------------------------------------------------- -->
<!-- --- ?venement souris drag sur la carte : si l'outil est zoom plus -->
<!-- dessinne un rectangle (divRect) sur la carte pour zoomer par rectangle -->
<!-- ----------------------------------------------------------------- -->

<!-- ----------------------------------------------------------------- -->
<!-- --- ?venement souris commence drag sur la carte : si l'outil est zoom plus -->
<!-- stockage des coordon?e pixel du d?but de rectangle pour le dessine du rectangle de zoom -->
<!-- ----------------------------------------------------------------- -->

<!-- -----------------------------------------------------------------  -->
<!-- --- ?venement fin drag sur la carte : si l'outil est zoom plus     -->
<!-- appel de updateBufferMap avec les coordonn?e de la nouvelle emprise-->
<!-- -----------------------------------------------------------------  -->


<!-- -----------------------------------------------------------------  -->
<!-- --- d?placement de la crate vers le nord														-->
<!-- -----------------------------------------------------------------  -->
function moveUp()
{
if(szFormat=="2")
{
 translateMap(0,-0.5);

}
else
{
if(infoBulle!=null)
{
	infoBulle.mustMove = false;
	infoBulle.setVisible(false);
}
        var loc = location.href;

 hideObject("divRect");
   var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
	  newheight = (maptop - mapbottom);
		newbottom = mapbottom+newheight/2.0;
		newleft = mapleft;
		
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

								
				
	updateBufferMap(chaine);
	}
	if(editSvg)
		translateEditedLayer(0,-0.5);
	
}

<!-- -----------------------------------------------------------------  -->
<!-- --- d?placement de la crate vers le sud														-->
<!-- -----------------------------------------------------------------  -->
function moveDown()
{
if(szFormat=="2")
{
 translateMap(0,0.5);

}
else
{
if(infoBulle!=null)
{
	infoBulle.mustMove = false;
	infoBulle.setVisible(false);
}
                var loc = location.href;
                hideObject("divRect");
                var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
	        newheight = (maptop - mapbottom);
		newbottom = mapbottom-newheight/2.0;
		newleft = mapleft;
	
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
	}
	
	if(editSvg)
		translateEditedLayer(0,0.5);
}


<!-- -----------------------------------------------------------------  -->
<!-- --- d?placement de la crate vers l''est														-->
<!-- -----------------------------------------------------------------  -->
function moveRight()
{
if(szFormat=="2")
{
 translateMap(0.5,0);

}
else
{
if(infoBulle!=null)
{
	infoBulle.mustMove = false;
	infoBulle.setVisible(false);
}
var loc = location.href;
 hideObject("divRect");
   var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
	  newheight = (maptop - mapbottom);
		newbottom = mapbottom;
		newleft = mapleft + newwidth/2.0;
		
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
	
}

if(editSvg)
			translateEditedLayer(0.5,0);
	
}

<!-- -----------------------------------------------------------------  -->
<!-- --- d?placement de la crate vers l''ouest														-->
<!-- -----------------------------------------------------------------  -->
function moveLeft()
{
if(szFormat=="2")
{
 translateMap(-0.5,0);

}
else
{
if(infoBulle!=null)
{
	infoBulle.mustMove = false;
	infoBulle.setVisible(false);
}
var loc = location.href;
 hideObject("divRect");
   var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft);
	  newheight = (maptop - mapbottom);
		newbottom = mapbottom;
		newleft = mapleft - newwidth/2.0;
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
	}
	if(editSvg)
		translateEditedLayer(-0.5,0);
}
<!-- -----------------------------------------------------------------  -->
<!-- ?venement bouton souris enfonc? sur la carte : si l'outil est zoom moins -->
<!-- -calcul la nouvelle emprise centr? sur le click et dont la largeur  -->
<!-- vaut deux fois la largeur pr?c?dente (on dezoom d'un facteur 2) -  -->
<!-- appel de updateBufferMap avec les coordonn?e de la nouvelle emprise-->
<!-- -----------------------------------------------------------------  -->

<!-- -----------------------------------------------------------------  -->
<!-- Recharge la carte tel que l'ensemble soit visible                  -->
<!-- -----------------------------------------------------------------  -->
function FitImage()
{
if(infoBulle!=null)
{
	infoBulle.mustMove = false;
	infoBulle.setVisible(false);
}
if(editSvg)
	//mode edition SVG
	{
		
		/*if(sendReq ==null || sendReq != false)
			//getEditionShapesCoordinates();
			
			mapWidth=null;
			mapHeight=null;*/
		var conf = haveTosend();
		if(conf==true)
		{
		var loc = location.href;
			var chaine = szHttpServeur  +
						"&ACTION=EditLayer!NAME="+currentEditedLayer+"!EMPRISE=ALL!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +"!LOCATION=" + loc + "!LAYER_EDITION";
			updateBufferEditLayer(chaine);
			editSvg=true;
		
			showObject("divEditLayer");
			
		
		
			var chaine = szHttpServeur +
							"&ACTION=BuildMap!EMPRISE=ALL!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc ;
			
			
			updateBufferMap(chaine);
			
		}
	
	}
	else
	{
		var loc = location.href;
		var chaine = szHttpServeur +
	                "&ACTION=BuildMap!EMPRISE=ALL!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc ;

		var chaine = szHttpServeur +
	                "&ACTION=BuildMap!EMPRISE=870992.6065999996@60609.688799999785@22750.678400000557@21408.644000000553!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc ;

		updateBufferMap(chaine);
	}
	curTool = 1;
  var obj = document.getElementById("divMap");
	//obj.style.cursor = "crosshair";
	UpdateToolPlugins();
	

}
<!-- -----------------------------------------------------------------  -->
<!-- Recharge la carte en effacent selection et analyse                 -->
<!-- -----------------------------------------------------------------  -->
function ClearMap()
{
if(infoBulle!=null)
{
	infoBulle.mustMove = false;
	infoBulle.setVisible(false);
}
	var loc = location.href;

	var chaine = szHttpServeur  +
                "&ACTION=ClearMap" + 
		"!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" + (maptop - mapbottom) + 
		"!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +
		"!LOCATION=" + loc ;	
	updateBufferMap(chaine);
	curTool = 1;
  var obj = document.getElementById("divMap");
	//obj.style.cursor = "crosshair";
	UpdateToolPlugins();
}

function initCaptureEvent()
{   
  /*
  // capture d'?v?n?nements appuyer, relacher
   var obj = document.getElementById("IMG");

	 
	 if(isMinNS4)
						{
						obj.useMap="#Mapcoord";
						}
						else
						{
					// met en place la map des infobulle (uniquement en IE)
						obj.useMap="#Mapcoord";
						
						 }
						 
  if (document.captureEvents)
  { // pour Mozilla
       //  alert("salut");
  //  document.captureEvents(Event.MOUSEDOWN | Event.MOUSEUP);
  }
    obj.onmousedown = startDrag;
		 obj.onmouseup = endDrag;
    document.onmousemove = null;
    if(isMinNS4==1)
    {
    //     document.onmouseup = endDrag;
		//		 document.onmousedown = startDrag;
    }
    else
    {
         obj.onmouseup = endDrag;
    }*/
}

function startDrag(e)
{ 
     /*
    ptDepart = getMousePosition(e);
    // capture de l'?v?n?nement d?placement du curseur
     var obj = document.getElementById("IMG");
    if (document.captureEvents)
    { // pour Mozilla
   //   document.captureEvents(Event.MOUSEMOVE);
    }
    
    obj.onmousemove= moveMouse;
    */
    return false; // retourne faux pour que l'explorateur ne tienne pas compte du d?placement 
}


function moveMouse(e)
{/*

 				var pt = getMousePosition(e);
        if (curTool == 209)
        {
        
        var w;
        var h;
        var leftRect;
        var topRect;
        
        w = Math.abs(pt.x-ptDepart.x);
        h = Math.abs(pt.y-ptDepart.y);
        var obj = document.getElementById("IMG");
        
        var emprise = GetMapEmpriseView();
               
      		if ((w>0)&&(h>0)&&(pt.x>emprise.x)&&(pt.y>emprise.y)&&(pt.x<emprise.x+emprise.width)&&(pt.y<emprise.y+emprise.height))
      		{
                    var obj=document.getElementById("divRect");
                    
                    if(pt.x > ptDepart.x)
                            leftRect = ptDepart.x;
                    else
                            leftRect = pt.x;
                    
                    if(pt.y > ptDepart.y)
                            topRect = ptDepart.y;
                    else
                            topRect = pt.y;
                            
                    obj.style.left = leftRect;
                    obj.style.top = topRect;	
                    obj.style.width = w;
                    obj.style.height = h;			
                    obj.style.border  = "1px solid #FF0000";
                    obj.style.color  = "#FF0000";
                    showObject("divRect");
      		 }
                 
        }
				else if (curTool == 213)
				{
				 		 var obj=document.getElementById("divImageMap");
						 
						 var deltax = pt.x-ptDepart.x;
						 var deltay = pt.y-ptDepart.y;
						 obj.style.left = deltax;
						 obj.style.top = deltay;
						 var emprise = GetMapEmpriseView();
						 var cliptop;
						 var clipbottom;
						 var clipleft;
						 var clipritgh;
						 
						 if(deltay>0)
						 		cliptop = 0;
						 else
								cliptop = -deltay;
								
						 if(deltax>0)
						 		clipleft = 0;
						 else
								clipleft = -deltax;
						
					//	 cliptop = emprise.y;
						// clipleft = emprise.x;
						 clipbottom = cliptop +  emprise.height-deltay;
						 clipright = clipleft +  emprise.width-deltax;
						 var strrect = "rect(" + cliptop + " " + clipright + " " + clipbottom + " " + clipleft + ")"
					//alert(strrect);
						 obj.style.clip = strrect;
						
						 
						 
				}
               */
        return false;
        
}

function ApplyGetInfo(x,y)
{
if(infoBulle!=null)
{
	infoBulle.mustMove = false;
	infoBulle.setVisible(false);
}
var loc = location.href;
ConvertViewToSys(x,y);
	 //mapCurrentX
	  var newwidth;
	 newwidth = (mapright - mapleft);
	 var tol;
	 tol = 5*newwidth/mapClientwidth;
		var chaine = szHttpServeur +
                "&ACTION=ClickMap!POSITION=" + mapCurrentX + "@" + mapCurrentY + "@" + tol + "!LOCATION=" + loc ;
    openInfo = true;    
		updateBufferResultatClick(chaine);
}

function ApplyPanMap(x0,y0,x2,y2)
{
var loc = location.href;
 ConvertViewToSys(x0,y0);  
		 var x1 = mapCurrentX;
		 var y1 = mapCurrentY;
	 ConvertViewToSys(x2,y2);
	  var newtop;
		var newleft;
		var newwidth;
		var newheight;
		var deltax = mapCurrentX-x1;
		var deltay = mapCurrentY-y1;
		newwidth = (mapright - mapleft);
	  newheight = (maptop - mapbottom);
		newbottom = mapbottom - deltay;
		newleft = mapleft - deltax;
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				
	updateBufferMap(chaine);
}
function ApplyZoomObject(x,y)
{
if(infoBulle!=null)
{
	infoBulle.mustMove = false;
	infoBulle.setVisible(false);
}
var loc = location.href;
 ConvertViewToSys(x,y);
	
		var chaine = szHttpServeur +
                "&ACTION=ZoomObjet!POSITION=" + mapCurrentX + "@" + mapCurrentY +
		"!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" + (maptop - mapbottom) + 
		"!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +
		"!LOCATION=" + loc ;		
               
		updateBufferMap(chaine);
}
function ApplyZoomMoins(x,y)
{
if(infoBulle!=null)
{
	infoBulle.mustMove = false;
	infoBulle.setVisible(false);
}
var loc = location.href;
 ConvertViewToSys(x,y);
	  var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = (mapright - mapleft)*2;
	  newheight = (maptop - mapbottom)*2;
		newbottom = mapCurrentY - newheight/2;
		newleft = mapCurrentX - newwidth/2;
		var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;
	updateBufferMap(chaine);
								if(editSvg)
								{
								var conf = haveTosend();
								
								if(conf==true)
								{
								
								 var chaineSvg = szHttpServeur  +
						"&ACTION=EditLayer!NAME="+currentEditedLayer+"!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +"!LOCATION=" + loc + "!LAYER_EDITION";
									updateBufferEditLayer(chaineSvg);
									editSvg=true;
									showObject("divEditLayer");
									}
								}
				

}

function UpdateViewBox(x0,y0,x1,y1)
{
if(infoBulle!=null)
{
	infoBulle.mustMove = false;
	infoBulle.setVisible(false);
}

  			 	 		if( x1 > x0 && y1 >y0)
                {
                        ConvertViewToSys(x0,y1);
                        newleft = mapCurrentX;
                        newbottom = mapCurrentY;
                        ConvertViewToSys(x1,y0);
                        newwidth = mapCurrentX - newleft;
                        newheight = mapCurrentY - newbottom;
                }
                else if ((x1 == x0)||(y1 == y0))
								{
								 		 		ConvertViewToSys(x0,y1);
								 		 		newwidth = (mapright - mapleft)/2;
	  										newheight = (maptop - mapbottom)/2;
		 										newbottom = mapCurrentY - newheight/2;
		  									newleft = mapCurrentX - newwidth/2;
								}
								else
                {
                        ConvertViewToSys(x1,y0);
                        newleft = mapCurrentX;
                        newbottom = mapCurrentY;
                        ConvertViewToSys(x0,y1);
                        newwidth = mapCurrentX - newleft;
                        newheight = mapCurrentY - newbottom;
                }
                 var loc = location.href;
                var chaine = szHttpServeur +
                           "&ACTION=BuildMap!EMPRISE=" + newleft + "@" + newbottom + "@" + newwidth + "@" +  newheight + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc ;
                                                
                updateBufferMap(chaine);

}
function endDrag(e)
{
/*
        hideObject("divRect");
        var loc = location.href;
        var pt = getMousePosition(e);
        releaseCaptureEvent();
        var emprise = GetMapEmpriseView();
        if( (pt.x < emprise.x) || (pt.x > emprise.x+emprise.width) || (pt.y < emprise.y) || (pt.y > emprise.y+emprise.height) )
        return false;
                
        if (curTool == 209)
        {
              
                UpdateViewBox(ptDepart.x,ptDepart.y,pt.x,pt.y);
    
								}
        if (curTool == 210)
        {
       
			 	 ApplyZoomMoins(pt.x,pt.y);
	}
	else if (curTool == 211)
	{
	 		 ApplyGetInfo(pt.x,pt.y);
		
	}
	else if (curTool == 212)
	{
	ApplyZoomObject(pt.x,pt.y);
	}
	  if (curTool == 213)
    {
    ApplyPanMap(ptDepart.x,ptDepart.y,pt.x,pt.y);
	}
        */
return false;
}
function releaseCaptureEvent()
{/*
 if (document.captureEvents)
  { // pour Mozilla
  //  document.releaseEvents(Event.MOUSEMOVE);
  //  document.releaseEvents(Event.MOUSEDOWN | Event.MOUSEUP);
  }
     var obj = document.getElementById("IMG");
     obj.onmousemove = null;
     */
}

function ConvertViewToSysSVG(x,y)
{
	var mapWidth;
	var mapHeigth;
        var pt = new Point();
	mapWidth = mapright-mapleft;
	var zoom;
	zoom = 0.0;
	zoom = mapClientwidth/mapWidth;
     
	pt.x = x/zoom + mapleft;
	pt.y = maptop - y/zoom;

        return pt;
}
function ConvertViewToSysDistanceSVG(d)
{
	var mapWidth;
	mapWidth = mapright-mapleft;
	var zoom=0.0;
	zoom = mapClientwidth/mapWidth;
     

        return d/zoom;
}
function sendSvgRequest(req)
{
        var loc = location.href;
	var newwidth = (mapright - mapleft);
	var tol= 5*newwidth/mapClientwidth;
        
        var chaine = szHttpServeur + "&ACTION=SelectTool!SHAPES=" + req + "!TOLERANCE=" + tol + "!LOCATION=" + loc+
        "!SELECTION"+
        "!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" + (maptop - mapbottom) + 
        "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight;
        updateBufferMap(chaine);
}


function sendNextRequest()
{
	
	if( sendingInProgress==true)
	{
	
		if(pile.length > 0)
		{
			
			var header ="";
			
			if(pile.length > 1)
				header="!NBLEFT="+(pile.length-1)+"!";
			//alert(pile[0]);
			
			sendSvgEditionRequest(header+pile[0]);
			
			pile.splice(0,1);
			
		
			return true;
		}
		sendingInProgress= false;

		//FitImage(false);
		reloadAllAfterEdition();
		return false;
	}
	
	return false;
}

function reloadAllAfterEdition()
{
	/*if(mapZoom==true)
	{
		var loc = location.href;
		
		var chaine = szHttpServeur +
			"&ACTION=BuildMap!EMPRISE=" + lastLeftSend  + "@" + lastBottomSend + "@" + 
										  lastWidthSend	  + "@" +  lastHeightSend + 
							"!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +
							"!LOCATION=" + loc ;
		updateBufferMap(chaine);
		
		//ActivateFonction(6,currentEditedLayer);
		ActivateFonction(6,currentEditedLayer,"","","",false);

	
	}
	else
	{
		FitImage(false);
	}*/
	RedrawMap();
	ActivateFonction(6,currentEditedLayer,"","","",false);
						
	
			
}
function edtionOk()
{
	sendingInProgress=false;
	
}

function sendSvgEditionRequest(req)
{
	var loc = location.href;
	var newwidth = (mapright - mapleft);
	var tol= 5*newwidth/mapClientwidth;
	
	var chaine = szHttpServeur + "&ACTION=EditionTool!LAYER="+currentEditedLayer + req + "!TOLERANCE=" + tol + "!LOCATION=" + loc+
	"!SELECTION"+
	"!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" + (maptop - mapbottom) + 
	"!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight;

	updateBufferResultatClick(chaine);
}

function sendClear()
{
        var loc = location.href;
	var chaine = szHttpServeur  +
                "&ACTION=clearSvgSelection" + 
		"!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" + (maptop - mapbottom) + 
		"!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight +
		"!LOCATION=" + loc ;	
	updateBufferMap(chaine);

}

function sendReDraw()
{
        var loc = location.href;
        var chaine = szHttpServeur + "&ACTION=SelectTool!REDRAW"  + "!LOCATION=" + loc+
        "!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" + (maptop - mapbottom) + 
        "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight;
  
        updateBufferMap(chaine);
}

function emptyDivMap()
{
	document.getElementById("divMap").innerHTML ="";
}