$(function()
{
	var posMID;
	/* Paramètre du style */
	var stylez = [
	{
		featureType: "all",
		elementType: "all",
		stylers: [
		//	{ hue: "#FF0099" }
			{ saturation: -100 },
			{ gamma: 0.03 }
		]
		
		/*
		featureType: "landscape.natural",
		stylers: [
		  { saturation: -100 },
		  { lightness: -100 }
		]
		*/
	}];
	
	
	function initialize()
	{
		posMID = new google.maps.LatLng(45.47581, -73.58005);
		
		var settings = {
			zoom: 16,
			center: posMID,
			mapTypeControl: false,
			streetViewControl: false,
		/*	mapTypeControlOptions: {
				style: google.maps.MapTypeControlStyle.DROPDOWN_MENU,
				position: google.maps.ControlPosition.LEFT_TOP
			},*/
			navigationControl: false,
		/*	navigationControlOptions: {
				style: google.maps.NavigationControlStyle.SMALL,
				position: google.maps.ControlPosition.TOP_LEFT
			},*/
			zoomControl: false,
		/*	zoomControlOptions: {
				style: google.maps.ZoomControlStyle.SMALL,
				position: google.maps.ControlPosition.TOP_LEFT
			},*/
			mapTypeControlOptions: {
				mapTypeIds: [google.maps.MapTypeId.ROADMAP, 'mid']
				
			},
			mapTypeId: 'mid'
		};
		var map = new google.maps.Map(document.getElementById("map_mid"), settings);
		
		/* Bulle d'info */
		var contentString = '<div class="contentInfoGM">'+
			'<div class="slogan"><span>Agence Intéractive</span> <br/>aux Idées Performantes.</div>'+
			'<div class="photo"><img src="'+stylesheet_uri+'/images/divers/batiment.jpg" width="250"></div>'+
			'</div>';
		var infowindow = new google.maps.InfoWindow({
			content: contentString
		});
		
		/* Applique le style */
		var midMapType = new google.maps.StyledMapType(stylez);
		map.mapTypes.set('mid', midMapType);
		map.setMapTypeId('mid');
		
		/* Crée le logo MID */
		var logoMID = new google.maps.MarkerImage(stylesheet_uri+'/images/logos/motion_in_design_google_map.png',
			new google.maps.Size(48,56),
			new google.maps.Point(0,0),
			new google.maps.Point(24,56)
		);
		/* Crée l"ombre du logo MID */
	/*	var shadowLogo = new google.maps.MarkerImage('images/logo_shadow.png',
			new google.maps.Size(71,38),
			new google.maps.Point(0,0),
			new google.maps.Point(20, 38)
		);*/
		var midMarker = new google.maps.Marker({
			position: posMID,
			map: map,
			icon: logoMID,
			title:"Motion In Design"
		});
		
		google.maps.event.addListener(midMarker, 'click', function() {
			infowindow.open(map,midMarker);
		});
		
		
		
		/* Crée le bouton qui replace Motion In Design au centre */
	/*	var goHomeControlDiv = document.createElement('DIV');
		var goHomeControl = new goHome(goHomeControlDiv, map);
		goHomeControlDiv.index = 1;
		map.controls[google.maps.ControlPosition.TOP_LEFT].push(goHomeControlDiv);*/
		
		/* Crée le bouton qui passe en mode carte */
		var modeCarteControlDiv = document.createElement('DIV');
		var modeCarteControl = new modeCarte(modeCarteControlDiv, map);
		modeCarteControlDiv.index = 1;
		map.controls[google.maps.ControlPosition.TOP_LEFT].push(modeCarteControlDiv);
		
		/* Crée le bouton qui passe en mode satellite */
		var modeSatelliteControlDiv = document.createElement('DIV');
		var modeSatelliteControl = new modeSatellite(modeSatelliteControlDiv, map);
		modeSatelliteControlDiv.index = 1;
		map.controls[google.maps.ControlPosition.TOP_LEFT].push(modeSatelliteControlDiv);
		
		/* Crée le bouton qui dézoome */
		var zoomOutControlDiv = document.createElement('DIV');
		var zoomOutControl = new zoomOut(zoomOutControlDiv, map);
		zoomOutControlDiv.index = 1;
		map.controls[google.maps.ControlPosition.TOP_LEFT].push(zoomOutControlDiv);
		
		/* Crée le bouton qui zoome */
		var zoomInControlDiv = document.createElement('DIV');
		var zoomInControl = new zoomIn(zoomInControlDiv, map);
		zoomInControlDiv.index = 1;
		map.controls[google.maps.ControlPosition.TOP_LEFT].push(zoomInControlDiv);
	}
	
	
	/******** Bouton pour replacer Motion In Design au centre de la carte ********/
/*	function goHome(controlDiv, map) {
		// Set CSS styles for the DIV containing the control
		controlDiv.style.padding = '10px';
		
		// Set CSS for the control border
		var controlUI = document.createElement('DIV');
		controlUI.style.backgroundColor = '#009DDC';
		controlUI.style.color = '#FFF';
		controlUI.style.cursor = 'pointer';
		controlUI.style.textAlign = 'center';
		controlDiv.appendChild(controlUI);
		
		// Set CSS for the control interior
		var controlText = document.createElement('DIV');
		controlText.style.padding = '10px';
		controlText.style.fontWeight = 'bold';
		controlText.style.fontSize = '12px';
		controlText.style.fontFamily = 'Helvetica';
		controlText.innerHTML = 'Motion In Design';
		controlUI.appendChild(controlText);
		
		// Setup the click event listeners
		google.maps.event.addDomListener(controlUI, 'click', function() {
			map.setCenter(posMID);
		});
	}*/
	
	
	/******** Bouton pour dézoomer ********/
	function zoomOut(controlDiv, map) {
		// Set CSS styles for the DIV containing the control
		controlDiv.style.padding = '10px 2px 0px 0px';
		
		// Set CSS for the control border
		var controlUI = document.createElement('DIV');
		controlUI.style.width = '26px';
		controlUI.style.height = '26px';
		controlUI.style.backgroundColor = '#009DDC';
		controlUI.style.backgroundImage = 'url("'+stylesheet_uri+'/images/boutons/zoom_moins.png")';
		controlUI.style.color = '#FFF';
		controlUI.style.cursor = 'pointer';
		controlUI.style.textAlign = 'center';
		controlDiv.appendChild(controlUI);
		
		// Set CSS for the control interior
		var controlText = document.createElement('DIV');
		controlUI.appendChild(controlText);
		
		// Setup the click event listeners
		google.maps.event.addDomListener(controlUI, 'click', function() {
			map.setZoom(map.getZoom()-1);
		});
	}
	
	
	/******** Bouton pour zoomer ********/
	function zoomIn(controlDiv, map) {
		// Set CSS styles for the DIV containing the control
		controlDiv.style.padding = '10px 2px 0px 0px';
		
		// Set CSS for the control border
		var controlUI = document.createElement('DIV');
		controlUI.style.width = '26px';
		controlUI.style.height = '26px';
		controlUI.style.backgroundColor = '#009DDC';
		controlUI.style.backgroundImage = 'url("'+stylesheet_uri+'/images/boutons/zoom_plus.png")';
		controlUI.style.color = '#FFF';
		controlUI.style.cursor = 'pointer';
		controlUI.style.textAlign = 'center';
		controlDiv.appendChild(controlUI);
		
		// Set CSS for the control interior
		var controlText = document.createElement('DIV');
		controlUI.appendChild(controlText);
		
		// Setup the click event listeners
		google.maps.event.addDomListener(controlUI, 'click', function() {
			map.setZoom(map.getZoom()+1);
		});
	}
	
	
	/******** Bouton pour passer en mode sattelite ********/
	function modeSatellite(controlDiv, map) {
		// Set CSS styles for the DIV containing the control
		controlDiv.style.padding = '10px 2px 0px 2px';
		
		// Set CSS for the control border
		var controlUI = document.createElement('DIV');
		controlUI.style.backgroundColor = '#009DDC';
		controlUI.style.color = '#FFF';
		controlUI.style.cursor = 'pointer';
		controlUI.style.textAlign = 'center';
		controlDiv.appendChild(controlUI);
		
		// Set CSS for the control interior
		var controlText = document.createElement('DIV');
		controlText.style.padding = '5px 10px';
		controlText.style.fontWeight = 'bold';
		controlText.style.fontSize = '12px';
		controlText.style.fontFamily = 'Arial';
		controlText.innerHTML = 'Satellite';
		controlUI.appendChild(controlText);
		
		// Setup the click event listeners
		google.maps.event.addDomListener(controlUI, 'click', function() {
			map.setMapTypeId(google.maps.MapTypeId.HYBRID);
		});
	}
	
	
	/******** Bouton pour passer en mode carte ********/
	function modeCarte(controlDiv, map) {
		// Set CSS styles for the DIV containing the control
		controlDiv.style.padding = '10px 0px 0px 10px';
		
		// Set CSS for the control border
		var controlUI = document.createElement('DIV');
		controlUI.style.backgroundColor = '#009DDC';
		controlUI.style.color = '#FFF';
		controlUI.style.cursor = 'pointer';
		controlUI.style.textAlign = 'center';
		controlDiv.appendChild(controlUI);
		
		// Set CSS for the control interior
		var controlText = document.createElement('DIV');
		controlText.style.padding = '5px 10px';
		controlText.style.fontWeight = 'bold';
		controlText.style.fontSize = '12px';
		controlText.style.fontFamily = 'Arial';
		controlText.innerHTML = 'Plan';
		controlUI.appendChild(controlText);
		
		// Setup the click event listeners
		google.maps.event.addDomListener(controlUI, 'click', function() {
			map.setMapTypeId(google.maps.MapTypeId.ROADMAP);
			/* Applique le style */
			var midMapType = new google.maps.StyledMapType(stylez);
			map.mapTypes.set('mid', midMapType);
			map.setMapTypeId('mid');
		});
	}
	
	initialize();
});

