//Modified by / Date:
//Description:
//----------------------------------
//B.Lim - JUN-14-2006
//Class and utils created
//uses validate.js
//uses cookieUtil.js

var RFLD_COUNTER = 'ctr';

function CookieCounterHandler(name, domain, path, encrypted, encKey) {
  this.CookieHandler(name, domain, path, encrypted, encKey);
  this.FieldList.addItem(RFLD_COUNTER, 0);
}
copyPrototype(CookieHandler, CookieCounterHandler);

CookieCounterHandler.prototype.incCount = function() {
  this.addCount(1);
}

CookieCounterHandler.prototype.decCount = function() {
  this.addCount(-1);
}

CookieCounterHandler.prototype.addCount = function(iCount) {
  var iCtr = this.FieldList.getItem(RFLD_COUNTER);
  if (iCtr == null) {
    iCtr = 0;
  }
  if (isNaN(iCtr)) {
    iCtr = 0;
  }
  if (isNumeric(iCtr) == false) {
    iCtr = 0;
  }
  iCtr = Number(iCtr) + iCount;
  this.FieldList.setItem(RFLD_COUNTER, iCtr);
  return iCtr;
}

CookieCounterHandler.prototype.getCount = function() {
  var iCtr = this.FieldList.getItem(RFLD_COUNTER);
  if (iCtr == null) {
    iCtr = 0;
  }
  if (isNaN(iCtr)) {
    return 0;
  } else {
    return iCtr;
  }
}