var IE4 = (document.all && !document.getElementById) ? true : false;
var NS4 = (document.layers) ? true : false;
var IE5 = (document.all && document.getElementById) ? true : false;
var NS6 = (document.getElementById && !document.all) ? true : false;
var color = '';
var selected = '';

// Changes the background image of a cell.
function changeBGImage(id, imageName)
{
  if (IE5 || NS6) {
    document.getElementById(id).style.background = 'url(' + imageName +')';
  }
  else if (IE4) {
    document.all[id].style.backgroundImage = 'url(' + imageName +' )';
  }
}

function tdOver(id, col, clicked) {
  if (IE5 || NS6) {
    window.color = window.document.getElementById(id).style.backgroundColor;
    window.document.getElementById(id).style.backgroundColor = col;
  }
  else if (IE4) {
    window.color = window.document.all[id].style.background;
    window.document.all[id].style.background = col;
  }
  if (clicked) window.selected = id;
}

function tdOut(id, col) {
  if (window.selected != id) {
    if (IE5 || NS6) window.document.getElementById(id).style.backgroundColor = window.color;
    else if (IE4) window.document.all[id].style.background = window.color;
  } else {
    if (IE5 || NS6) window.document.getElementById(id).style.backgroundColor = col;
    else if (IE4) window.document.all[id].style.background = col;
  }
}

function del_confirm(itm, qs, tbl) {//v1
  if (confirm("Are you sure you want to delete " + itm + " from " + tbl)) window.location.href = window.location.pathname+"?"+qs;
}

function textareaLimiter(field, maxlimit) {
  if (field.value.length > maxlimit) field.value = field.value.substring(0, maxlimit);
}

function confirmPassword() {
  var password = document.getElementById('txt_Password').value;
  var password2 = document.getElementById('Password2').value;
  if (password != password2)  {
    alert("Your password must match your confirmation password.")
    document.MM_returnValue = false
  } else {
    document.MM_returnValue = true
  }
}