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

Event.observe(window, 'load', function() {
  var e = $A(document.getElementsByTagName('*')).find(function(e) {
    return (e.tagName.toUpperCase() == 'INPUT' && (e.type == 'text' || e.type == 'password'))
        || e.tagName.toUpperCase() == 'TEXTAREA' || e.tagName.toUpperCase() == 'SELECT';
  });
  if (e) e.focus();
});


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

function toggleSection(control, div_section)
{
	// toggle the div
	new Effect.toggle(div_section, 'blind', {duration: 0.25});
	
	// toggle the image
	var imageControl = $(control).firstDescendant();
	if ( imageControl.src.search("arrow_up") > -1)
	{
		imageControl.src = imageControl.src.sub("arrow_up", "arrow_down");
	}
	else
	{
		imageControl.src = imageControl.src.sub("arrow_down", "arrow_up");
	}
}