
var Secteur = {
	lists: [
		{ name: "acheux-en-amienois", color: "#f27e00", points: [[49.990172,2.604446],[49.959437,2.502136],[49.96805,2.506943],[50.006856,2.48497],[50.033768,2.460251],[50.055904,2.412186],[50.125245,2.449608],[50.1241,2.449265],[50.127226,2.453384],[50.084067,2.657661],[50.045764,2.662125],[50.037738,2.633286],[50.028917,2.596893],[49.994145,2.59552],[49.990084,2.605133],[49.992115,2.595863],[49.99057,2.603416]] }, 
		{ name: "albert", color: "#0084b8", points: [[50.027637,2.597237],[50.042853,2.661438],[50.029402,2.707443],[49.994542,2.709846],[49.979532,2.652512],[49.992997,2.598953],[50.027637,2.597237]] }, 
		{ name: "amiens", color: "#000000", points: [[49.937168,2.241898],[49.925676,2.272797],[49.92435,2.291336],[49.926914,2.309875],[49.923466,2.328415],[49.917188,2.339401],[49.907991,2.344894],[49.898615,2.369614],[49.885344,2.371674],[49.876495,2.366867],[49.867733,2.369614],[49.857464,2.363434],[49.853568,2.347641],[49.859323,2.319489],[49.860651,2.291336],[49.861094,2.270737],[49.851355,2.237091],[49.862422,2.220612],[49.874371,2.215805],[49.891626,2.231598],[49.904453,2.236404],[49.91595,2.244644],[49.930981,2.246704],[49.937168,2.241898]] },
		{ name: "salouel", color: "#00d5d0", points: [[49.875699,2.214432],[49.876584,2.202759],[49.858881,2.166367],[49.846042,2.145081],[49.842057,2.098389],[49.82877,2.06543],[49.819025,2.031784],[49.809897,2.009811],[49.811005,1.963806],[49.791727,1.978569],[49.78685,1.980972],[49.775544,1.984062],[49.772218,1.999512],[49.766897,2.006035],[49.765788,2.012215],[49.761353,2.022171],[49.76184,2.05307],[49.758292,2.081909],[49.748976,2.109375],[49.744983,2.120361],[49.743208,2.133408],[49.741877,2.156067],[49.777806,2.175293],[49.817696,2.213058],[49.848256,2.239151],[49.853126,2.228851],[49.86375,2.216492],[49.871716,2.214432],[49.875699,2.214432]] },
		{ name: "dury", color: "#5405e6", points: [[49.849584,2.240524],[49.777806,2.179413],[49.74232,2.158813],[49.740102,2.182159],[49.743208,2.229538],[49.758292,2.353134],[49.857995,2.313995],[49.858881,2.285843],[49.859323,2.27417],[49.849584,2.240524]] },
		{ name: "boves", color: "#32ee00", points: [[49.857553,2.317429],[49.759179,2.355881],[49.771598,2.487717],[49.788446,2.578354],[49.863307,2.373047],[49.855339,2.364807],[49.851797,2.349701],[49.852683,2.339401],[49.857553,2.317429]] },
		{ name: "villers-bretonneux", color: "#d11348", points: [[49.865077,2.373734],[49.76734,2.632599],[49.874283,2.662811],[49.865077,2.373734]] },
		{ name: "corbie", color: "#a4e000", points: [[49.867866,2.378197],[49.871406,2.519989],[49.873619,2.590027],[49.87561,2.663155],[49.901004,2.668304],[49.971716,2.543335],[49.915154,2.348328],[49.909716,2.348328],[49.899323,2.37133],[49.885831,2.372704],[49.869415,2.37854]] },
		{ name: "bray-sur-somme", color: "#e304e6", points: [[49.991143,2.612],[49.972864,2.544708],[49.902596,2.667618],[49.906311,2.849579],[49.939024,2.850952],[49.961999,2.856445],[49.977015,2.802887],[49.979664,2.752075],[49.997323,2.727356],[49.992379,2.698517],[49.984676,2.671909],[49.982799,2.648563],[49.991143,2.612]] },
		{ name: "rosieres-en-santerre", color: "#a05c00", points: [[49.707786,2.771301],[49.7653,2.632599],[49.902596,2.671051],[49.905249,2.848206],[49.850558,2.831726],[49.820265,2.811127],[49.795627,2.802887],[49.707786,2.771301]] },
		{ name: "combles", color: "#f2180b", points: [[49.999883,2.730789],[49.981784,2.753448],[49.980459,2.8022],[49.964561,2.855759],[49.992379,2.874298],[50.02724,2.885284],[50.078823,2.870865],[50.099089,2.748642],[50.084067,2.657661],[50.042412,2.663498],[50.028475,2.71019],[49.997588,2.710876]] },
		{ name: "villers-bocage", color: "#700e98", points: [[50.038267,2.232285],[49.928328,2.287903],[49.929212,2.307129],[49.92877,2.319489],[49.92435,2.333221],[49.914535,2.342834],[49.938406,2.425919],[49.961381,2.504883],[50.006459,2.491493],[50.034209,2.463684],[50.052995,2.411156],[50.051055,2.324295],[50.038267,2.232285]] },
		{ name: "amiens-ouest", color: "#a05c00", points: [[50.051055,2.324295],[50.038267,2.232285],[49.928328,2.287903],[49.937168,2.241898],[49.930981,2.246704],[49.91595,2.244644],[49.904453,2.236404],[49.891626,2.231598],[49.871716,2.214432],[49.876584,2.202759],[49.858881,2.166367],[49.846042,2.145081],[49.842057,2.098389],[49.82877,2.06543],[49.819025,2.031784],[49.809897,2.009811],[49.811005,1.963806],[49.791727,1.978569],[49.78685,1.980972],[49.775544,1.984062],[49.772218,1.999512],[49.766897,2.006035],[49.765788,2.012215],[49.761353,2.022171],[49.758292,2.081909],[49.748976,2.109375],[49.744983,2.120361],[49.743208,2.133408],[49.741877,2.156067],[49.740102,2.182159],[49.740102,2.182159],[49.743208,2.229538],[49.71116061678412,2.229538],[49.71116061678412,1.891021728515625],[50.13554457352548,1.891021728515625],[50.13554457352548,2.324295]] }, 
		{ name: "amiens-est", color: "#0084b8", points: [[50.051055,2.324295],[50.052995,2.411156],[50.1241,2.449265],[50.084067,2.657661],[50.099089,2.748642],[50.078823,2.870865],[50.02724,2.885284],[49.992379,2.874298],[49.961999,2.856445],[49.939024,2.850952],[49.905249,2.848206],[49.850558,2.831726],[49.820265,2.811127],[49.795627,2.802887],[49.707786,2.771301],[49.7653,2.632599],[49.788446,2.578354],[49.771598,2.487717],[49.758292,2.353134],[49.743208,2.229538],[49.707786,2.229538],[49.707786,3.19976806640625],[50.13554457352548, 3.19976806640625],[50.13554457352548,2.324295]] },
	], 
	/*
	49.928328,2.287903
49.925676,2.272797
	*/
	
	
	
	initialize: function() {
		if ( GBrowserIsCompatible() ) {
			var map = new GMap2(document.getElementById("map_canvas"));
			map.disableDragging();
			map.setCenter(new GLatLng(49.923378,2.545395), 10);
			$.each( this.lists, function( k, v ) {
				var points = [];
				for( var i = 0; i < v.points.length; i ++ ) {
					points[i] = new GLatLng(v.points[i][0],v.points[i][1]);
					/*
					if( v.name == 'villers-bocage' || v.name == 'amiens-ouest' ) {
						var marker=new GMarker(points[i], { title: points[i].lat() + ',' + points[i].lng() });
						
						map.addOverlay(marker);
						GEvent.addListener(marker, "click", function() {
							$("#debug").append( this.getTitle() + "<br>" );
						});
					}*/
					/*
					49.71116061678412, 1.891021728515625
					50.13554457352548, 3.19976806640625
					*/
				}
				
				
				var polygon = new GPolygon(points,v.color, 2, 0, v.color, 0.2);
				map.addOverlay(polygon);
				
				GEvent.addListener(polygon, "mouseover", function(){
					this.setFillStyle({ opacity: 0.4 });
					this.setStrokeStyle( { opacity: 0.8 });
					$("#secteur-biens a[rel='"+v.name+"']").trigger("mouseover");
				});
				GEvent.addListener(polygon, 'mouseout', function() {
					this.setFillStyle({ opacity: 0.2 });
					this.setStrokeStyle( { opacity: 0 });
					$("#secteur-biens a[rel='"+v.name+"']").trigger("mouseout");
				});
				GEvent.addListener(polygon, 'click', function() {
					$("#secteur-biens a[rel='"+v.name+"']").trigger("click");
				});
				$("#secteur-biens a[rel='"+v.name+"']").data("polygon", polygon);
			});
			
			$("#secteur-biens a").hover( function() {
				$(this).data("polygon").setFillStyle({ opacity: 0.4 });
				$(this).data("polygon").setStrokeStyle( { opacity: 0.8 });
			}, function() {
				$(this).data("polygon").setFillStyle({ opacity: 0.2 });
				$(this).data("polygon").setStrokeStyle( { opacity: 0 });
			});
		}
	}, 
	initialize_home: function() {
		if ( GBrowserIsCompatible() ) {
			var map = new GMap2(document.getElementById("map_canvas"));
			map.setCenter(new GLatLng(49.923378,2.515395), 9);
			geocoder = new GClientGeocoder();
			/*
			var blueIcon = new GIcon(G_DEFAULT_ICON);
			blueIcon.image = "/images/agence-point.gif";
			blueIcon.iconSize = new GSize(14, 14);
			blueIcon.iconAnchor = new GPoint(14,14);
			markerOptions = { icon:blueIcon };
*/
			markerOptions = { };
			$.each( markerAgences, function( k, v ) {
				geocoder.getLatLng( v.address,function(point) {
					if (point) {
						var marker=new GMarker(point,markerOptions);
						var infoTabs = [
						new GInfoWindowTab("Adresse", "<b>" + v.name + "</b><br>" + v.label ),
						];
						GEvent.addListener(marker, "click", function() {
							marker.openInfoWindowTabsHtml(infoTabs);
						});
						map.addOverlay(marker);
					}
				} );
			} );
		}
	}
};
