function initialize() {
var mapOpts = { mapTypeId: google.maps.MapTypeId.ROADMAP, zoom: 9, center: new google.maps.LatLng(43.326366,10.465178) }
var map = new google.maps.Map(document.getElementById("mapdx"), mapOpts);
var infoWindow = new google.maps.InfoWindow();
var markerBounds = new google.maps.LatLngBounds();
var markerArray = [];
 
function makeMarker(options){
  var pushPin = new google.maps.Marker({map:map});
  pushPin.setOptions(options);
  google.maps.event.addListener(pushPin, "click", function(){
    infoWindow.setOptions(options);
    infoWindow.open(map, pushPin);
    if(this.sidebarButton)this.sidebarButton.button.focus();
  });
  var idleIcon = pushPin.getIcon();
  if(options.sidebarItem){
    pushPin.sidebarButton = new SidebarItem(pushPin, options);
    pushPin.sidebarButton.addIn("sidebar");
  }
  markerBounds.extend(options.position);
  markerArray.push(pushPin);
  return pushPin;
}
 
google.maps.event.addListener(map, "click", function(){
  infoWindow.close();
});

function SidebarItem(marker, opts){
  var tag = opts.sidebarItemType || "text";
  var row = document.createElement(tag);
  row.innerHTML = opts.sidebarItem;
  row.className = opts.sidebarItemClassName || "sidebar_item";  
  row.style.display = "block";
  row.style.width = opts.sidebarItemWidth || "150px";
  row.onclick = function(){
    google.maps.event.trigger(marker, 'click');
  }
  row.onmouseover = function(){
    google.maps.event.trigger(marker, 'mouseover');
  }
  row.onmouseout = function(){
    google.maps.event.trigger(marker, 'mouseout');
  }
  this.button = row;
}

SidebarItem.prototype.addIn = function(block){
  if(block && block.nodeType == 1)this.div = block;
  else
    this.div = document.getElementById(block)
    || document.getElementById("sidebar")
    || document.getElementsByTagName("body")[0];
  this.div.appendChild(this.button);
}

SidebarItem.prototype.remove = function(){
  if(!this.div) return false;
  this.div.removeChild(this.button);
  return true;
}

makeMarker({
  position: new google.maps.LatLng(43.7687324,11.2569013),
  title: "Firenze", sidebarItem: "FIRENZE", content: "<a href=residence-firenze.asp>Firenze</a>"
});   
makeMarker({
  position: new google.maps.LatLng(43.3570,10.450),
  title: "Pisa", sidebarItem: "PISA", content: "<a href=residence-pisa.asp>Pisa</a>"
});
makeMarker({
  position: new google.maps.LatLng(43.2333333,10.6166667),
  title: "San Gimignano", sidebarItem: "SAN GIMIGNANO", content: "<a href=residence-san-gimignano.asp>San Gimignano</a>"
});
makeMarker({
  position: new google.maps.LatLng(43.172635,10.56),
  title: "Siena", sidebarItem: "SIENA", content: "<a href=residence-siena.asp>Siena</a>"
});
makeMarker({
  position: new google.maps.LatLng(43.2333,10.5166),
  title: "Volterra", sidebarItem: "VOLTERRA", content: "<a href=residence-volterra.asp>Volterra</a>"
});   

 map.fitBounds(markerBounds);
}
