function clearStatusMsg($obj) {
	if($('div#statusMsg').html() != "") {
		$('div#statusMsg').html('');
	}
}
function ajaxDelete(id) {
	$('img#loading').show();
	$.ajax({
		type: "POST", 
		url: "tiamot.php",
		data: "action=delete&id=" + id,
		success: function(msg) { 
			if(msg.indexOf("false") == -1) {
				$('tr.' + id).fadeOut("fast", function() {
					$(this).remove();
					$("#tiamot").trigger("update"); 
					$("#tiamot").trigger("reSort");
					$('img#loading').hide();
					$('div#statusMsg').html('<span class="success">Row ' + id + ' was deleted successfully</span>'); 
				});
				t = setTimeout("clearStatusMsg()", 5000000);
			} else {
				$('div#statusMsg').html('<span class="failed">Sorry, row ' + id + ' could not be deleted.</span>');
				$('img#loading').hide(); 
				t = setTimeout("clearStatusMsg()", 5000);
			}
		}
	});
}
function init() {
	$(".edit").editable("tiamot.php", {
		 type      : 'text', 
		 cancel    : 'Cancel', 
		 submit    : 'Save', 
		 indicator : "<img src=\"/images/ajaxDeleteLoad.gif\" id=\"loading\" />",
		 tooltip   : 'Click to edit...',
		 onblur    : 'ignore',
		 width     : '200px',
		 height    : '20px',
		 callback  : function(value, settings) { 
			if(value.indexOf("false") == -1) {
				$('div#statusMsg').html('<span class="success">Row was updated successfully.</span>');
				$(this).html(value);
				$('#tiamot').trigger("update");
				$('#tiamot').trigger("reSort");
			} else {
				$('div#statusMsg').html('<span class="success">Sorry, that row was not updated successfully.</span>');
				$(this).html('error');
				$('#tiamot').trigger("update");
				$('#tiamot').trigger("reSort");
			}
			t = setTimeout("clearStatusMsg()", 5000); 
		}
	});
}
