
  var markersArray = [];
  var map;
var geocoder;


function initialize() {

  var centerMap = new google.maps.LatLng(42.15,12.5);
  geocoder = new google.maps.Geocoder();

  var myOptions = {
    zoom: 5,
    center: centerMap,
    streetViewControl: false,
    mapTypeId: google.maps.MapTypeId.TERRAIN
  };

  map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
  
  var imageBounds = new google.maps.LatLngBounds( new google.maps.LatLng(36.5,7), new google.maps.LatLng(48,18));


  var groundOverlay = new google.maps.GroundOverlay("http://www.mondometeo.org/kml/observed/img/colorbar_help.gif",imageBounds);

//  groundOverlay.setMap(map);


   groundOverlay = new google.maps.GroundOverlay("http://www.mondometeo.org/kml/observed/gif.php?pos=prova-3",imageBounds);
   markersArray.push(groundOverlay);

   groundOverlay = new google.maps.GroundOverlay("http://www.mondometeo.org/kml/observed/gif.php?pos=prova-2",imageBounds);
   markersArray.push(groundOverlay);

   groundOverlay = new google.maps.GroundOverlay("http://www.mondometeo.org/kml/observed/gif.php?pos=prova-1",imageBounds);
   markersArray.push(groundOverlay);

   groundOverlay = new google.maps.GroundOverlay("http://www.mondometeo.org/kml/observed/gif.php?pos=prova",imageBounds);
   markersArray.push(groundOverlay);

  showOverlays();

}




function clearOverlays() {
  if (markersArray) {
    for (i in markersArray) {
      markersArray[i].setMap(null);
    }
  }
}

function animate(){
   var j = 0;
   for(i = 0 ; i<4 ; i++){
      if (i>0 && markersArray[i-1].getMap()!=null) {
          markersArray[i-1].setMap(null);
          j = i;
          break;
      }
   }

   markersArray[j].setMap(map);
   if ( j==3 ) {
    setTimeout("showOverlays()",1000);
   }
}

function showOverlays() {
   clearOverlays();
   if (markersArray) {
      for (i = 0 ; i<4 ; i++) {
         setTimeout("animate()",700*i);
      }
   }
}

 function codeAddress() {
    var address = document.getElementById("address").value;
    geocoder.geocode( { 'address': address}, function(results, status) {
      if (status == google.maps.GeocoderStatus.OK) {
        map.setCenter(results[0].geometry.location);
        var marker = new google.maps.Marker({
            map: map, 
            position: results[0].geometry.location
        });
      } else {
        alert("Geocode was not successful for the following reason: " + status);
      }
    });
  }



