(function($) {
	$(document).ready(function() {
		$('.moduleLink').dialog({
			lang: {
				header: 'Module Description'
			},
			onContentLoad: function(obj, dialog) {
				var tag = $(obj);
				var href = tag.attr('href');
				var loading = $(document.createElement('div')).addClass('sys_loading').text('Processing... Please wait.');
				var dlg = dialog.append(loading);
				$.ajax({
					type: 'GET',
					data: {},
					url: href, 
					cache: false,
					dataType: 'jsonp',
					jsonp: 'jsoncallback',
					async: true,
					success: function(result) {
						loading.remove();
						dlg.text(result.Description);
					},
					error: function() {
						loading.remove();
						dlg.innerText('Definitive Documents Service is unavailable. Please try again later.');
					}
				});
			}
		});	
	});
})(jQuery);
