function delete_pic(id){
	var i = id;
	$.get("./?module=listings&function=deleter&img_id=" + id,{},function(data){
		//console.log(i)
		$("#image-" + i).hide('slow');
	})
}
function delete_listing(id){
	if(confirm("Are you sure you want to delete this listing?")){
		$.get("./?module=listings&function=delete_listing&listing_id=" + id,{},function(data){
		//console.log(i)
			$("#listing-" + id).hide('slow');
		});
	}
}
var map_added = false;
var address = "";
function detail(row){
	var popup = $("<div class='popup'></div>");
	if(!map_added)
		$("body").append(popup);
		var img_src='/images/image-not-available.png';
		var image = "<img width='266' height='200' id='large-picture' src='"+img_src+"' /><br /><div id='large-picture-caption'>Click a thumbnail to display the larger image</div>";
		var img_div = $("<div class='left'></div>");
		
		img_div.append(image);
		var img_thumb_div = $("<div class='thumb_row'></div>");
		popup.append(img_div);
		var map_div =  $("<div id='property_map'></div>");
		popup.append(map_div);
		popup.append(img_thumb_div);
		//console.log(row);
		var x = 0;
		$.each(row['listing_pictures'],function(i){
			if(x++ == 0)
				$("#large-picture").attr("src","photos/listings/"+row['id']+"/"+row['listing_pictures'][i]['filename'] + "_medium.png");
			var img_thumb = row['listing_pictures'][i]['filename'] + "_small.png";
			var thumb = $("<img  src='photos/listings/"+row['id']+"/"+img_thumb+"' />"); 
			//console.log(thumb);
			
			img_thumb_div.append(thumb);
			thumb.click(function(){
				$("#large-picture").attr("src","photos/listings/"+row['id']+"/"+row['listing_pictures'][i]['filename'] + "_medium.png");
				$("#large-picture-caption").html(row['listing_pictures'][i]['caption'])
			})
		});
	var comments = $("#listing_"+row['id']).html()
	var comments_div = $("<div class='comments'>"+comments+"</div>");

	popup.append(comments_div);
	  // Call this function when the page has been loaded
	  var a = this;
	popup.Popup();
	address = row['address'] + ", New York City NY" + row['zipcode'];
	initialize();
}

	function initialize() {
	  	var geocoder = new GClientGeocoder();
		 
			var prop_map = new GMap2(document.getElementById("property_map"));

	   // prop_map = new google.maps.Map2(document.getElementById("property_map"));
	    //a.prop_map.setCenter(new google.maps.LatLng(a.data.deal.lat, a.data.deal.longitude), 13);
	    //var point = new GLatLng(a.data.deal.lat,a.data.deal.longitude);
    	//prop_map.addOverlay(new GMarker(point));
    	//prop_map.setMapType(G_SATELLITE_3D_MAP);
    	prop_map.addControl(new GSmallMapControl());
			prop_map.addControl(new GMapTypeControl());
console.log(address);
			geocoder.getLatLng(
		    address,
		    function(point) {
		      if (!point) {
		        //alert(address + " not found");
		      } else {
		        prop_map.setCenter(point, 13);
		        var marker = new GMarker(point);
		        prop_map.addOverlay(marker);
		        marker.openInfoWindowHtml(address + "<br />" + row['type']);
		      }
		    }
		  );

  	}

