/*
 * Menu TD change
 * from phpMyAdmin
 */
function changeTd(tdId, colour)
{
  var td      = null;
  var picName = 'img/common/menuTopItem' + colour.replace("#","") + '.gif';

  if (typeof(document.getElementById) != 'undefined') {
    td = document.getElementById(tdId);

  } else if (typeof(document.all) != 'undefined') {
    td = document.all(tdId);

  } else {
    return false;
  }

  if (typeof(td.getAttribute) != 'undefined') {

    if (tdId == 'menuTd1') {
      td.setAttribute('background', picName, 0);
    } else {
      td.setAttribute('bgcolor', colour, 0);
    }
  } else {

    if (tdId == 'menuTd1') {
      td.style.background = 'url(' + picName + ')';
    } else {
      td.style.backgroundColor = colour;
    }
  }
}


/*
 * Textarea counter
 * from ASP Wizard
 */
function textCounter(field, id, str) {
  maxlimit = 255;
  if (field.value.length > maxlimit) {
    field.value = field.value.substring(0, maxlimit);
  } else {
    document.getElementById(id).firstChild.nodeValue = maxlimit - field.value.length + ' ' + str;
  }
}


// Deletion confirm
function confirmDel(page, num, msg) {

  var areYouSure = confirm(msg);
  if (areYouSure)
    window.location.href = "index.php?page=" + page + "&action=Delete&recordNum=" + num;
}


function confirmFileDel(page, filename, msg) {

  var areYouSure = confirm(msg);
  if (areYouSure)
    window.location.href = "index.php?page=" + page + "&action=DeleteAFile&fileToDelete=" + filename;
}

