
	function enlarge(filename) {
		$('photo').src = filename;
	}

	function openSlideShow(id_asso_bien) {
	
		var data = $H({'id_asso_bien' : id_asso_bien}).toQueryString();
		new Ajax.Updater('slideshow', '/slideshow.php', { method : 'get', parameters : data });	
		var elt = document.getElementById('slideshow');
		elt.style.display = 'block';
	}
	
	function closeSlideShow() {

		var elt = document.getElementById('slideshow');
		elt.style.display = 'none';
		elt.innerHTML = '';
	}


	/* */

	function changeRateRange(o) {
		
		(listbox = document.getElementById("rateRanges")).innerHTML = null;
		
		listbox.appendChild(newElement = document.createElement("option"));
		newElement.setAttribute("value", "NULL");
		newElement.setAttribute("selected", "");
		newElement.appendChild(document.createTextNode("> Au prix de"));

		/* */

		switch(o.options[o.selectedIndex].value) {
		
			case "1" : // ACHAT

				addNode(listbox, "- 350 000", "0n350000");
				addNode(listbox, "350 000 à 800 000", "350000n800000");
				addNode(listbox, "800 000 à 1 500 000", "800000n1500000");
				addNode(listbox, "1 500 000 à 3 000 000", "1500000n3000000");
				addNode(listbox, ">+ 3 000 000", "3000000n1000000000");

			break;
		
			case "2" : // LOCATION
			
				addNode(listbox, "- 1500 /mois", "0n1500");
				addNode(listbox, "1500 à 2500 /mois", "1500n2500");
				addNode(listbox, "2500 à 4500 /mois", "2500n4500");
				addNode(listbox, "+ 4500 /mois", "4500n1000000000");

			break;
		
			case "3" : // LOCATION
				
				addNode(listbox, "- 1500 /mois", "0n1500");
				addNode(listbox, "1500 à 2500 /mois", "1500n2500");
				addNode(listbox, "2500 à 4500 /mois", "2500n4500");
				addNode(listbox, "+ 4500 /mois", "4500n1000000000");

			break;
		
			case "4" : // LOCATION SAISONNIERE

				addNode(listbox, "- 3500 /mois", "0n3500");
				addNode(listbox, "3500 à 6500 /mois", "3500n6500");
				addNode(listbox, "6500 à 15000 /mois", "6500n15000");
				addNode(listbox, "+ 15000 /mois", "15000n1000000000");

			break;

			default:break;
		
		}
	}
	
	function addNode(o, name, value) {
	
		o.appendChild(newElement = document.createElement("option"));
		newElement.setAttribute("value", value);	
		newElement.appendChild(document.createTextNode(name));
	}
	
/* EK JS FUNCTIONS */

function	myGetFicheBien()
{
	document.getElementById('dzone_fiche_produit').style.display = "";
	document.getElementById('dzone_google_map').innerHTML = '';
	document.getElementById('bouton_fiche_produit_deux').style.background = "#E7E4DB";
	document.getElementById('bouton_fiche_produit_un').style.background = "#F9FAF4";
}

function	myGetGmapFP(id_bien, id_type_bien)
{
	var url = 'bien_fiche_inc/bien_gmap.inc.php';
    var myAjax = new Ajax.Request(url, 
        {
          method: 'post',
          onLoading: function (xhr)
            { // Après appel méthode open
              // (début de la requête Ajax)
            },
          onSuccess: function (xhr)
            {
				// Des qu'on a le nouveau contenu
				$('dzone_fiche_produit').style.display = "none";
				$('bouton_fiche_produit_un').style.background = "#E7E4DB";
				$('bouton_fiche_produit_deux').style.background = "#F9FAF4";
                $('dzone_google_map').innerHTML = xhr.responseText;
				//load();
				
            },
          onComplete: function()
            { // Toujours appelé en fin de requête
				//fill_gmap(id_bien, id_type_bien);
				gmap_init(id_bien, id_type_bien);
            }
	});
}


/* Gmap FUNCTIONS */

    var map = null;
    var geocoder = null;

    function load(adresse) {
      if (GBrowserIsCompatible()) {
        map = new GMap2(document.getElementById("myGmap"));
        map.setCenter(new GLatLng(37.4419, -122.1419), 13);
//        geocoder = new GClientGeocoder();
//		showAdress(adresse);
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
      }
    }


/* ==== FONCTIONS GOOGLE MAP ==== */

function	fill_gmap(id_bien, id_type_bien)
{
    if (GBrowserIsCompatible())
	{
      // arrays to hold copies of the markers and html used by the side_bar
      // because the function closure trick doesnt work there
      var gmarkers = [];
      var htmls = [];
      var i = 0;
	  var open_marker = 0;
      
      // === Create an associative array of GIcons() ===
      var gicons = [];
gicons["1"] = new GIcon();
	  gicons["1"].image = "/google_map/gmap_icons/immeuble.png";
	  gicons["1"].iconSize = new GSize(35, 35);
	  gicons["1"].iconAnchor = new GPoint(17, 17);
	  gicons["1"].infoWindowAnchor = new GPoint(35, 17);
gicons["1_selected"] = new GIcon();
	  gicons["1_selected"].image = "/google_map/gmap_icons/immeuble_selected.png";
	  gicons["1_selected"].iconSize = new GSize(35, 35);
	  gicons["1_selected"].iconAnchor = new GPoint(17, 17);
	  gicons["1_selected"].infoWindowAnchor = new GPoint(35, 17);
gicons["2"] = new GIcon();
	  gicons["2"].image = "/google_map/gmap_icons/maison.png";
	  gicons["2"].iconSize = new GSize(35, 35);
	  gicons["2"].iconAnchor = new GPoint(17, 17);
	  gicons["2"].infoWindowAnchor = new GPoint(35, 17);
gicons["2_selected"] = new GIcon();
	  gicons["2_selected"].image = "/google_map/gmap_icons/maison_selected.png";
	  gicons["2_selected"].iconSize = new GSize(35, 35);
	  gicons["2_selected"].iconAnchor = new GPoint(17, 17);
	  gicons["2_selected"].infoWindowAnchor = new GPoint(35, 17);
gicons["3"] = new GIcon();
	  gicons["3"].image = "/google_map/gmap_icons/terrain.png";
	  gicons["3"].iconSize = new GSize(35, 35);
	  gicons["3"].iconAnchor = new GPoint(17, 17);
	  gicons["3"].infoWindowAnchor = new GPoint(35, 17);
gicons["3_selected"] = new GIcon();
	  gicons["3_selected"].image = "/google_map/gmap_icons/terrain_selected.png";
	  gicons["3_selected"].iconSize = new GSize(35, 35);
	  gicons["3_selected"].iconAnchor = new GPoint(17, 17);
	  gicons["3_selected"].infoWindowAnchor = new GPoint(35, 17);
gicons["4"] = new GIcon();
	  gicons["4"].image = "/google_map/gmap_icons/parking.png";
	  gicons["4"].iconSize = new GSize(35, 35);
	  gicons["4"].iconAnchor = new GPoint(17, 17);
	  gicons["4"].infoWindowAnchor = new GPoint(35, 17);
gicons["4_selected"] = new GIcon();
	  gicons["4_selected"].image = "/google_map/gmap_icons/parking_selected.png";
	  gicons["4_selected"].iconSize = new GSize(35, 35);
	  gicons["4_selected"].iconAnchor = new GPoint(17, 17);
	  gicons["4_selected"].infoWindowAnchor = new GPoint(35, 17);

      // A function to create the marker and set up the event window
      function createMarker(point,html,icontype)
	  {
        // === create a marker with the requested icon ===
		var marker = new GMarker(point, gicons[icontype]);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        // save the info we need to use later for the side_bar
        gmarkers[i] = marker;
        htmls[i] = html;
        i++;
        return marker;
      }


      // This function picks up the click and opens the corresponding info window
      function myclick(i)
	  {
        gmarkers[i].openInfoWindowHtml(htmls[i]);
      }

      // create the map
      map = new GMap2(document.getElementById("myGmap"));
	  map.addControl(new GSmallMapControl());
	  map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng( 48.856558,2.350966), 15);


	  // === Define the function thats going to process the text file ===
	  process_it = function(doc)
	  {
		// === split the document into lines ===
		lines = doc.split("\n");
		for (var i=0; i<lines.length; i++)
		{
		  if (lines[i].length > 1)
		  {
			// === split each line into parts separated by "|" and use the contents ===
			parts = lines[i].split("|");
			var lat = parseFloat(parts[0]);
			var lng = parseFloat(parts[1]);
			var bien = parseInt(parts[2]);
			var type = parseInt(parts[3]);
			var html = parts[4];
			if (id_bien == bien && id_type_bien == type)
			{
				// recuperation de la position pour centrer la carte
				var center_map_lat = lat;
				var center_map_lng = lng;
				map.setCenter(new GLatLng(center_map_lat,center_map_lng), 15);
				open_marker = i;
				// on cree le marker du bien selectionne
				var icontype = type+"_selected";
			}
			else
			{
				// === read the icontype attribute ===
				var icontype = parts[3];
			}
			var point = new GLatLng(lat,lng);
			// create the marker
			var marker = createMarker(point,html,icontype);
			map.addOverlay(marker);
		  }
		}
		if (open_marker > 0)
		{
			gmarkers[open_marker].openInfoWindowHtml(htmls[open_marker]);
		}
	  }
	  GDownloadUrl("google_map/gmap_xml/gmap_markers.txt", process_it);
    }
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
    // This Javascript is based on code provided by the
    // Blackpool Community Church Javascript Team
    // http://www.commchurch.freeserve.co.uk/   
    // http://www.econym.demon.co.uk/googlemaps/
}


function	old_fill_big_gmap(ville)
{
    if (GBrowserIsCompatible())
	{
      // arrays to hold copies of the markers and html used by the side_bar
      // because the function closure trick doesnt work there
      var gmarkers = [];
      var htmls = [];
      var i = 0;
	  var open_marker = 0;
      
      // === Create an associative array of GIcons() ===
      var gicons = [];
gicons["1"] = new GIcon();
	  gicons["1"].image = "/google_map/gmap_icons/immeuble.png";
	  gicons["1"].iconSize = new GSize(35, 35);
	  gicons["1"].iconAnchor = new GPoint(17, 17);
	  gicons["1"].infoWindowAnchor = new GPoint(35, 17);
gicons["1_selected"] = new GIcon();
	  gicons["1_selected"].image = "/google_map/gmap_icons/immeuble_selected.png";
	  gicons["1_selected"].iconSize = new GSize(35, 35);
	  gicons["1_selected"].iconAnchor = new GPoint(17, 17);
	  gicons["1_selected"].infoWindowAnchor = new GPoint(35, 17);
gicons["2"] = new GIcon();
	  gicons["2"].image = "/google_map/gmap_icons/maison.png";
	  gicons["2"].iconSize = new GSize(35, 35);
	  gicons["2"].iconAnchor = new GPoint(17, 17);
	  gicons["2"].infoWindowAnchor = new GPoint(35, 17);
gicons["2_selected"] = new GIcon();
	  gicons["2_selected"].image = "/google_map/gmap_icons/maison_selected.png";
	  gicons["2_selected"].iconSize = new GSize(35, 35);
	  gicons["2_selected"].iconAnchor = new GPoint(17, 17);
	  gicons["2_selected"].infoWindowAnchor = new GPoint(35, 17);
gicons["3"] = new GIcon();
	  gicons["3"].image = "/google_map/gmap_icons/terrain.png";
	  gicons["3"].iconSize = new GSize(35, 35);
	  gicons["3"].iconAnchor = new GPoint(17, 17);
	  gicons["3"].infoWindowAnchor = new GPoint(35, 17);
gicons["3_selected"] = new GIcon();
	  gicons["3_selected"].image = "/google_map/gmap_icons/terrain_selected.png";
	  gicons["3_selected"].iconSize = new GSize(35, 35);
	  gicons["3_selected"].iconAnchor = new GPoint(17, 17);
	  gicons["3_selected"].infoWindowAnchor = new GPoint(35, 17);
gicons["4"] = new GIcon();
	  gicons["4"].image = "/google_map/gmap_icons/parking.png";
	  gicons["4"].iconSize = new GSize(35, 35);
	  gicons["4"].iconAnchor = new GPoint(17, 17);
	  gicons["4"].infoWindowAnchor = new GPoint(35, 17);
gicons["4_selected"] = new GIcon();
	  gicons["4_selected"].image = "/google_map/gmap_icons/parking_selected.png";
	  gicons["4_selected"].iconSize = new GSize(35, 35);
	  gicons["4_selected"].iconAnchor = new GPoint(17, 17);
	  gicons["4_selected"].infoWindowAnchor = new GPoint(35, 17);

      // A function to create the marker and set up the event window
      function createMarker(point,html,icontype)
	  {
        // === create a marker with the requested icon ===
		var marker = new GMarker(point, gicons[icontype]);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        // save the info we need to use later for the side_bar
        gmarkers[i] = marker;
        htmls[i] = html;
        i++;
        return marker;
      }


      // This function picks up the click and opens the corresponding info window
      function myclick(i)
	  {
        gmarkers[i].openInfoWindowHtml(htmls[i]);
      }
	  
	  if (ville == 1) // PARIS
	  {
		  map_center_lat = 48.856558;
		  map_center_lng = 2.350966;
		  map_zoom = 12;
	  }
	  else if (ville == 2) // DEAUVILLE
	  {
		  map_center_lat = 49.357315;
		  map_center_lng = 0.074075;
		  map_zoom = 13;
	  }

      // create the map
      map = new GMap2(document.getElementById("myGmap"));
	  map.addControl(new GSmallMapControl());
	  map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(map_center_lat,map_center_lng), map_zoom);


	  // === Define the function thats going to process the text file ===
	  process_it = function(doc)
	  {
		// === split the document into lines ===
		lines = doc.split("\n");
		for (var i=0; i<lines.length; i++)
		{
		  if (lines[i].length > 1)
		  {
			// === split each line into parts separated by "|" and use the contents ===
			parts = lines[i].split("|");
			var lat = parseFloat(parts[0]);
			var lng = parseFloat(parts[1]);
			var bien = parseInt(parts[2]);
			var type = parseInt(parts[3]);
			var html = parts[4];
			var icontype = parts[3];
			var point = new GLatLng(lat,lng);
			// create the marker
			var marker = createMarker(point,html,icontype);
			map.addOverlay(marker);
		  }
		}
	  }
	  GDownloadUrl("/google_map/gmap_xml/gmap_markers.txt", process_it);
    }
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
    // This Javascript is based on code provided by the
    // Blackpool Community Church Javascript Team
    // http://www.commchurch.freeserve.co.uk/   
    // http://www.econym.demon.co.uk/googlemaps/
}

/* UPDATED FCT API GMAP */

function	gmap_init(id_bien, id_type_bien)
{
	var biens = window.biens;
	
	if (GBrowserIsCompatible())
	{
		// arrays to hold copies of the markers and html used by the side_bar
		// because the function closure trick doesnt work there
		var gmarkers = [];
		var htmls = [];
		var i = 0;
		var open_marker = 0;
		
		geocoder = new GClientGeocoder();
		
		// === Create an associative array of GIcons() ===
		var gicons = [];
		gicons["1"] = new GIcon();
		gicons["1"].image = "/google_map/gmap_icons/immeuble.png";
		gicons["1"].iconSize = new GSize(35, 35);
		gicons["1"].iconAnchor = new GPoint(17, 17);
		gicons["1"].infoWindowAnchor = new GPoint(35, 17);
		gicons["1_selected"] = new GIcon();
		gicons["1_selected"].image = "/google_map/gmap_icons/immeuble_selected.png";
		gicons["1_selected"].iconSize = new GSize(35, 35);
		gicons["1_selected"].iconAnchor = new GPoint(17, 17);
		gicons["1_selected"].infoWindowAnchor = new GPoint(35, 17);
		gicons["2"] = new GIcon();
		gicons["2"].image = "/google_map/gmap_icons/maison.png";
		gicons["2"].iconSize = new GSize(35, 35);
		gicons["2"].iconAnchor = new GPoint(17, 17);
		gicons["2"].infoWindowAnchor = new GPoint(35, 17);
		gicons["2_selected"] = new GIcon();
		gicons["2_selected"].image = "/google_map/gmap_icons/maison_selected.png";
		gicons["2_selected"].iconSize = new GSize(35, 35);
		gicons["2_selected"].iconAnchor = new GPoint(17, 17);
		gicons["2_selected"].infoWindowAnchor = new GPoint(35, 17);
		gicons["3"] = new GIcon();
		gicons["3"].image = "/google_map/gmap_icons/terrain.png";
		gicons["3"].iconSize = new GSize(35, 35);
		gicons["3"].iconAnchor = new GPoint(17, 17);
		gicons["3"].infoWindowAnchor = new GPoint(35, 17);
		gicons["3_selected"] = new GIcon();
		gicons["3_selected"].image = "/google_map/gmap_icons/terrain_selected.png";
		gicons["3_selected"].iconSize = new GSize(35, 35);
		gicons["3_selected"].iconAnchor = new GPoint(17, 17);
		gicons["3_selected"].infoWindowAnchor = new GPoint(35, 17);
		gicons["4"] = new GIcon();
		gicons["4"].image = "/google_map/gmap_icons/parking.png";
		gicons["4"].iconSize = new GSize(35, 35);
		gicons["4"].iconAnchor = new GPoint(17, 17);
		gicons["4"].infoWindowAnchor = new GPoint(35, 17);
		gicons["4_selected"] = new GIcon();
		gicons["4_selected"].image = "/google_map/gmap_icons/parking_selected.png";
		gicons["4_selected"].iconSize = new GSize(35, 35);
		gicons["4_selected"].iconAnchor = new GPoint(17, 17);
		gicons["4_selected"].infoWindowAnchor = new GPoint(35, 17);
		gicons["jb_boitard"] = new GIcon();
		gicons["jb_boitard"].image = "/google_map/gmap_icons/agence_jb.png";
		gicons["jb_boitard"].iconSize = new GSize(35, 35);
		gicons["jb_boitard"].iconAnchor = new GPoint(17, 17);
		gicons["jb_boitard"].infoWindowAnchor = new GPoint(35, 17);
		
		// A function to create the marker and set up the event window
		function createMarker(point,html,icontype)
		{
			// === create a marker with the requested icon ===
			var marker = new GMarker(point, gicons[icontype]);
			GEvent.addListener(marker, "click", function() {
			marker.openInfoWindowHtml(html);
			});
			// save the info we need to use later for the side_bar
			gmarkers[i] = marker;
			htmls[i] = html;
			i++;
			return marker;
		}
		
		// This function picks up the click and opens the corresponding info window
		function myclick(i)
		{
			gmarkers[i].openInfoWindowHtml(htmls[i]);
		}
		
		// create the map
		map = new GMap2(document.getElementById("myGmap"));
		map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());
		map.setCenter(new GLatLng( 48.856558,2.350966), 15);
		
		// On parcour le tableau des biens et on les place sur la carte
		for (var pos = 0; biens[pos]; pos++)
		{
			if (biens[pos]["id_bien"] == id_bien && biens[pos]["id_type_bien"] == id_type_bien)
			{
				// recuperation de la position pour centrer la carte
				var center_map_lat = biens[pos]["lat"];
				var center_map_lng = biens[pos]["lng"];
				map.setCenter(new GLatLng(center_map_lat,center_map_lng), 15);
				open_marker = pos;
				// on cree le marker du bien selectionne
				var icontype = biens[pos]["id_type_bien"]+"_selected";
			}
			else
			{
				// === read the icontype attribute ===
				var icontype = biens[pos]["id_type_bien"];
			}
			
			// creation contenu info bulle
			var html = "<div style=\"width:250px;\"><div style=\"width:80px; float:left;\"><a href=\"index.php?page=bien_fiche&id_bien="+biens[pos]["id_bien"]+"&id_type_bien="+biens[pos]["id_type_bien"]+"\"><img width=\"80\" src=\"/uploads/"+biens[pos]["image"]+"\" /></a></div><div style=\"width:160px; float:right; margin-left:10px; text-align:left;\">"+biens[pos]["titre"]+"<br>"+biens[pos]["adresse"]+"<br>Prix : "+biens[pos]["prix"] +"</div></div>";
			// creation position icone
			var point = new GLatLng(biens[pos]["lat"],biens[pos]["lng"]);
			// ajout marker sur carte GoogleMap
			var marker = createMarker(point,html,icontype);
			map.addOverlay(marker);
		}
		
		// placement agence JB Boitard Paris & Deauville
		// Paris
		var html = "<div style=\"width:200px;\"><div style=\"width:80px; float:left;\"><a href=\"?page=ag_paris2\"><img width=\"80\" src=\"/imgs/Agences_fotoagenceP.jpg\" /></a></div><div style=\"width:110px; float:right; margin-left:10px;\">Agence JB BOITARD<br>Paris<br>117, rue Saint-Dominique<br>75007 Paris<br></div></div>";
		// creation position icone
		var point = new GLatLng(48.859068,2.304374);
		// ajout marker sur carte GoogleMap
		var marker = createMarker(point,html,"jb_boitard");
		map.addOverlay(marker);
		// Deauville
		var html = "<div style=\"width:200px;\"><div style=\"width:80px; float:left;\"><a href=\"?page=ag_deauville2\"><img width=\"80\" src=\"/imgs/Agences_fotoagenceD.jpg\" /></a></div><div style=\"width:110px; float:right; margin-left:10px;\">Agence JB BOITARD<br>Deauville<br>85, rue Eugène Colas<br>14800 Deauville<br></div></div>";
		// creation position icone
		var point = new GLatLng(49.359417,0.072602);
		// ajout marker sur carte GoogleMap
		var marker = createMarker(point,html,"jb_boitard");
		map.addOverlay(marker);

		// On ouvre info bulle du bien selectionné
		if (open_marker > 0)
		{
			gmarkers[open_marker].openInfoWindowHtml(htmls[open_marker]);
		}
		else if (open_marker == 0)
		{
			document.getElementById('myGmap').innerHTML = '<img style="margin-top:60px;" src="uploads/default_big.jpg"><br>Ce bien n\'est pas visible sur la carte';
			document.getElementById('legende_gmap2').style.visibility = "hidden";
			//alert('Ce bien n\'est pas visible sur la carte');
		}
	}
	else
	{
		alert("Sorry, the Google Maps API is not compatible with this browser");
	}
	// This Javascript is based on code provided by the
	// Blackpool Community Church Javascript Team
	// http://www.commchurch.freeserve.co.uk/   
	// http://www.econym.demon.co.uk/googlemaps/
}


function	fill_big_gmap(ville)
{
    if (GBrowserIsCompatible())
	{
      // arrays to hold copies of the markers and html used by the side_bar
      // because the function closure trick doesnt work there
      var gmarkers = [];
      var htmls = [];
      var i = 0;
	  var open_marker = 0;
	  var biens = window.biens;
      
      // === Create an associative array of GIcons() ===
      var gicons = [];
gicons["1"] = new GIcon();
	  gicons["1"].image = "/google_map/gmap_icons/immeuble.png";
	  gicons["1"].iconSize = new GSize(35, 35);
	  gicons["1"].iconAnchor = new GPoint(17, 17);
	  gicons["1"].infoWindowAnchor = new GPoint(35, 17);
gicons["1_selected"] = new GIcon();
	  gicons["1_selected"].image = "/google_map/gmap_icons/immeuble_selected.png";
	  gicons["1_selected"].iconSize = new GSize(35, 35);
	  gicons["1_selected"].iconAnchor = new GPoint(17, 17);
	  gicons["1_selected"].infoWindowAnchor = new GPoint(35, 17);
gicons["2"] = new GIcon();
	  gicons["2"].image = "/google_map/gmap_icons/maison.png";
	  gicons["2"].iconSize = new GSize(35, 35);
	  gicons["2"].iconAnchor = new GPoint(17, 17);
	  gicons["2"].infoWindowAnchor = new GPoint(35, 17);
gicons["2_selected"] = new GIcon();
	  gicons["2_selected"].image = "/google_map/gmap_icons/maison_selected.png";
	  gicons["2_selected"].iconSize = new GSize(35, 35);
	  gicons["2_selected"].iconAnchor = new GPoint(17, 17);
	  gicons["2_selected"].infoWindowAnchor = new GPoint(35, 17);
gicons["3"] = new GIcon();
	  gicons["3"].image = "/google_map/gmap_icons/terrain.png";
	  gicons["3"].iconSize = new GSize(35, 35);
	  gicons["3"].iconAnchor = new GPoint(17, 17);
	  gicons["3"].infoWindowAnchor = new GPoint(35, 17);
gicons["3_selected"] = new GIcon();
	  gicons["3_selected"].image = "/google_map/gmap_icons/terrain_selected.png";
	  gicons["3_selected"].iconSize = new GSize(35, 35);
	  gicons["3_selected"].iconAnchor = new GPoint(17, 17);
	  gicons["3_selected"].infoWindowAnchor = new GPoint(35, 17);
gicons["4"] = new GIcon();
	  gicons["4"].image = "/google_map/gmap_icons/parking.png";
	  gicons["4"].iconSize = new GSize(35, 35);
	  gicons["4"].iconAnchor = new GPoint(17, 17);
	  gicons["4"].infoWindowAnchor = new GPoint(35, 17);
gicons["4_selected"] = new GIcon();
	  gicons["4_selected"].image = "/google_map/gmap_icons/parking_selected.png";
	  gicons["4_selected"].iconSize = new GSize(35, 35);
	  gicons["4_selected"].iconAnchor = new GPoint(17, 17);
	  gicons["4_selected"].infoWindowAnchor = new GPoint(35, 17);
		gicons["jb_boitard"] = new GIcon();
		gicons["jb_boitard"].image = "/google_map/gmap_icons/agence_jb.png";
		gicons["jb_boitard"].iconSize = new GSize(35, 35);
		gicons["jb_boitard"].iconAnchor = new GPoint(17, 17);
		gicons["jb_boitard"].infoWindowAnchor = new GPoint(35, 17);

      // A function to create the marker and set up the event window
      function createMarker(point,html,icontype)
	  {
        // === create a marker with the requested icon ===
		var marker = new GMarker(point, gicons[icontype]);
        GEvent.addListener(marker, "click", function() {
          marker.openInfoWindowHtml(html);
        });
        // save the info we need to use later for the side_bar
        gmarkers[i] = marker;
        htmls[i] = html;
        i++;
        return marker;
      }


      // This function picks up the click and opens the corresponding info window
      function myclick(i)
	  {
        gmarkers[i].openInfoWindowHtml(htmls[i]);
      }
	  
	  if (ville == 1) // PARIS
	  {
		  map_center_lat = 48.856558;
		  map_center_lng = 2.350966;
		  map_zoom = 12;
	  }
	  else if (ville == 2) // DEAUVILLE
	  {
		  map_center_lat = 49.357315;
		  map_center_lng = 0.074075;
		  map_zoom = 12;
	  }

      // create the map
      map = new GMap2(document.getElementById("myGmap"));
	  map.addControl(new GSmallMapControl());
	  map.addControl(new GMapTypeControl());
      map.setCenter(new GLatLng(map_center_lat,map_center_lng), map_zoom);


		// On parcour le tableau des biens et on les place sur la carte
		for (var pos = 0; biens[pos]; pos++)
		{
			// === read the icontype attribute ===
			var icontype = biens[pos]["id_type_bien"];
			// creation contenu info bulle
			var html = "<div style=\"width:250px;\"><div style=\"width:80px; float:left;\"><a href=\"index.php?page=bien_fiche&id_bien="+biens[pos]["id_bien"]+"&id_type_bien="+biens[pos]["id_type_bien"]+"\"><img width=\"80\" src=\"/uploads/"+biens[pos]["image"]+"\" /></a></div><div style=\"width:160px; float:right; margin-left:10px;\">"+biens[pos]["titre"]+"<br>"+biens[pos]["adresse"]+"<br>Prix : "+biens[pos]["prix"] +"</div></div>";
			// creation position icone
			var point = new GLatLng(biens[pos]["lat"],biens[pos]["lng"]);
			// ajout marker sur carte GoogleMap
			var marker = createMarker(point,html,icontype);
			map.addOverlay(marker);
		}
		
		// placement agence JB Boitard Paris & Deauville
		// Paris
		var html = "<div style=\"width:200px;\"><div style=\"width:80px; float:left;\"><a href=\"?page=ag_paris2\"><img width=\"80\" src=\"/imgs/Agences_fotoagenceP.jpg\" /></a></div><div style=\"width:110px; float:right; margin-left:10px;\">Agence JB BOITARD<br>Paris<br>117, rue Saint-Dominique<br>75007 Paris<br></div></div>";
		// creation position icone
		var point = new GLatLng(48.859068,2.304374);
		// ajout marker sur carte GoogleMap
		var marker = createMarker(point,html,"jb_boitard");
		map.addOverlay(marker);
		// Deauville
		var html = "<div style=\"width:200px;\"><div style=\"width:80px; float:left;\"><a href=\"?page=ag_deauville2\"><img width=\"80\" src=\"/imgs/Agences_fotoagenceD.jpg\" /></a></div><div style=\"width:110px; float:right; margin-left:10px;\">Agence JB BOITARD<br>Deauville<br>85, rue Eugène Colas<br>14800 Deauville<br></div></div>";
		// creation position icone
		var point = new GLatLng(49.359417,0.072602);
		// ajout marker sur carte GoogleMap
		var marker = createMarker(point,html,"jb_boitard");
		map.addOverlay(marker);
    }
    else {
      alert("Sorry, the Google Maps API is not compatible with this browser");
    }
    // This Javascript is based on code provided by the
    // Blackpool Community Church Javascript Team
    // http://www.commchurch.freeserve.co.uk/   
    // http://www.econym.demon.co.uk/googlemaps/
}

//===================================//
//       GESTION FICHE PRODUIT       //
//===================================//

function	prototype_include(url, target, flag)
{
    var myAjax = new Ajax.Request(url, 
        {
          method: 'post',
          onLoading: function (xhr)
            { // Après appel méthode open
              // (début de la requête Ajax)
            },
          onSuccess: function (xhr)
            {
				// Des qu'on a le nouveau contenu
                $(target).innerHTML = xhr.responseText;
				//load();
				
            },
          onComplete: function()
            { // Toujours appelé en fin de requête
				if (flag != false) // gestion api google map
					gmap_init(flag[0], flag[1])
            }
	});
}


function	load_FP(page,id_bien, id_type_bien, id_asso_bien, id_onglet)
{
	var flag = false;
	if (page == "bien_gmap")
	{
		flag = new Array;
		flag[0] = id_bien;
		flag[1] = id_type_bien;
		
		// mise en evidence onglet localisation
		document.getElementById('bouton_fiche_produit_deux').style.background= "#f9faf4";
		document.getElementById('bouton_fiche_produit_deux').style.fontWeight = "bold";
		// devalorisation onglet fiche produit
		document.getElementById('bouton_fiche_produit_un').style.background = "#e7e4db";
		document.getElementById('bouton_fiche_produit_un').style.fontWeight = "normal";

	}
	else
	{
		// mise en evidence onglet fiche produit
		document.getElementById('bouton_fiche_produit_un').style.background= "#f9faf4";
		document.getElementById('bouton_fiche_produit_un').style.fontWeight = "bold";
		// devalorisation onglet localisation
		document.getElementById('bouton_fiche_produit_deux').style.background = "#e7e4db";
		document.getElementById('bouton_fiche_produit_deux').style.fontWeight = "normal";		
	}
	
	// creation url page a charger
	var url = 'bien_fiche/'+page+'.inc.php?id_bien='+id_bien+'&id_type_bien='+id_type_bien+'&id_asso_bien='+id_asso_bien;
	// chargement page via prototype
	prototype_include(url, 'dzone', flag);
}