

// Hides the Change Properties form
function revisionAddCancel()
{
  $("#revision-add-form-holder").slideUp('slow', function(){$("#section-links").show();});
}

// Shows the Change Properties form
function revisionAddShow()
{
  $("#section-links").hide();
  $("#revision-add-form-holder").slideDown('slow');
}


// Confirms whether or not the user wants to delete a certain item
function confirmDelete(entity)
{
  if (confirm('Are you sure you want to delete this ' + entity + '?'))
  {
    return true;
  }
  else
  {
    return false;
  }
}

function reverseList(listElementId)
{
  listElement = document.getElementById(listElementId);
  listOptions = Array();
  for (i = 0; i < listElement.options.length; i++)
  {
    listOptions[i] = listElement.options[i];
  }
  listOptions.reverse();
  for (i = 0; i < listOptions.length; i++)
  {
    listElement.options[i] = listOptions[i];
  }
}

// Checks to see if two passwords are the same
function checkPassword(new_password, conf_password)
{
  if ($('#' + new_password).val() == $('#' + conf_password).val())
  {
    return true;
  }
  else
  {
    alert('Your new passwords do not match!');
    document.getElementById(new_password).focus();
    return false;
  }
}

function increase(elem)
{
  $(elem).val(parseInt($(elem).val()) + 1);
  return false;
}

function decrease(elem)
{
  $(elem).val(parseInt($(elem).val()) - 1);
  return false;
}

function removeAttachment(button)
{
  $(button).parent().remove();
  return false;
}

function addAttachment()
{
    $("#attachments-list").append(
        $("<div>").attr("class", "form-item")
            .append($("<input>").attr("type", "file").attr("class", "form-file").attr("name", "attachment"))
            .append($("<input>").attr("type", "button").attr("class", "form-button").val("Remove").click())
    );
    return false;
}

$ProjectHQ.Utils.bind_load(function ()
{
  // Initialise syntax highlighting
  ChiliBook.recipeFolder = "/global/javascript/syntax/";
  ChiliBook.automaticSelector = "pre";
  ChiliBook.lineNumbers = true;
});

