//
//  CS Object Model Compatibility layer
//
//  Author: Micah Dubinko
//  Date:   4/20/2001
//
//  Requires: no dependencies
//

function CSClient_Obj() {}

CSClient_Obj.prototype.alert = function( msg, btns ) {
  if (btns==1) {
    var rc = confirm( msg ); // returns bool
    if (rc) return 1; else return 0;
  } else {
    return alert( msg );
  }
}
CSClient_Obj.prototype.prompt = function( msg, defval ) { return prompt( msg, defval ); }
CSClient_Obj.prototype.getAgent = function() { return navigator.userAgent.toLowerCase(); }

CSClient_Obj.prototype.getLanguageCode = function() {
  if (document.htmlform.DFS__LanguageCode) return document.htmlform.DFS__LanguageCode.value;
}

function CSForm_Obj( htmlform ) {
  this.hf = htmlform; // reference to HTML form object
}
// note that custom properties here require the DFS__ prefix so as not to conflict with potential field names
CSForm_Obj.prototype.submit = function( uri ) {
  if (uri) this.hf.action = uri;
  var res = csformsubmit();
  if (res) {
    cs_prepare_for_submit();
    res = this.hf.submit();
  }
  return res;
}

CSForm_Obj.prototype.reset = function() { return this.hf.reset(); }

CSForm_Obj.prototype.setFocus = function( fname ) {
  //  Show page
  var elt = null;
  if (this.hf[0])
    elt = this.hf[0].parentNode;
  else
    elt = this.hf.parentNode;

  while((elt.id == null) || (elt.id.indexOf("DFS__container") == -1)) {
    elt = elt.parentNode;
  }
  var index = elt.id.substr("DFS__container".length);
  cs_ShowPage( index );
  //  Set focus
  try {
    if (this.hf[fname] ) {
      if (this.hf[fname].authWith) // signature
        return this.hf["DFS__" + fname].focus();
  
      if (this.hf[fname][0] && this.hf[fname][0].type && this.hf[fname][0].type == "radio")
        return this.hf[fname][0].focus();
      else
        return this.hf[fname].focus();
    }
  } catch(e) {}
}
CSForm_Obj.prototype.getLJOMVersion = function() { return "1.001"; }
CSForm_Obj.prototype.getPubType = function() { return "HTML"; }
CSForm_Obj.prototype.getTitle = function() { return this.hf.DFS__title; }
CSForm_Obj.prototype.getID = function() {
  if (!this.hf.DFS__FormGUID)
    return "";
  return this.hf.DFS__FormGUID.value;
}
CSForm_Obj.prototype.getLocation = function() { return document.location; }
CSForm_Obj.prototype.getNumberOfFields = function() {
  if (!this.hf.DFS__UserFieldList) {
    var ofs = 0;
    var NoDupes = new Object();
    this.hf.DFS__UserFieldList = [];
    var iofs = 0;
    this.hf.DFS__PrivateFieldList = [];
    for( var idx=0; idx < this.hf.elements.length; idx++ ) {
      var fld = this.hf.elements[idx];
      if (fld.name.indexOf("DFS__") != 0) {
        if (!NoDupes[fld.name] || (NoDupes[fld.name].length == 0))
          this.hf.DFS__UserFieldList[ofs++] = fld.name;
        // no (radio) duplicates
        NoDupes[fld.name] = fld.name;
      } else {
        this.hf.DFS__PrivateFieldList[iofs++] = fld.name; // internal
      }
    }
  }
  return this.hf.DFS__UserFieldList.length;
}

CSForm_Obj.prototype.getField = function( fref ) {
  var fld;
  if (typeof fref == "number") {
    if (!this.hf.DFS__UserFieldList) this.getNumberOfFields();
    fld = this.hf[ this.hf.DFS__UserFieldList[ fref ] ];
  } else {
    fld = this.hf[fref];
  }
  if (fld)
    return new CSField_Obj( fld );
  else
    return null;
}

CSForm_Obj.prototype.getResponseURL = function() {
  if (this.hf.DFS__CustResp) return this.hf.DFS__CustResp.value;
}

CSForm_Obj.prototype.setResponseURL = function( uri ) {
  if (this.hf.DFS__CustResp) this.hf.DFS__CustResp.value = uri;
}

CSForm_Obj.prototype.getFinalized = function() {
  if (this.hf.DFS__FinalCopy) return this.hf.DFS__FinalCopy.value;
}

function CSField_Obj( htmlfield ) {
  this.hf = htmlfield;
}
CSForm_Obj.prototype.getBuildNumber = function() { return "$LODBuild: 2219 $"; }
CSField_Obj.prototype.setFocus = function() {
  //  Show page
  var elt = null;
  if (this.hf[0])
    elt = this.hf[0].parentNode;
  else
    elt = this.hf.parentNode;

  while((elt.id == null) || (elt.id.indexOf("DFS__container") == -1)) {
    elt = elt.parentNode;
  }
  var index = elt.id.substr("DFS__container".length);
  cs_ShowPage( index );
  //  Set focus
  try {
    if (this.hf[0] && this.hf[0].type && this.hf[0].type == "radio")
      this.hf[0].focus();
    else
      this.hf.focus();
  } catch(e) {}
}
CSField_Obj.prototype.getName = function() {
  if (this.hf[0] && this.hf[0].name)
    return this.hf[0].name;
  else
    return this.hf.name;
}
CSField_Obj.prototype.getDescription = function() {
  var desc = "";
  if (this.hf[0] && this.hf[0].type && this.hf[0].type == "radio")
    desc = this.hf[0].description;
  else
    desc = this.hf.description;
    
  return desc;
}
CSField_Obj.prototype.getValue = function() {
  if (this.hf.type=="select-multiple") {
    // tab-separated list
    var rv = "";
    for(var idx=0; idx< this.hf.options.length; idx++) {
      if (this.hf.options[idx].selected) {
        if (rv.length>0) rv += String.fromCharCode(9);//TAB
        rv += this.hf.options[idx].value;
      }
    }
    return rv;
  } else if (this.hf[0] && this.hf[0].type && this.hf[0].type=="radio") {
    for(var idx=0; idx<this.hf.length; idx++) {
      if (this.hf[idx].checked) return this.hf[idx].value;
    }
    return "";
  } else if (this.hf.type=="checkbox") {
    if (this.hf.checked) return 1; else return 0;
  } else {
    return this.hf.value;
  }
}
CSField_Obj.prototype.setValue = function( str ) {
  var compare = this.getValue();
  if (this.hf.options) {
    var setv = false;
    for( var idx=0; idx < this.hf.options.length; idx++) {
      if (this.hf.options[idx].value==str) {
        this.hf.options[idx].selected = true;
        setv = true;
      } else {
        this.hf.options[idx].selected = false;
      }
    }
    if ( this.getType()=="Combo" && !setv) {
      // add new choice to combo
      this.getChoices().insertAt( 0, str, str );
      this.hf.options[0].selected = true;
    }
    
  } else if (this.hf[0] && this.hf[0].type && this.hf[0].type=="radio") {
    for(var idx=0; idx<this.hf.length; idx++) {
      this.hf[idx].checked = (this.hf[idx].value == str);
    }
  } else if (this.hf.type=="checkbox") {
    if (str==1 || str=="1") this.hf.checked = true; else this.hf.checked = false;
  } else {
    this.hf.value = str;
  }
  if (this.getValue() != compare) {
    CS_FireOnChange( this.hf );
    this.hf.cmpvalue = this.hf.value; // save for later
  }
}
CSField_Obj.prototype.getValues = function() {
  var ra = new Array();
  if (this.hf.type=="select-multiple") {
    var ofs = 0;
    for(var idx=0; idx< this.hf.options.length; idx++) {
      if (this.hf.options[idx].selected) ra[ofs++] = this.hf.options[idx].value;
    }
  } else {
    ra[0] = this.getValue();
  }
  return ra;
}
CSField_Obj.prototype.setValues = function( array_of_values ) {
  var compare = this.getValue();
  var found = false;
  if (this.hf.type=="select-multiple") {
    var rv = 0;
    if (array_of_values.length==0) return rv;
    for(var idx=0; idx<this.hf.options.length ; idx++) {
      found = false;
      for(var jdx=0; jdx< array_of_values.length; jdx++) {
        if (this.hf.options[idx].value == array_of_values[jdx]) {
          found = true;
        }  
      this.hf.options[idx].selected = found;
      }
    }
  } else {
    this.setValue( array_of_values[0] );
  }
  if (this.getValue() != compare) {
    CS_FireOnChange( this.hf );
    this.hf.cmpvalue = this.hf.value; // save for later
  }
}
CSField_Obj.prototype.getChoices = function() {
  if (this.getType()=="List" || this.getType()=="Drop" || this.getType()=="Combo")
    return new CSChoices_Obj(this.hf);
  else
    return null;
}
CSField_Obj.prototype.getType = function() {
  // button, select-one, select-multiple, button, submit, reset, checkbox, radio, image
  var htmltype = this.hf.type;
  if (htmltype=="button")   return "Button";
  if (htmltype=="text")     return "Text";
  if (htmltype=="textarea") return "Text";
  if (htmltype=="radio")    return "Radio";
  if (htmltype=="checkbox") return "Check";
  if (htmltype=="select" || htmltype=="select-one" || htmltype=="select-multiple") {
    var extended_name = "DFS__" + this.hf.name;
    if (document.htmlform[extended_name]) return "Combo";
    if (this.hf.size > 1) return "List"; else return "Drop";
  }
  if (htmltype=="hidden") {
    if (this.hf.authWith) return "Signature";
    return "Text";
  }
  if (this.hf.length) return "Radio";
  return "(" + htmltype + ")" ;
}
CSField_Obj.prototype.isReadOnly = function() {
  if (this.hf[0] && this.hf[0].type && this.hf[0].type == "radio")
    return this.hf[0].readOnly;
  else
    return this.hf.readOnly;
}
CSField_Obj.prototype.setReadOnly = function( b ) {
  if (this.hf[0] && this.hf[0].type && this.hf[0].type == "radio") {
    for( var idx=0; idx < this.hf.length; idx++) {
      this.hf[idx].readOnly = b;
      this.hf[idx].disabled = b;
    }
  } else {
    this.hf.readOnly = b;
    this.hf.disabled = b;
  }
}
CSField_Obj.prototype.isRequired = function() {
  if (this.hf[0] && this.hf[0].type && this.hf[0].type == "radio")
    return this.hf[0].required;
  else
  return this.hf.required;
} // CSPROP
CSField_Obj.prototype.setRequired = function( b ) {
  if (this.hf[0] && this.hf[0].type && this.hf[0].type == "radio")
    this.hf[0].required = b;
  else
    this.hf.required = b;
}
CSField_Obj.prototype.isHidden = function() {
  if (this.hf[0] && this.hf[0].type && this.hf[0].type == "radio")
    return this.hf[0].style.visibility == "hidden";
  else
    return this.hf.style.visibility == "hidden";
}
CSField_Obj.prototype.setHidden = function( b ) {
  var setting = "visible";
  if (b)
    setting = "hidden";
    
  if (this.hf[0] && this.hf[0].type && this.hf[0].type == "radio")
    for (var idx=0; idx < this.hf.length; idx++)
      this.hf[idx].style.visibility = setting;
  else
    this.hf.style.visibility = setting;
}
CSField_Obj.prototype.getTextColor = function() {
  if (this.hf[0] && this.hf[0].type && this.hf[0].type == "radio")
    return cs_format_rgb(this.hf[0].style.color);
  else
    return cs_format_rgb(this.hf.style.color);
}
CSField_Obj.prototype.setTextColor = function( rgb ) {
  var sv = cs_assemble_color_string(rgb);
  if (this.hf[0] && this.hf[0].type && this.hf[0].type == "radio")
    for (var idx=0; idx < this.hf.length; idx++)
      this.hf[idx].style.color = sv;
  else
    this.hf.style.color = sv;
}
CSField_Obj.prototype.getFillColor = function() {
  if (this.hf[0] && this.hf[0].type && this.hf[0].type == "radio")
    return cs_format_rgb(this.hf[0].style.backgroundColor);
  else
    return cs_format_rgb(this.hf.style.backgroundColor);
}
CSField_Obj.prototype.setFillColor = function( rgb ) {
  var sv = cs_assemble_color_string(rgb);
  if (this.hf[0] && this.hf[0].type && this.hf[0].type == "radio")
    for (var idx=0; idx < this.hf.length; idx++)
    this.hf[idx].style.backgroundColor = sv;
  else
    this.hf.style.backgroundColor = sv;
}
CSField_Obj.prototype.isPassword = function() { return this.hf.password; } // CSPROP
CSField_Obj.prototype.isMultiline = function() { return this.hf.multiline; } // CSPROP
CSField_Obj.prototype.getMaxLength = function() {
  if (!this.hf.maxLength) return 0;
  if (this.hf.maxLength < 0 || this.hf.maxLength >= 2147483647) return 0;
  return this.hf.maxLength;
}

CSField_Obj.prototype.getDefaultDataType = function() {
  if (this.hf.fmttxt)  return "String";
  if (this.hf.fmtnmbr) return "Numeric";
  if (this.hf.fmtdt)   return "Date";
  if (this.hf.fmttm)   return "Date";
  if (this.hf.fmttmpl) return "String";
  return "Unknown";
}

function CSChoices_Obj( htmlchoice ) {
  this.hc = htmlchoice;
}
CSChoices_Obj.prototype.getCount = function() { return this.hc.options.length; }
CSChoices_Obj.prototype.getAt = function( num, bDispVal ) {
  if (bDispVal) {
    return this.hc.options[num].text;
  } else {
    return this.hc.options[num].value;
  }
}
CSChoices_Obj.prototype.insertAt = function( num, expVal, dispVal ) {
  var newopt = document.createElement("option");
  if (dispVal==null) newopt.text = expVal; else newopt.text = dispVal;
  newopt.value = expVal;
  if (this.hc.options.add) { //IE -- need to check first since IE fld.add is broken
    if (num==-1) num = this.hc.options.length;
    this.hc.options.add(newopt, num);
    return 0;
  }
  if (this.hc.add) { // W3C
    if (num==-1) {
      this.hc.add(newopt, null);
    } else {
      this.hc.add(newopt, this.hc.options[num]);
    }
    return 0;
  }
  return 1;
}
CSChoices_Obj.prototype.deleteAt = function( num ) {
  if (this.hc.remove) { //W3C
    this.hc.remove(num);
    return 0;
  }
  if (this.hc.options.remove) { // IE
    this.hc.remove(num); //IE
    return 0;
  }
  return 1;
}
CSChoices_Obj.prototype.getSelections = function() {
  var ra = new Array();
  var ofs = 0;
  for(var idx=0; idx<this.hc.options.length; idx++) {
    if (this.hc.options[idx].selected)
      ra[ofs++] = idx;
  }
  return ra;
}
CSChoices_Obj.prototype.setSelections = function( arr ) {
  for (var ofs=0; ofs<this.hc.options.length; ofs++) {
    this.hc.options[ofs].selected = false;
  }
  if(arr.length > 1){
    for (var idx=0; idx<arr.length; idx++) {
      this.hc.options[arr[idx]].selected = true;
    }
  }else { //Netscape 6.1
    this.hc.selectedIndex = arr[0];
  }
}
CSChoices_Obj.prototype.choiceExists = function( expVal, dispVal ) {
  var exists = false;
  for( var idx=0; idx<this.getCount(); idx++ ) {
    var curEV = this.getAt( idx, false );
    var curDV = this.getAt( idx, true );
    if ( curEV==expVal && curDV==dispVal ) {
      exists = true;
      break;
    }
  }
  return exists;
}
function CSEvent_Obj( htmltarget ) {
  this.ht = htmltarget;
}
CSEvent_Obj.prototype.getTarget = function() { return this.ht; }
CSEvent_Obj.prototype.setTarget = function(targ) { this.ht = targ; }

function cs_assemble_color_string( str ) {
  if (str.search(/[a-zA-Z]/g) == 0 && (isNaN(parseInt(str,16)) || parseInt(str,16)<256) )
    return str;
  else
    return "#" + cs_format_rgb(str);
}

function cs_format_rgb( str ) {
  // format a browser-returned string into "RRGGBB"
  // browsers may return either "#xxxxxx" or "rgb(ddd,ddd,ddd)" where x represents a hex digit and d a decimal digit
  if (str.charAt(0) == "#") return str.substr(1).toLowerCase();
  if (str.indexOf("rgb")==0) {
    var open_pr=str.indexOf("(");
    var comma1=str.indexOf(",");
    var comma2=str.lastIndexOf(",");
    var close_pr=str.indexOf(")");
    var result = CS_toHex(str.substr(open_pr+1, comma1-open_pr)) +
                 CS_toHex(str.substr(comma1+1, comma2-comma1)) +
                 CS_toHex(str.substr(comma2+1, close_pr-comma2));
    return result;
  }
  return str;
}

function CS_toHex(byt) {
  if (typeof byt == "string") byt = parseInt(byt);
  var hexChars = "0123456789abcdef";
  if (byt > 255) return null;
  var i = byt % 16;
  var j = (byt-i)/16;
  return hexChars.charAt(j) + hexChars.charAt(i);
}  

///////

CSExt = {
  Initialize: {},
  Form_OnLoad_bEP: {},
  Form_OnLoad_aEP: {},
  UnInitialize: {},
  Form_OnSubmit_bEP: {},
  Form_OnSubmit_aEP: {},
  OnFocus_bEP: {},
  OnFocus_aEP: {},
  OnChange_bEP: {},
  OnChange_aEP: {},
  OnBlur_bEP: {},
  OnBlur_aEP: {},
  OnButtonClick_bEP: {},
  OnButtonClick_aEP: {},
  OnKeyPress: {}, // only called for CardiffInternalDebug fields
  preventedDefault: false,
  flags: { msxml_warn: false, msxml_pending: false,
  ProfileInfo: "" }
};
CSClient = new CSClient_Obj();
CSForm = new CSForm_Obj(document.htmlform);
CSEvent = new CSEvent_Obj(null);

CSExt.dispatchEvent = function( evtName, param ) {
  CSExt.preventedDefault = false;
  cstrace( "dispatching event " + evtName );
  for( var func in CSExt[evtName]) {
    cstrace( "  .." + func);
    CSExt[evtName][func](param);
  }
  return !CSExt.preventedDefault;
}

CSExt.preventDefault = function() {
  CSExt.preventedDefault = true;
}

function csformload() {
  //<profile>
  //alert( "timing begins..." );
  //</profile>
  cs_profile("csformload begins");
  CSForm.hf = document.htmlform;
  //<debug>
  //for ( var xyz in CSExt.Initialize ) {
  //  cstrace( "found property " + xyz + " " + typeof CSExt.Initialize[xyz] );
  //}
  //</debug>
  
  // field locking
  for ( var idx=0; idx < document.htmlform.elements.length; idx++) {
    if (document.htmlform.elements[idx].readOnly == true)
      document.htmlform.elements[idx].disabled = true;
  }
  cs_profile("field locking done");
  
  // final copy
  var nf = CSForm.getNumberOfFields();
  cs_profile("getNumberOfFields("+nf+")");
  
  if (document.htmlform.DFS__FinalCopy && document.htmlform.DFS__FinalCopy.value == "1") {
    var all_array = document.htmlform.DFS__PrivateFieldList.concat( document.htmlform.DFS__UserFieldList );
    for( var idx=0; idx < all_array.length; idx++) {
      var csfld = new CSField_Obj( document.htmlform[all_array[idx]] );
      if (csfld.getName().indexOf("DFS__Page") < 0)
        csfld.setReadOnly( true );
    }
  }
  cs_profile("final copy done");
  
  CSExt.dispatchEvent( "Initialize", null );
  cs_profile("dispatchEvent done");
  var proceed = true;
  csinit();   // initialize custom properties

  //  Disable action button if there is no value in Action List.
  if (CSForm.getField( "DFS__ActionList" ) != null) {
    var actionList = CSForm.getField( "DFS__ActionList" ).getChoices();
    if ((actionList.getCount() == 1) && (actionList.getAt( 0, false ).length == 0)) {
      CSForm.getField( "DFS__GO" ).setReadOnly( true );
      CSForm.getField( "DFS__ActionList" ).setReadOnly( true );
    }
  }
  cs_profile("action button done");

  // status message
  if (document.htmlform.DFS__StatusMsg && document.htmlform.DFS__StatusMsg.value != "") {
    alert( document.htmlform.DFS__StatusMsg.value );
    document.htmlform.DFS__StatusMsg.value = "";
  }
  cs_profile("status msg done");

  proceed = CSExt.dispatchEvent( "Form_OnLoad_bEP", document.htmlform );
  cs_profile("dispatchEventB done");

  // call custom entry point
  if (this.CSForm_OnLoad && proceed) {
    CSEvent.setTarget( new CSForm_Obj(document.htmlform) );
    CSForm_OnLoad();
  }
  cs_profile("EntryPoint done");
   
  CSExt.dispatchEvent( "Form_OnLoad_aEP", document.htmlform );
  cs_profile("dispatchEventA done");

  //<profile>
  //alert( CSExt.ProfileInfo );
  //</profile>  
}

function csformunload() {
  CSExt.dispatchEvent( "UnInitialize", null );
}

function csformsubmit() {
  var doSubmit = true;  // return false to abort submit
  // onsubmit entry point, call the from csform.onsubmit()
  doSubmit = CSExt.dispatchEvent( "Form_OnSubmit_bEP", document.htmlform );

  // call custom entry point
  if (this.CSForm_OnSubmit && doSubmit) {
    CSEvent.setTarget( new CSForm_Obj(document.htmlform) );
    doSubmit = CSForm_OnSubmit();
  }
  
  if (doSubmit) doSubmit = CSExt.dispatchEvent( "Form_OnSubmit_aEP", document.htmlform );
  
  return doSubmit;
}

function cs_prepare_for_submit() {
  // page display
  for (i = 1; i <= document.htmlform.DFS__countPage; i++) {
    document.getElementById( "DFS__container" + i ).style.display = "block";
    document.getElementById( "DFS__container" + i ).style.visibility = "hidden";    
  }
  // field locking
  for( var idx=0; idx<document.htmlform.elements.length; idx++) {
    document.htmlform.elements[idx].disabled = false;
  }
}

function cs_prepare_after_reset(init) {
  var hf = document.htmlform;
  var entries = hf.DFS__UserFieldList;
  for (var idx = 0; idx < entries.length; idx++) {
    if( hf[entries[idx]] && hf[entries[idx]].authWith ) {
      CS_RefreshSig( hf["DFS__" + entries[idx]], hf[entries[idx]], init );
    }
  }
}

function csfocus( fld ) {
  // field-specific onfocus entry point, call from each field's onfocus()
  cstrace( "enter csfocus() " + fld.name );
  fld.cmpvalue = fld.value; // save for later
  var proceed = true;
  proceed = CSExt.dispatchEvent( "OnFocus_bEP", fld );
  
  var func = fld.name + "_OnFocus";
  if (this[func] && proceed) {
    CSEvent.setTarget( new CSField_Obj(fld) );
    this[func]();
  }
  CSExt.dispatchEvent( "OnFocus_aEP", fld );
  cstrace( "leave csfocus() " + fld.name );
}

function csblur( fld ) {
  // field-specific onblur entry point, call from each field's onblur()
  cstrace( "enter csblur() " + fld.name );
  
  // onchange is evil, for consistent behavior we roll our own
  CS_FireOnChange( fld );

  var proceed_bl = true;
  proceed_bl = CSExt.dispatchEvent( "OnBlur_bEP", fld );
  
  var func_bl = fld.name + "_OnBlur";
  if (this[func_bl] && proceed_bl) {
    CSEvent.setTarget( new CSField_Obj(fld) );
    this[func_bl]();
  }
  CSExt.dispatchEvent( "OnBlur_aEP", fld );
  cstrace( "leave csblur() " + fld.name );
}

function CS_FireOnChange( fld ) {
  var proceed_ch = true;
  if (fld.value!=fld.cmpvalue) {
    cstrace( "begin OnChange handling...");
    proceed_ch = CSExt.dispatchEvent( "OnChange_bEP", fld );
    cs_CalculationAction( fld );
  
    var func_ch = fld.name + "_OnChange";
    if (this[func_ch] && proceed_ch) {
      CSEvent.setTarget( new CSField_Obj(fld) );
      this[func_ch]();
    }
      
    CSExt.dispatchEvent( "OnChange_aEP", fld );
    cstrace( "end OnChange handling...");
  }
  fld.cmpvalue = fld.value;
}

function csclick( fld ) {
  // field-specific, call from each button's event handler
  var proceed = true;
  proceed = CSExt.dispatchEvent( "OnButtonClick_bEP", fld );
  
  var func = fld.name + "_OnButtonClick";
  if (this[func] && proceed) {
    CSEvent.setTarget( new CSField_Obj(fld) );
    this[func]();
  }
  CSExt.dispatchEvent( "OnButtonClick_aEP", fld );
}

function cschange( fld ) {}

function cskeypress( fld, evt ) {
  // keypress notifications
  if (fld.name.indexOf("CardiffInternalDebug") != -1) {
    return CSExt.dispatchEvent( "OnKeyPress", fld );
  }
  // entry-field-specific, call from each entry field's onkeypress()
  if (CSExt.KeystrokeFilter) return CSExt.KeystrokeFilter( fld, evt );
  return true;
}

function cs_profile( msg ) {
  var timestamp;
  if (msg)
    timestamp = msg + ":\t"
  else
    timestamp = "event:\t";
  timestamp += new Date().getTime() / 1000;
  timestamp += "\n";
  if (!CSExt.ProfileInfo)
    CSExt.ProfileInfo = "";
  CSExt.ProfileInfo += timestamp;
}

