
		var map = null;
		var geocoder = null;
		var address;


		function initialize(idDiv) {
			if (GBrowserIsCompatible()) {
				map = new GMap2(document.getElementById(idDiv));
				map.setCenter(new GLatLng(46.75984,1.738281) , 13);
				map.setZoom(6);
				map.setUIToDefault();
				//GEvent.addListener(map, "click", getAddress);
				geocoder = new GClientGeocoder();

			}
		}




		function createMarker(point, picto){

			markerOptions = {};

			var icfIcon = new GIcon(G_DEFAULT_ICON);

			if(picto)	icfIcon.image = picto;
			else	 icfIcon.image = "http://www.investissement-immobilier-icf.fr/typo3conf/ext/daws_gmap/img/icf_pointer.gif";

			icfIcon.shadow= "";
			icfIcon.iconSize = new GSize(32, 37);

			// Set up our GMarkerOptions object
			markerOptions = { icon:icfIcon };

			var marker = new GMarker(point, markerOptions);

			return marker;
			
		}



		function showAddress(address, title) {
			if (geocoder) {
				geocoder.getLatLng(
					address,
					function(point) {
						if (!point) {
//							alert("adresse " + address + " invalide");
						} else {
							map.setCenter(point, 13);
							var marker = createMarker(point);
							

							GEvent.addListener(marker, "click", function() {
										marker.openInfoWindowHtml("<b>" + title + "</b><p>" + address + "</p>");
							});


							map.addOverlay(marker);
							marker.openInfoWindowHtml("<b>" + title + "</b><p>" + address + "</p>");
						}
					}
				);
			}
		}

		function mark(address, title) {
			if (geocoder) {
				geocoder.getLatLng(
					address,
					function(point) {
						if (!point) {
//							alert("adresse " + address + " invalide");
							lastActionSuccess = false;
						} else {
							map.setCenter(point, 13);
							var marker = createMarker(point);
							

							GEvent.addListener(marker, "click", function() {
										marker.openInfoWindowHtml("<b>" + title + "</b><p>" + address + "</p>");
							});


							map.addOverlay(marker);
						}
					}
				);
			}
		}


		function clearMap(){
			map.clearOverlays();
		}

		function getAddress(overlay, latlng) {
			if (latlng != null) {
				address = latlng;
				geocoder.getLocations(latlng, showAddressOnClick);
			}
		}


		function showAddressOnClick(response) {
			map.clearOverlays();
			if (!response || response.Status.code != 200) {
				alert("Status Code:" + response.Status.code);
				//return false;
			} else {
				place = response.Placemark[0];
				point = new GLatLng(place.Point.coordinates[1],
														place.Point.coordinates[0]);
				marker = createMarker(point);
				map.addOverlay(marker);
				marker.openInfoWindowHtml(
						'<b>Address:</b><br />'
						+ place.address 
					);
				
			//	if($('tx_dawsgmap_pi4[address]'))	$('tx_dawsgmap_pi4[address]').value = place.address;


							GEvent.addListener(marker, "click", function() {

									marker.openInfoWindowHtml(
											'<b>Address:</b><br />'
											+ place.address 
										);
									
				//					if($('tx_dawsgmap_pi4[address]'))	$('tx_dawsgmap_pi4[address]').value = place.address;

							});


				//console.debug(point);

			}
		}




		function showAddressAndPic(address, title, img, link, picto, description, alreadyOpen, setCenter) {
			if(!alreadyOpen)	 var alreadyOpen = false;
			if(!setCenter)	 var setCenter = false;



			if (geocoder) {
				geocoder.getLatLng(
					address,
					function(point) {
						if (!point) {
//							alert("adresse " + address + " invalide");
						} else {
//console.debug(address);
//console.debug(point);
							if(setCenter)	map.setCenter(point, 13);
							var marker = createMarker(point, picto);

							map.addOverlay(marker);
							if(link!="")	var temp = "<b><a href=" + link + ">" + title + "</a></b>"
							else	 var temp = "<b>" + title + "</b>"

							temp = temp + "<br /><br />"

							temp = temp + "<table style=\"width: 100%; height: 100px;\">"
							temp = temp + "<tr style=\"vertical-align: top;\">"
								temp = temp + "<td style=\"text-align: left; width: 120px; border: 0;\">"
									temp = temp + address
								temp = temp + "</td>"
								temp = temp + "<td style=\"text-align: right; width: 110px; border: 0;\">"
									if(link!="")	temp = temp + "<a href=" + link + ">"
										if(img!="uploads/tx_dawsgmap/" && img!="")	temp = temp + "<img src=" + img + " width=\"100\" />"
									if(link!="")	temp = temp + "</a>"
								temp = temp + "</td>"
							temp = temp + "</tr>"
							
							if(description!=""){
								var ligne = "<tr>"
									ligne = ligne + "<td colspan=\"2\" style=\"text-align: left; width: 120px; border: 0;\">"
										ligne = ligne + description
										
										if(link!="")	ligne = ligne + "<br /><br /><a href=" + link + ">Voir cette recommandation</a>"
									ligne = ligne + "</td>"
								ligne = ligne + "</tr>"
								temp = temp + ligne
							}
							
							temp = temp + "</table>"
							if(alreadyOpen)	marker.openInfoWindowHtml(temp);

							GEvent.addListener(marker, "click", function() {
								marker.openInfoWindowHtml(temp);
							});


						}
					}
				);
			}
		}





		function showPointAndPic(lat, lon, address, title, img, link, picto, description, alreadyOpen, setCenter) {
			if(!alreadyOpen)	 var alreadyOpen = false;
			if(!setCenter)	 var setCenter = false;

			if (geocoder) {
						point = new GLatLng(lat, lon);
//console.debug(point);
						if (point) {
							if(setCenter){
								map.setCenter(point, 13);
								map.setZoom(5);
							}
							var marker = createMarker(point, picto);

							map.addOverlay(marker);
							if(link!="")	var temp = "<b><a href=" + link + ">" + title + "</a></b>"
							else	 var temp = "<b>" + title + "</b>"

							temp = temp + "<br /><br />"

							temp = temp + "<table style=\"width: 200px; height: 100px; border: solid 1px transparent;\">"
							temp = temp + "<tr style=\"vertical-align: top;\">"
								temp = temp + "<td style=\"text-align: left; width: 120px; border: 0;\">"
									temp = temp + address
								temp = temp + "<br /><br /></td>"
								temp = temp + "<td style=\"text-align: right; width: 110px; border: 0;\">"
									if(link!="")	temp = temp + "<a href=" + link + ">"
										if(img!="uploads/tx_dawsgmap/" && img!="")	temp = temp + "<img src=" + img + " width=\"100\" />"
									if(link!="")	temp = temp + "</a>"
								temp = temp + "</td>"
							temp = temp + "</tr>"

							if(description!=""){
								var ligne = "<tr>"
									ligne = ligne + "<td colspan=\"2\" style=\"text-align: left; width: 120px; border: 0;\">"
										ligne = ligne + description
										
										if(link!="")	ligne = ligne + "<br /><br /><a href=" + link + ">Voir cette recommandation</a>"
										
									ligne = ligne + "</td>"
								ligne = ligne + "</tr>"
								temp = temp + ligne
							}
							
							temp = temp + "</table>"
							if(alreadyOpen)	marker.openInfoWindowHtml(temp);

							GEvent.addListener(marker, "click", function() {
								marker.openInfoWindowHtml(temp);
							});


						}
					}
		}