/* $Id: boss_panic.js 23 2008-04-21 08:15:07Z edin.coralic $ */

var AddFoto = {

	run: function() {
		var button = $$('#desc_form_button_add').first();
		if (button) {
			button.observe('click', AddFoto.post.bindAsEventListener(button));
		}
	},

	post: function(event) {
		var hidden = $$('#desc_form_hidden').first();
		hidden.value = 'js_post';		
		var form = $$('#desc_form').first();
		form.submit();
	}

}
new StartUp(AddFoto);
var DeleteButton = {

	link : null,

	run: function() {
		$$('.delete_image_id').each(function (item, i) {
			Event.observe(item, 'click', DeleteButton.store_delete.bindAsEventListener(item));		
		});		
	},

	store_delete: function(event) {
		var url = displayAjaxUrl+"&delete_image="+this.rel;
		DeleteButton.link = this;
		new Ajax.Request(url, {
		  method: 'get',
		  onComplete: function(transport) {
			DeleteButton.link.up().style.display = 'none';
			DeleteButton.link.up().previous().style.display = 'none';
		  }
		});
				
		Event.stop(event);
	}

}
new StartUp(DeleteButton);