﻿
			function loadgmap(indexItem ,videoDatas,source) {
				//document.getElementById('map').innerHTML='<img src="/media/v2/images/carte.png" alt="" title=""/>';
				//return;
				ProvinceNumero=videoDatas.items[indexItem].state;
				if (GBrowserIsCompatible()) {
					
			        var map = new GMap2(document.getElementById("map"));
					map.addControl(new GLargeMapControl());
					
								if ( ProvinceNumero == 1 ) { map.setCenter(new GLatLng(51,3.1), 9); }
 
								if ( ProvinceNumero == 2 ) { map.setCenter(new GLatLng(51,3.7), 9); }
 
								if ( ProvinceNumero == 3 ) { map.setCenter(new GLatLng(51.2,4.6), 9); }
 
								if ( ProvinceNumero == 4 ) { map.setCenter(new GLatLng(51,5.5), 9); }
 
								if ( ProvinceNumero == 5 ) { map.setCenter(new GLatLng(50.5,5.65), 9); }
 
								if ( ProvinceNumero == 6 ) { map.setCenter(new GLatLng(49.85,5.3), 9); }
 
								if ( ProvinceNumero == 7 ) { map.setCenter(new GLatLng(50.3,4.9), 9); }
 
								if ( ProvinceNumero == 8 ) { map.setCenter(new GLatLng(50.45,4), 9); }
 
								if ( ProvinceNumero == 9 ) { map.setCenter(new GLatLng(50.95,4.6), 9); }
 
								if ( ProvinceNumero == 10 ) { map.setCenter(new GLatLng(50.65,4.6), 9); }
 
								if ( ProvinceNumero == 11 ) { map.setCenter(new GLatLng(50.8,4.35), 9); }
 
					//map.addControl(new GOverviewMapControl());
					var baseIcon = new GIcon();
					baseIcon.shadow = "/media/images/MapAPIMarkerShadow.png";
					baseIcon.shadowSize = new GSize(24,17);
					baseIcon.iconAnchor = new GPoint(0,0);
					baseIcon.infoWindowAnchor = new GPoint(9,2);
					baseIcon.infoShadowAnchor = new GPoint(0,0);		
					
					function createMarker(point, index, texte, CusNum,idVideo,source,host,lng,total,mainid,vids) {  
					
						baseIcon.iconSize = new GSize(24,17);
						var letteredIcon = new GIcon(baseIcon);  
						
						if (idVideo!=mainid) letteredIcon.image = "/media/images/MapAPIMarker.png"; else letteredIcon.image = "/media/images/MapAPIMarkerOne.png";
						markerOptions = { icon:letteredIcon , title:texte};
						var marker = new GMarker(point, markerOptions);  
						//GEvent.addListener(marker, "click", function() { 
							//window.location.href=host+'/'+lng+'/mapVideo?id='+idVideo+'&section='+source+'&limit='+total;
							//map_list(source,vids,index);
						//});
						//alert(marker);
						return marker;
					}
					
					//ajout du point de la video
					var pindex=0;
					var total=videoDatas.totalVideos;
					if (!total) total=29;
					
					//récupération des videos de la région
					
					var videos2 = null;
					/*if (source>-1)
					{
					videos2 = $.ajax({
  					url: "/"+lng+"/getMap",
					data: 'closet='+videoDatas.items[indexItem].id+'&source='+source+'&lang='+lng+'&page=0&limit=29',
  					async: false
 					}).responseText;
					}
					else
					{
					videos2 = $.ajax({
  					url: "/"+lng+"/getMap",
					data: 'closet='+videoDatas.items[indexItem].id+'&lang='+lng+'&page=0&limit=29',
  					async: false
 					}).responseText;
					}*/
					
					eval('videos2='+videos2+';');

				//alert(videoDatas.items[indexItem].latitude);

				var point = new GLatLng(videoDatas.items[indexItem].latitude, videoDatas.items[indexItem].longitude);


				if (videoDatas.items[indexItem].latitude!=null) {
					map.addOverlay(createMarker(point,pindex,videoDatas.items[indexItem].customerName,videoDatas.items[indexItem].customerId,videoDatas.items[indexItem].id,source,host,lng,total,videoDatas.items[indexItem].id,videos2));
					
					map.setCenter(point, 9);
				}										
						/*for(i=0;i<videos2.items.length;i++)
						{
							if (videos2.items[i].id!=videoDatas.items[indexItem].id) 
							{
								
								var point = new GLatLng(videos2.items[i].latitude, videos2.items[i].longitude);
								map.addOverlay(createMarker(point,i,videos2.items[i].customerName,videos2.items[i].customerId,videos2.items[i].id,source,host,lng,total,videoDatas.items[indexItem].id,videos2));
							}
						}*/
					
					
					if ((source==-1)||(videoDatas.items[indexItem].keywords==null)) {
						if (videoDatas.items[indexItem].keywords==null)
							$('#GoogleApiMap').css('margin-left','166px');
						else
							$('#GoogleApiMap').css('margin-left','0px');
					}
					else
					{
						$('#GoogleApiMap').css('margin-left','0px');
					}
					
				
						
						
				}
			}
			
			function loadgmapfull(indexItem ,videoDatas,source) {
				
				//document.getElementById('map').innerHTML='<img src="/media/v2/images/carte.png" alt="" title=""/>';
				//return;
				ProvinceNumero=videoDatas.items[indexItem].state;
				if (GBrowserIsCompatible()) {
					
			        var map = new GMap2(document.getElementById("map"));
					map.addControl(new GLargeMapControl());
					
								if ( ProvinceNumero == 1 ) { map.setCenter(new GLatLng(51,3.1), 9); }
 
								if ( ProvinceNumero == 2 ) { map.setCenter(new GLatLng(51,3.7), 9); }
 
								if ( ProvinceNumero == 3 ) { map.setCenter(new GLatLng(51.2,4.6), 9); }
 
								if ( ProvinceNumero == 4 ) { map.setCenter(new GLatLng(51,5.5), 9); }
 
								if ( ProvinceNumero == 5 ) { map.setCenter(new GLatLng(50.5,5.65), 9); }
 
								if ( ProvinceNumero == 6 ) { map.setCenter(new GLatLng(49.85,5.3), 9); }
 
								if ( ProvinceNumero == 7 ) { map.setCenter(new GLatLng(50.3,4.9), 9); }
 
								if ( ProvinceNumero == 8 ) { map.setCenter(new GLatLng(50.45,4), 9); }
 
								if ( ProvinceNumero == 9 ) { map.setCenter(new GLatLng(50.95,4.6), 9); }
 
								if ( ProvinceNumero == 10 ) { map.setCenter(new GLatLng(50.65,4.6), 9); }
 
								if ( ProvinceNumero == 11 ) { map.setCenter(new GLatLng(50.8,4.35), 9); }
 
					//map.addControl(new GOverviewMapControl());
					var baseIcon = new GIcon();
					baseIcon.shadow = "/media/images/MapAPIMarkerShadow.png";
					baseIcon.shadowSize = new GSize(24,17);
					baseIcon.iconAnchor = new GPoint(0,0);
					baseIcon.infoWindowAnchor = new GPoint(9,2);
					baseIcon.infoShadowAnchor = new GPoint(0,0);		
					
					function createMarker(point, index, texte, CusNum,idVideo,source,host,lng,total,mainid,vids) {  
					
						baseIcon.iconSize = new GSize(24,17);
						var letteredIcon = new GIcon(baseIcon);  
						
						if (idVideo!=mainid) letteredIcon.image = "/media/images/MapAPIMarker.png"; else letteredIcon.image = "/media/images/MapAPIMarkerOne.png";
						markerOptions = { icon:letteredIcon , title:texte};
						var marker = new GMarker(point, markerOptions);  
						GEvent.addListener(marker, "click", function() { 
							//window.location.href=host+'/'+lng+'/mapVideo?id='+idVideo+'&section='+source+'&limit='+total;
							map_list(source,vids,index);
							swapVideo(index);
						});
						//alert(marker);
						return marker;
					}
					
					//ajout du point de la video
					var pindex=0;
					var total=videoDatas.totalVideos;
					if (!total) total=29;
					
					//récupération des videos de la région
					//$('#map').html('<img id="waitmap" src="/media/v2/images/ajax-loader.gif"/>');

					//$('#waitmap').css('display','block');
					
					var videos2 = null;
					if (source>-1)
					{
					videos2 = $.ajax({
  					url: "/"+lng+"/getMap",
					data: 'closet='+videoDatas.items[indexItem].id+'&source='+source+'&lang='+lng+'&page=0&limit=29',
  					async: false
 					}).responseText;
					}
					else
					{
					videos2 = $.ajax({
  					url: "/"+lng+"/getMap",
					data: 'closet='+videoDatas.items[indexItem].id+'&lang='+lng+'&page=0&limit=29',
  					async: false
 					}).responseText;
					}

					eval('videos2='+videos2+';');

				//alert(videoDatas.items[indexItem].latitude);

				var point = new GLatLng(videoDatas.items[indexItem].latitude, videoDatas.items[indexItem].longitude);

				if (videoDatas.items[indexItem].latitude!=null) {
					map.addOverlay(createMarker(point,pindex,videoDatas.items[indexItem].customerName,videoDatas.items[indexItem].customerId,videoDatas.items[indexItem].id,source,host,lng,total,videoDatas.items[indexItem].id,videos2));
					
					map.setCenter(point, 9);
				}										
						for(i=0;i<videos2.items.length;i++)
						{
							if (videos2.items[i].id!=videoDatas.items[indexItem].id) 
							{
								
								var point = new GLatLng(videos2.items[i].latitude, videos2.items[i].longitude);
								map.addOverlay(createMarker(point,i,videos2.items[i].customerName,videos2.items[i].customerId,videos2.items[i].id,source,host,lng,total,videoDatas.items[indexItem].id,videos2));
							}
						}
					//return;
					//$('#waitmap').css('display','none');
					
					if ((source==-1)||(videoDatas.items[indexItem].keywords==null)) {
						if (videoDatas.items[indexItem].keywords==null)
							$('#GoogleApiMap').css('margin-left','166px');
						else
							$('#GoogleApiMap').css('margin-left','0px');
					}
					else
					{
						$('#GoogleApiMap').css('margin-left','0px');
					}
					
				
						
						
				}
			}

