var LmsAPI = Class.create({
	Initialize: function() {
		this.endpoint = "/lms";
		new Ajax.Request(this.endpoint, {method: 'post', asynchronous: false});
		return true;
	},
  LMSInitialize: function() {return this.Initialize();},
  
	Terminate: function() {
		new Ajax.Request(this.endpoint, {method: 'delete'});
	},
  LMSFinish: function() {return this.Terminate();},
	
	GetValue: function(key) {
	  value = "";
		new Ajax.Request(this.endpoint + '/' + key, {
			method: 'get',
			asynchronous: false, // has to be async, otherwise the onSuccess happens after the return and we don't get our value back
			onComplete: function(transport) { value = transport.responseText; },
			onFailure:  function(transport) { value = ""; },
			onError:    function(transport) { value = ""; }
		});
		return value;
	},
	LMSGetValue: function(key) {return this.GetValue(key);},
	
	SetValue: function(key, value) {
		new Ajax.Request(this.endpoint + '/' + key, {
			method: 'put',
			asynchronous: false,
			parameters: {value: value}
		});
		return value;
	},
	LMSSetValue: function(key, value) {return this.SetValue(key, value);},
	
	Commit: function(string) {
		console.log("lms commit", string);
	},
	LMSCommit: function(string) {return this.Commit(string)},
	
	GetLastError: function() {
		console.log("lms getLastError");
	},
	LMSGetLastError: function() {return this.GetLastError();},
	
	GetErrorString: function(errorCode) {
		console.log("lms getErrorString", errorCode);
	},
	LMSGetErrorString: function() {return this.GetErrorString();},
	
	GetDiagnostic: function(errorCode) {
		console.log("lms initialize", errorCode);
	},
	LMSGetDiagnostic: function(errorCode) {return this.GetDiagnostic();},
	
	comment: function(comment) {
	  this.SetValue('comment', comment);
	}
});