function newImage(arg) {
        if (document.images) {
                rslt = new Image();
                rslt.src = arg;
                return rslt;
        }
}

function PCase(STRING){
  var strReturn_Value = "";
  var iTemp = STRING.length;
  if(iTemp==0){
  return"";
  }
  if (STRING == "UK" || STRING == "uk") {
    return UCase(STRING);
  }
  var UcaseNext = false;
  strReturn_Value += STRING.charAt(0).toUpperCase();
  for(var iCounter=1;iCounter < iTemp;iCounter++){
    if(UcaseNext == true){
      strReturn_Value += STRING.charAt(iCounter).toUpperCase();
    }
    else{
      strReturn_Value += STRING.charAt(iCounter).toLowerCase();
    }
    var iChar = STRING.charCodeAt(iCounter);
    if(iChar == 32 || iChar == 45 || iChar == 46){
      UcaseNext = true;
    }
    else{
      UcaseNext = false
    }
    if (iChar >= 16 && iChar <= 25) UcaseNext = true;
    if(iChar == 99 || iChar == 67){
      if(STRING.charCodeAt(iCounter-1)==77 || STRING.charCodeAt(iCounter-1)==109){
      UcaseNext = true;
    }
  }


  } //End For

  return strReturn_Value;
} //End Function

function UCase(STRING){
  var strReturn_Value = "";
  var iTemp = STRING.length;
  if(iTemp==0){
  return"";
  }
  var UcaseNext = true;
  strReturn_Value += STRING.charAt(0).toUpperCase();
  for(var iCounter=1;iCounter < iTemp;iCounter++){
    strReturn_Value += STRING.charAt(iCounter).toUpperCase();
  } //End For

  return strReturn_Value;
} //End Function

// script for use with nested_checkboxes()

_parent = new Array();
_parent[0] = new Array();
_parent[1] = new Array();
_parent[2] = new Array();

function siblingsChecked(table, checkbox_id) {
  result = false;
  table_id = (table == "region" ? 0 : (table == "coding" ? 1 : 2));
  if (_parent[table_id][checkbox_id]) {
    for (key in _parent[table_id]) {
      if (_parent[table_id][key] == _parent[table_id][checkbox_id]) {
        result = result || document.getElementById(table + '_' + key).checked;
      }
    }
  }
  return result;
}

function checkUp(table, checkbox_id, checked) {
  table_id = (table == "region" ? 0 : (table == "coding" ? 1 : 2));
  if (_parent[table_id][checkbox_id]) {
    document.getElementById(table + '_' + _parent[table_id][checkbox_id]).checked = checked ||
      siblingsChecked(table, checkbox_id);
    checkUp(table, _parent[table_id][checkbox_id], checked);
  }
}

function checkDown(table, checkbox_id, checked) {
  table_id = (table == "region" ? 0 : (table == "coding" ? 1 : 2));
  for (key in _parent[table_id]) {
    if (_parent[table_id][key] == checkbox_id) {
      document.getElementById(table + '_' + key).checked = checked;
      checkDown(table, key, checked);
    }
  }
}

function checkbranch(table, checkbox_id, checked, untree_field) {
  if ((untree_field == '') || (!document.getElementById(untree_field).checked)) {
    checkUp(table, checkbox_id, checked);
    checkDown(table, checkbox_id, checked);
  }
}

