/*
 * 	22/3/11
 *
 * 	This version of 'default.js' was copied from the Intranet's
 * 	trunk/docroot/includes/js/default.js.
 */

/*
 * 	statusmessage() is passed two parameters:
 *
 * 	-	text message to display
 * 	-	true if the message is an error/warning message
 *
 * 	We store the previous message in the global variable _statusmessage so we can
 * 	remove the last before displaying the current messsage.
 */
_statusmessage = null;		//	set to jQuery element of last mesasge

function statusmessage(text, is_error_message) {
	if (_statusmessage) {
		_statusmessage.remove();
		_statusmessage = null;
	}

	var msgclass = is_error_message ? 'warning' : 'message';

	var field = $('<div class="message_window message ' + msgclass + '" style="text-align: center">' + text + '</div>');

	$('body').append(field);

	var left = ($(window).width() - field.outerWidth()) / 2;
	//var top = ($(window).height() - field.outerHeight()) / 2;

	field.css('left', left).css('top', '20px');

	field.delay(5000).fadeOut(400);

	_statusmessage = field;
}


/*
 * 	Do a GET of a URL and plonk the contents into a <div>.
 */
function loadcontent(div_id, url) {
	$(id_to_jq_selector(div_id)).html(
			"<center><img src='/images/spinner.gif' /> Loading...</center>");

	$.get(url, function(data) {
		$(id_to_jq_selector(div_id)).html(data);
	});

	return false;
}

