(function($) {

	$.fn.hello_persistent = function(method, options) {

		options = options || {};
		var callback  = options.callback || function() {};

		return this.each(function() {
			if (this.id) {
				var key = this.id + '-persistent';
				switch(method) {
					case 'set':
						var cookieOptions = options.expires ? {expires: options.expires} : {};
						$.cookie(key, true, cookieOptions);
						break;
					case 'unset':
						$.cookie(key, null);
						break;
					case 'onset':
						if ($.cookie(key)) {
							callback.call(this);
						}
						break;
					case 'onunset':
						if (!$.cookie(key)) {
							callback.call(this);
						}
						break;
					default:
						console.log('$.persistent: unknown method');
				}
			} else {
				console.log('$.persistent: no id found');
			}
		});

	};
})(jQuery);

