/* funcio per escriure el mail per pantalla*/
function mail(nom, domini, id){
	
}
    
//function load() {
//	if (GBrowserIsCompatible()) {
//		var map = new GMap2(document.getElementById("map"));
//		map.setCenter(new GLatLng(41.97404058798256, 3.1851768493652344), 13);		
//	}
//}

 
var map;
var gdir;
var geocoder = null;
var addressMarker;

function load() {
    if (GBrowserIsCompatible()) {      
        map = new GMap2(document.getElementById("map_canvas"));
        map.setCenter(new GLatLng(41.9936593392329, 3.185734748840332), 13);	
        gdir = new GDirections(map, document.getElementById("directions"));
	    map.addControl(new GSmallMapControl());
		map.addControl(new GMapTypeControl());

        //   map.addControl(new GLargeMapControl());
        
        GEvent.addListener(gdir, "load", onGDirectionsLoad);
        GEvent.addListener(gdir, "error", handleErrors);

// marca poble de pals
//        var pals = new GLatLng(41.971215, 3.148876);
//        map.addOverlay(new GMarker(pals));
    
     	setDirections("", "Pals", "ca_ES");
// marca apartaments 
        var fIcon = new GIcon(G_DEFAULT_ICON);
        fIcon.image = "imatges/seccions/situacio/apartaments.png";
        fIcon.iconSize = new GSize(124,115);
        fIcon.iconAnchor = new GPoint(15,101);
        fIcon.shadow=null;
        markerOptions = { icon:fIcon };			/*41.995611,3.198503*/
        map.addOverlay(new GMarker(new GLatLng(41.99567271042535, 3.1991028785705566), markerOptions));
// marca mas gelebert (fet)
        var fIcon = new GIcon(G_DEFAULT_ICON);
        fIcon.image = "imatges/seccions/situacio/gelabert.png";
        fIcon.iconSize = new GSize(75,70);
        fIcon.iconAnchor = new GPoint(64,68);
        markerOptions = { icon:fIcon };  
        map.addOverlay(new GMarker(new GLatLng(42.003578064777145, 3.1658005714416504), markerOptions));
// marca golf pals  platja (fet com marca el google)
        var fIcon = new GIcon(G_DEFAULT_ICON);
        fIcon.image = "imatges/seccions/situacio/golf.png";
        fIcon.iconSize = new GSize(108,75);
         fIcon.iconAnchor = new GPoint(97,56);       
        markerOptions = { icon:fIcon };
        map.addOverlay(new GMarker(new GLatLng(41.993380253051356, 3.1923115253448486), markerOptions));	

               
        
        
// marca La costa (fet )
        var fIcon = new GIcon(G_DEFAULT_ICON);
        fIcon.image = "imatges/seccions/situacio/resort.png";
        fIcon.iconSize = new GSize(131,91);
        fIcon.iconAnchor = new GPoint(5,6);        
        markerOptions = { icon:fIcon };			/* (41.9959079318153, 3.1975257396698) */
        map.addOverlay(new GMarker(new GLatLng(41.9959079318153, 3.1975257396698), markerOptions));

// marca golf les serres(fet)
        var fIcon = new GIcon(G_DEFAULT_ICON);
        fIcon.image = "imatges/seccions/situacio/serres.png";
        fIcon.iconSize = new GSize(78,75);
        fIcon.iconAnchor = new GPoint(7,63);
        markerOptions = { icon:fIcon };
        map.addOverlay(new GMarker(new GLatLng(42.0040564208188, 3.166680335998535), markerOptions));
    }
}
    
function setDirections(fromAddress, toAddress, locale) {
	gdir.load("from: " + fromAddress + " to: " + toAddress,
		{ "locale": locale });
}

function handleErrors(){
	
/**	
	if (gdir.getStatus().code == G_GEO_UNKNOWN_ADDRESS)
		alert("No s'ha pogut trobar una de les ubicacions geográfiques. Això pot ser degut a que la direcció és relativament nova o incorrecta.\nError code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_SERVER_ERROR)
		alert("Una de les geocodificacions o direccions solicitades no ha pogut ser procesada amb exit, no obstant, la rao exacta és:\n Error code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_MISSING_QUERY)
		alert("No s'ha especificat una direcció d'entrada.\n Error code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_BAD_KEY)
		alert("La clau donada no es valida o no coincideix amb el domini per el que s'ha donat. \n Error code: " + gdir.getStatus().code);
	else if (gdir.getStatus().code == G_GEO_BAD_REQUEST)
		alert("Les direccions no han pogut ser analitzades amb exit..\n Error code: " + gdir.getStatus().code);
	else alert("Error desconegut."); 
*****/
}

function onGDirectionsLoad(){ 
  // Use this function to access information about the latest load()
  // results.
  // e.g.
  // document.getElementById("getStatus").innerHTML = gdir.getStatus().code;
  // and yada yada yada...
}

       
