$(function() {
	var cardID = $(".slistingbox").attr("id");
	var summary = $.ajax({type: "POST", async: false, url : "/listings.post.php", data : "docid=" + cardID + "&what=summary"}).responseText;
	$(".slistingbox .tab-area").html(summary);

	// Code
	$(".tab-menu ul li.tab-title a").click(function(event) {
		event.preventDefault();
		
		cardID = $(this).parents("li").parents("ul").attr("id");
		
		var tabType = $(this).attr("class");
		if(tabType == "map") {
			var data = $.ajax({type: "POST", async: false, url : "/listings.post.php", data : "docid=" + cardID + "&what=map"}).responseText;
			data = data.split("|");
			$(".slistingbox .tab-area").googleMap(data[0], data[1], 13, {controls: ["GSmallMapControl", "GMapTypeControl"]});
		}else{
			$.post("/listings.post.php", "docid=" + cardID + "&what=" + tabType, function(returnData) {
				$(".slistingbox .tab-area").css({backgroundColor: "#FFF", border: "solid 1px #DDD"});
				$(".slistingbox .tab-area").html(returnData);			
			});
		}
		return false; // Stops the actual link travelling
	});
});

