// JavaScript Document
//<![CDATA[

    var map = null;
    var geocoder = null;
	
	  
function load_G() 
	{
	GUnload();
      if (GBrowserIsCompatible()) 
	  {
        map = new GMap2(document.getElementById("map"));
		
		map.addControl(new GLargeMapControl());
		map.addControl(new GMapTypeControl());
		//coordonnees Lyon
		
		var mt = map.getMapTypes();
		// Overwrite the getMinimumResolution() and getMaximumResolution() methods
		for (var i=0; i<mt.length; i++) {
		mt[i].getMinimumResolution = function() {return 13;}
		mt[i].getMaximumResolution = function() {return 19;}
		}
		
		// Add a move listener to restrict the bounds range
		GEvent.addListener(map, "move", function() {
		checkBounds();
		});
		
		// The allowed region which the whole map must be within
		var allowedBounds = new GLatLngBounds(new GLatLng(40,3.5), new GLatLng(50,5.6));
		
		// If the map position is out of range, move it back
		function checkBounds() {
		// Perform the check and return if OK
		if (allowedBounds.contains(map.getCenter())) {
		return;
		}
		// It`s not OK, so find the nearest allowed point and move there
		var C = map.getCenter();
		var X = C.lng();
		var Y = C.lat();
		
		var AmaxX = allowedBounds.getNorthEast().lng();
		var AmaxY = allowedBounds.getNorthEast().lat();
		var AminX = allowedBounds.getSouthWest().lng();
		var AminY = allowedBounds.getSouthWest().lat();
		
		if (X < AminX) {X = AminX;}
		if (X > AmaxX) {X = AmaxX;}
		if (Y < AminY) {Y = AminY;}
		if (Y > AmaxY) {Y = AmaxY;}
		//alert ("Restricting "+Y+" "+X);
		map.setCenter(new GLatLng(Y,X));
		}    
		map.setCenter(new GLatLng(45.75,4.83),11);
        geocoder = new GClientGeocoder();
		connect('valideV5.php','recherche','form1',1);
      }
    }
	function createMarker(point,icon,infoTabs,lat,lng) 
	{
		var marker = new GMarker(point,icon);
		GEvent.addListener(marker, "click", function() {		
		marker.openInfoWindowTabsHtml(infoTabs);
		map.setCenter(new GLatLng(lat+0.015,lng));
		});
		return marker;
	}
	function trouveLocation(lat,lng,imagetxt,page1_titre,page1_adr,page2_det,page3_det)
	{
		var point = new GLatLng(lat,lng);
		
		/* CHANGEMENT D'ICONE
		var icon = new GIcon();
		icon.image = 'http://www.sacvl.fr/images/sacvl2.png';
		icon.shadow = '';
		icon.iconSize = new GSize(35, 48);
		icon.shadowSize = new GSize(38, 38);
		icon.iconAnchor = new GPoint(6, 20);
		icon.infoWindowAnchor = new GPoint(17, 24);
		marker = new GMarker(point,icon);
		map.addOverlay(marker);*/
		
		map.openInfoWindowTabsHtml(point,[new GInfoWindowTab('Résidence','<div id=\'ficheGmaps\'><div id=\'img\' style=\'width:135px;\'><img src=\"'+imagetxt+'\" width=\'135\' /></div><div id=\'texte\' style=\'text-align:left;padding-right:5px;\'>'+page1_titre+'<br />'+page1_adr+'<p style=\'line-height:12px;font-size:9px;\'>'+page2_det+'</p></div></div>'),new GInfoWindowTab('A louer','<div id=\'detailsGmaps\'><div style=\'border-bottom:1px solid #E3E6EE;height:30px;\'><div style=\'float:left;width:40px;\'><strong>Type</strong></div><div style=\'float:left;width:60px;\'><strong>Surface</strong></div><div style=\'float:left;width:60px;\'><strong>Loyer (HC)</strong></div><div style=\'float:left;width:60px;\'><strong>Charges</strong></div><div style=\'float:left;width:97px;\'>&nbsp;</div></div>'+page3_det+'</div>')]);
		
		map.panTo(new GLatLng(lat+0.015,lng));
	}
		
   //]]>

