	


	var wolpins = new Array();
	var map;
    
	function createWolpinMarker(id, yellow_icon) {
		var wolpin = wolpins[id];
		if(yellow_icon==true){
			var marker = new GMarker(wolpin, markerOptions);
		}else{
			var marker = new GMarker(wolpin);
		}
		
		
		GEvent.addListener(marker, "click", function() { 
			marker.openInfoWindow(wolpin.content); 
		});
		return marker;
	}
	
	function maxZ(){
		return 100000000000;
	}
	function load() {
	// Create our "tiny" marker icon
	var yellow_flag = new GIcon(G_DEFAULT_ICON);
	yellow_flag.image = "/media/images/marker_yellow.png";
	// Set up our GMarkerOptions object
	markerOptions = { icon:yellow_flag, zIndexProcess:maxZ};
	default_location = new GLatLng(5,-20);
	
	  if (GBrowserIsCompatible()) {
		map = new GMap2(document.getElementById("map"));

		map.addControl(new GSmallMapControl(), new GControlPosition(G_ANCHOR_TOP_LEFT, new GSize(15,50)));
		initWolpins();
		
		map.setCenter(default_location, 2);
		
		for(id in wolpins) {
			var wolpin = wolpins[id];
			if(id==wolpins.length-1){
				name = "wolpin_newyork";
			}else if(id==wolpins.length-2){
				name = "wolpin_london";
			}
			//uncomment this for dubai
			else if(id==wolpins.length-3){
    				name = "wolpin_dubai";
    		}
    		else{
				name = "wolpin" + id
			}
			wolpin.content = document.getElementById(name);
			
			//wolpin.marker = createWolpinMarker(id, id>=wolpins.length-2);
			wolpin.marker = createWolpinMarker(id, id>=wolpins.length-3);//uncomment this for dubai, delete the previous line
			map.addOverlay(wolpin.marker);
			
		}
	  }
	}
	
	function adjust() {
		$("#map").height($(window).height()-80);
		map.checkResize();
	}

	$(document.body).unload(function() {
		if (GBrowserIsCompatible()) {
			GUnload();
		}
	});

	function loadContent(id) {
		$("#mapajaxcontent").html('<div id="text"><\/div><div id="author"><\/div>');
		$("#text").load("/text_id/"+id);
		$("#author").load("/author_tid/"+id);
	}
	
	function unloadContent(id) {
		$("#mapajaxcontent").html('');
	}
	
	$(document).ready(function(){
		// $(window).resize(function(){ adjust(); });
		//get the yellow marker ready
		
		$("div.wolpinbox a").click(function(){
			alert($(this).attr("href").substr(9));
			loadContent($(this).attr("href").substr(9));
			return false;
		});
		
		load();
		// adjust();
	});