'Tgyz.Core.Widget.Loader'.namespace();

Tgyz.Core.Widget.Loader = function() {};

Tgyz.Core.Widget.Loader.baseUrl = '/';

Tgyz.Core.Widget.Loader.queue = function(module, name, data, containerId, callback) {
	Tgyz.Core.Widget.Loader.queueAction(module, name, 'show', data, containerId, callback);
};

Tgyz.Core.Widget.Loader.queueAction = function(module, name, act, data, containerId, callback) {
	$('#' + containerId).addClass('loading').html('');
	var baseUrl = Tgyz.Core.Widget.Loader.baseUrl;
	baseUrl = baseUrl.replace(/\/+$/, "");
	$.ajaxq('widget', {
		url: baseUrl + '/widget/ajax/',
		type: 'POST',
		data: { mod: module, name: name, act: act, params: data },
		success: function(response) {
			response = $.evalJSON(response);
			$('#' + containerId).removeClass('loading').html(response.content);
			
			if (callback) {
				callback(response);
			}
		}
	});
};
