/**
 * JSON API Service Wrapper
 */
function JAS(options) {
	var self = this;
	
	this.o = {
		api: "",
		data: {},
		async: true,
		cache: true,
		success: undefined,
		error: undefined
	}
	
	this.o = $.extend({}, this.o, options);
	
	this.invoke = function () {
		$.ajax({ url: document.location.href, async: self.o.async, type: "post", dataType: "json", cache: self.o.cache, 
			data: {
				"api": self.o.api, 
				"data": self.o.data
			},
			success: function(result) {				
				// Invoke callbacks
				if (result.status == 'ok') {
					if (self.o.success != undefined) {
						self.o.success(result);
					}
				} else if (result.status == 'error') {
					if (self.o.error != undefined) {
						self.o.error(result);
					}
				}
			}
		});
	}
}
