Merkliste = {
	pid: 0,
	list: [],
	merken: function() {
		// do not mark a given post more than one time in a row
//		if (this.list[this.list.length - 1] != this.pid) {
		if (jQuery.inArray(this.pid.toString(), this.list) < 0) {
			this.list.push(this.pid.toString());
			this.store();
			this.update();
		}
	},
	store: function() {
		$.cookie("merkliste", this.list.join(','), { path: '/', expires: 365 });
	},
	init: function () {
		var ls = $.cookie("merkliste");
		this.list = ls ? ls.split(',') : [];
		this.update();
	},
	update: function() {
		$('#merklistecount').text(this.list.length);
	},
	reset: function() {
		this.list = [];
		this.store();
		this.update();
	}
};

$(window).load(function() {
	Merkliste.init();
});
