	/* all functions related to google maps */
	var bmap;
	var bmarkerPosition;
	var binfowindow;
	
	$(document).ready(function() {
		$.getJSON("/wp-content/plugins/social-sharer/social-get-resolutions.php", 
		{},
		function(data) {
			googleBigMapInitialize(data);
		});
	});

  function googleBigMapInitialize(markerData) {
    // windowText = buildInfoWindowContent(false,false,false);
    // binfowindow = new google.maps.InfoWindow({maxWidth:300,height:200,content:windowText});
    // binfowindow.setContent(windowText);

    var myOptions = {
      zoom: 8,
      mapTypeId: google.maps.MapTypeId.HYBRID
    };
    bmap = new google.maps.Map(document.getElementById('bigmap_canvas'),
        myOptions);
	
    var pos = new google.maps.LatLng(52.090142,5.109665);
	
    var saveMarker = false;
	var infoBox = false;

	//console.log('markerData: '+markerData);

	for(var k=0;k<markerData.length;k++) {

		var pos = new google.maps.LatLng(markerData[k].lat,markerData[k].lon);
		var tempMarker = createBigMapMarker(bmap,pos,markerData[k].users_id, markerData[k].socialavatar,markerData[k].socialname,markerData[k].resolutionText);
		//console_log(tempMarker);
		
		//console.log('showRes: '+showResolution);
		
		if(showResolution) {
			if(markerData[k].id == showResolution) {
				saveMarker = tempMarker.marker;
				infoBox = tempMarker.info;
				savePos = pos;
			}
		}
	}
	
    if(saveMarker) {
		//console.log('saveMarker');
      infoBox.open(bmap, saveMarker);
      bmap.setCenter(savePos);
      bmap.panBy(0,-100)
    } else {
		//console.log('DEFAULT UTRECHT');
		pos = new google.maps.LatLng(52.090142,5.109665);
      bmap.setCenter(pos);
	  bmap.setZoom(8);
    }
  }

function createBigMapMarker(bmap,pos,user_id, avatar,name,text) {
	
	
	//console_log(user_id);
	var image = new google.maps.MarkerImage("/wp-content/uploads/map-markers/"+user_id+"-marker.png",
	// This marker is 20 pixels wide by 32 pixels tall.
	new google.maps.Size(51, 71),
	// The origin for this image is 0,0.
	new google.maps.Point(0,0),
	// The anchor for this image is the base of the flagpole at 0,32.
	new google.maps.Point(11, 71));
	
	var shadow = new google.maps.MarkerImage('/wp-content/plugins/buddypress/bp-themes/actimel/_inc/images/resolutions/google-maps-marker-shade.png',
	// The shadow image is larger in the horizontal dimension
	// while the position and offset are the same as for the main image.
	new google.maps.Size(74, 46),
	// The origin for this image is 0,0.
	new google.maps.Point(0,0),
	// The anchor for this image is the base of the flagpole at 0,32.
	new google.maps.Point(11, 71));

	var bmarker = new google.maps.Marker({
		position:pos,
		map:bmap,
		draggable:false,
		icon:image,
		shadow:shadow
	});

	var InfoWindowContent ="<div style='position: absolute; overflow:hidden; display:block;height:46px;width:156px; top: 14px; left: 20px; line-height: 14px'><img style='margin-right:5px; float:left; width:25px; height:25px;' align='left' src='"+avatar+"'/><span style='display:block; width:120px; float:left;'><p style='margin-bottom: 0; color: #0193f1; font-family: Trebuchet MS; font-size: 12px;font-weight: bold;'>"+name+"</p><p style='color: #6c7c81; font-family: Trebuchet MS; font-size: 10px; font-weight: normal;'>"+text+"</p></span><span style='clear:both;'></span></div>";

	var myOptions = {
		content: InfoWindowContent
		,disableAutoPan: false
		,maxWidth: 0
		,pixelOffset: new google.maps.Size(-49, -91)
		,zIndex: null
		,boxStyle: { 
			background: "url('/wp-content/plugins/buddypress/bp-themes/actimel/_inc/images/resolutions/google-maps-infobox-bg.png') no-repeat"
			,width: "263px"
			,height: "97px"
		}
		,closeBoxMargin: "17px 80px 0px 0px"
		,closeBoxURL: "/wp-content/plugins/buddypress/bp-themes/actimel/_inc/images/resolutions/google-maps-close-btn.png"
		,infoBoxClearance: new google.maps.Size(1, 1)
		,isHidden: false
		,pane: "floatPane"
		,enableEventPropagation: false
	};

	var ib = new InfoBox(myOptions);
	// ib.open(bmap, bmarker);
	
    bmarkerPosition = pos;
    google.maps.event.addListener(bmarker, "click", function (e) {
		ib.open(bmap, this);
	});
	
	var markerInfo = {marker:bmarker, info:ib};
	
    return markerInfo;
}



