/*
 * @author Christian Kulenkampff
 */
(function($) {
	var idSelectionImpl = {
		get : function(selectionName) { 
			var selectionString=$.cookie(selectionName);
			if(selectionString!=null)
				return selectionString.split(",");
			else
				return [];
		},
		set : function( selectionName, selectedIds ) {
			$.cookie(selectionName,selectedIds.toString());
		},
		addId : function(selectionName, id) { 					
			var selection=this.get(selectionName);
			if($.inArray(id,selection)<0)
				selection.push(id);
				
			this.set(selectionName,selection);			
		},
		removeId : function(selectionName, id) {
			var selection=this.get(selectionName);
			var selectionIndex=$.inArray(id ,selection);
			if(selectionIndex>-1) {
				selection.splice(selectionIndex,1);
			}
			this.set(selectionName,selection);
		},
		containsId : function(selectionName, id) { 
			var selection=this.get(selectionName);
			if($.inArray(id, selection)<0)
				return false;
			return true;
		}
	};
	$.idSelection=idSelectionImpl;
})(jQuery); 
