﻿<!--
var map;
var gdir;
var geocoder = null;
var addressMarker;
var adresseCamping = "1410 Route 131, St-Félix-de-Valois, Québec, J0K 2M0";
var isInit = false;

function submitEnter(e) {
    var keycode;
    if (window.event) keycode = window.event.keyCode;
    else if (e) keycode = e.which;
    else return true;
    if (keycode == 13){
       setDirectionsToCamping();
       return false;
     } else return true;
}


function initializeGMap() {
  if (GBrowserIsCompatible()) { 
    isInit = true;  
    map = new GMap2(document.getElementById("map_canvas"));
    geocoder = new GClientGeocoder();
	gdir = new GDirections(map, document.getElementById("directions-details"));
    GEvent.addListener(gdir, "error", handleErrors);
	//map.addControl(new GMapTypeControl());
	map.addControl(new GSmallMapControl());
	map.setMapType(G_HYBRID_MAP);
					

    if (geocoder) {
			geocoder.getLatLng(
			adresseCamping,
			function(point) {
				if (point) {
				    map.setCenter(point, 10);
				    var marker = new GMarker(point);
				    map.addOverlay(marker);
				    marker.openInfoWindowHtml('<strong>Domaine Camping Sentinelle</strong><br />1410 Route 131<br />St-Félix-de-Valois, Québec<br />J0K 2M0<br /><br /><strong>Sans frais: 1-800-268-8892</strong><br /><a href=\'mailto:info@campingsentinelle.com\'>info@campingsentinelle.com</a>');

				}
			}
			);
		}

    
  }
}

function setDirectionsToCamping() { 
    if( !isInit ) { initializeGMap(); }
    
    var fromAddress = $("#txtGMapFrom").val();
    if( fromAddress != undefined) { 
        $("#directions").show();
        gdir.load("from: " + fromAddress + " to: " + adresseCamping, { "locale": "fr" });
    }
    else { 
        $("#directions").hide();
        alert("Vous devez entrer une adresse pour obtenir le trajet.");
    }
}
function setDirections(fromAddress, toAddress, locale) {
  gdir.load("from: " + fromAddress + " to: " + toAddress, { "locale": locale });
}

function handleErrors(){
   alert("Impossible de trouver votre adresse!");
}

-->
