var TabbloidAPI = {
	auth_header_token: '',
	root: '.',
	my_id: '0',
	auth_username: null,
	auth_password: null,
	
	_call: function(url, method, data, callback) {
		url = this.root + "/rest" + url;
		var options = {
			url: url,
			data: data,
			dataType: 'json',
			type: method,
			success: callback,
			username: this.auth_username,
			password: this.auth_password
		};
		jQuery.ajax(options);
	},
	
	verifyFeed: function(feed_url, callback) {
		this._call('/feeds/verify', 'GET', {url: feed_url}, callback);
	},
	
	addFeed: function(feed_url, feed_secret, callback) {
		this._call('/subscribers/' + this.my_id + '/feeds', 'POST', {url: feed_url, token: feed_secret, action: 'add'}, callback);
	},
	
	addStockFeeds: function(feed_type, callback) {
		this._call('/subscribers/' + this.my_id + '/feeds', 'POST', {stock_type: feed_type}, callback);
	},
	
	removeFeed: function(feed_url, callback) {
		this._call('/subscribers/' + this.my_id + '/feeds', 'POST', {url: feed_url, action: 'remove'}, callback);
	},
	
	changeSettings: function(settings, callback) {
		this._call('/subscribers/' + this.my_id, 'POST', settings, callback);
	},
	
	updateCookie: function() {
		this._call('/subscribers/' + this.my_id + '/cookie', 'GET', null, null);
	},
	
	getPDF: function() {
		window.open(this.root + '/rest/subscribers/' + this.my_id + '/pdf');
	}
	
};