/**
 * 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);
					}
				}
			}
		});
	}
}

/** Slideout menu */
sfHover = function() {
	var sfEls = document.getElementById("nav").getElementsByTagName("LI");
	for (var i=0; i<sfEls.length; i++) {
		sfEls[i].onmouseover=function() {
			this.className+=" sfhover";
		}
		sfEls[i].onmouseout=function() {
			this.className=this.className.replace(new RegExp(" sfhover\\b"), "");
		}
	}
}
if (window.attachEvent) window.attachEvent("onload", sfHover);
