function processCancelButton(location) {
    var redirectForm = document.getElementById('redirectForm');

    redirectForm.action = location;
    redirectForm.submit();
}

function addElementToRedirectForm(name, value) {
    addElementToForm(document.getElementById('redirectForm'), name, value);
}

function addElementToForm(form, name, value) {
    var input = document.createElement('input');
    input.type = 'hidden';
    input.name = name;
    input.value = value;

    form.appendChild(input);
}

function fixArray(array) {
    var arrayContacts = new Array();

    if (typeof array != 'undefined') {
        if (typeof array.length == 'undefined') {
            arrayContacts = [array]; //stick it in a array
        } else {
            arrayContacts = array; //already in one
        }
    }

    return arrayContacts;
}

function updateCursor(obj, todo) {
  if (todo == 1)
    obj.style.cursor = 'pointer';
  else if (todo == 2)
    obj.style.cursor = 'auto';
}

function redirectToAdminPage() {
  var redirectForm = document.getElementById('redirectForm');
  addElementToForm(redirectForm, 'action', 'admin');
  redirectForm.submit();
}

function redirectToEditSecondHandProductCategoryCat(id) {
  var redirectForm = document.getElementById('redirectForm');
  addElementToForm(redirectForm, 'action', 'editSecondHandProductCategory');
  addElementToForm(redirectForm, 'id', id);
  redirectForm.submit();
}

function redirectToDelSecondHandProductCategoryCat(id) {
  var redirectForm = document.getElementById('redirectForm');
  addElementToForm(redirectForm, 'action', 'deleteSecondHandProductCategory');
  addElementToForm(redirectForm, 'id', id);
  redirectForm.submit();
}

function redirectToEditNewProductCategoryCat(id) {
  var redirectForm = document.getElementById('redirectForm');
  addElementToForm(redirectForm, 'action', 'editNewProductCategory');
  addElementToForm(redirectForm, 'id', id);
  redirectForm.submit();
}

function redirectToDelNewProductCategoryCat(id) {
  var redirectForm = document.getElementById('redirectForm');
  addElementToForm(redirectForm, 'action', 'deleteNewProductCategory');
  addElementToForm(redirectForm, 'id', id);
  redirectForm.submit();
}

function redirectToEditWebsiteText(websiteTextName) {
  var redirectForm = document.getElementById('redirectForm');
  addElementToForm(redirectForm, 'action', 'editWebsiteText');
  addElementToForm(redirectForm, 'name', websiteTextName);
  redirectForm.submit();
}

function redirectToDelNewsMessage(id) {
  var redirectForm = document.getElementById('redirectForm');
  addElementToForm(redirectForm, 'action', 'deleteNewsMessage');
  addElementToForm(redirectForm, 'id', id);
  redirectForm.submit();
}

function redirectToEditNewsMessage(id) {
  var redirectForm = document.getElementById('redirectForm');
  addElementToForm(redirectForm, 'action', 'editNewsMessage');
  addElementToForm(redirectForm, 'id', id);
  redirectForm.submit();
}

function redirectToEditSecondHandProduct(id) {
  var redirectForm = document.getElementById('redirectForm');
  addElementToForm(redirectForm, 'action', 'editSecondHandProduct');
  addElementToForm(redirectForm, 'id', id);
  redirectForm.submit();
}

function redirectToDelSecondHandProduct(id) {
  var redirectForm = document.getElementById('redirectForm');
  addElementToForm(redirectForm, 'action', 'deleteSecondHandProduct');
  addElementToForm(redirectForm, 'id', id);
  redirectForm.submit();
}

function redirectToEditNewProduct(id) {
  var redirectForm = document.getElementById('redirectForm');
  addElementToForm(redirectForm, 'action', 'editNewProduct');
  addElementToForm(redirectForm, 'id', id);
  redirectForm.submit();
}

function redirectToDelNewProduct(id) {
  var redirectForm = document.getElementById('redirectForm');
  addElementToForm(redirectForm, 'action', 'deleteNewProduct');
  addElementToForm(redirectForm, 'id', id);
  redirectForm.submit();
}


