	   /*************************************************************
		/*
		/*           Fichier de navigation sur SVG
		/*
		/*					 Editer les variable szSelectColor et iSelectWeight pour les selections
		/*
		/*************************************************************/
		
		var 	szSelectColor = "rgb(255,237,0)";
		var 	iSelectWeigth = 3;
		var   currentHiLight = null;
		var scaleMap  = 1;
		var svgDoc;
		var pixHeight;
		var pixWidth;
		var origPixSize;
		var lastcolor;
		var lastfill;
		var laststroke;
		var lastopacity;
		var svgcurtool = 209;
		var mapCurrentX;
		var mapCurrentY;
		var sysCurrentX;
		var sysCurrentY;
		var topMap=0;
		var leftMap=0;
		var curZoom = 1.0;
		var widthMap=1.0;
		var heightMap=1.0;
		var mapObj;
		
		var nextechelle = 0;
		var prevechelle = 100000000;
		var ymincarto=0.0;
		var xmincarto=0.0;
		var xmaxcarto=0.0;
		var ymaxcarto=0.0;
		var mouseisout = true;
		var tLayer = new Array(100);
		var tLayerVisible = new Array(100);
    var nbLayer = 0;
		var isZooming =0;
		var interval = "";


	var cartoNS = "http://www.carto.net/attrib";
	function Translation(x,y){this.x=x;this.y=y;}
function setCurrentToolSVG(numTool)
{
alert(numTool);
//svgcurtool = numTool;
}

 
function addLayer(namelayer)
{

var layerfound = false;
var i=0;
for(i=0;i<nbLayer;i++)
{
  if(tLayer[i]==namelayer)
  {
   layerfound = true;
 
	
   break;
  }

}
if(layerfound == false)
{
 tLayer[nbLayer] = namelayer;
 tLayerVisible[nbLayer] = 1;
 nbLayer++;
}


}

function UpdateVisibility()
{
var i=0;
for(i=0;i<nbLayer;i++)
{
  setLayerVisible(tLayer[i],tLayerVisible[i]);
	}
	if(parent.legvisible == 0)
	{
	HideAllCheckbox();
	}
}
function getLayerID(layername)
 {
 var layerfound = false;
 var i=0;
 for(i=0;i<nbLayer;i++)
 {
 	if(tLayer[i]==layername)
	{
	 
 	 return(i);
 	 break;
	 }
	}
	return(-1);

 }
function setLayerVisible(myLayer,vis)
{
 				 
 			var myLayerObj = svgDoc.getElementById(myLayer);
			
			if(myLayerObj!=null)
			{
			var myLayerObjInterior = svgDoc.getElementById(myLayer+"1");
			var idLayer = getLayerID(myLayer);
			var idLayer1 = getLayerID(myLayer+"1");
			var myCheckCrossObj = svgDoc.getElementById("checkCross"+myLayer);
			if(myCheckCrossObj!=null)
			{
			var myCheckCrossVisibility = myCheckCrossObj.getAttributeNS(null,"visibility");
			var visibility = "hidden";
			if(idLayer1>=0)
  			{
  			tLayerVisible[idLayer1] = vis;
  			}
  			if(idLayer>=0)
  			{
  			tLayerVisible[idLayer] = vis;
  			}
			if(vis==1)
			{
  			visibility = "visible";
  			
			}
			
			myLayerObj.setAttributeNS(null,"visibility",visibility);
			
			if(myLayerObjInterior!=null)
			{
			 myLayerObjInterior.setAttributeNS(null,"visibility",visibility);
			 
			}
			myCheckCrossObj.setAttributeNS(null,"visibility",visibility);
			}
			
			}
				

}


function HideAllCheckbox()
{
var i=0;
for(i=0;i<nbLayer;i++)
{
  var myCheckCrossObj = svgDoc.getElementById("checkCross"+tLayer[i]);
	if(myCheckCrossObj!=null)
	{
	var visibility = "hidden";
	myCheckCrossObj.setAttributeNS(null,"visibility",visibility);
	}
	}

}

function ShowAllCheckbox()
{
var i=0;
for(i=0;i<nbLayer;i++)
{
  var myCheckCrossObj = svgDoc.getElementById("checkCross"+tLayer[i]);
	if(myCheckCrossObj!=null)
	{
	var visibility = "hidden";
	if(tLayerVisible[i]==1)
						visibility = "visible";
	myCheckCrossObj.setAttributeNS(null,"visibility",visibility);
	}
	}

}

function checkBoxScript(evt,myLayer) { //checkBox for toggling layers an contextMenue
			
			var myCheckCrossObj = svgDoc.getElementById("checkCross"+myLayer);
			var myCheckCrossVisibility = myCheckCrossObj.getAttributeNS(null,"visibility");
			if (evt.type == "click") 
			{
				if (myCheckCrossVisibility == "visible")
				 {
					setLayerVisible(myLayer,0);
				}
				else 
				{
					setLayerVisible(myLayer,1);
				}
			}
			
		
}

		
function showCoords(x,y) {
			var scale = mapObj.getCurrentScale();
			svgDoc.getElementById("coordX").firstChild.nodeValue = (x).toFixed(3);
			svgDoc.getElementById("coordY").firstChild.nodeValue = (y).toFixed(3);
			svgDoc.getElementById("zoom").firstChild.nodeValue = (curZoom).toFixed(3);
			svgDoc.getElementById("scale").firstChild.nodeValue = (scale).toFixed(3);
			
		}

function updateViewBox(evt)
{
// Retrieve the SVG document object:
	var directTarget = evt.target;
	if( directTarget.getNodeType() != 9 ) // if not DOCUMENT_NODE
		svgDoc = directTarget.ownerDocument;
	else
		svgDoc = directTarget;
	
	
	//reference to coordinate box (for later scaling and translating)
  var mainMap= 'MainMap'; 

  mapObj = svgDoc.getElementById (mainMap); 
	//initialize coordinates, pixsize etc.
	mouseisout = true;
	var empriseCarto = mapObj.getAttributeNS(cartoNS,"EmpriseCarto");
	var echelles = mapObj.getAttributeNS(cartoNS,"echelles");
	var techelle = echelles.split(' ');
	nextechelle = parseFloat(techelle[0]);
	prevechelle = parseFloat(techelle[1]);
	var xymin = empriseCarto.split(' ');
	xmincarto = parseFloat(xymin[0]);
	ymincarto = parseFloat(xymin[1]);
  var viewbox = new String(mapObj.getAttribute("viewBox"));
	var viewboxes = viewbox.split(' ');
	var ulXCorner = parseFloat(viewboxes[0]);
	var ulYCorner = parseFloat(viewboxes[1]);
	widthMap = parseFloat(viewboxes[2]);
	heightMap = parseFloat(viewboxes[3]);
  maptop=ymincarto+heightMap;
	mapbottom=ymincarto;
	mapleft=xmincarto;
	mapright=xmincarto+widthMap;
	xmaxcarto = xmincarto+widthMap;
	ymaxcarto = ymincarto+heightMap;
	
	
	
	
	topMap=0;
	leftMap=0;
	
  GetEchelleMap();
  pixWidth = mapObj.getAttribute("width");
	pixHeight = mapObj.getAttribute("height");
	curZoom = 1.0;
	origPixSize = widthMap / (pixWidth);
	scaleMap = origPixSize;
	UpdateVisibility();
	
}




function RescaleSVG(diffscale)
{
var i=0;
var node;
var layer;
var nombre;
var k=1;
var objet;
var cur_transform;
var indexscale;
var subscale;
var indexscale2;
var curscale;
var cureppaisseur

for(i=0;i<nbLayer;i++)
{
 
  node=svgDoc.getElementById(tLayer[i]);
	if(node!=null)
	{
  layer=node.childNodes;
  nombre=layer.length;
	var k=0;
	// mise à jour des epaisseur sur le style du groupe

	if(node.nodeType==1)
	{
	
	var svgstyle = node.getStyle(); 
	var laststroke = svgstyle.getPropertyValue('stroke-width');
  
	var newstroke = parseFloat(laststroke);
	
	newstroke = newstroke/diffscale;
	svgstyle.setProperty('stroke-width',newstroke);
	//node.setAttribute('stroke-width',newstroke);
	
	}
	while (k<nombre)
	{
	
  	objet=layer.item(k);
  	if(objet.nodeType==1)
  	{
  	
  	 cur_transform = objet.getAttribute ("transform");
  	 indexscale = cur_transform.indexOf("scale(");
		 if(indexscale>=0)
		 {
  	 subscale = cur_transform.substr(indexscale,cur_transform.length-indexscale);
  	 indexscale2 = subscale.indexOf(")");
  	 curscale = parseFloat(subscale.substr(6,indexscale2-6));
  	 curscale = curscale/diffscale;
  	 subscale = cur_transform.substr(0,indexscale);
  	 cur_transform = subscale + "scale("+ curscale +")";
  	 objet.setAttribute("transform",cur_transform);
		 }
		 
  	}
  	k=k+1;
	}

 }
 }
 	 	 var strLayerSel = "layerTempSelect";
		 var myLayerObj = svgDoc.getElementById(strLayerSel);
		 myLayerObj.setAttributeNS(null,"visibility","hidden");
}

function ExtractTranslation(node)
{
 				 var transform = node.getAttribute("transform");
				 var thetrans = new Translation(0,0);
        if (transform!=null) 
				{
            var p = "[0-9, -.]";
            var regex = new RegExp("(translate\\(" + p + "+\\)|scale\\(" + p + "+\\)|matrix\\(" + p + "+\\)|rotate\\(" + p + "+\\))", "g");
            var params = transform.match(regex);
            if (params!=null) {
                for (var i=params.length-1; i>=0; i--) 
								{
                    var param = params[i];
                    if (param.indexOf("translate")==0) 
										{
                        var values = param.match(new RegExp("[0-9.-]+", "g"));
                        
												thetrans.x = parseFloat(values[0]);
												thetrans.y = parseFloat(values[1]);
                    }
                }
            }
        }
				return(thetrans);

}


function initMap(evt) 
{

	
	updateViewBox(evt);
	
	// redimensionne le canvas
	
	var canvas= 'canvas'; 
  var svgcanvas = svgDoc.getElementById (canvas);  	
	
	svgcanvas.setAttribute('width',widthMap);
	svgcanvas.setAttribute('height',heightMap);
	
	var svgbox,w,h,x,y;
	
	
	
	// récuperation de la taille de la legende totale
	var strLegende= 'Legende'; 
	var Legende=svgDoc.getElementById (strLegende);
	
	// la legende est visible ?
	var legvisible1 = Legende.getAttributeNS(null,"visibility");
	if(legvisible1=="visible")
	  parent.legvisible = 1;
	else
	{
	  parent.legvisible = 0;
		
		}
	
	
	Legende.setAttributeNS(null,"visibility","visible");
	//recuperation de la taille du layercontrol
	var maplayercontrol = 'mapLayerControls'; 
	var layercontrol = svgDoc.getElementById (maplayercontrol);

	
  svgbox=layercontrol.getBBox();
	
	x=svgbox.width+40;
  y=0;
	
	//déplacement du control des analyse
	
	var mapanalysecontrol= 'mapAnalyseControls'; 
	var analysecontrol=svgDoc.getElementById (mapanalysecontrol);
	if(analysecontrol!=null)
	{
	
					analysecontrol.setAttribute("transform","translate("+x+" "+y+")");
	}
	
	
	
	
	// mise en place du cadre
	svgbox=Legende.getBBox();
	var rectLegende= 'rectLegende'; 
	var cadrelegende =svgDoc.getElementById (rectLegende);
	var widthcadre = svgbox.width + 40;
	var heightcadre = svgbox.height + 40;
	cadrelegende.setAttribute("width",widthcadre);
	cadrelegende.setAttribute("height",heightcadre);
	
	// redimensionnement du svg total
	
	Legende=svgDoc.getElementById (strLegende);
	svgbox=Legende.getBBox();
	
	
	
  var obj = document.getElementById("svgMap");

	var thetrans = ExtractTranslation(Legende);
	
  var righttotal = svgbox.width + thetrans.x +10;
  var bottomtotal = svgbox.height + thetrans.y +10;
	
	if(righttotal<mapClientwidth)
				righttotal = mapClientwidth;
	if(bottomtotal<mapClientheight)
	      bottomtotal = mapClientheight;
	obj.width = righttotal;
	obj.height = bottomtotal;

	Legende.setAttributeNS(null,"visibility",legvisible1 );
	
	

}

		function OnMouseMoveSVG(evt) {
		if ((curTool != 209)&&(curTool != 213))
		{
			var myPoly = evt.target;
	
			
			
			if ((evt.type == "mouseover")&&(mouseisout)) {
				   var strToolTip = myPoly.getAttributeNS("http://www.carto.net/attrib","strToolTip");
			
					
					mouseisout = false;
					lastfill = myPoly.getAttribute("fill");
					lastcolor = myPoly.getAttribute("stroke");
					laststroke = myPoly.getAttribute("stroke-width");
					lastopacity = myPoly.getAttribute("opacity");
					var strw = (scaleMap/curZoom)*iSelectWeigth;
					
					
					
					if((laststroke!=null)&&(laststroke!=""))
					{
					 var fstrw = parsefloat(laststroke) * 3;
					 strw = "" & fstrw;
					
					 }
					 
					 var parentHightlight = myPoly.parentNode;
					 //a t on affaire à des analyse multi ?
					var multi = false;
					var strAttribMulti = parentHightlight.getAttributeNS("http://www.carto.net/attrib","datam");
					if((strAttribMulti!=null)&&(strAttribMulti!=""))
					{
					 multi = true;
					
					}
					
					var strTagName = myPoly.getTagName();
					if((strTagName == "path")&&(!multi))
					{
					currentHiLight = myPoly.cloneNode(true);
				  currentHiLight.setAttribute("fill","none");
					currentHiLight.setAttribute("opacity","1.0");
					currentHiLight.setAttribute("stroke",szSelectColor);
					currentHiLight.setAttribute("stroke-width",strw);
					parentHightlight.appendChild(currentHiLight);
				
					}
					else
					{
					myPoly.setAttribute("opacity","0.6");
					currentHiLight = null;
					}
					
				/*	if (lastfill!="none")
					{
					    myPoly.setAttribute("fill","red");
					}
					else
					{
					 		myPoly.setAttribute("stroke","blue");
					}
					myPoly.setAttribute("opacity","0.8");*/
					processToolTip(evt,strToolTip);
				
					}
			else if ((evt.type == "mouseout")&&(!mouseisout))
					{
					if (currentHiLight!=null)
					{
					 var parentHightlight = myPoly.parentNode;
					 parentHightlight.removeChild(currentHiLight);
					 parentHightlight = null;
					}
					
					mouseisout = true;
					myPoly.setAttribute("fill",lastfill);
					myPoly.setAttribute("stroke",lastcolor);
					myPoly.setAttribute("opacity",lastopacity);
					processToolTip(evt,"");
					
					}
					}
			
		}
		function addSquare(x,y)
		{
		 var trans = mapObj.getCurrentTranslate();
     var scale = mapObj.getCurrentScale();
  	 x = (x - mapleft)*((scale*curZoom)/origPixSize);
		 y = (maptop -y)*((scale*curZoom)/origPixSize);
		
		 var strLayerSel = "layerTempSelect";
		 var myLayerObj = svgDoc.getElementById(strLayerSel);
		 myLayerObj.setAttributeNS(null,"visibility","visible");
		 myLayerObj.setAttribute("transform","translate("+x+","+y+")");
		 
		 
		 
		}
		 function convertViewToSys(evt)
		 {
 			 
        var SVGRoot = svgDoc.rootElement;
 				var trans = mapObj.getCurrentTranslate();
        var scale = mapObj.getCurrentScale();
				
          // Remove the current pan and zoom from the mouse coordinate
        mapCurrentX = (( evt.clientX) / ((scale*curZoom)/origPixSize)) + leftMap;
        mapCurrentY = (( evt.clientY) / ((scale*curZoom)/origPixSize)) + topMap;	
			//	showCoords(mapCurrentX,mapCurrentY);
		 }
		 
		
		 function processToolTip(evt,strToolTip) {
    
             showToolTip(evt.target, evt.clientX, evt.clientY, strToolTip, 1);
						 var strToolTip = evt.target.parentNode.getAttributeNS("http://www.carto.net/attrib","datam");
						 if(strToolTip!="")
						 {
						 var tval =  strToolTip.split("|");
						 var quick= 'QuickInfo'; 
       			 var fulltext = "";
        		 var svgobj = svgDoc.getElementById (quick); 
						 if(svgobj!=null)
						 {
						 for(i=0;i<tval.length;i++)
						 {
						 fulltext = fulltext + "\n" + tval[i];
        		 	
						 }
						
						 var newNode = svgDoc.createTextNode(fulltext);
						 svgobj.appendChild(newNode);
						 }
						 }
					
						
        }
		
		function showToolTip (target, mx, my, info,scale){ 
     scale = 1 / scale;
  
     
      if(info.length>0){
        var tooltip= 'Tooltip'; 
        var tooltiprect= 'TooltipRect'; 
        var svgobj = svgDoc.getElementById (tooltip); 
        svgobj.setAttribute ('x', mx); 
        svgobj.setAttribute ('y', my + 30*scale); 
				
				// on coupe en morceau le tooltip pour le multi ligne
				// on fabrique des noueds tspan
				
     var tinfo = info.split("\\n");
		 var szInfo = "";
		 var ctwritten = 0;
		
		 for(var i=0;i<tinfo.length;i++)
		 {
		 if(tinfo[i]!="")
	
		 {
			var tspan  = svgDoc.createElement("tspan");
			tspan.setAttribute ('x', mx);
			if(ctwritten>0)
						 tspan.setAttribute ('dy', 15);
			if(i==0)
							tspan.setAttribute ('style', 'fill:blue; font-weight:bold');

			tspan.appendChild (svgDoc.createTextNode (tinfo[i]));
			svgobj.appendChild (tspan);
			ctwritten++;
			
			}

		 }
			 
        var svgstyle = svgobj.getStyle(); 
        svgstyle.setProperty ('visibility', 'visible'); 
				svgstyle.setProperty ('font-size', 12*scale); 
				var  svgbox=svgobj.getBBox();
					
        var svgobj = svgDoc.getElementById (tooltiprect);
     
		   
        svgobj.setAttribute ('x', svgbox.x - 5);
        svgobj.setAttribute ('y',svgbox.y - 5);
        svgobj.setAttribute ('width', svgbox.width + 10);
				svgobj.setAttribute ('height',svgbox.height + 10);
        var svgstyle = svgobj.getStyle();
        svgstyle.setProperty ('visibility', 'visible');
				
      }
      else {
        var tooltip= 'Tooltip'; 
        var tooltiprect= 'TooltipRect'; 
        var svgobj = svgDoc.getElementById (tooltip); 
				// efface les noueds enfant du tooltip
				if( svgobj.childNodes!=null)
				{
				var ctchild = svgobj.childNodes.length;
				var children = svgobj.childNodes;
				for(var i=0;i<ctchild;i++)
				{
				 var curCh = children.item(0);
				 svgobj.removeChild(curCh);
				}
				}
        var svgstyle = svgobj.getStyle(); 
        svgstyle.setProperty ('visibility', 'hidden'); 
        var svgobj = svgDoc.getElementById (tooltiprect);
        var svgstyle = svgobj.getStyle();
        svgstyle.setProperty ('visibility', 'hidden');
      
      }
}

/***************** fonction de zoom ****************/
var appui=false,x0=0.0,y0=0.0,x1,y1;

 
function bouger(evt)
{
OnMouseMoveSVG(evt);
convertViewToSys(evt);
if((appui==true)&&(curTool==209))
{
  var zoomrect= 'ZoomRect'; 
  var svgobj = svgDoc.getElementById (zoomrect); 
  var svgstyle = svgobj.getStyle(); 
	
	 x1 = mapCurrentX;
	 y1 = mapCurrentY;
	
	svgobj.setAttribute('width',x1-x0);
	svgobj.setAttribute('height',y1-y0);

  }
	else if((appui==true)&&(curTool==213))
{
 x1 = mapCurrentX;
	 y1 = mapCurrentY;
 	var deltax = x1-x0;
	var deltay = y1-y0;
	if((deltax!=0)||(deltay!=0))
	{
	panMap(-deltay,-deltax);
	x0 = x1;
	y0 = y1;
	}
	
}

}
 

 
function cliquer(evt)
{
 if(curTool==209)
 {

	var zoomrect= 'ZoomRect'; 
  var svgobj = svgDoc.getElementById (zoomrect); 
  var svgstyle = svgobj.getStyle(); 
	convertViewToSys(evt);
	x0 = mapCurrentX;
	y0 = mapCurrentY;
	x1 = mapCurrentX;
	y1 = mapCurrentY;
	svgobj.setAttribute ('x', x0); 
  svgobj.setAttribute ('y', y0); 
	svgobj.setAttribute('width',0);
	svgobj.setAttribute('height',0);
  svgstyle.setProperty ('visibility', 'visible'); 
	}
 if(curTool==213)
 {
  convertViewToSys(evt);
	x0 = mapCurrentX;
	y0 = mapCurrentY;
	x1 = mapCurrentX;
	y1 = mapCurrentY;
 }
	appui=true;

	}
function checkEmprise(curech)
{

    if((maptop>ymaxcarto)||(mapleft<xmincarto)||(mapright>xmaxcarto)||(mapbottom<ymincarto)||(curech<nextechelle)||(curech>prevechelle))
		{
		  var loc = window.location;
			   
	  	var chaine = szHttpServeur +
                "&ACTION=BuildMap!EMPRISE=" + mapleft + "@" + mapbottom + "@" + (mapright-mapleft) + "@" +  (maptop-mapbottom) + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc;

				updateBufferMap(chaine);
		}
 		
}	


function startZoom(factor)
{
    interval = window.setInterval("zoomPlus("+ factor + ")",100);
} 
function stopZoom()
{
    window.clearInterval (interval);
    interval="";
		var curech = GetEchelleMap();
	
		checkEmprise(curech);
}

function startTranslate(dxpercent,dypercent)
{
    interval = window.setInterval("translateMap("+dxpercent+","+dypercent+")",30);
} 
function stopTranslate()
{
    window.clearInterval (interval);
    interval="";
		var curech = GetEchelleMap();
	
		checkEmprise(curech);
}

function panMap(dy,dx)
 {
		
		
		
		var viewbox = new String(mapObj.getAttribute("viewBox"));
		var viewboxes = viewbox.split(' ');
		
		var curwidthMap = parseFloat(viewboxes[2]);
		var curheightMap = parseFloat(viewboxes[3]);
		
		var newbottom = parseFloat(viewboxes[1])+dy;
		var newleft = parseFloat(viewboxes[0])+dx;
		

		
		var viewbox = "" + newleft + " " + newbottom + " " + curwidthMap + " " + curheightMap;
		var lx0 = newleft;
		var ly0 = newbottom;
		
			
		mapObj.setAttribute("viewBox",viewbox);
		
		maptop = maptop-dy;
		mapbottom = mapbottom - dy;
		mapleft = mapleft+dx;
		mapright =mapright+dx;
		
		
 }
 

function translateMap(dxpercent,dypercent)
{
 		var viewbox = new String(mapObj.getAttribute("viewBox"));
		var viewboxes = viewbox.split(' ');
		var curwidthMap = parseFloat(viewboxes[2]);
		var curheightMap = parseFloat(viewboxes[3]);
		panMap(curheightMap*dypercent,curwidthMap*dxpercent);
		
		
		var curech = GetEchelleMap();
	
		checkEmprise(curech);
		
	
}

function zoomPlus(facteur)
{
 		var oldzoom = 	curZoom;		
	 
	  var viewbox = new String(mapObj.getAttribute("viewBox"));
		var viewboxes = viewbox.split(' ');
	
		var curwidthMap = parseFloat(viewboxes[2]);
		var curheightMap = parseFloat(viewboxes[3]);
	
		mapCurrentY = parseFloat(viewboxes[1])+curheightMap/2.0;
		mapCurrentX = parseFloat(viewboxes[0])+curwidthMap/2.0;
	  var newtop;
		var newleft;
		var newwidth;
		var newheight;
		
		newwidth = curwidthMap*facteur;
	  newheight = curheightMap*facteur;
		newbottom = mapCurrentY - newheight/2.0;
		newleft = mapCurrentX - newwidth/2.0;
	
		var viewbox = "" + newleft + " " + newbottom + " " + newwidth + " " + newheight;
	  x0 = newleft;
		y0 = newbottom;
		
		curZoom = widthMap/(newwidth);
	 ZoomY = heightMap/(newheight);
	 if(ZoomY<curZoom)
			curZoom = ZoomY;
			
	 var centerX = x0+newwidth/2.0;
	 var centerY = y0+newheight/2.0;
	
	
	topMap = centerY-heightMap/(2.0*curZoom);
	leftMap = centerX-widthMap/(2.0*curZoom);
	
	mapObj.setAttribute("viewBox",viewbox);
		
		maptop = ymaxcarto - topMap;
		mapbottom = maptop - heightMap/(curZoom);
		mapleft = leftMap+xmincarto;
		mapright =leftMap+xmincarto+widthMap/(curZoom);
		
	RescaleSVG(curZoom/oldzoom);
}
function lacher(evt)
{
 
  
	if(appui=true)
	{
	appui=false;
	if ((curTool == 211)||(curTool==212))
	{
	
	 //mapCurrentX
	 var myPoly = evt.target;
	 var couche = myPoly.parentNode;
	 var idcouche = "";
	 var inputcouche ="";
	 
	 idcouche = couche.getAttribute('id');
	var idObj = myPoly.getAttribute('id');
	 if(idcouche=="")
	 {
	 
		 inputcouche = couche.getAttributeNS("http://www.carto.net/attrib","inputCouche");
		 
		 if(inputcouche!="")
		 {
		 	idcouche = inputcouche;
		 }
		 else
		 {
		 	inputcouche = couche.parentNode.getAttributeNS("http://www.carto.net/attrib","inputCouche");
			idcouche = inputcouche;
		 }
	
	 }
	 else
	 {
	 	 inputcouche = couche.getAttributeNS("http://www.carto.net/attrib","inputCouche");
		
		 if(inputcouche!="")
		 {
		 idcouche = inputcouche;
		 }
		 else
		 {
		 	inputcouche = couche.parentNode.getAttributeNS("http://www.carto.net/attrib","inputCouche");
			idcouche = inputcouche;
			var idObj = myPoly.parentNode.getAttribute('id');
		 }
	 }
	 var loc = window.location;
	 var chaine;
	 
	 if (curTool == 211)
	 {
							 chaine = szHttpServeur +
               "&ACTION=ClickMap!OBJETCLICK=" + idObj + "@" + idcouche + "!LOCATION=" + loc ;
							 updateBufferResultat(chaine);
							
							 }
							 else
							 {
							 chaine = szHttpServeur +
               "&ACTION=ZoomObjet!OBJETCLICK=" + idObj + "@" + idcouche + "!OUTPUTSIZE=" + mapClientwidth + "@" + mapClientheight + "!LOCATION=" + loc ;
							 updateBufferMap(chaine);
							 }
		
	}
	
	else if((curTool==209)&&((x1-x0)!=0))
 {
 
  var zoomrect= 'ZoomRect';     
  var svgobj = svgDoc.getElementById (zoomrect); 
  var svgstyle = svgobj.getStyle(); 
  svgstyle.setProperty ('visibility', 'hidden'); 
	var oldzoom = 	curZoom;					
	var viewbox = "" + x0 + " " + y0 + " " + (x1-x0) + " " + (y1-y0);
	
	
	
	
	
	// zoom par click and drag
	
	curZoom = widthMap/(x1-x0);
	var ZoomY = heightMap/(y1-y0);
	if(ZoomY<curZoom)
			curZoom = ZoomY;
			
	var centerX = (x1+x0)/2.0;
	var centerY = (y1+y0)/2.0;
	
	
	topMap = centerY-heightMap/(2.0*curZoom);
	leftMap = centerX-widthMap/(2.0*curZoom);
	
	mapObj.setAttribute("viewBox",viewbox);
	var viewbox1 = new String(mapObj.getAttribute("viewBox"));
		
		maptop = ymaxcarto - topMap;
		mapbottom = maptop - heightMap/(curZoom);
		mapleft = leftMap+xmincarto;
		mapright =leftMap+xmincarto+widthMap/(curZoom);
		
		RescaleSVG(curZoom/oldzoom);
		var curech = GetEchelleMap();
	
		checkEmprise(curech);
	}
	else if(curTool==213)
	{
	  var curech = GetEchelleMap();
		checkEmprise(curech);
	}
	else if((curTool==210)||((curTool==209)&&((x1-x0)==0)))
	{
	
	  var oldzoom = 	curZoom;		
	  convertViewToSys(evt);
	  var viewbox = new String(mapObj.getAttribute("viewBox"));
		var viewboxes = viewbox.split(' ');
	
		var curwidthMap = parseFloat(viewboxes[2]);
		var curheightMap = parseFloat(viewboxes[3]);
	
	  var newtop;
		var newleft;
		var newwidth;
		var newheight;
		var facteur = 2.0;
		if (curTool==209)
		{
		 facteur = 0.5;
		}
		newwidth = curwidthMap*facteur;
	  newheight = curheightMap*facteur;
		newbottom = mapCurrentY - newheight/2.0;
		newleft = mapCurrentX - newwidth/2.0;
	
		var viewbox = "" + newleft + " " + newbottom + " " + newwidth + " " + newheight;
	  x0 = newleft;
		y0 = newbottom;
		
		curZoom = widthMap/(newwidth);
	 ZoomY = heightMap/(newheight);
	if(ZoomY<curZoom)
			curZoom = ZoomY;
			
	 var centerX = x0+newwidth/2.0;
	 var centerY = y0+newheight/2.0;
	
	
	topMap = centerY-heightMap/(2.0*curZoom);
	leftMap = centerX-widthMap/(2.0*curZoom);
	
	mapObj.setAttribute("viewBox",viewbox);
		
		maptop = ymaxcarto - topMap;
		mapbottom = maptop - heightMap/(curZoom);
		mapleft = leftMap+xmincarto;
		mapright =leftMap+xmincarto+widthMap/(curZoom);
		
		RescaleSVG(curZoom/oldzoom);
		var curech = GetEchelleMap();
		checkEmprise(curech);
	}
	
	}
	
}
