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

/**
 * Conditionally sitches visibility of one element to 'on', if 
 * another element is a checkbox and the state of this checkbox is checked
 * @param id_element the id of the element to be made visible
 * @param id_condition_element the id of the checkbox element
 * @param compare_value value to be compared with the current value of the element addressed by id_condition_element
 */
function toggleVisibility(id_element, id_condition_element, compare_value) 
{
  element = document.getElementById(id_element);
  compare_element = document.getElementById(id_condition_element);
	
	if ((compare_value != null && compare_element.value == compare_value) || compare_element.checked)
	{
		element.style.display = "";
	}
	else
  {
    element.style.display = "none";
  }
}

function toggleVisibilityElement(id_element)
{
	element = document.getElementById(id_element);
	if (element.style.display == 'none')
	{
		element.style.display = '';
	}
	else
	{
		element.style.display = 'none';
	}
}

function fillField(id_to, id_from)
{
	element_to = document.getElementById(id_to)
	element_from = document.getElementById(id_from)
	element_to.value = element_from.value
}

function setEmpty(id)
{
	element = document.getElementById(id);
	element.value = '';
}

