// JavaScript Document
function jqueryAlert(id, msgTitle, msgStr) {
	// Set the focus on the offending field.
	if (id != '') $('#' + id).focus();
	
	// Must first destroy the dialog functionality completely before re-creating it so the we can reset the options.
	// Use autoOpen since we will only be using the dialog once.
	$('#alert').dialog('destroy');
	var $alert = $('#alert') 
		.html(msgStr)
		.dialog({
			autoOpen: true,
			modal: true,
			closeOnEscape: true,
			buttons: { "OK": function() { $(this).dialog("close"); } },
			title: msgTitle,
			close: function(event, ui) { if (id != '') $('#' + id).focus(); } // Set the focus again since the modal nature of the dialog messes up the focus
		});
}

function jqueryConfirm(id, msgTitle, msgStr) {
	// Set the focus on the offending field.
	if (id != '') $('#' + id).focus();
	
	// Must first destroy the dialog functionality completely before re-creating it so the we can reset the options.
	// Use autoOpen since we will only be using the dialog once.
	$('#alert').dialog('destroy');
	var $alert = $('#alert') 
		.html(msgStr)
		.dialog({
			autoOpen: true,
			modal: true,
			buttons: {
				'Yes': function() {
					$(this).dialog('close');
					return true;
				},
				'No': function() {
					$(this).dialog('close');
					return false;
				}
			},
			title: msgTitle,
			close: function(event, ui) { if (id != '') $('#' + id).focus(); } // Set the focus again since the modal nature of the dialog messes up the focus
		});
}

