 var map = null;
 var geocoder = null;
 var b2aAccordion = null;
 var gdir = null;
 var addressMarker = null;
 var b2a_adresse = "4 r Claude Chappe 69370 SAINT DIDIER AU MONT D'OR";
 var b2a_new = "58 Chemin de la Bruyere 69570 Dardilly";
 var adresse = "";
 
function printme()
{
	window.print();
}
 
 function initMap(imageDir)
{
	if (GBrowserIsCompatible()) 
	{
	  map = new GMap2(document.getElementById("map"));
	  gdir = new GDirections(map, document.getElementById("directions"));
	  //gdir = new GDirection(map);
	  	map.addControl(new GLargeMapControl());
	 	 map.addControl(new GMapTypeControl());
	  	geocoder = new GClientGeocoder();
	  	adresse = (Date.parse(Date()) > Date.parse("Jun 21 2008"))? b2a_new : b2a_adresse;
	  	showAddress(adresse,imageDir);	
	  }
}
	
function makeb2Aicon(imageDir)
{
	var icon = new GIcon();
        icon.image = imageDir + "pointeur-carte.png";
        icon.iconAnchor = new GPoint(25, 72);
        icon.infoWindowAnchor = new GPoint(16, 0);
        icon.iconSize = new GSize(50, 72);
        icon.shadow = imageDir + "pointeur-ombre.png";
        icon.shadowSize = new GSize(89, 72);
		  return icon;
}
//function setDirections(fromAddress, toAddress, locale) {
function setDirections(fromAddress) {
	//alert("yo");
      gdir.load("from: " + fromAddress + " to: " + adresse, { "locale": "fr" });
}
 function showAddress(adr,imageDir) {
	if (geocoder) 
	{
	  geocoder.getLatLng(
		 adr,
		 function(point) 
		 {
			if (!point) {
			  alert(adr + " not found");
			} else {
				
			 map.setCenter(point, 15);
			  var marker = new GMarker(point, { icon: makeb2Aicon(imageDir) });
			  map.addOverlay(marker);
			 // GEvent.addListener(map, "dragstart", alert(map.getCenter()));
			  //alert(map.getCenter());
			}
		 }
	  );
	}
 }