$(document).ready(function(){
	
	$('#dialog').dialog({ autoOpen: false });
   
	$("#jasperMoreInfo").hide();
	$("#jasper").click(function () {
		event.preventDefault();
		toggleInfo("jasper")
    });


});

function toggleInfo(id)
{	
	var link = "#" + id;
	var container = "#" + id + "MoreInfo";
	
	if($(container + ":visible").length > 0)
	{
		$(container).hide("normal");
	}
	else
	{
		if($(container).children().length <= 0)
		{
			$.ajax({
				url: id + ".php",
				dataFilter: function (data, type) {
				var re = new RegExp("<div class = \"moreInfo\">[^]*</div>", "m");
				var arry = data.match(re);
				data = arry[0];
				return data;
				},
				success: function(response) {
				$(container).html(response);
				$(container).show("normal");
				},
				error: function(xhr) {
				alert('Error!  Status = ' + xhr.status);
				}
			});
		}
		else
			$(container).show("slow");
	}
}
