/* CONFIG */
/*
menuClassName = "menuNavigazione";
*/

/* SCRIPT */

/*
function closeSub(menu) {
	for (var i=0; i<menu.childNodes.length; i++)
		if (menu.childNodes[i].nodeName.toLowerCase()=="li") {
			li = menu.childNodes[i];
			li.onmouseover = li.onactivate = li.onfocus = function() { if (this.subMenu) this.subMenu.className = this.subMenu.className.replace(/subMenu-off/g,"subMenu-on") };
			li.onmouseout = li.ondeactivate = li.onblur = function() { if (this.subMenu) closeSub(this.subMenu) };
			for (j=0; j<li.childNodes.length; j++)
				if (li.childNodes[j].nodeName.toLowerCase()=="ul" || li.childNodes[j].nodeName.toLowerCase()=="ol") closeSub(li.subMenu = li.childNodes[j]);
		}
	menu.className = menu.className.replace(/\s?subMenu-on/g,"")+" subMenu-off";
}
*/

/* ON LOAD */

window.onload = function(e) {
	init();
/*
	if(tags_ = document.getElementsByTagName('ul'))
		for(i=0; i<tags_.length; i++) 
			if (tags_[i].className==menuClassName) closeSub(tags_[i]);
	if(tags_ = document.getElementsByTagName('ol'))
		for(i=0; i<tags_.length; i++) 
			if (tags_[i].className==menuClassName) closeSub(tags_[i]);
*/
}


var centerLatitude = 44.29999;
var centerLongitude = 8.46;
var startZoom = 13;

var map;

function addMarker(latitude, longitude, description) {
    var marker = new GMarker(new GLatLng(latitude, longitude));

    GEvent.addListener(marker, 'click',
        function() {
            marker.openInfoWindowHtml(description);
        }
    );

    map.addOverlay(marker);
}

function init() {
    if (GBrowserIsCompatible()) {	
        map = new GMap2(document.getElementById("mappa_dinamica"));
        map.addControl(new GSmallMapControl());
        map.setCenter(new GLatLng(centerLatitude, centerLongitude), startZoom);

        for(id in markers) {
        	if(markers[id].latitude!=undefined){
	            addMarker(markers[id].latitude, markers[id].longitude, markers[id].name);
        	}
        }
    }
}
//window.onload = init;
window.onunload = GUnload;
