
var GSMAP_INFOBULL = 108;
var GSMAP_PHOTO = 109;
var GSMAP_PRINT = 110;

//Extension de la classe gsMapTools
gsMapTools.implement({

/*  Function: zoomScale
        Zoom par Echelle
    */
	zoomScale: function(echelle){
        this.map.newExtent.toScale(1/echelle, this.map.srcExtent);
        this.map.draw();
	},
    sendActionToMap : function(query){
        this.map.draw(query);
    },
    affinfoBulle : function () {
        this.setMode(GSMAP_INFOBULL);
		  this.setCursor("default", "help.cur");
        //this.setCursor(GSMAP_INFOBULL);
    },
    affCadrePrint : function () {
        this.setMode(GSMAP_PRINT);
	},
	
	
  sendX_Load: function(param){
  	GSMAP_SEND_XLOAD = true ;
		this.query = param;
		this.sendDraw();
  	GSMAP_SEND_XLOAD = false ;
 	},	  
	sendDraw: function(){
  	for(var lr=0;lr<this.map.layers.length;lr++){
  		this.map.layers[lr].addQuery(this.query);
  	}
  	this.map.draw();
	}
	,
  // affiche la liste des menus sélections
  affMenuSelection : function () {
		if($('adminSelListProfil')) return;
  	var debId = 14;
  	if(!$('navselection')) {
	  	aL = getOffset('sub7','offsetLeft');
	  	aT = getOffset('sub7','offsetTop');
			aH = $('sub7').offsetHeight;
			aW = $('sub7').offsetWidth;
	  	var divSel = createAndAppend('div',document.body,true);
	  	divSel.id = 'navselection';
	  	divSel.style.display = 'block';
	  	divSel.onmousemove = function(){
	  		divSel.style.display = 'block';
	  	}
      divSel.style.zIndex = 200;
	  	divSel.style.position = 'absolute';
	  	//divSel.style.top = aT+aH+1;
	  	divSel.style.top = aT+aH;
	  	divSel.style.left = aL;				
			divSel.style.overflow = 'hidden';				
	  	divSel.style.width = aW;
	  	var ulL = createAndAppend('ul',divSel,true);	
	  	// sélection par cercle
	  	var l1 = createAndAppend('li',ulL,true);
	  	var a1 = createAndAppend('a',l1,true);
	  	a1.id = 'sub'+debId;
	  	a1.style.backgroundImage = "url(images/nav/sub72f.png)";
	  	a1.onmouseover = function(){
	  		a1BgBefore = a1.style.backgroundImage;
	  		a1BgAfter = a1BgBefore.replace(/f/,"n");
	  		a1.style.backgroundImage = a1BgAfter;
	  	}
	  	a1.onmouseout = function(){
	  		setBgToBlue(a1.id);
	  	}
	  	a1.onclick = function() {
	  		sub8Bg = $('sub7').style.backgroundImage;
	  		currBg = this.style.backgroundImage;
	  		$('sub7').style.backgroundImage = currBg;
	  		$('sub14').style.backgroundImage = sub8Bg;
				switchMenu('navselection');
				contraireNavCurrent('sub',7,16);
	  		swithNavselection();
	  	}
	  	
	  	// sélection par polygone
	  	var l4 = createAndAppend('li',ulL,true);
	  	var a2 = createAndAppend('a',l4,true);
	  	a2.style.backgroundImage = "url(images/nav/sub73f.png)";
	  	a2.id = 'sub'+(debId+1);
	  	a2.onmouseover = function(){
	  		a2BgBefore = a2.style.backgroundImage;
	  		a2BgAfter = a2BgBefore.replace(/f/,"n");
	  		a2.style.backgroundImage = a2BgAfter;
	  	}
	  	a2.onmouseout = function(){
	  		setBgToBlue(a2.id);
	  	}
	  	a2.onclick = function() {
	  		sub8Bg = $('sub7').style.backgroundImage;
	  		currBg = this.style.backgroundImage;
	  		$('sub7').style.backgroundImage = currBg;
	  		$('sub15').style.backgroundImage = sub8Bg;
				switchMenu('navselection');
				contraireNavCurrent('sub',7,16);
	  		swithNavselection();
	  	}
			
			// sélection par rectangle
	  	var l5 = createAndAppend('li',ulL,true);
	  	var a3 = createAndAppend('a',l5,true);
	  	a3.style.backgroundImage = "url(images/nav/sub71f.png)";
	  	a3.id = 'sub'+(debId+2);
	  	a3.onmouseover = function(){
	  		a3BgBefore = a3.style.backgroundImage;
	  		a3BgAfter = a3BgBefore.replace(/f/,"n");
	  		a3.style.backgroundImage = a3BgAfter;
	  	}
	  	a3.onmouseout = function(){
	  		setBgToBlue(a3.id);
	  		
	  	}
	  	a3.onclick = function() {
	  		sub8Bg = $('sub7').style.backgroundImage;
	  		currBg = this.style.backgroundImage;
	  		$('sub7').style.backgroundImage = currBg;
	  		$('sub16').style.backgroundImage = sub8Bg;
				switchMenu('navselection');
				contraireNavCurrent('sub',7,16);
	  		swithNavselection();
	  	}
  	}else {
  			switchMenu('navselection');
  	}
  },
  affMenuMeasure : function(){
  	if(!$('navmeasure2')) {
  		aL = getOffset('sub9','offsetLeft');
	  	aT = getOffset('sub9','offsetTop');
			aH = $('sub9').offsetHeight;
			aW = $('sub9').offsetWidth;
	  	var divSel = createAndAppend('div',document.body,true);
	  	divSel.id = 'navmeasure2';
	  	//divSel.style.border ='black 1px solid';
	  	divSel.style.display = 'block';
      divSel.style.zIndex = 200;
	  	divSel.style.position = 'absolute';
	  	divSel.style.top = aT+aH;
	  	divSel.style.left = aL;				
			divSel.style.overflow = 'hidden';				
	  	divSel.style.width = aW;
	  	divSel.style.height = aH;
	  	$('sub9').style.backgroundImage = "url(images/nav/sub9f.png)"
	  	var ulL = createAndAppend('ul',divSel,true);
	  	var l1 = createAndAppend('li',ulL,true);
	  	var lien = createAndAppend('a',l1,true);
	  	lien.id ='sub13';
	  	lien.style.backgroundImage = "url(images/nav/sub13f.png)";
	  	lien.onmouseover = function(){
	  		lienBgBefore = lien.style.backgroundImage;
	  		lienBgAfter = lienBgBefore.replace(/f/,"n");
	  		lien.style.backgroundImage = lienBgAfter;
	  	}
	  	lien.onmouseout = function(){
	  		setBgToBlue(lien.id);
	  	}
	  	lien.onclick = function() {
	  		sub9Bg = $('sub9').style.backgroundImage;
	  		sub13Bg = $('sub13').style.backgroundImage;
	  		$('sub9').style.backgroundImage = sub13Bg;
	  		$('sub13').style.backgroundImage = sub9Bg;
	  		swithNavmeasure();
	  		contraireNavCurrent('sub',9,16);
	  		switchMenu('navmeasure2');
	  	}
  	}else{
  		switchMenu('navmeasure2');
  	}
  }
 
});

/*  Class: gsMap.implement
        surcharge de la classe gsMap pour faciliter l'appel des outils
    */
gsMap.implement({
	zoomScale: function(echelle) {this.tool.zoomScale(echelle);},
	affinfoBulle: function() {this.tool.affinfoBulle();},
	affCadrePrint: function() {this.tool.affCadrePrint();},
	affMenuSelection: function() {this.tool.affMenuSelection();},
	affMenuMeasure: function() {this.tool.affMenuMeasure();},
	sendX_Load : function(param) {this.tool.sendX_Load(param);},
	sendDraw : function() {this.tool.sendDraw();}
});
