var DynContextePointToAction=Class.create();
DynContextePointToAction.prototype={
	initialize:function(){
	},
	onStart:function(){ 
	SetevenementCl(2);
		GestEvtDyn.ajouteEcouteur('MOUSECLICK',this._doAct2,this);
	
	},
	_doAct2:function(X,Y,objId){
	//alert('toto');
	  var foncSpec=this.getParam();
    SetevenementCl(0);
	   foncSpec(X,Y,objId);
	},
	onEnd:function(){
		GestEvtDyn.enleveEcouteur('MOUSECLICK',this._doAct2,this);
		SetevenementCl(0);
	}
}
var DynContexteselectRectangle=Class.create();
DynContexteselectRectangle.prototype={
	initialize:function(){
	},
	onStart:function(){
		this.svgdoc=document.svgmap.getSVGDocument();
		SetevenementCl('2');
		GestEvtDyn.ajouteEcouteur('MOUSEDOWN',this._AccrocheRectangleSelection,this);
	},
	onEnd:function(){
		SetevenementCl('0');
		GestEvtDyn.enleveEcouteur('MOUSEDOWN',this._AccrocheRectangleSelection,this);
		GestEvtDyn.enleveEcouteur('MOUSEMOVE',this._DrawRectangleSelection,this);

	},
	_AccrocheRectangleSelection : function(X,Y,objId){

		GestEvtDyn.enleveEcouteur('MOUSEDOWN',this._AccrocheRectangleSelection,this);
		GestEvtDyn.ajouteEcouteur('MOUSEMOVE',this._DrawRectangleSelection,this);

		this.Xorigine = X;
		this.Yorigine = Y;

		var rootNode = this.svgdoc;
		var rectSel = rootNode.createElement("path");
		rectSel.setAttribute("id","rectangleSelection");
		rectSel.setAttribute("fill","#000000");
		rectSel.setAttribute("fill-opacity","0.2");
		rectSel.setAttribute("stroke","#FF0000");
		rectSel.setAttribute("shape-rendering","crispEdges");

		rootNode.getElementById("options").appendChild(rectSel);

		GestEvtDyn.ajouteEcouteur('MOUSEUP',this._CloseRectangleSelection,this);

	},
	_DrawRectangleSelection : function(X,Y,objId){

		var rootNode = this.svgdoc;

		var rSel = rootNode.getElementById("rectangleSelection");

		var xAccroche = this.Xorigine;
		var yAccroche = this.Yorigine;
		var xpos	  = X;
		var ypos	  = Y;

		//Déplacement de droite vers gauche
		if(X<xAccroche){
			xpos	  = xAccroche;
			xAccroche = X;
		}

		//Déplacement de bas vers haut
		if(Y<yAccroche){
			ypos	  = yAccroche;
			yAccroche = Y;
		}


		var newWidth  = xpos-xAccroche;
		var	newHeight = ypos-yAccroche;

		rSel.setAttribute("d","M"+xAccroche+" "+yAccroche+"l"+newWidth+" 0l0 "+newHeight+"l-"+newWidth+" 0z");

	},
	_CloseRectangleSelection : function(X,Y,objId){

		GestEvtDyn.enleveEcouteur('MOUSEUP',this._CloseRectangleSelection,this);
		GestEvtDyn.enleveEcouteur('MOUSEMOVE',this._DrawRectangleSelection,this);
		//alert('clsoe appele');
		var rootNode = this.svgdoc;

		var rSel = rootNode.getElementById("rectangleSelection");

		var tp=this.getParam();

		SetTypeFind('onlySelection',true);

		svgIntersectionLayer(["rectangleSelection"], tp,ret_inverseSelection_with_oldSelection);

		rootNode.getElementById("options").removeChild(rootNode.getElementById("rectangleSelection"));

		GestEvtDyn.ajouteEcouteur('MOUSEDOWN',this._AccrocheRectangleSelection,this);

		DynCm.endCurrentContext();
	}
}


var DynContexteselectCercle=Class.create();
DynContexteselectCercle.prototype={
	initialize:function(){
	},
	onStart:function(){
		this.svgdoc=document.svgmap.getSVGDocument();
		SetevenementCl('2');
		GestEvtDyn.ajouteEcouteur('MOUSEDOWN',this._AccrocheCercleSelection,this);
	},
	onEnd:function(){
		SetevenementCl('0');
	},
	_AccrocheCercleSelection : function(X,Y,objId){

		GestEvtDyn.enleveEcouteur('MOUSEDOWN',this._AccrocheCercleSelection,this);
		GestEvtDyn.ajouteEcouteur('MOUSEMOVE',this._DrawCercleSelection,this);

		this.Xorigine = X;
		this.Yorigine = Y;

		var rootNode = this.svgdoc;
		var rectSel = rootNode.createElement("circle");
		rectSel.setAttribute("id","cercleSelection");
		rectSel.setAttribute("cx",X);
		rectSel.setAttribute("cy",Y);
		rectSel.setAttribute("r","1");
		rectSel.setAttribute("fill","#000000");
		rectSel.setAttribute("fill-opacity","0.2");
		rectSel.setAttribute("stroke","#FF0000");
		rectSel.setAttribute("shape-rendering","crispEdges");

		rootNode.getElementById("options").appendChild(rectSel);

		GestEvtDyn.ajouteEcouteur('MOUSEUP',this._CloseCercleSelection,this);

	},
	_DrawCercleSelection : function(X,Y,objId){

		var rootNode = this.svgdoc;

		var cSel = rootNode.getElementById("cercleSelection");

		var newR  = Math.abs(X)-this.Xorigine;

		cSel.setAttribute("cx",this.Xorigine);
		cSel.setAttribute("cy",this.Yorigine);
		cSel.setAttribute("r",newR);
	},
	_CloseCercleSelection : function(X,Y,objId){

		GestEvtDyn.enleveEcouteur('MOUSEUP',this._CloseCercleSelection,this);
		GestEvtDyn.enleveEcouteur('MOUSEMOVE',this._DrawCercleSelection,this);

		var rootNode = this.svgdoc;
		rootNode.getElementById("options").removeChild(rootNode.getElementById("cercleSelection"));
	}
}

var DynContexteselectMap=Class.create();
DynContexteselectMap.prototype={
	initialize:function(){
	},
	onStart:function(){
		SetevenementCl(1);
	},
	onEnd:function(){
		SetevenementCl(0);
	}
}

var DynContexteinformation =Class.create();
DynContexteinformation.prototype={
	initialize:function(){
	},
	onStart:function(){
		SetevenementCl(0);
	},
	onEnd:function(){
		SetevenementCl(0);
	}
}



var DynContexteannotation =Class.create();
DynContexteannotation.prototype={
	initialize:function(){
	},
	onStart:function(){
		if(getRightAnnotation()==0)
		{
			alert("Cette fonctionnalité a été interdite par l'administrateur");
	 
		}else{
			GestEvtDyn.ajouteEcouteur('DESSINOFF',DynStopDrawExterne);
			switchDraw('annotations','1');
		}
	},
	onEnd:function(){
		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);
		switchDraw('close',1);
		SetevenementCl(0);

	}
}
var DynContextezoomRect =Class.create();
DynContextezoomRect.prototype={
	initialize:function(){
	},
	onStart:function(){

		var strDep=this.getParam();
 if(this.getParamSpec('endAfterOnce')){
      GestEvtDyn.ajouteEcouteur('DOZOOMBYRECT',this._endOnce,this);
    }
		try{
			mapActionByButton(strDep);
		}catch(e){
			alert('Parametre de deplacement inconnu dans l\'objet DynContextezoomRect');
		}
	},
	_endOnce:function(){
    	DynCm.endCurrentContext();
  	},
	onEnd:function(){
  if(this.getParamSpec('endAfterOnce')){
      GestEvtDyn.enleveEcouteur('DOZOOMBYRECT',this._endOnce,this);
    }
		mapActionByButton();
		SetevenementCl(0);

	}
}
var DynContextepanMap =Class.create();
DynContextepanMap.prototype={
	initialize:function(){
	},
	onStart:function(){

		mapActionByButton('PAN');

	},
	onEnd:function(){

		mapActionByButton();
		SetevenementCl(0);

	}
}
function DynStopMeasure(){
	//alert('toto');
	GestEvtDyn.enleveEcouteur('MESUREOFFCLICK',DynStopMeasure);
	DynWatch.chgContextApi('Default');
}
var DynContextemeasureMap =Class.create();
DynContextemeasureMap.prototype={
	initialize:function(){
	},
	onStart:function(){

		switchMesure(this.getParam());
		GestEvtDyn.ajouteEcouteur('MESUREOFFCLICK',DynStopMeasure);
	},
	onEnd:function(){
		//alert('test');
		GestEvtDyn.enleveEcouteur('MESUREOFFCLICK',DynStopMeasure);
		HideMeasure();
		SetevenementCl(0);
	}
}
//appel de dynmap en interne

//appel de dynmap en interne
function DynStopDrawExterne(){
  //alert('toto');
	DynWatch.chgContextApi('Default');
	GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);
		switchDraw('close',1);
}


var DynContextedrawSimple =Class.create();
DynContextedrawSimple.prototype={
	initialize:function(){
	},
	onStart:function(){
		var tp=0;
		GestEvtDyn.ajouteEcouteur('DESSINOFF',DynStopDrawExterne);
		if(this.getParam())
		{
		  	SvgSwitchModeDraw(0);
        switchDraw(this.getParam(),1);
		}
	},
	onEnd:function(){
	//	alert ('end dem');
		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);
		if(this.getParam())
		{
			switchDraw('close',1);
			if(document.all['SPAN_DRAWLAYERS']){
				document.all['SPAN_DRAWLAYERS'].innerHTML='';
			}
			SetevenementCl(0);
		}
	}
}



var DynContextedrawPolygon =Class.create();
DynContextedrawPolygon.prototype={
	initialize:function(){
	},
	onStart:function(){
		var tp=0;
		//alert('test');
		GestEvtDyn.ajouteEcouteur('DESSINOFF',DynStopDrawExterne);
		if(this.getParam()){
			tp=this.getParam();
		}
		//alert(tp);
		var testOk=ExternDraw('POLYGONE',tp);
		//alert(testOk);
		//if(testOk==-1){
		//alert('test'+this.cleParamApi);
		//	DynWatch.chgContextApi(this.cleParamApi);





	},
	onEnd:function(){
		//alert ('end dem');
		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);
		switchDraw('close',1);
		if(document.all['SPAN_DRAWLAYERS']){
			document.all['SPAN_DRAWLAYERS'].innerHTML='';
		}
		SetevenementCl(0);
	}
}

var DynContextedrawLine =Class.create();
DynContextedrawLine.prototype={
	initialize:function(){
	},
	onStart:function(){
		var tp=0;
		GestEvtDyn.ajouteEcouteur('DESSINOFF',DynStopDrawExterne);
		if(this.getParam()){
			tp=this.getParam();
		}
		ExternDraw('POLYLIGNE',tp);
	},
	onEnd:function(){
		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);
		switchDraw('close',1);
		if(document.all['SPAN_DRAWLAYERS']){
			document.all['SPAN_DRAWLAYERS'].innerHTML='';
		}
		SetevenementCl(0);
	}
}
 
var DynContextedrawPointXY =Class.create();
DynContextedrawPointXY.prototype={
	initialize:function(){
	},
	onStart:function(){
		GestEvtDyn.ajouteEcouteur('DESSINOFF',DynStopDrawExterne);
		var tp=0;
		if(this.getParam()){
			tp=this.getParam();
		}
		ExternDraw('POINTXY',tp);
	},
	onEnd:function(){
		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);
		switchDraw('close',1);

		if(document.all['SPAN_DRAWLAYERS']){
			document.all['SPAN_DRAWLAYERS'].innerHTML='';
		} 
		SetevenementCl(0);
	}
}

var DynContextedrawPoint =Class.create();
DynContextedrawPoint.prototype={
	initialize:function(){
	},
	onStart:function(){
		GestEvtDyn.ajouteEcouteur('DESSINOFF',DynStopDrawExterne);
		var tp=0;
		if(this.getParam()){
			tp=this.getParam();
		}
		ExternDraw('POINT',tp);
	},
	onEnd:function(){
		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);
		switchDraw('close',1);

		if(document.all['SPAN_DRAWLAYERS']){
			document.all['SPAN_DRAWLAYERS'].innerHTML='';
		}


		SetevenementCl(0);
	}
}
var DynContextedrawMove =Class.create();
DynContextedrawMove.prototype={
	initialize:function(){
	},
	onStart:function(){
		GestEvtDyn.ajouteEcouteur('DESSINOFF',DynStopDrawExterne);
		var tp=0;
		if(this.getParam()){
			tp=this.getParam();
		}

		ExternDraw('MOVE',tp);
	},
	onEnd:function(){
		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);
		switchDraw('close',1);
		if(document.all['SPAN_DRAWLAYERS']){
			document.all['SPAN_DRAWLAYERS'].innerHTML='';
		}

		SetevenementCl(0);
	}
}
var DynContextedrawEditNode =Class.create();
DynContextedrawEditNode.prototype={
	initialize:function(){
	},
	onStart:function(){

		GestEvtDyn.ajouteEcouteur('DESSINOFF',DynStopDrawExterne);
		//	alert(this.getParamSpec('dynmapROWID'));
		alert(this.getParamSpec('dynmapROWID'));
		if(!this.getParamSpec('dynmapROWID')){

			var tp=0;
			if(this.getParam()){
				tp=this.getParam();
			}

			ExternDraw('EDITNODE',tp);

		}else{
			row=this.getParamSpec('dynmapROWID');
			tabRow=row.split('.');
			switchActiveLayers(false,tabRow[0]);
			SetevenementCl(2);
			GestEvtDyn.ajouteEcouteur("MOUSECLICK",this.editClick,this);


			editNodes(0,0,row	);
		}
	},
	editClick:function(x,y,obj){
		var tmp = obj.split(".");
		if( tmp.length==2){
			confirmModificationOfLastObject();
			this.onEnd();
		}
	},
	onEnd:function(){
		GestEvtDyn.enleveEcouteur("MOUSECLICK",this.editClick,this);
		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);
		switchDraw('close',1);
		if(document.all['SPAN_DRAWLAYERS']){
			document.all['SPAN_DRAWLAYERS'].innerHTML='';
		}

		SetevenementCl(0);
	}
}
var DynContextedrawBuffer =Class.create();
DynContextedrawBuffer.prototype={
	initialize:function(){
	},
	onStart:function(){
		GestEvtDyn.ajouteEcouteur('DESSINOFF',DynStopDrawExterne);
		var couche=0;
		var paramBuff=""; // à vide dynmap demandera la taille du buffer avec un prompt javascript
		if(this.getParam())
		{
			couche = this.getParam();
			if (couche.indexOf(",") > -1)
			{
				var arrtemp = new Array ();
				arrtemp = couche.split(",");
				couche = arrtemp[0];
				paramBuff = arrtemp[1];
			}
		}
		ExternDraw('BUFFER',couche, paramBuff);

		switchDraw('close',1);
		if(document.all['SPAN_DRAWLAYERS']){
			document.all['SPAN_DRAWLAYERS'].innerHTML='';
		}
		SetevenementCl(0);
	},
	onEnd:function(){
		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);
		switchDraw('close',1);
		if(document.all['SPAN_DRAWLAYERS']){
			document.all['SPAN_DRAWLAYERS'].innerHTML='';
		}
		SetevenementCl(0);
	}
}
var DynContextedrawFusion =Class.create();
DynContextedrawFusion.prototype={
	initialize:function(){
	},
	onStart:function(){
		GestEvtDyn.ajouteEcouteur('DESSINOFF',DynStopDrawExterne);
		var couche=0;
		var paramBuff=""; // à vide dynmap demandera la taille du buffer avec un prompt javascript
		if(this.getParam())
		{
			couche = this.getParam();
		}
		ExternDraw('BUFFER',couche, '0');

		switchDraw('close',1);
		if(document.all['SPAN_DRAWLAYERS']){
			document.all['SPAN_DRAWLAYERS'].innerHTML='';
		}
		SetevenementCl(0);
	},
	onEnd:function(){
		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);
		switchDraw('close',1);
		if(document.all['SPAN_DRAWLAYERS']){
			document.all['SPAN_DRAWLAYERS'].innerHTML='';
		}
		SetevenementCl(0);
	}
}
//Suppression de l'intérieur de l'objet par rapport à la selection
var DynContextedrawSupInt =Class.create();
DynContextedrawSupInt.prototype={
	initialize:function(){

	},
	onStart:function(){

		this.showed = 0;
		GestEvtDyn.ajouteEcouteur('DESSINOFF',DynStopDrawExterne);
		var tableauSelection = getCurrentSelection();
		this.contexte='';
		if(!this.getParamSpec('contexteAppel')){
			this.contexte='externe';
		}else{
			this.contexte=this.getParamSpec('contexteAppel');
		}

		if(tableauSelection==""){
			alert("Veuillez sélectionner au moins un objet cible ....");

			this.initEnd();

		}else{

			SetevenementCl(2);

			if(!this.getParamSpec('dynmapROWID')){

				var tp=0;

				//Num de couche
				if(this.contexte=="externe"){
					tp=this.getParam();
					ExternDraw('SPATIALOPERATION_DIFFERENCE',tp);
				}else{
					tp=getDrawLayer();
					switchDraw(tp);
					switchActivTool("spatialOperationDifference");
				}

				var svgdoc=document.svgmap.getSVGDocument();
				GestEvtDyn.ajouteEcouteur("MOUSECLICK",this._drawSupInt,this);

				var rootNode = svgdoc;
				if(rootNode.getElementById("selections_in")){
					rootNode.getElementById("selections_in").setAttribute("pointer-events","none");
				}
			}else{
				this._drawSupInt(0,0,this.getParamSpec('dynmapROWID'));
			}
		}
	},
	initEnd:function(){

		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);
		//DynWatch.chgContextApi('Default');
		init_selection();
	},
	onEnd:function(){

		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);


		if(document.all['SPAN_DRAWLAYERS']){
			document.all['SPAN_DRAWLAYERS'].innerHTML='';
		}
		GestEvtDyn.enleveEcouteur("MOUSECLICK",this._drawSupInt,this);
		try{
			var rootNode = svgdoc;
			if(rootNode.getElementById("selections_in")){
				rootNode.getElementById("selections_in").removeAttribute("pointer-events");
			}
		}catch(e){

		}
		SetevenementCl(0);

	},
	_drawSupInt:function(x,y,obj){
		
		var tmp = obj.split(".");

		if(tmp.length==2){

			StartTimer("     Modification de l'objet ...");

			var svgdoc=document.svgmap.getSVGDocument();
			var rootNode = svgdoc;

			this.srcObject = new SVGobject({svgId:obj});
			this.idobj = obj;

			var dynmap_urlpars	="path_application="+path_application+"&";
			dynmap_urlpars +='method=WKT_TRANSFORMATION_OBJECT_FROM_SELECTION&args='+obj+',Difference';
			
			var ajx = new Ajax.Request (dynmap_url , {method: 'post', parameters: dynmap_urlpars, onComplete:this._showNewObject,objetLie:this} );

		}

	},
	_showNewObject:function(res){

		if(this.showed==0){
			this.showed = 1;

			StopTimer();

			var svgdoc=document.svgmap.getSVGDocument();
			var rootNode = svgdoc;

			if(res.responseText=="")
			{
				
				rootNode.getElementById(this.srcObject.svgId).setAttribute("d","");
				//Suppression de l'objet demandé
				var co = confirm("L'opération a retourné un objet vide.\r\n\r\nSouhaitez vous supprimer cet objet ?");

				if(co){

					var dynmap_urlpars	="path_application="+path_application+"&";
					dynmap_urlpars +='method=DELETE_OBJECT&args='+this.srcObject.svgId;
					var ajx = new Ajax.Request (dynmap_url , {method: 'post', parameters: dynmap_urlpars, objetLie:this} );

				}else{
					rootNode.getElementById(this.srcObject.svgId).setAttribute("d",this.srcObject.getAttribute("d"));
				}

				this.showed = 0;
				return;
			}

			var newNode  = parseXMLfunction(res.responseText);

			svgdoc.getElementById("options").appendChild(newNode);

			var newObject = rootNode.getElementById("Object_draw_1");

			this.destObject = new SVGobject({svgRoot:newObject});

			rootNode.getElementById(this.srcObject.svgId).setAttribute("d",this.destObject.getAttribute("d"));
			rootNode.getElementById("options").removeChild(newObject);
			this._accept();
			//init_selection();
		}
	},
	_accept:function(){



		var co=confirm("Sauvegarder la modification ?");
		if(co){
			var idObj = this.srcObject.svgId;

			var dynmap_urlpars	="path_application="+path_application+"&";
			dynmap_urlpars +='method=MOVE_OBJECT&args='+idObj+'[p]'+getCurrentObject(0,idObj).replace("#","[DIESE]");

			var ajx = new Ajax.Request (dynmap_url , {method: 'post', parameters: dynmap_urlpars, onComplete:this.initEnd,objetLie:this} );

		}else{
			var svgdoc=document.svgmap.getSVGDocument();
			var rootNode = svgdoc;
			rootNode.getElementById(this.srcObject.svgId).setAttribute("d",this.srcObject.getAttribute("d"));
		}

		this.showed = 0;
	}
}
//Suppression de l'exterieur de l'objet par rapport à la selection
var DynContextedrawSupExt =Class.create();
DynContextedrawSupExt.prototype={
	initialize:function(){
	},
	initEnd:function(){
 
		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne); 
		//DynWatch.chgContextApi('Default');
		init_selection();
		 
	}, 
	onStart:function(){

		this.showed = 0;
		GestEvtDyn.ajouteEcouteur('DESSINOFF',DynStopDrawExterne);
		var tableauSelection = getCurrentSelection();

		this.contexte='';
		if(!this.getParamSpec('contexteAppel')){
			this.contexte='externe';
		}else{
			this.contexte=this.getParamSpec('contexteAppel');
		}

		if(tableauSelection==""){
			alert("Veuillez sélectionner au moins un objet cible ...");
			this.initEnd();
		}else{
			GestEvtDyn.ajouteEcouteur('DESSINOFF',DynStopDrawExterne);


			SetevenementCl(2);

			if(!this.getParamSpec('dynmapROWID')){

				var tp=0;

				//Num de couche
				if(this.contexte=="externe"){

					tp=this.getParam();
					ExternDraw('SPATIALOPERATION_INTERSECTION',tp);
				}else{

					tp=getDrawLayer();
					switchDraw(tp);
					switchActivTool("spatialOperationIntersection");
				}


				var svgdoc=document.svgmap.getSVGDocument();
				var rootNode = svgdoc;
				if(rootNode.getElementById("selections_in")){
					rootNode.getElementById("selections_in").setAttribute("pointer-events","none");
				}
				GestEvtDyn.ajouteEcouteur("MOUSECLICK",this._drawSupExt,this);

			}else{
				this._drawSupExt(0,0,this.getParamSpec('dynmapROWID'))	;
			}
		}
	},
	onEnd:function(){
		GestEvtDyn.enleveEcouteur('DESSINOFF',DynStopDrawExterne);
		switchDraw('close',1);
		if(document.all['SPAN_DRAWLAYERS']){
			document.all['SPAN_DRAWLAYERS'].innerHTML='';
		}
		GestEvtDyn.enleveEcouteur("MOUSECLICK",this._drawSupExt,this);
		var svgdoc=document.svgmap.getSVGDocument();
		try{
			var rootNode = svgdoc;
			if(rootNode.getElementById("selections_in")){
				rootNode.getElementById("selections_in").removeAttribute("pointer-events");
			}
		}catch(e){

		}
		//SetevenementCl(0);

	},
	_drawSupExt:function(x,y,obj){

		var tmp = obj.split(".");

		if(tmp.length==2){

			StartTimer("     Modification de l'objet ...");

			var svgdoc=document.svgmap.getSVGDocument();
			var rootNode = svgdoc;
			this.srcObject = new SVGobject({svgId:obj});
			this.idobj = obj;

			var dynmap_urlpars	="path_application="+path_application+"&";
			dynmap_urlpars +='method=WKT_TRANSFORMATION_OBJECT_FROM_SELECTION&args='+obj+',Intersection';
			var ajx = new Ajax.Request (dynmap_url , {method: 'post', parameters: dynmap_urlpars, onComplete: this._showNewObject,objetLie:this} );

		}

	},
	_showNewObject:function(res){

		if(this.showed==0){
			this.showed = 1;

			StopTimer();

			var svgdoc=document.svgmap.getSVGDocument();
			var rootNode = svgdoc;

			if(res.responseText=="")
			{
				rootNode.getElementById(this.srcObject.svgId).setAttribute("d","");
				//Suppression de l'objet demandé
				var co = confirm("L'opération a retourné un objet vide.\r\n\r\nSouhaitez vous supprimer cet objet ?");

				if(co){

					var dynmap_urlpars	="path_application="+path_application+"&";
					dynmap_urlpars +='method=DELETE_OBJECT&args='+this.srcObject.svgId;
					var ajx = new Ajax.Request (dynmap_url , {method: 'post', parameters: dynmap_urlpars,onComplete:this.initEnd, objetLie:this} );

				}else{
					rootNode.getElementById(this.srcObject.svgId).setAttribute("d",this.srcObject.getAttribute("d"));
				}

				this.showed = 0;
				return;
			}

			var newNode  = parseXMLfunction(res.responseText);

			svgdoc.getElementById("options").appendChild(newNode);

			var newObject = rootNode.getElementById("Object_draw_1");

			this.destObject = new SVGobject({svgRoot:newObject});

			rootNode.getElementById(this.srcObject.svgId).setAttribute("d",this.destObject.getAttribute("d"));
			rootNode.getElementById("options").removeChild(newObject);
			this._accept();
			//init_selection();
		}
	},
	_accept:function(){

		var co=confirm("Sauvegarder la modification ?");

		if(co){
			var idObj = this.srcObject.svgId;

			var dynmap_urlpars	="path_application="+path_application+"&";
			dynmap_urlpars +='method=MOVE_OBJECT&args='+idObj+'[p]'+getCurrentObject(0,idObj).replace("#","[DIESE]");
			var ajx = new Ajax.Request (dynmap_url , {method: 'post', parameters: dynmap_urlpars,onComplete:this.initEnd, objetLie:this} );

		}else{
			var svgdoc=document.svgmap.getSVGDocument();
			var rootNode = svgdoc;
			rootNode.getElementById(this.srcObject.svgId).setAttribute("d",this.srcObject.getAttribute("d"));
		}

		this.showed = 0;
		
		       
	}
}

