jQuery.cookie = function(name, value, options) {
	if (typeof value != 'undefined') { // name and value given, set cookie
		options = options || {};
 
		if (value === null) {
			$.ajax({
				type: "POST",
				url: BASE_URL + "cookie/delete",
				data: 'name='+name,
			});
 
			return;
		}
 
		var expires = '';
		if (options.expires && (typeof options.expires == 'number' || options.expires.toUTCString)) {
			var date;
			if (typeof options.expires == 'number') {
				date = new Date();
				date.setTime(date.getTime() + (options.expires * 24 * 60 * 60 * 1000));
			} else {
				date = options.expires;
			}
			expires = '&expires=' + date.toUTCString(); // use expires attribute, max-age is not supported by IE
		}
 
		var path = options.path ? '&path=' + (options.path) : '';
		var domain = options.domain ? '&domain=' + (options.domain) : '';
		var secure = options.secure ? '&secure' : '';
		$.ajax({
			type: "POST",
			url: BASE_URL + "cookie/set",
			data: 'name='+name+'&value='+value+expires+path+domain+secure,
		});
	} else { // only name given, get cookie
		var result = '';
 
		$.ajax({
			async: false,
			type: "POST",
			url: BASE_URL + "cookie/get",
			data: "name="+name,
			success: function(msg){
				result = msg;
			}
		});
 
		return result;
	}
};
