// Place your application-specific JavaScript functions and classes here
// This file is automatically included by javascript_include_tag :defaults

function mark_for_destroy(element,holder){
	$(element).next('.should_destroy').value = 1;
	$(element).up('.'+holder+'').hide();
}


var toggle = {
	show : function() {
		for ( i=0; i < arguments.length; i++ ) {
			$(arguments[i]).style.display = '';
		}
	},
	hide : function() {
		for ( i=0; i < arguments.length; i++ ) {
			$(arguments[i]).style.display = 'none';
		}
	}
};






function installAutocompletion() {
  $$('input.autocomplete[type=text]').each(function(element) {
    var fieldId = element.id;
    var completions = document.createElement('div');
    completions.id = fieldId + '_auto_complete';
    completions.className = 'auto_complete';
    completions.style.display = 'none';
    element.parentNode.insertBefore(completions, element.nextSibling);

    var url = 'auto_complete_for_' + fieldId;
    var options = {};
    if (/new_tag$/.test(fieldId)) {
      options.tokens = ',';
    }
    new Ajax.Autocompleter(element, completions, url, options);
  });
}

Event.observe(window, 'load', installAutocompletion);