var map = new Array();
var mapsList = new Array();

function PrintMaps() {
	
	mapCounter = 0;
	for (var mapData in mapsList) {
		
		// Estilo
		style = (mapsList[mapData][4]) ? mapsList[mapData][4] : "r";

		// Zoom
		zoom = (mapsList[mapData][3]) ? mapsList[mapData][3] : 1;
		
		// Modo
		mode = ( mapsList[mapData][5] ) ? mapsList[mapData][5] : 2;
		switch (mode) {
			case 3:
				mode = VEMapMode.Mode3D;
				break;
			default:
				mode = VEMapMode.Mode2D;
				break;
		}
		
		map[mapCounter] = new VEMap(mapsList[mapData][0]);
		map[mapCounter].SetDashboardSize(VEDashboardSize.Normal);
		
		map[mapCounter].LoadMap(new VELatLong(mapsList[mapData][1], mapsList[mapData][2]), zoom, style, false, mode, true);
		
		// add pushpins
		var pushpinList = mapsList[mapData][6];

		if ( pushpinList && pushpinList != "" ) {
			var pin;
			for ( i = 0; i < pushpinList.length; i++ ) {
				if ( pushpinList[i] ) {
					var p_lat = pushpinList[i][0];
					var p_long = pushpinList[i][1];
					
					pin = new VEShape( VEShapeType.Pushpin, new VELatLong(p_lat, p_long) );
					
					var p_title = pushpinList[i][2];
					if ( p_title != '' ) pin.SetTitle(p_title);
					
					var p_descript = pushpinList[i][3];
					if( p_descript != '' ) p_descript = "<p>" + p_descript + "</p>";
					
					var p_moreinfoURL = pushpinList[i][4];
					if( p_moreinfoURL != '' ) p_moreinfoURL = '<div style="padding: 5px">' + '<a href="' + p_moreinfoURL + '" target="_blank">' + moreinfoText + '</a></div>';
					
					pin.SetDescription( p_descript + p_moreinfoURL );

					var p_photoURL = pushpinList[i][5];
					if ( p_photoURL != '' ) pin.SetPhotoURL(p_photoURL);
					
					map[mapCounter].AddShape(pin);
				}
			}

		}
	}	
}

function addMapListLoadEvent(func) {
	var oldonload = window.onload;
	if (typeof window.onload != 'function'){
		window.onload = func;
	} else {
		window.onload = function() { oldonload(); func(); }
	}
}
addMapListLoadEvent(PrintMaps);

