function flash_media(url) {
	var code = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="400" height="400"><param name="movie" value="' + url + '" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="wmode" value="" /><embed src="' + url + '" wmode="" quality="high" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="400" height="400"></embed></object>';
	document.getElementById("content").innerHTML = code;
}

function flash_mission(url) {
	var code = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,29,0" width="520" height="327"><param name="movie" value="' + url + '" /><param name="quality" value="high" /><param name="menu" value="false" /><param name="wmode" value="" /><embed src="' + url + '" wmode="" quality="high" menu="false" pluginspage="http://www.macromedia.com/go/getflashplayer" type="application/x-shockwave-flash" width="520" height="327"></embed></object>';
	document.getElementById("content").innerHTML = code;
}

function show() {
		document.getElementById('top_shelf').style.display = 'block';
		document.getElementById('top_nav').style.display = 'block';
		document.getElementById('top_nav_close').style.display = 'none';
		setCookie("box","box=show",1);
}

function hide() {
		document.getElementById('top_shelf').style.display = 'none';
		document.getElementById('top_nav').style.display = 'none';
		document.getElementById('top_nav_close').style.display = 'block';
		setCookie("box","box=hide",1);
}

function getCookie(NameOfCookie) {
	if (document.cookie.length > 0) {
		begin = document.cookie.indexOf(NameOfCookie+"=");
		if (begin != -1) {
			begin += NameOfCookie.length+1;
			end = document.cookie.indexOf(";", begin);
			return unescape(document.cookie.substring(begin, end));
		}
		else
			return null;
	}
	else
		return null;
}

function setCookie(NameOfCookie, value, expirehours) {
	var ExpireDate = new Date ();
	ExpireDate.setTime(ExpireDate.getTime() + (expirehours * 3600 * 1000));
	document.cookie = NameOfCookie + "=" + escape(value) + ((expirehours == null) ? "" : "; expires=" + ExpireDate.toGMTString());
}

function checkBoxCookie() {
	var cookie = getCookie("box");
	if (cookie != null) {
		if (cookie == "box=show")
			show();
		else
			hide();
	} else
		show();
}

var trip;
var map_arr = new Array();
map_arr["id"] = new Array("map_cm","map_sc","map_im","map_sv","map_sl","map_centroascolto","map_bancoalimenti","map_mondobambino","map_mozambico","map_congo");
map_arr["lat"] = new Array(40.7998,40.8039,40.7976,40.8016,40.7978,40.7984,40.8036,40.7989,-20.8226,-4.0383);
map_arr["lng"] = new Array(16.9236,16.9234,16.9278,16.9267,16.9197,16.9178,16.9234,16.924,33.6425,21.7587);
map_arr["zoom"] = new Array(17,16,17,17,17,16,16,17,5,5);
map_arr["icon"] = new Array("http://www.upgo.org/upgov1/images/map/CM_sphere.png","http://www.upgo.org/upgov1/images/map/SC_sphere.png","http://www.upgo.org/upgov1/images/map/IM_sphere.png","http://www.upgo.org/upgov1/images/map/SV_sphere.png","http://www.upgo.org/upgov1/images/map/SL_sphere.png",true,true,true,false,false);
map_arr["marker"] = new Array(false,false,false,false,false,false,false,false,
							  new Array(new Array('<div style="color:#0033cc">Luogo: <b>Maputo</b> (Capitale)<br><br>Qui ha sede la missione di Fra Domenico Maria.<br><br><b><a href="http://www.upgo.org/upgov1/index.php?option=com_content&task=view&id=196&Itemid=120" style="color:#0033cc">> Articoli su Maputo</a></b></div>',-25.9686,32.5804),
																						new Array('<div style="color:#0033cc">Luogo: <b>Muhalaze</b><br><br>Presenza di un centro nutrizionale gestito da suore domenicane.<br><br><b><a href="http://www.upgo.org/upgov1/index.php?option=com_content&task=view&id=193&Itemid=120" style="color:#0033cc">> Articoli su Muhalaze</a></b></div>',-25.7983,32.5011)),
							  new Array(new Array('<div style="color:#0033cc">Luogo: <b>Bukavu</b><br><br>Qui ha sede la missione di Padre Pio De Mattia.</div>',-2.5304,28.8499)));
var index;

function load_map() {
	for (var i=0; i<map_arr["id"].length; i++) {
		if (document.getElementById(map_arr["id"][i]) != null) {
			if (GBrowserIsCompatible()) {
				var map = new GMap2(document.getElementById(map_arr["id"][i]));
				trip = new GDirections(map);
				map.addControl(new GSmallMapControl());
				var center = new GLatLng(map_arr["lat"][i], map_arr["lng"][i]);
				map.setCenter(center, map_arr["zoom"][i]);
				if (map_arr["icon"][i] == true)
					map.addOverlay(new GMarker(center));
				else if (map_arr["icon"][i] == false) {}
				else {
					var icon = new GIcon();
					icon.image = map_arr["icon"][i];
					icon.iconSize = new GSize(24, 24);
					icon.iconAnchor = new GPoint(12, 12);
					map.addOverlay(new GMarker(center,icon));
				}
				if (map_arr["marker"][i] != false) {
					var icon = new GIcon();
					icon.image = "http://www.upgo.org/upgov1/images/map/point.png";
					icon.iconSize = new GSize(21, 30);
					icon.iconAnchor = new GPoint(10, 30);
					icon.infoWindowAnchor = new GPoint(10, 1);
					for (var j=0; j<map_arr["marker"][i].length; j++) {
						var marker = new GMarker(new GLatLng(map_arr["marker"][i][j][1],map_arr["marker"][i][j][2]),icon);
						marker.bindInfoWindowHtml(map_arr["marker"][i][j][0]);
						map.addOverlay(marker);
					}
				}
				index = i;
			}
			return;
		}
	}
}

function set_trip(partenza) {
	trip.load("from: " + partenza + " to: " + map_arr["lat"][index] + ", " + map_arr["lng"][index]);
}

function load_missio_map(id) {
	var elemento = document.getElementById(id);
	elemento.innerHTML = '<div id="map_' + id + '" style="width: 520px; height: 327px">&nbsp;</div>';
	load_map();
}
