/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */


$(window).load(function () {

    /*
     * Google Maps a l'inici. Creació del div on apareix el map amb la
     * caixa de text per a cercar, i les variables necessàries.
     */

    var map;
    var map2;
    var map3;
    var marker;
    var marker2;
    var marker3;

    inicialitzarMapa();

});


function inicialitzarMapa() {
	
    var lat;
    var lon;
	var lat2;
    var lon2;
    var lat3; 
	var lon3;

	if ( document.getElementById('lat_map') )
		lat1 = document.getElementById('lat_map').value;
	else
		lat1 = 0;
		
	if ( document.getElementById('long_map') )
     	lon1 = document.getElementById('long_map').value;
	else
		lat1 = 0;

	if ( document.getElementById('lat_map_ant') )
		lat2 = document.getElementById('lat_map_ant').value;		
	else
		lat2 = 0;

	if ( document.getElementById('long_map_ant') )
     	lon2 = document.getElementById('long_map_ant').value;
	else
		lat2 = 0;

	if ( document.getElementById('lat_map_des') )
		lat3 = document.getElementById('lat_map_des').value;
	else
		lat3 = 0;
		
	if ( document.getElementById('long_map_des') )
     	lon3 = document.getElementById('long_map_des').value;
	else
		lat3 = 0;
    
    if (lat2 == 0)
        lat2=41.722131;
        
    if (lon2 == 0)
        lon2 = 1.829224;

    var myLatlng = new google.maps.LatLng(lat, lon);
    var myLatlng2 = new google.maps.LatLng(lat2, lon2);
    var myLatlng3 = new google.maps.LatLng(lat3, lon3);
    var myCentre = new google.maps.LatLng(41.722131,1.829224);

    var myOptions = {
      zoom: 7,
      center: myCentre,
      disableDefaultUI: true,
      scrollwheel: false,
      mapTypeId: google.maps.MapTypeId.TERRAIN
    };

    map = new google.maps.Map(document.getElementById("propera_activitat_mapa"),
        myOptions);

    map2 = new google.maps.Map(document.getElementById("darrera_activitat_mapa"),
        myOptions);

    map3 = new google.maps.Map(document.getElementById("activitat_destacada_mapa"),
        myOptions);

    marker = new google.maps.Marker({
        position: myLatlng,
        map: map
    });

    marker2 = new google.maps.Marker({
        position: myLatlng2,
        map: map2
    });

    marker3 = new google.maps.Marker({
        position: myLatlng3,
        map: map3
    });
}
