$(function() {
	$(".tabchanger").css("display", "block");
	$(".jq_tab hr").css("display", "none");
	$(".jq_tab h3").css("display", "none");
	$("#agh_tabs").tabs();
	
	$.getJSON("/index.php?load=pse&action=countPropsByArea", function(data) {
		$.each(data.areas, function(i, area) {
			var areaName = area.area;
			var areaProps = area.total;
			var areaRef = area.area_ref;
			$("#area_" + areaRef).attr("rel", areaProps);										 
		});
		$('#areas area[alt]').each(function()  {
			var alt = $(this).attr("alt");
			var alt = alt.split(": ");
			$(this).qtip({
				position: {
					corner: {
						target: 'topMiddle',
						tooltip: 'bottomMiddle'
					},
					adjust: {
						screen: true
					}
				}, 
				content: {
					text: '<p>' + alt[1] + '<p><a href="' + $(this).attr("href") + '">Read more</a> &raquo;</p><p>' + $(this).attr("rel") + ' properties for sale in this area<!-- - <a href="#" onclick="return false;">Show</a>--></p>',
					title: {
						text: alt[0] + ' Area Guide',
						button: 'Close'
					}
				},
				show: {
					solo: true
					// when: 'click'
				},
				hide: {
					when: 'mouseout',
					fixed: true
				},
				style: {
					border : {
						width: 3,
						radius: 8
					},
					tip: {
						corner: 'bottomMiddle',
						size: {
							x: 7,
							y: 15	
						}
					},
					width: {
						min: 300
					},
					name: 'dark',
					classes: {
						content: 'agh_map'
					}
				}
			});
			$(this).click(function() {
				   return false;
			});
	   });
	});
});