	var map = null;
	var moveMarker = null;
	var bns = null;
	var mapIsReady = false;
	
	function initialize() 
	{
		if (GBrowserIsCompatible()) 
		{
			//Set up mal and layout. Set CH as center
			map = new GMap2(document.getElementById("map_canvas"));
			var center = new GLatLng(40.73233, 8.45947);
			map.setCenter(center, 7);
			map.addControl(new GMapTypeControl());
			map.addControl(new GLargeMapControl());
			map.setMapType(G_SATELLITE_MAP);
			
			//Init vars
			bns = new GLatLngBounds();
			mapIsReady = true;
		}
	}
	
	function getResearchMarkers(ssid) {
		$.get("googlemap/googlemap-jsoninterface.ext", { "action": "getsitesforresearch", "selectedsiteid": ssid }, dataMarkers);
	}
	
	function dataMarkers(data) {
	
		var oData = eval ( data );
		//alert(data)
		if (oData && oData.sites) {
		
			var bFoundLoc = false;
			for (var iSite = 0; iSite < oData.sites.length; iSite++) {
			
				var site = oData.sites[iSite];
				if (site.latitude && site.longitude) {
					
					var sHtmlBubble = 	'<div id="bubble" class="clearfix" style="width:450px;">'
					
					if (site.picurl && site.picurl != "null") {
						if (site.picurl && site.picurl != "") {
						 	sHtmlBubble += '<div class="floating"><img src="'+site.picurl+'"></div>';
						}
					}
					sHtmlBubble += '<div class="column" >'+
										'<p style="padding-right:0px;">'+
											'<strong>' + site.title + '</strong><br />' + 
											//site.adr + 
											site.teaser_text + 
										'</p>'
					
					var bShowBubble = false;
					var sSpecialIcon = null;
					var oDomEle = new Object();
					oDomEle.className = "";
					
					if (site.id == oData.request.selectedsiteid) {
						bShowBubble = true;
						sSpecialIcon = "blue";
						bFoundLoc = true;
						
						map.setZoom(12);
						
						if (site.site_google_zoom) {
							//alert(site.site_google_zoom)
							map.setZoom(site.site_google_zoom);
						}

						map.setCenter(new GLatLng(site.latitude, site.longitude));
						
						oDomEle.className = "active";
					}
					else {
						sHtmlBubble += '<p><a href="googlemap/r_d_sites.htm?id='+site.id+'">Click to see details</a></p><br style="clear: both;">';
					}
					
					sHtmlBubble += '</div>'; //Text
					sHtmlBubble += '</div>'; //Bubble
					
					AddMarkerAtPosition(site.latitude, site.longitude, sHtmlBubble, sSpecialIcon, bShowBubble);
					
					
					if (!oData.request.selectedsiteid || oData.request.selectedsiteid == "null") {
						var sHtmlLink = ""
						if (site.title) {
							sHtmlLink = site.title;
						}
						
						var oLi = "<li class='" + oDomEle.className + "'><a href='googlemap/r_d_sites.htm?id=" + site.id + "'><img src='red-dot.gif' width='16' height='16' class='inl' />" + sHtmlLink + "</a></li>";
													
						$('ul#countryList').append(oLi);
					}
				}
			}
			if (!bFoundLoc) {
				ZoomMapToShowAllPoints();
			}
		}
	}
	
	function AddMarkerAtPosition(lat, lng, txt, spec, bShowBubble)
	{
		var icoW = 32;
		var icoH = 32;
		var icoUrl = "http://images.google.com/intl/en_ALL/mapfiles/ms/icons/red-dot.png";
		//var icoUrl = "red-dot.gif";
		
		if (isNaN(parseInt(spec)))
			switch (spec)
			{
				case "blue":
					icoW = 32;
					icoH = 32;
					icoUrl = "http://images.google.com/intl/en_ALL/mapfiles/ms/icons/blue-dot.png";
					//icoUrl = "blue-dot.gif";
					break;
					
				default:
					//icoUrl = "http://www.danysan.com/gennamedmarker?txt="+spec;
					break;
					
			}
		else
			if (parseInt(spec) > 0)
			{
				icoW = 20;
				icoH = 34;
				icoUrl = "http://gmaps-samples.googlecode.com/svn/trunk/markers/green/marker"+spec+".png";
			}
				
		var ico = GetGIcon(icoW, icoH, icoUrl);
		var pt = new GLatLng(lat, lng);
		
		var mk = new GMarker(pt, { icon:ico });
			
		map.addOverlay(mk);
		
		bns.extend(pt);
		
		
		GEvent.addListener(mk, "click", function() {
	    mk.openInfoWindowHtml(txt);
	  	});
		  
		if (bShowBubble) {
			mk.openInfoWindowHtml(txt);
		}
	}
	
	function GetGIcon(w, h, imgUrl)
	{
		var iUr = imgUrl || "http://www.google.com/mapfiles/marker.png";
	
		var gIco = new GIcon();
		    gIco.shadow = "http://www.google.com/mapfiles/shadow50.png";
			
		gIco.iconSize = new GSize(w, h);
	    gIco.shadowSize = new GSize(w*2, h);
	    gIco.iconAnchor = new GPoint(w/2, h);
	    gIco.infoWindowAnchor = new GPoint(w/2, 2);
	    gIco.infoShadowAnchor = new GPoint(w/2, 2);
		
		
		var spIcon = new GIcon(gIco);
		spIcon.image = iUr;
			
		return spIcon;
	}
	
	function ZoomMapToShowAllPoints()
	{
		map.setZoom(map.getBoundsZoomLevel(bns));
		map.setCenter(bns.getCenter());
	}
