//<![CDATA[
gmapNQ = 
{
		map_id : '',
		map : null,	
		geocoder : null,
		cursorScroll_id : "",
		fondScroll_id : "",
		max_zoom : 18,
		min_zoom : 1,
		directions : null,
		iconMacDo : null,
		iconTotal : null,
		iconPlan : null,
		controlTrafic : null,
		trafficInfo : null,
		markerTraffic : [],
		dragZoomControl : null,
		controlMeteo : null,
		markerMeteo : [],
		stylesIconeRegroup : [],
		markerLieuInteret : [],
		logoSupprLieuInteret : [],
		
		controlReperageDiv : false,
		elementChange : 0,
		premiereOuverture : true,
		etapeBulleZoom : 0 ,
		control_premierePassage : true,
		
		
		dragZoom : null,
		controlDragZoom : false, 
		dragZoomButtonID : null ,
		markerControlHTML : false,
		controlDeplacement: false,
		controlZoomImpression: false,
		
		layers : [{ name: "Pano", obj: new GLayer("com.panoramio.all") },{ name: "Tube", obj: new GLayer("com.youtube.all") },{ name: "Wiki", obj: new GLayer("org.wikipedia.en") },{ name: "Cams", obj: new GLayer("com.google.webcams") }],

		
//-----------------------------------------------------------------------------------------------------------------------------------------------	
//---------------------------------------------------Initialisations (icone, map, controlleur config)--------------------------------------------
//-----------------------------------------------------------------------------------------------------------------------------------------------
		init_icone : function()
		{
			
			
		/*	gmapNQ.iconWifi = new GIcon();
			gmapNQ.iconWifi.image = "../../images/images_icone/wifi.png";
			//icon.shadow = "images/ombre_1.png";
			gmapNQ.iconWifi.iconSize = new GSize(28, 30);
			//icon.shadowSize = new GSize(34, 30);
			gmapNQ.iconWifi.iconAnchor = new GPoint(10, 29);
			gmapNQ.iconWifi.infoWindowAnchor = new GPoint(120, 10);	
			
			
			gmapNQ.markerLieuInteret = [null,gmapNQ.iconMacDo,gmapNQ.iconCourtepaille,gmapNQ.iconF1,gmapNQ.iconWifi,gmapNQ.iconStarbuck,null,gmapNQ.iconAgip,gmapNQ.iconAvia,gmapNQ.iconBp,null,null,null,gmapNQ.iconEsso,null,gmapNQ.iconShell,gmapNQ.iconTotal,17,gmapNQ.iconElf];
			
			gmapNQ.logoSupprLieuInteret = [null,"images/logo/mac_suppr.png","images/logo/courtepaille_suppr.png","images/logo/f1_suppr.png","images/logo/wifi_suppr.png","images/logo/startbuck_suppr.png",null,"images/logo/agip_suppr.png","images/logo/avia_suppr.png",null,null,null,null,"images/logo/esso_suppr.png",null,"images/logo/self_suppr.png","images/logo/total_suppr.png",17,"images/logo/elf_suppr.png"];*/
			
			
		

			
			//style icone regrouper----------------
			gmapNQ.stylesIconeRegroup[1] = [{
					url: '../../images/images_icone/mac_do_regroup.png',
					width: 45,
					height: 50,
					opt_anchor: [35, 4],
					opt_textColor: '#000000'
				  },
				  {
					url: '../../images/images_icone/mac_do_regroup.png', 
					width: 45,
					height: 50,
					opt_anchor: [35, 4],
					opt_textColor: '#000000'
				  },
				  {
					url: '../../images/images_icone/mac_do_regroup.png',
				   width: 45,
					height: 50,
					opt_anchor: [35, 4],
					opt_textColor: '#000000'
				  },
				  {
					url: '../../images/images_icone/mac_do_regroup.png', 
					width: 45,
					height: 50,
					opt_anchor: [35, 4],
					opt_textColor: '#000000'
				  },
				  {
					url: '../../images/images_icone/mac_do_regroup.png',
					width: 45,
					height: 50,
					opt_anchor: [35, 4],
					opt_textColor: '#000000'
				  }];
			

			
		},
		
		set : function (map) 
		{
			 gmapNQ.map = map;
			 gmapNQ.init_icone();
		},
		
		init : function (id_map) 
		{
			
			gmapNQ.map_id = id_map;
			
			try
			{
				
				gmapNQ.map = new google.maps.Map2(document.getElementById(gmapNQ.map_id), {backgroundColor:"#9CB2CE"});
				
				gmapNQ.map.setCenter(new GLatLng(45.4673, 5.9951), 4);
				
				GEvent.addListener(gmapNQ.map, 'zoomend', function(oldLevel, newLevel) {
					gmapNQ.placeCursorScroll(newLevel);
					gmapNQ.gestionZoomMarkerDiv();
					gmapNQ.gestionZoomImpression(gmapNQ.map.getZoom());
					
					
					
					//gmapNQ.map.setCenter(new GLatLng(gmapNQ.map.getCenter().lat()-0.02,gmapNQ.map.getCenter().lng()),newLevel);
				});
				
				
				gmapNQ.map.setMapType(G_HYBRID_MAP);
				
				
				GEvent.addListener(gmapNQ.map, 'extinfowindowopen', function(){
		
					$("#custom_info_window_red").parent().css("zIndex",999999);
				
				});
				
				
			}
			catch(e)
			{
				utilsNQ.debug("Une erreur a été detecter sur l'initialisation de la Gmap (class gmapNQ)",e)
			}
			
		

		},

//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------

	desactiveDragZoom : function ()
	{
		
	},



//-----------------------------------------------------------------------------------------------------------------------------------------------	
//---------------------------------------------------------config controlleurs map-----------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------
		configZoomControl : function (id_zoom_plus, id_zoom_moins)
		{
			
				//YAHOO.util.Event.addListener(id_zoom_plus, 'click', function(e) { gmapNQ.zoom('plus'); });
				$("#"+id_zoom_plus).click(function(e) {gmapNQ.zoom('plus');});
				//YAHOO.util.Event.addListener(id_zoom_moins, 'click', function(e) { gmapNQ.zoom('moins'); });
				$("#"+id_zoom_moins).click(function(e) {gmapNQ.zoom('moins'); });
		},
		
		configDeplaControl : function (id_gauche_depla,id_haut_depla,id_droite_depla,id_bas_depla)
		{
				//YAHOO.util.Event.addListener(id_droite_depla, 'click', function(e) { gmapNQ.deplace('right'); });
				$("#"+id_droite_depla).click(function(e) {gmapNQ.deplace('right');});
				//YAHOO.util.Event.addListener(id_gauche_depla, 'click', function(e) { gmapNQ.deplace('left'); });
				$("#"+id_gauche_depla).click(function(e) {gmapNQ.deplace('left');});
				//YAHOO.util.Event.addListener(id_haut_depla, 'click', function(e) { gmapNQ.deplace('up'); });
				$("#"+id_haut_depla).click(function(e) {gmapNQ.deplace('up');});
				//YAHOO.util.Event.addListener(id_bas_depla, 'click', function(e) { gmapNQ.deplace('down'); });
				$("#"+id_bas_depla).click(function(e) {gmapNQ.deplace('down');});
		},
		
		configTypeControl : function (id_sat,id_physic,id_hybride,id_normal, id_trafic, id_meteo, dragZoomButton)
		{
			
				if(id_sat != null ){
					//YAHOO.util.Event.addListener(id_sat, 'click', function(e) { gmapNQ.changeType('sattellite'); });
					//$("#"+id_sat).click(function(e) {gmapNQ.changeType('sattellite');});
					$("#"+id_sat).click(function(e) {gmapNQ.changeType('hybride');});
					
				};
				if(id_physic != null ){
					//YAHOO.util.Event.addListener(id_physic, 'click', function(e) { gmapNQ.changeType('physic'); });
					$("#"+id_physic).click(function(e) {gmapNQ.changeType('physic');});
				};
				if(id_hybride != null ){
					//YAHOO.util.Event.addListener(id_hybride, 'click', function(e) { gmapNQ.changeType('hybride'); });
					$("#"+id_hybride).click(function(e) {gmapNQ.changeType('hybride');});
				};
				if(id_normal != null ){
					//YAHOO.util.Event.addListener(id_normal, 'click', function(e) { gmapNQ.changeType('normal'); });
					$("#"+id_normal).click(function(e) {gmapNQ.changeType('normal');});
				};
				if(id_trafic != null ){
					//YAHOO.util.Event.addListener(id_trafic, 'click', function(e) {  gmapNQ.afficheTrafic(); });
					$("#"+id_trafic).click(function(e) { gmapNQ.afficheTrafic();});
				};
				if(id_meteo != null ){
					//YAHOO.util.Event.addListener(id_meteo, 'click', function(e) {  gmapNQ.afficheMeteo(); });
					$("#"+id_meteo).click(function(e) {gmapNQ.afficheMeteo();});
				};
				if(dragZoomButton != null ){
					//YAHOO.util.Event.addListener(dragZoomButton, 'click', function(e) {  gmapNQ.dragZoomControlleur(); });
					$("#"+dragZoomButton).click(function(e) {gmapNQ.dragZoomControlleur();});
				};
				gmapNQ.dragZoomButtonID  = dragZoomButton;
			
		},
		
		configScrollZoomControl : function(id_scroll, id_fond)
		{

				gmapNQ.cursorScroll_id = id_scroll;
				gmapNQ.fondScroll_id = id_fond;
				gmapNQ.placeCursorScroll(-1);
				//YAHOO.util.Event.addListener(gmapNQ.fondScroll_id, 'click', gmapNQ.clickFond);
				$("#"+gmapNQ.fondScroll_id).click(gmapNQ.clickFond);

		},
		
	
//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------




//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------zoom-----------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------
	

	
		clickFond : function(e) 
		{ 
			try
			{
			
				//var t_reg_fond = Dom.getRegion(gmapNQ.fondScroll_id);
			   var hauteur_fond = $("#"+gmapNQ.fondScroll_id).height();
			   
			   var position = $("#"+gmapNQ.fondScroll_id).position();
			  var positionOutils =  $("#toolboxJaugeGlobal").position();
			    var positionMap =  $("#map_flash").position();
			  
			   
			   var bord_haut_fond = position.top+positionOutils.top+positionMap.top;
			   
			   var bord_haut_curseur= null ; 
			  if(typeof(e.pageY) != 'undefined')
			  {
			   	bord_haut_curseur = e.pageY;
			  }
			  else
			  {
				  bord_haut_curseur = e.clientY;
			  }
			   
			
			   var delta = (hauteur_fond)-(parseInt(bord_haut_curseur) - parseInt(bord_haut_fond));
			   
			   var zoomSuiv = Math.abs(delta *gmapNQ.max_zoom / hauteur_fond);
		   		//alert(bord_haut_fond+"   "+bord_haut_curseur);
				
				
					gmapNQ.map.setZoom(parseInt(zoomSuiv));
					gmapNQ.placeCursorScroll(parseInt(zoomSuiv));	
				
					
				
				
			}
			catch(e)
			{
				utilsNQ.debug("Une erreur a été detecter le calcul du zoom quand on clique sur le scroll de la carte (class gmapNQ)",e)
			}
		},
		
		placeCursorScroll : function(zoomParticulier)
		{
			try
			{
				if(gmapNQ.cursorScroll_id != ''){
					var zoomEncour = 0;
					if(zoomParticulier == -1)
					{
						zoomEncour = gmapNQ.map.getZoom();
					}
					else
					{
						zoomEncour = zoomParticulier;
					}
					if(zoomEncour > 17){
						zoomEncour = 18;
					}
					if(typeof(importNQ) != 'undefined' && typeof(importNQ.gestionMarkerZoom) == 'function'  ){
						importNQ.gestionMarkerZoom(zoomEncour); 
					}
						//var t_reg_fond = Dom.getRegion(gmapNQ.fondScroll_id);
						
						var hauteurFond = $("#"+gmapNQ.fondScroll_id).height();
						
						var hauteurJauge = (hauteurFond/gmapNQ.max_zoom)*zoomEncour;
						var hauteurInverse = (hauteurFond-hauteurJauge);
						//Dom.setStyle(gmapNQ.cursorScroll_id,'height',hauteurJauge+'px');
						$("#"+gmapNQ.cursorScroll_id).css('backgroundPosition',"0pt "+hauteurInverse+"px");
				}
				
			}
			catch(e)
			{
				utilsNQ.debug("Une erreur a été detecter durant l'affectation d'un zoom nouveau au scroll (class gmapNQ)",e)
			}
			
		},
		
		zoom :function (type)
		{
			try
			{
			
					if(type == 'plus'  )
					{
						gmapNQ.map.zoomIn();
						
					}
					if(type == 'moins')
					{
						gmapNQ.map.zoomOut();
					}
					
					
			
			}
			catch(e)
			{
				utilsNQ.debug("Une erreur a été detecter durant le zoom sur la carte (class gmapNQ)",e)
			}
			
				gmapNQ.placeCursorScroll(-1);
			
		},
		
		gestionZoomImpression : function(zoom){
			
			if(gmapNQ.controlZoomImpression){
					if(gmapNQ.map.getZoom() > 17){
						gmapNQ.map.setZoom(17);
					}
			}
			
		},
//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------




		
//-----------------------------------------------------------------------------------------------------------------------------------------------	
//----------------------------------------------------------deplacemùent map controlleur-----------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------
		deplace : function (type)
		{
			try
			{
				switch(type)
				{
					case 'up':
						deplacement = new GSize(0,100);
						break;
					case 'down':
						deplacement = new GSize(0,-100);
						break;
					case 'left':
						deplacement = new GSize(100,0);
						break;
					case 'right':
						deplacement = new GSize(-100,0);
						break;
				}
				gmapNQ.map.panBy(deplacement);
			}
			catch(e)
			{
				utilsNQ.debug("Une erreur a été detecter durant le deplacement de la carte (class gmapNQ)",e)
			}
			
		},
//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------



//-----------------------------------------------------------------------------------------------------------------------------------------------	
//--------------------------------------------------type map controleur--------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------
		changeType : function (type)
		{
			try
			{
				switch(type)
				{
					case 'hybride':
						gmapNQ.map.setMapType(G_HYBRID_MAP);
						break;
					case 'normal':
						gmapNQ.map.setMapType(G_NORMAL_MAP);
						break;
					case 'sattellite':
						gmapNQ.map.setMapType(G_SATELLITE_MAP);
						//G_SATELLITE_3D_MAP
						break;
					case 'physic':
						gmapNQ.map.setMapType(G_PHYSICAL_MAP);
						break;
				}
			}
			catch(e)
			{
				utilsNQ.debug("Une erreur a été detecter durant le changement de type de la carte (class gmapNQ)",e)
			}
		},
//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------



//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------------------layout photo, wiki, webcam...---------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------
//gmapNQ.switchLayer(true, gmapNQ.layers[0].obj)
switchLayer : function(checked, layer) 
{
		
	 if(checked) {
	  gmapNQ.map.addOverlay(layer);
	 }
	 else {
	  gmapNQ.map.removeOverlay(layer);
	 }

},


ajoutMarkerDiv : function(lat,long,ico){
	
		
	/*var div  = document.createElement("div");
	div.id = "monmarkerDiv";
	div.title = lat+","+long;
	div.style.position = "absolute";
	
	var pos = gmapNQ.map.fromLatLngToDivPixel(new GLatLng(lat,long));
	
	pos.x -= parseInt(div.style.width / 2, 10);
	pos.y -= parseInt(div.style.height / 2, 10);
		
	div.style.left = pos.x+"px";
	div.style.top = pos.y+"px";
	
	div.innerHTML = html+'<div title ="'+lat+','+long+'" id="monmarkerDivClick" onclick="" style="position:absolute;width:100%;height:100%;top:0px;left:0px;z-index:10000000;">&nbsp;</div>';
	
	
	 gmapNQ.map.getPane(G_MAP_MAP_PANE).appendChild(div);
	 gmapNQ.map.markerControlHTML = true;*/
	 var kicon = new GIcon();
			kicon.image = ico.img;
			kicon.iconSize = new GSize(ico.w,ico.h);
			kicon.shadowSize= new GSize(0,0);
			kicon.iconAnchor = new GPoint(13, 22);
			kicon.infoWindowAnchor = new GPoint(95,5);
	
	var kmlMarker = new GMarker(new GLatLng(lat,long), {icon:kicon});
	kmlMarker.info = ico.texte;

	gmapNQ.map.addOverlay(kmlMarker);
	
	GEvent.addListener(kmlMarker, 'click', function() {
			var strChUserAgent = navigator.userAgent;
			 var intSplitStart = strChUserAgent.indexOf("(",0);
			 var intSplitEnd = strChUserAgent.indexOf(")",0);
			 var strChStart = strChUserAgent.substring(0,intSplitStart);
			 var strChMid = strChUserAgent.substring(intSplitStart, intSplitEnd);
			 var strChEnd = strChUserAgent.substring(strChEnd);
			
			  var ie = false ;
			 if(strChMid.indexOf("MSIE") != -1)
			 ie = true; 
			
			
			var bulleHTML = '<div class="infosBox2 '+((ie == true)?'':'border')+'"><div class="close"  onclick="gmapNQ.map.closeExtInfoWindow();"></div><table border="0" cellspacing="0" cellpadding="0" width="100%"><tr><td style="padding: 14px 10px 14px 10px;" align="center">'+this.info+'</td></tr></table></div>';
			this.openExtInfoWindow(gmapNQ.map,"custom_info_window_red",bulleHTML,{beakOffset: 3}); 
	}); 
	 
	 
},

gestionZoomMarkerDiv : function(){
	if(gmapNQ.map.markerControlHTML){
		var div  = document.getElementById('monmarkerDiv');
		var latLong = div.title.split(',');
		var pos = gmapNQ.map.fromLatLngToDivPixel(new GLatLng(latLong[0],latLong[1]));	
		div.style.left = pos.x+"px";
		div.style.top = pos.y+"px";
	}
},


placeVousEteIci : function(lat,long,offset){
		var kicon = new GIcon();
		kicon.image = "/sd_img/integre/compte/map_pointer.png";
		kicon.iconSize = new GSize(90,90);
		kicon.shadowSize= new GSize(0,0);
		kicon.iconAnchor = new GPoint(45, 45);
		kicon.infoWindowAnchor = new GPoint(parseInt(10), parseInt(10));
		var marker = new GMarker(new GLatLng(lat,long), {icon:kicon});
		
		gmapNQ.map.addOverlay(marker);
		gmapNQ.map.setCenter(new GLatLng(lat,(long+offset)),10)
}
		

//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------	
//-----------------------------------------------------------------------------------------------------------------------------------------------
		
};
//]]>

