function Clipboard()
{
	this.clipcore = new ClipCore('/application/clipboard/clip_gateway.php');
	this.clipcore.setResponseFormat('json');
	this.clipcore.setConnectionFailedHandler(this.onConnectionFailed);
}

Clipboard.prototype = {
	clip: function (section_id, item_type, item_id, listener)
	{
		var info = {
			'namespace': 'living.'+section_id,
			'item_id': item_id,
			'item_type': item_type,
			'visibility': 1
		};
		return this.clipcore.addItem(info, listener);
	},
	
	unclip: function (clip_id, listener)
	{
		this.clipcore.removeItem(clip_id, listener);
	},
	
	fetchClippings: function (section_id, item_type, listener)
	{
		if (typeof item_type != 'string')
			item_type = item_type.join(',');
		
		var info = {
			'namespace': 'living.'+section_id,
			'item_type': item_type
		};
		
		this.clipcore.fetchItems(info, listener);
	},
	
	isClipped: function (section_id, item_type, item_ids, listener)
	{
		var info = {
			'namespace': 'living.'+section_id,
			'item_id': item_ids.join(','),
			'item_type': item_type
		};
		
		var req_id = this.clipcore.checkItems(info, listener);
		return req_id;
	},
	
	fetchClippingCountsBySection: function (listener)
	{
		var args = {
			namespace: 'living.1,living.2,living.3,living.4'
		};
		
		this.clipcore.fetchItemCountsByNamespace(args, listener);
	},
	
	fetchClippingCountsByType: function (args, listener)
	{
		var info = {};
		if (args.section)
		{
			info.namespace = 'living.'+args.section;
		}
		if (args.types)
			info.item_type = args.types.join(',');
		
		this.clipcore.fetchItemCountsByType(info, listener);
	},
	
	onConnectionFailed: function () {}
}

