jQuery(document).ready(function() {
	jQuery('a.jbox').click(function() {
			var hreflink = $(this).attr('href');
			$.ajax({
				type: "GET",
				url: hreflink,
				cache: false,
				success: function(data){
					var regex_scriptstring = new RegExp("script","gi"); //Find all script tags
					var ajax_result = $('<div/>').append($.trim(data.replace(regex_scriptstring,"scriptdisabled"))); //Rename the script tags, to disable it
					var ajax_result_configs = ajax_result.find("div#box_config").text();
					var ajax_result_title = ajax_result.find("div#box_title").text();
					var cBox = {
						href:hreflink,
						title: ajax_result_title,
						onClosed:function(){ $(ajax_result).remove(); }
					}
					eval('{' +  $.trim(ajax_result_configs)  + '}');
					$.extend(cBox, colorboxconfig);
					$.colorbox(cBox);
				},
				error: function(xhr, thrownError){ alert(xhr.statusText + " ("+xhr.status+")");},
				complete: function(){}
			});
			return false;
	});
});
