var functions = {}

Object.extend(functions,{	
	getMap : function(id) {
		var mapcontainer = $("mapcontainer_"+id);
		var map = $("map_"+id);
		if (mapcontainer.style.display == "none") {
			if (mapcontainer.getAttribute("loaded")) {
				Element.toggle(mapcontainer);
			}
			else {
				var r = new Ajax.Request("/applications/spug/htdocs/get_google_map.php?cmd=get_map&id="+id,{
					onLoading: function() {

					},
					onComplete: function(res) {
						Element.update(map,res.responseText);
						Element.toggle(mapcontainer);
						mapcontainer.setAttribute("loaded",1);
					}
				});
			}

		}
		else {
			Element.toggle(mapcontainer);
		}
	}
});