
var map;
var directionsPanel;
var directions;
var egzIcon;

function loadMap() {
  if (GBrowserIsCompatible()) {
    map = new GMap2(document.getElementById("map"));

	var egzPoint = new GLatLng(46.343316,-72.543900);

	map.setCenter(egzPoint, 7);
	map.setMapType(G_SATELLITE_MAP);
	map.addControl(new GSmallZoomControl());
	map.addControl(new GMapTypeControl());
	map.enableDoubleClickZoom();
	map.enableContinuousZoom();
	map.enableScrollWheelZoom();

	myKBHandler = new GKeyboardHandler(map);
	
	egzIcon = new GIcon();
	egzIcon.image = "http://www.egzakt.com/images/ul/icones/PinEgz.png";
	egzIcon.shadow = "http://www.egzakt.com/images/ul/icones/PinEgz_Ombre.png";
	egzIcon.iconSize = new GSize(70, 42);
	egzIcon.shadowSize = new GSize(70, 42);
	egzIcon.iconAnchor = new GPoint(25, 42);
	egzIcon.infoWindowAnchor = new GPoint(5, 1);
	
	//markerOptions = { icon:egzIcon };
	
	marker01 = new GMarker(egzPoint, egzIcon);

	directionsPanel = document.getElementById("directions");
	directions = new GDirections(map, directionsPanel);
	//directions.load("from: 5233, rue Rivard, Montreal, QC, Canada to: 1350 Rue Royale, Trois-Rivieres, QC, Canada");

	var it = new GInfoWindowTab("Place Royale",$('#infobulle').html());

	GEvent.addListener(marker01, "click", function() {
		marker01.openInfoWindowTabsHtml([it]);
	});
	map.addOverlay(marker01);
	GEvent.addListener(directions, "load", onGDirectionsLoad);
	//GEvent.addListener(directions, "error", onGDirectionsError);
  }
}

function getDirections(from){
	dirString = "from: "+from+" to: 1350 Rue Royale, Trois-Rivieres, QC, Canada";
	directions.load(dirString);
}

function onGDirectionsLoad(){
	$("#directions").show();
	map.setMapType(G_NORMAL_MAP);
}

function onGDirectionsError(){
	$("#directions").show();
	console.log(directions.getStatus());
}

//]]>

$(function() {
	});
