function register_confirmation(path, options, register_options)
{
	$$(path).each(function(action) {
		action.observe('click', function(event) {
			event.stop();
			a = event.findElement('a');
			action = a.readAttribute('href');
			
			// tytuł
			if(options && options.title) {
				//a tutaj dynamiczny tytuł
				if(typeof(options.title) == 'function') {
					title = options.title(a);
				}
				else {
					title = options.title;
				}
			}
			else {
				title = a.readAttribute('title');
			}

			new Api_confirmation_message(title, {
				on_ok: function() {
					window.location = action + '/confirmed/1';
				}
			});
		});
	});	
}





/**
 * Klasa wyświetlania pytanie w małym wysuwanym u góry ekranu okienku.
 */
var Api_confirmation_message = Class.create({
	div: null,
  
	default_options: {
		duration: 0.3
  	},

  	initialize: function(message, options)
  	{
  		this.options = Object.extend(Object.extend({ }, this.default_options), options || { });
  		this.create_html();
  		this.set_message(message);
  		this.install_actions();
  		this.positione();
  		this.show();
  	},

  	/**
  	 * Metoda tworzy dynamicznie kod html
  	 */
  	create_html: function()
  	{
  		overlay = Builder.node('div', {className: 'api_overlay' });
  		$$('body')[0].insert(overlay);
  		this.overlay = $(overlay);
    
	    msg_window = Builder.node('div', { className: 'api_msg_wraper', style: 'display: none;' }, [
	      Builder.node('div', { className: 'api_msg api_confirmation_message' }, [
	        Builder.node('div', { className: 'content_wraper' }, [ 
	          Builder.node('div', { className: 'content' }),
	          Builder.node('div', { className: 'button_area' }, [
	            Builder.node('input', { className: 'action_ok btn_violet', type: 'image', src: '/img/btn-green-ok.png', value: 'Ok'}),
	            Builder.node('input', { className: 'action_cancel btn_violet', type: 'image', src: '/img/btn-green-cancel.png', value: 'Anuluj'})
	          ])
	        ]),
	        Builder.node('div', { className: 'footer' }, [
	          Builder.node('div', { className: 'cl' }),
	          Builder.node('div', { className: 'bb' }),
	          Builder.node('div', { className: 'cr' })
	        ])
	      ])
	    ]);
	    
    	$$('body')[0].insert(msg_window);
    	this.div = $(msg_window);
  	},  
  	
  	set_message: function(message)
  	{
  		this.div.down('.content').update(message);
  	},

  	/**
  	 * Instaluje akcje na okienku, w tej chwili tylko zamykanie
  	 */
  	install_actions: function()
  	{
  		t = this;
  		t.overlay.observe('click', t.action_close.bindAsEventListener(t));
  		
  		t.div.select('.action_cancel').each(function(action) {
  			action.observe('click', t.action_close.bindAsEventListener(t));
  		});
  		
  		t.div.select('.action_ok').each(function(action) {
  			action.observe('click', t.action_ok.bindAsEventListener(t));
  		});
  	},
  
  	/**
  	 * Ustawiamy na środku ekranu, na samej górze
  	 */
  	positione: function()
  	{
  		desktop = $$('body')[0];

  		arrayPageSize = getPageSize();
  		this.overlay.setStyle({ width: arrayPageSize[0] + 'px', height: arrayPageSize[1] + 'px' });
	  
  		desktopWidth = desktop.getWidth();
  		desktopOffset = desktop.cumulativeOffset();
  		elementWidth = this.div.getWidth();
    
  		this.div.setStyle({
  			left: ((desktopWidth - elementWidth) / 2 + desktopOffset.left) + "px"
  		});
  	},
  
	/**
	 * Efektowanie pokazuje wiadomość 
	 */
	show: function()
	{
		this.overlay.show();
	
		t = this;
		t.isToggling = true;
		Effect.SlideDown(t.div, { duration: t.options.duration, afterFinish: function() {
			t.isToggling = false;
		}});
	},

	/**
	 * Efektowanie chowa wiadomość
	 */
	hide: function()
	{
		t = this;
		t.isToggling = true;
		Effect.SlideUp(t.div, { duration: t.options.duration, afterFinish: function() {
			t.isToggling = false;
			t.div.remove();
			t.overlay.remove();
		}});
	},

	/**
	 * Obsługa akcji zamykającej okienko
	 */
	action_close: function(event)
	{
		event.stop();
		if(!this.isToggling) this.hide();
	},

	/**
	 * Obsługa akcji ok
	 */
	action_ok: function(event)
	{
		event.stop();
		this.hide();
		if(this.options.on_ok) this.options.on_ok();
	} 
	
});
