function confirmdelete(record){ 
  var agree=confirm("Are you sure you wish to delete record " + record + "?\n\nWARNING: This is permanent!");
  if (agree) {
    return true;
  } else {
    return false;
  }
}
function button(action,type,id,epoch,spec) {
  document.store.action.value = action;
  document.store.type.value   = type;
  document.store.id.value     = id;
  document.store.epoch.value  = epoch;
  document.store.spec.value   = spec;
  if(action == 'login' || action == 'logout') {
    self.close();
    document.store.target='_blank';
  }
  document.store.submit();
}
function newImage(arg) {
  if (document.images) {
    rslt = new Image();
    rslt.src = arg;
    return rslt;
  }
}
function changeImages() {
  for (var i=0; i<changeImages.arguments.length; i+=2) {
    document[changeImages.arguments[i]].src = changeImages.arguments[i+1];
  }
}
var preloadFlag = false;
function preloadImages() {
  if (document.images) {
    reserve_over = newImage("/sources/reserve.gif");
    admin_over = newImage("/sources/admin.gif");
    logout_over = newImage("/sources/logout.gif");
    preloadFlag = true;
  }
}
login_over = newImage("/sources/login.gif");

function restrictinput(maxlength,e,placeholder){
  if ( window.event&&event.srcElement.value.length >= maxlength ) {
    return false;
  } else if ( e.target&&e.target == eval(placeholder) &&
              e.target.value.length >= maxlength ) {
    var pressedkey = /[a-zA-Z0-9\.\,\/]/;
    if ( pressedkey.test(String.fromCharCode(e.which)) ) {
      e.stopPropagation();
    }
  }
}

function countlimit(maxlength,e,placeholder) {
  var theform = eval(placeholder);
  var lengthleft = maxlength-theform.value.length;
  var placeholderobj = document.all
        ? document.all[placeholder]
        : document.getElementById(placeholder);
  if ( window.event||e.target&&e.target == eval(placeholder) ){
    if ( lengthleft < 0 ) {
      theform.value=theform.value.substring(0,maxlength);
    }
    placeholderobj.innerHTML = lengthleft;
  }
}      

function displaylimit(theform,thelimit) {
  var limit_text=
    '<b><span id="'+
    theform.toString()+
    '">'+
    thelimit+
    '</span></b>';
  if (document.all||ns6) { document.write(limit_text); }
  if (document.all){
    eval(theform).onkeypress =
      function() { return restrictinput(thelimit,event,theform); }
    eval(theform).onkeyup =
      function() { countlimit(thelimit,event,theform); }
  } else if (ns6){
    document.body.addEventListener(
      'keypress',
      function(event) { restrictinput(thelimit,event,theform) },
      true
    ); 
    document.body.addEventListener(
      'keyup',
      function(event) { countlimit(thelimit,event,theform) },
      true
    ); 
  }
}

