function encode(v) {
  if (v==null || v=="") {
    return "";
  }
  r = "";
  for (i=0;v.length>i; i++) {
    c = v.charAt(i);
    cc = v.charCodeAt(i);
    if (cc>127 || c=="#") {
      s = new Number(cc);
      r += "#"+s.toString(16)+";";
    } else {
      r += c;
    }
  }
  return r;
}

function encrypt(v) {
  return encode(v);
}

function findControlByName(f, n) {
  for (var i=0; i < f.length; i++) {
    var e = f.elements[i];
    if (e.name == n) {
      return e;	
    }
  }
  return null;
}

function get_object(id) {
  var object = null;
  if( document.layers ) {
    object = document.layers[id];
  } else if( document.all ) {
    object = document.all[id];
  } else if( document.getElementById ) {
    object = document.getElementById(id);
  }
  return object;
}

function replaceString(oldS,newS,fullS) {
  // Replaces oldS with newS in the string fullS
  for (var i=0; i<fullS.length; i++) {
    if (fullS.substring(i,i+oldS.length) == oldS) {         
      fullS = fullS.substring(0,i)+newS+fullS.substring(i+oldS.length,fullS.length)      
    }   
  }   
  return fullS
}